diff --git a/lib/libimhex/include/hex/ui/imgui_imhex_extensions.h b/lib/libimhex/include/hex/ui/imgui_imhex_extensions.h index 18e2a8d3f..831f725f4 100644 --- a/lib/libimhex/include/hex/ui/imgui_imhex_extensions.h +++ b/lib/libimhex/include/hex/ui/imgui_imhex_extensions.h @@ -263,6 +263,7 @@ namespace ImGuiExt { bool DimmedButton(const char* label, ImVec2 size = ImVec2(0, 0)); bool DimmedIconButton(const char *symbol, ImVec4 color, ImVec2 size = ImVec2(0, 0)); + bool DimmedButtonToggle(const char *icon, bool *v, ImVec2 size); bool DimmedIconToggle(const char *icon, bool *v); void TextOverlay(const char *text, ImVec2 pos); diff --git a/lib/libimhex/source/ui/imgui_imhex_extensions.cpp b/lib/libimhex/source/ui/imgui_imhex_extensions.cpp index 985fbf425..ac16cbd20 100644 --- a/lib/libimhex/source/ui/imgui_imhex_extensions.cpp +++ b/lib/libimhex/source/ui/imgui_imhex_extensions.cpp @@ -832,6 +832,26 @@ namespace ImGuiExt { return res; } + bool DimmedButtonToggle(const char *icon, bool *v, ImVec2 size) { + bool pushed = false; + bool toggled = false; + + if (*v) { + PushStyleColor(ImGuiCol_Border, GetStyleColorVec4(ImGuiCol_ButtonActive)); + pushed = true; + } + + if (DimmedIconButton(icon, GetStyleColorVec4(ImGuiCol_Text), size)) { + *v = !*v; + toggled = true; + } + + if (pushed) + PopStyleColor(); + + return toggled; + } + bool DimmedIconToggle(const char *icon, bool *v) { bool pushed = false; bool toggled = false; diff --git a/plugins/builtin/source/content/views/view_data_inspector.cpp b/plugins/builtin/source/content/views/view_data_inspector.cpp index 576684a77..4d8bc9850 100644 --- a/plugins/builtin/source/content/views/view_data_inspector.cpp +++ b/plugins/builtin/source/content/views/view_data_inspector.cpp @@ -330,9 +330,7 @@ namespace hex::plugin::builtin { ImGui::EndTable(); } - if (ImGuiExt::DimmedButton("hex.builtin.common.edit"_lang, ImVec2(ImGui::GetContentRegionAvail().x, 0))) { - this->m_tableEditingModeEnabled = !this->m_tableEditingModeEnabled; - } + ImGuiExt::DimmedButtonToggle("hex.builtin.common.edit"_lang, &this->m_tableEditingModeEnabled, ImVec2(ImGui::GetContentRegionAvail().x, 0)); ImGui::NewLine(); ImGui::Separator();