Skip to content

Commit

Permalink
Update code using Dear ImGui for v1.91.2
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielGibson committed Oct 2, 2024
1 parent 9dffb36 commit 9f21cea
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
38 changes: 33 additions & 5 deletions neo/sys/imgui_savestyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ namespace DG {
D3_IMATTR_FLOAT( TabBorderSize ) \
D3_IMATTR_FLOAT( TabMinWidthForCloseButton ) \
D3_IMATTR_FLOAT( TabBarBorderSize ) \
D3_IMATTR_FLOAT( TabBarOverlineSize ) \
D3_IMATTR_FLOAT( TableAngledHeadersAngle ) \
D3_IMATTR_VEC2( TableAngledHeadersTextAlign ) \
D3_IMATTR_DIR( ColorButtonPosition ) \
Expand Down Expand Up @@ -186,11 +187,13 @@ namespace DG {
D3_IMSTYLE_COLOR( ResizeGrip ) \
D3_IMSTYLE_COLOR( ResizeGripHovered ) \
D3_IMSTYLE_COLOR( ResizeGripActive ) \
D3_IMSTYLE_COLOR( Tab ) \
D3_IMSTYLE_COLOR( TabHovered ) \
D3_IMSTYLE_COLOR( TabActive ) \
D3_IMSTYLE_COLOR( TabUnfocused ) \
D3_IMSTYLE_COLOR( TabUnfocusedActive ) \
D3_IMSTYLE_COLOR( Tab ) \
D3_IMSTYLE_COLOR( TabSelected ) \
D3_IMSTYLE_COLOR( TabSelectedOverline ) \
D3_IMSTYLE_COLOR( TabDimmed ) \
D3_IMSTYLE_COLOR( TabDimmedSelected ) \
D3_IMSTYLE_COLOR( TabDimmedSelectedOverline ) \
DGIMST_ENABLE_IF_DOCKING( D3_IMSTYLE_COLOR( DockingPreview ) ) \
DGIMST_ENABLE_IF_DOCKING( D3_IMSTYLE_COLOR( DockingEmptyBg ) ) \
D3_IMSTYLE_COLOR( PlotLines ) \
Expand All @@ -202,6 +205,7 @@ namespace DG {
D3_IMSTYLE_COLOR( TableBorderLight ) \
D3_IMSTYLE_COLOR( TableRowBg ) \
D3_IMSTYLE_COLOR( TableRowBgAlt ) \
D3_IMSTYLE_COLOR( TextLink ) \
D3_IMSTYLE_COLOR( TextSelectedBg ) \
D3_IMSTYLE_COLOR( DragDropTarget ) \
D3_IMSTYLE_COLOR( NavHighlight ) \
Expand Down Expand Up @@ -297,6 +301,21 @@ static void parseBehaviorLine( ImGuiStyle& s, const char* line )
#undef D3_IMATTR_DIR
#undef D3_IMATTR_BOOL

namespace {
// for renamed colors
struct ImGuiColorBackwardCompat {
const char* oldColorStr;
enum ImGuiCol_ newColorVal;
};

static struct ImGuiColorBackwardCompat backwardCompatColorMappings[] = {
{ "TabActive", ImGuiCol_TabSelected },
{ "TabUnfocused", ImGuiCol_TabDimmed },
{ "TabUnfocusedActive", ImGuiCol_TabDimmedSelected },
};

} //anon namespace

static void parseColorLine( ImGuiStyle& s, const char* line )
{
ImVec4 c;
Expand All @@ -313,9 +332,18 @@ static void parseColorLine( ImGuiStyle& s, const char* line )

// NOTE: here backwards-compat is also possible, like
// if ( sscanf( line, "OldColorName = %f , %f , %f , %f", &c.x, &c.y, &c.z, &c.w) == 4 ) {
// s.Colors[ ImGuiCol_NewColorName = c;
// s.Colors[ ImGuiCol_NewColorName ] = c;
// return;
// }
for( const ImGuiColorBackwardCompat& bc : backwardCompatColorMappings ) {
char matchString[64];
snprintf( matchString, sizeof(matchString), "%s = %%f , %%f , %%f , %%f", bc.oldColorStr );

if ( sscanf( line, matchString, &c.x, &c.y, &c.z, &c.w) == 4 ) {
s.Colors[ bc.newColorVal ] = c;
return;
}
}

warnPrintf( "Invalid line in ImGui style under [colors] section: '%s'\n", line );
}
Expand Down
2 changes: 1 addition & 1 deletion neo/sys/sys_imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ void SetDhewm3StyleColors( ImGuiStyle* dst )
colors[ImGuiCol_TitleBgActive] = ImVec4(0.03f, 0.33f, 0.33f, 1.00f);
//colors[ImGuiCol_TitleBg] = ImVec4(0.12f, 0.17f, 0.16f, 0.90f);
colors[ImGuiCol_TabHovered] = ImVec4(0.42f, 0.69f, 1.00f, 0.80f);
colors[ImGuiCol_TabActive] = ImVec4(0.24f, 0.51f, 0.83f, 1.00f);
colors[ImGuiCol_TabSelected] = ImVec4(0.24f, 0.51f, 0.83f, 1.00f);
}

void SetUserStyleColors()
Expand Down

0 comments on commit 9f21cea

Please sign in to comment.