1
0
mirror of synced 2025-01-18 00:56:49 +01:00

impr: Prettier data inspector edit button

This commit is contained in:
WerWolv 2023-11-19 16:08:21 +01:00
parent bd59bcda2c
commit f9073ee8ee
3 changed files with 22 additions and 3 deletions

View File

@ -263,6 +263,7 @@ namespace ImGuiExt {
bool DimmedButton(const char* label, ImVec2 size = ImVec2(0, 0)); bool DimmedButton(const char* label, ImVec2 size = ImVec2(0, 0));
bool DimmedIconButton(const char *symbol, ImVec4 color, 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); bool DimmedIconToggle(const char *icon, bool *v);
void TextOverlay(const char *text, ImVec2 pos); void TextOverlay(const char *text, ImVec2 pos);

View File

@ -832,6 +832,26 @@ namespace ImGuiExt {
return res; 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 DimmedIconToggle(const char *icon, bool *v) {
bool pushed = false; bool pushed = false;
bool toggled = false; bool toggled = false;

View File

@ -330,9 +330,7 @@ namespace hex::plugin::builtin {
ImGui::EndTable(); ImGui::EndTable();
} }
if (ImGuiExt::DimmedButton("hex.builtin.common.edit"_lang, ImVec2(ImGui::GetContentRegionAvail().x, 0))) { ImGuiExt::DimmedButtonToggle("hex.builtin.common.edit"_lang, &this->m_tableEditingModeEnabled, ImVec2(ImGui::GetContentRegionAvail().x, 0));
this->m_tableEditingModeEnabled = !this->m_tableEditingModeEnabled;
}
ImGui::NewLine(); ImGui::NewLine();
ImGui::Separator(); ImGui::Separator();