ui: Added custom theme colors, improved look of description button
This commit is contained in:
parent
02a63639da
commit
205d88cd23
19
external/ImGui/include/imgui_imhex_extensions.h
vendored
19
external/ImGui/include/imgui_imhex_extensions.h
vendored
@ -12,6 +12,23 @@ namespace ImGui {
|
||||
|
||||
void UnderlinedText(const char* label, ImColor color, const ImVec2& size_arg = ImVec2(0, 0));
|
||||
|
||||
void Disabled(std::function<void()> widgets, bool disabled);
|
||||
void Disabled(const std::function<void()> &widgets, bool disabled);
|
||||
void TextSpinner(const char* label);
|
||||
|
||||
enum ImGuiCustomCol {
|
||||
ImGuiCustomCol_DescButton,
|
||||
ImGuiCustomCol_DescButtonHovered,
|
||||
ImGuiCustomCol_DescButtonActive,
|
||||
ImGuiCustomCol_COUNT
|
||||
};
|
||||
|
||||
struct ImHexCustomData {
|
||||
ImVec4 Colors[ImGuiCustomCol_COUNT];
|
||||
};
|
||||
|
||||
ImU32 GetCustomColorU32(ImGuiCustomCol idx, float alpha_mul = 1.0F);
|
||||
|
||||
void StyleCustomColorsDark();
|
||||
void StyleCustomColorsLight();
|
||||
void StyleCustomColorsClassic();
|
||||
}
|
37
external/ImGui/source/imgui_imhex_extensions.cpp
vendored
37
external/ImGui/source/imgui_imhex_extensions.cpp
vendored
@ -107,11 +107,11 @@ namespace ImGui {
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.0, 0.5));
|
||||
|
||||
// Render
|
||||
const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_TableHeaderBg : hovered ? ImGuiCol_TableBorderLight : ImGuiCol_TableBorderStrong);
|
||||
const ImU32 col = GetCustomColorU32((held && hovered) ? ImGuiCustomCol_DescButtonActive : hovered ? ImGuiCustomCol_DescButtonHovered : ImGuiCustomCol_DescButton);
|
||||
RenderNavHighlight(bb, id);
|
||||
RenderFrame(bb.Min, bb.Max, col, true, style.FrameRounding);
|
||||
PushStyleColor(ImGuiCol_Text, GetColorU32(ImGuiCol_ButtonActive));
|
||||
RenderTextClipped(bb.Min + style.FramePadding * 2, bb.Max - style.FramePadding * 2, label, NULL, &text_size, style.ButtonTextAlign, &bb);
|
||||
RenderTextWrapped(bb.Min + style.FramePadding * 2, label, nullptr, CalcWrapWidthForPos(window->DC.CursorPos, window->DC.TextWrapPos));
|
||||
PopStyleColor();
|
||||
PushStyleColor(ImGuiCol_Text, GetColorU32(ImGuiCol_Text));
|
||||
RenderTextClipped(bb.Min + style.FramePadding * 2 + ImVec2(style.FramePadding.x * 2, label_size.y), bb.Max - style.FramePadding, description, NULL, &text_size, style.ButtonTextAlign, &bb);
|
||||
@ -141,7 +141,7 @@ namespace ImGui {
|
||||
PopStyleColor();
|
||||
}
|
||||
|
||||
void Disabled(std::function<void()> widgets, bool disabled) {
|
||||
void Disabled(const std::function<void()> &widgets, bool disabled) {
|
||||
if (disabled) {
|
||||
ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, ImGui::GetStyle().Alpha * 0.5F);
|
||||
@ -157,4 +157,35 @@ namespace ImGui {
|
||||
ImGui::Text("[%c] %s", "|/-\\"[ImU32(ImGui::GetTime() * 20) % 4], label);
|
||||
}
|
||||
|
||||
ImU32 GetCustomColorU32(ImGuiCustomCol idx, float alpha_mul) {
|
||||
auto& customData = *static_cast<ImHexCustomData*>(GImGui->IO.UserData);
|
||||
ImVec4 c = customData.Colors[idx];
|
||||
c.w *= GImGui->Style.Alpha * alpha_mul;
|
||||
return ColorConvertFloat4ToU32(c);
|
||||
}
|
||||
|
||||
void StyleCustomColorsDark() {
|
||||
auto &colors = static_cast<ImHexCustomData*>(GImGui->IO.UserData)->Colors;
|
||||
|
||||
colors[ImGuiCustomCol_DescButton] = ImColor(20, 20, 20);
|
||||
colors[ImGuiCustomCol_DescButtonHovered] = ImColor(40, 40, 40);
|
||||
colors[ImGuiCustomCol_DescButtonActive] = ImColor(60, 60, 60);
|
||||
}
|
||||
|
||||
void StyleCustomColorsLight() {
|
||||
auto &colors = static_cast<ImHexCustomData*>(GImGui->IO.UserData)->Colors;
|
||||
|
||||
colors[ImGuiCustomCol_DescButton] = ImColor(230, 230, 230);
|
||||
colors[ImGuiCustomCol_DescButtonHovered] = ImColor(210, 210, 210);
|
||||
colors[ImGuiCustomCol_DescButtonActive] = ImColor(190, 190, 190);
|
||||
}
|
||||
|
||||
void StyleCustomColorsClassic() {
|
||||
auto &colors = static_cast<ImHexCustomData*>(GImGui->IO.UserData)->Colors;
|
||||
|
||||
colors[ImGuiCustomCol_DescButton] = ImColor(40, 40, 80);
|
||||
colors[ImGuiCustomCol_DescButtonHovered] = ImColor(60, 60, 100);
|
||||
colors[ImGuiCustomCol_DescButtonActive] = ImColor(80, 80, 120);
|
||||
}
|
||||
|
||||
}
|
@ -62,12 +62,15 @@ namespace hex {
|
||||
default:
|
||||
case 0: /* Dark theme */
|
||||
ImGui::StyleColorsDark();
|
||||
ImGui::StyleCustomColorsDark();
|
||||
break;
|
||||
case 1: /* Light theme */
|
||||
ImGui::StyleColorsLight();
|
||||
ImGui::StyleCustomColorsLight();
|
||||
break;
|
||||
case 2: /* Classic theme */
|
||||
ImGui::StyleColorsClassic();
|
||||
ImGui::StyleCustomColorsClassic();
|
||||
break;
|
||||
}
|
||||
ImGui::GetStyle().Colors[ImGuiCol_DockingEmptyBg] = ImGui::GetStyle().Colors[ImGuiCol_WindowBg];
|
||||
@ -637,6 +640,8 @@ namespace hex {
|
||||
io.KeyMap[ImGuiKey_Y] = GLFW_KEY_Y;
|
||||
io.KeyMap[ImGuiKey_Z] = GLFW_KEY_Z;
|
||||
|
||||
io.UserData = new ImGui::ImHexCustomData();
|
||||
|
||||
if (this->m_globalScale != 0.0f)
|
||||
style.ScaleAllSizes(this->m_globalScale);
|
||||
|
||||
@ -716,6 +721,8 @@ namespace hex {
|
||||
}
|
||||
|
||||
void Window::deinitImGui() {
|
||||
delete static_cast<ImGui::ImHexCustomData*>(ImGui::GetIO().UserData);
|
||||
|
||||
ImGui_ImplOpenGL3_Shutdown();
|
||||
ImGui_ImplGlfw_Shutdown();
|
||||
ImGui::DestroyContext();
|
||||
|
Loading…
x
Reference in New Issue
Block a user