DearPyGui icon indicating copy to clipboard operation
DearPyGui copied to clipboard

Inconsistency in Tab-related theme entries in the style editor due to variable renaming in imgui 1.90.9.

Open wuyao1997 opened this issue 6 months ago • 0 comments

2.0.0 of Dear PyGui

Version: 2.0.0 Operating System: Windows 11

Inconsistency in Tab-related theme entries in the style editor due to variable renaming in imgui 1.90.9.

In version 1.90.9, the following changes were made to ImGui:

// imgui.h

...
ImGuiCol_TabHovered,            // Tab background, when hovered
ImGuiCol_Tab,                   // Tab background, when tab-bar is focused & tab is unselected
ImGuiCol_TabSelected,           // Tab background, when tab-bar is focused & tab is selected
ImGuiCol_TabSelectedOverline,   // Tab horizontal overline, when tab-bar is focused & tab is selected
ImGuiCol_TabDimmed,             // Tab background, when tab-bar is unfocused & tab is unselected
ImGuiCol_TabDimmedSelected,     // Tab background, when tab-bar is unfocused & tab is selected
ImGuiCol_TabDimmedSelectedOverline,//..horizontal overline, when tab-bar is unfocused & tab is selected
...

#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
    ImGuiCol_TabActive = ImGuiCol_TabSelected,                  // [renamed in 1.90.9]
    ImGuiCol_TabUnfocused = ImGuiCol_TabDimmed,                 // [renamed in 1.90.9]
    ImGuiCol_TabUnfocusedActive = ImGuiCol_TabDimmedSelected,   // [renamed in 1.90.9]
#endif

// imgui.cpp
/*
- 2024/06/18 (1.90.9) - style: renamed ImGuiCol_TabActive -> ImGuiCol_TabSelected, ImGuiCol_TabUnfocused -> ImGuiCol_TabDimmed, ImGuiCol_TabUnfocusedActive -> ImGuiCol_TabDimmedSelected.
*/
...
case ImGuiCol_TabHovered: return "TabHovered";
case ImGuiCol_Tab: return "Tab";
case ImGuiCol_TabSelected: return "TabSelected";
case ImGuiCol_TabSelectedOverline: return "TabSelectedOverline";
case ImGuiCol_TabDimmed: return "TabDimmed";
case ImGuiCol_TabDimmedSelected: return "TabDimmedSelected";
case ImGuiCol_TabDimmedSelectedOverline: return "TabDimmedSelectedOverline";
...

In DearPyGui, these keys seem to be manually bound in dearpygui.cpp, while the color settings in mvStyleWindow.cpp are automatically retrieved by accessing ImGui::GetStyleColorName. Although the old names are still supported in imgui.h by using the IMGUI_DISABLE_OBSOLETE_FUNCTIONS option, this seems to cause confusion. Moreover, dearpygui.cpp does not bind ImGuiCol_TabSelectedOverline and ImGuiCol_TabDimmedSelectedOverline, which may lead to unknown issues.

// dearpygui.cpp
...
ModuleConstants.push_back({ "mvThemeCol_Tab", ImGuiCol_Tab });
ModuleConstants.push_back({ "mvThemeCol_TabHovered", ImGuiCol_TabHovered });
ModuleConstants.push_back({ "mvThemeCol_TabActive", ImGuiCol_TabActive });
ModuleConstants.push_back({ "mvThemeCol_TabUnfocused", ImGuiCol_TabUnfocused });
ModuleConstants.push_back({ "mvThemeCol_TabUnfocusedActive", ImGuiCol_TabUnfocusedActive });
...

// mvStyleWindow.cpp
...
ImGui::BeginChild("##colors", ImVec2(0, 0), ImGuiChildFlags_Border, ImGuiWindowFlags_AlwaysVerticalScrollbar | ImGuiWindowFlags_AlwaysHorizontalScrollbar | ImGuiWindowFlags_NavFlattened);
ImGui::PushItemWidth(-300);
for (int i = 0; i < ImGuiCol_COUNT; i++)
{
    const char* name = ImGui::GetStyleColorName(i);
    if (!filter.PassFilter(name))
        continue;
    ImGui::PushID(i);
    ImGui::ColorEdit4("##color", (float*)&style.Colors[i], ImGuiColorEditFlags_AlphaBar | alpha_flags); 
    ImGui::SameLine(0.0f, style.ItemInnerSpacing.x); 
    ImGui::Text("mvThemeCol_%s", name);

    ImGui::PopID();
}
...

Unfortunately, I am not proficient in C++ and Python, so I am unable to submit a PR for the revisions.

Thanks to the author and all contributors of DearPyGui. I'm really looking forward to the 2.1.0 version!

To Reproduce

Steps to reproduce the behavior:

  1. Open style editor
  2. View Tab related color settings
  3. label of setting is not consistent with DearPyGui 2.0.0

Expected behavior

Label of Tab related color settings in style editor is consistent with DearPyGui 2.0.0

Screenshots/Video

Image

Standalone, minimal, complete and verifiable example

import dearpygui.dearpygui as dpg

dpg.create_context()
dpg.create_viewport(title="Custom Title", width=600, height=300)

with dpg.window(label="Window", width=200, height=200):
    with dpg.tab_bar():
        dpg.add_tab(label="a")
        dpg.add_tab(label="b")
        dpg.add_tab(label="c")


with dpg.theme() as global_theme:
    with dpg.theme_component(dpg.mvAll):
        dpg.add_theme_color(dpg.mvThemeCol_Tab, (120, 120, 120, 255))
        dpg.add_theme_color(dpg.mvThemeCol_TabHovered, (160, 160, 160, 255))
        dpg.add_theme_color(dpg.mvThemeCol_TabActive, (255, 0, 0, 255))
        dpg.add_theme_color(dpg.mvThemeCol_TabUnfocused, (0, 0, 255, 255))
        dpg.add_theme_color(dpg.mvThemeCol_TabUnfocusedActive, (0, 0, 255, 255))


dpg.bind_theme(global_theme)

dpg.show_style_editor()

dpg.create_viewport(title="Custom Title", width=800, height=600)
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()

wuyao1997 avatar Jun 28 '25 04:06 wuyao1997