1
0
mirror of synced 2025-02-15 01:52:40 +01:00

impr: Allow sidebar to be only resized from the right

This commit is contained in:
WerWolv 2025-02-10 21:42:12 +01:00
parent e8b391c0f6
commit b3d208e6e6
3 changed files with 18 additions and 1 deletions

View File

@ -159,6 +159,8 @@ namespace ImGuiExt {
void OpenPopupInWindow(const char *window_name, const char *popup_name);
void DisableWindowResize(ImGuiDir dir);
struct ImHexCustomData {
ImVec4 Colors[ImGuiCustomCol_COUNT];

View File

@ -743,6 +743,17 @@ namespace ImGuiExt {
End();
}
void DisableWindowResize(ImGuiDir dir) {
const auto window = GetCurrentWindow();
const auto borderId = GetWindowResizeBorderID(window, dir);
if (borderId == GetHoveredID()) {
GImGui->ActiveIdMouseButton = 0;
SetHoveredID(0);
}
if (borderId == GetActiveID())
SetActiveID(0, window);
}
bool TitleBarButton(const char *label, ImVec2 size_arg) {
ImGuiWindow *window = GetCurrentWindow();

View File

@ -125,7 +125,6 @@ namespace hex::plugin::builtin {
bool open = static_cast<u32>(openWindow) == index;
if (open) {
ImGui::SetNextWindowPos(ImGui::GetWindowPos() + sidebarPos + ImVec2(sidebarWidth - 1_scaled, -1_scaled));
ImGui::SetNextWindowSizeConstraints(ImVec2(0, dockSpaceSize.y + 5_scaled), ImVec2(FLT_MAX, dockSpaceSize.y + 5_scaled));
@ -140,6 +139,11 @@ namespace hex::plugin::builtin {
if (!ImGui::IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows) && !sideBarFocused) {
openWindow = -1;
}
ImGuiExt::DisableWindowResize(ImGuiDir_Up);
ImGuiExt::DisableWindowResize(ImGuiDir_Down);
ImGuiExt::DisableWindowResize(ImGuiDir_Left);
}
ImGui::End();
ImGui::PopStyleVar();