Skip to content

Commit e21d366

Browse files
committed
Merge branch 'WidgetTextColors' into microstrain
2 parents 7bbe1ce + befdb72 commit e21d366

File tree

5 files changed

+50
-10
lines changed

5 files changed

+50
-10
lines changed

imgui.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3313,9 +3313,11 @@ const char* ImGui::GetStyleColorName(ImGuiCol idx)
33133313
case ImGuiCol_Button: return "Button";
33143314
case ImGuiCol_ButtonHovered: return "ButtonHovered";
33153315
case ImGuiCol_ButtonActive: return "ButtonActive";
3316+
case ImGuiCol_ButtonText: return "ButtonText"; // MicroStrain Custom
33163317
case ImGuiCol_Header: return "Header";
33173318
case ImGuiCol_HeaderHovered: return "HeaderHovered";
33183319
case ImGuiCol_HeaderActive: return "HeaderActive";
3320+
case ImGuiCol_HeaderText: return "HeaderText"; // MicroStrain Custom
33193321
case ImGuiCol_Separator: return "Separator";
33203322
case ImGuiCol_SeparatorHovered: return "SeparatorHovered";
33213323
case ImGuiCol_SeparatorActive: return "SeparatorActive";
@@ -3327,13 +3329,15 @@ const char* ImGui::GetStyleColorName(ImGuiCol idx)
33273329
case ImGuiCol_TabActive: return "TabActive";
33283330
case ImGuiCol_TabUnfocused: return "TabUnfocused";
33293331
case ImGuiCol_TabUnfocusedActive: return "TabUnfocusedActive";
3332+
case ImGuiCol_TabText: return "TabText"; // MicroStrain Custom
33303333
case ImGuiCol_DockingPreview: return "DockingPreview";
33313334
case ImGuiCol_DockingEmptyBg: return "DockingEmptyBg";
33323335
case ImGuiCol_PlotLines: return "PlotLines";
33333336
case ImGuiCol_PlotLinesHovered: return "PlotLinesHovered";
33343337
case ImGuiCol_PlotHistogram: return "PlotHistogram";
33353338
case ImGuiCol_PlotHistogramHovered: return "PlotHistogramHovered";
33363339
case ImGuiCol_TableHeaderBg: return "TableHeaderBg";
3340+
case ImGuiCol_TableHeaderText: return "TableHeaderText"; // MicroStrain Custom
33373341
case ImGuiCol_TableBorderStrong: return "TableBorderStrong";
33383342
case ImGuiCol_TableBorderLight: return "TableBorderLight";
33393343
case ImGuiCol_TableRowBg: return "TableRowBg";
@@ -15031,7 +15035,7 @@ void ImGui::UpdatePlatformWindows()
1503115035
if (is_new_platform_window)
1503215036
{
1503315037
IMGUI_DEBUG_LOG_VIEWPORT("[viewport] Create Platform Window %08X '%s'\n", viewport->ID, viewport->Window ? viewport->Window->Name : "n/a");
15034-
15038+
1503515039
//Microstrain Custom Edit
1503615040
if(viewport->Window->Flags & ImGuiWindowFlags_Native_Child_Window)
1503715041
viewport->Flags |= ImGuiViewportFlags_NativeChild;

imgui.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1721,9 +1721,11 @@ enum ImGuiCol_
17211721
ImGuiCol_Button,
17221722
ImGuiCol_ButtonHovered,
17231723
ImGuiCol_ButtonActive,
1724+
ImGuiCol_ButtonText, // MicroStrain
17241725
ImGuiCol_Header, // Header* colors are used for CollapsingHeader, TreeNode, Selectable, MenuItem
17251726
ImGuiCol_HeaderHovered,
17261727
ImGuiCol_HeaderActive,
1728+
ImGuiCol_HeaderText, // MicroStrain
17271729
ImGuiCol_Separator,
17281730
ImGuiCol_SeparatorHovered,
17291731
ImGuiCol_SeparatorActive,
@@ -1735,13 +1737,15 @@ enum ImGuiCol_
17351737
ImGuiCol_TabActive,
17361738
ImGuiCol_TabUnfocused,
17371739
ImGuiCol_TabUnfocusedActive,
1740+
ImGuiCol_TabText, // MicroStrain
17381741
ImGuiCol_DockingPreview, // Preview overlay color when about to docking something
17391742
ImGuiCol_DockingEmptyBg, // Background color for empty node (e.g. CentralNode with no window docked into it)
17401743
ImGuiCol_PlotLines,
17411744
ImGuiCol_PlotLinesHovered,
17421745
ImGuiCol_PlotHistogram,
17431746
ImGuiCol_PlotHistogramHovered,
17441747
ImGuiCol_TableHeaderBg, // Table header background
1748+
ImGuiCol_TableHeaderText, // MicroStrain
17451749
ImGuiCol_TableBorderStrong, // Table outer and header borders (prefer using Alpha=1.0 here)
17461750
ImGuiCol_TableBorderLight, // Table inner borders (prefer using Alpha=1.0 here)
17471751
ImGuiCol_TableRowBg, // Table row background (even rows)

imgui_draw.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,10 @@ void ImGui::StyleColorsDark(ImGuiStyle* dst)
177177
ImVec4* colors = style->Colors;
178178

179179
colors[ImGuiCol_Text] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
180+
colors[ImGuiCol_ButtonText] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); // MicroStrain
181+
colors[ImGuiCol_HeaderText] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); // MicroStrain
182+
colors[ImGuiCol_TabText] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); // MicroStrain
183+
colors[ImGuiCol_TableHeaderText] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); // MicroStrain
180184
colors[ImGuiCol_TextDisabled] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f);
181185
colors[ImGuiCol_WindowBg] = ImVec4(0.06f, 0.06f, 0.06f, 0.94f);
182186
colors[ImGuiCol_ChildBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
@@ -239,6 +243,10 @@ void ImGui::StyleColorsClassic(ImGuiStyle* dst)
239243
ImVec4* colors = style->Colors;
240244

241245
colors[ImGuiCol_Text] = ImVec4(0.90f, 0.90f, 0.90f, 1.00f);
246+
colors[ImGuiCol_ButtonText] = ImVec4(0.90f, 0.90f, 0.90f, 1.00f); // MicroStrain
247+
colors[ImGuiCol_HeaderText] = ImVec4(0.90f, 0.90f, 0.90f, 1.00f); // MicroStrain
248+
colors[ImGuiCol_TabText] = ImVec4(0.90f, 0.90f, 0.90f, 1.00f); // MicroStrain
249+
colors[ImGuiCol_TableHeaderText] = ImVec4(0.90f, 0.90f, 0.90f, 1.00f); // MicroStrain
242250
colors[ImGuiCol_TextDisabled] = ImVec4(0.60f, 0.60f, 0.60f, 1.00f);
243251
colors[ImGuiCol_WindowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.85f);
244252
colors[ImGuiCol_ChildBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
@@ -302,6 +310,10 @@ void ImGui::StyleColorsLight(ImGuiStyle* dst)
302310
ImVec4* colors = style->Colors;
303311

304312
colors[ImGuiCol_Text] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f);
313+
colors[ImGuiCol_ButtonText] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f); // MicroStrain
314+
colors[ImGuiCol_HeaderText] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f); // MicroStrain
315+
colors[ImGuiCol_TabText] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f); // MicroStrain
316+
colors[ImGuiCol_TableHeaderText] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f); // MicroStrain
305317
colors[ImGuiCol_TextDisabled] = ImVec4(0.60f, 0.60f, 0.60f, 1.00f);
306318
colors[ImGuiCol_WindowBg] = ImVec4(0.94f, 0.94f, 0.94f, 1.00f);
307319
colors[ImGuiCol_ChildBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);

imgui_tables.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3114,12 +3114,12 @@ void ImGui::TableHeader(const char* label)
31143114
float y = label_pos.y;
31153115
if (column->SortOrder > 0)
31163116
{
3117-
PushStyleColor(ImGuiCol_Text, GetColorU32(ImGuiCol_Text, 0.70f));
3117+
PushStyleColor(ImGuiCol_TableHeaderText, GetColorU32(ImGuiCol_TableHeaderText, 0.70f)); // MicroStrain
31183118
RenderText(ImVec2(x + g.Style.ItemInnerSpacing.x, y), sort_order_suf);
31193119
PopStyleColor();
31203120
x += w_sort_text;
31213121
}
3122-
RenderArrow(window->DrawList, ImVec2(x, y), GetColorU32(ImGuiCol_Text), column->SortDirection == ImGuiSortDirection_Ascending ? ImGuiDir_Up : ImGuiDir_Down, ARROW_SCALE);
3122+
RenderArrow(window->DrawList, ImVec2(x, y), GetColorU32(ImGuiCol_TableHeaderText), column->SortDirection == ImGuiSortDirection_Ascending ? ImGuiDir_Up : ImGuiDir_Down, ARROW_SCALE); // MicroStrain
31233123
}
31243124

31253125
// Handle clicking on column header to adjust Sort Order

imgui_widgets.cpp

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,10 @@ bool ImGui::ButtonEx(const char* label, const ImVec2& size_arg, ImGuiButtonFlags
710710

711711
if (g.LogEnabled)
712712
LogSetNextTextDecoration("[", "]");
713+
714+
PushStyleColor(ImGuiCol_Text, GetColorU32(ImGuiCol_ButtonText));
713715
RenderTextClipped(bb.Min + style.FramePadding, bb.Max - style.FramePadding, label, NULL, &label_size, style.ButtonTextAlign, &bb);
716+
PopStyleColor();
714717

715718
// Automatically close popups
716719
//if (pressed && !(flags & ImGuiButtonFlags_DontClosePopups) && (window->Flags & ImGuiWindowFlags_Popup))
@@ -781,7 +784,7 @@ bool ImGui::ArrowButtonEx(const char* str_id, ImGuiDir dir, ImVec2 size, ImGuiBu
781784

782785
// Render
783786
const ImU32 bg_col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button);
784-
const ImU32 text_col = GetColorU32(ImGuiCol_Text);
787+
const ImU32 text_col = GetColorU32(ImGuiCol_ButtonText); // MicroStrain
785788
RenderNavHighlight(bb, id);
786789
RenderFrame(bb.Min, bb.Max, bg_col, true, g.Style.FrameRounding);
787790
RenderArrow(window->DrawList, bb.Min + ImVec2(ImMax(0.0f, (size.x - g.FontSize) * 0.5f), ImMax(0.0f, (size.y - g.FontSize) * 0.5f)), text_col, dir);
@@ -6538,7 +6541,7 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
65386541
g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_ToggledSelection;
65396542

65406543
// Render
6541-
const ImU32 text_col = GetColorU32(ImGuiCol_Text);
6544+
const ImU32 text_col = GetColorU32(ImGuiCol_HeaderText); // MicroStrain
65426545
ImGuiNavHighlightFlags nav_highlight_flags = ImGuiNavHighlightFlags_TypeThin;
65436546
if (display_frame)
65446547
{
@@ -6578,12 +6581,16 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
65786581
if (span_all_columns)
65796582
TablePopBackgroundChannel();
65806583

6584+
PushStyleColor(ImGuiCol_Text, text_col); // MicroStrain
6585+
65816586
// Label
65826587
if (display_frame)
65836588
RenderTextClipped(text_pos, frame_bb.Max, label, label_end, &label_size);
65846589
else
65856590
RenderText(text_pos, label, label_end, false);
65866591

6592+
PopStyleColor(); // MicroStrain
6593+
65876594
if (is_open && !(flags & ImGuiTreeNodeFlags_NoTreePushOnOpen))
65886595
TreePushOverrideID(id);
65896596
IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags | (is_leaf ? 0 : ImGuiItemStatusFlags_Openable) | (is_open ? ImGuiItemStatusFlags_Opened : 0));
@@ -6852,8 +6859,18 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
68526859
PopColumnsBackground();
68536860
}
68546861

6862+
// MicroStrain
6863+
if(hovered || selected)
6864+
ImGui::PushStyleColor(ImGuiCol_Text, GetColorU32(ImGuiCol_HeaderText));
6865+
else if(disabled_item || disabled_global)
6866+
ImGui::PushStyleColor(ImGuiCol_Text, GetColorU32(ImGuiCol_TextDisabled));
6867+
68556868
RenderTextClipped(text_min, text_max, label, NULL, &label_size, style.SelectableTextAlign, &bb);
68566869

6870+
// MicroStrain
6871+
if(hovered || selected || disabled_item || disabled_global)
6872+
ImGui::PopStyleColor();
6873+
68576874
// Automatically close popups
68586875
if (pressed && ((window->Flags & ImGuiWindowFlags_Popup) || (window->IsExplicitChild && window->ParentWindow->Flags & ImGuiWindowFlags_Popup)) && !(flags & ImGuiSelectableFlags_DontClosePopups) && !(g.LastItemData.InFlags & ImGuiItemFlags_SelectableDontClosePopup))
68596876
CloseCurrentPopup();
@@ -8672,10 +8689,10 @@ static ImGuiTabItem* ImGui::TabBarScrollingButtons(ImGuiTabBar* tab_bar)
86728689
//window->DrawList->AddRect(ImVec2(tab_bar->BarRect.Max.x - scrolling_buttons_width, tab_bar->BarRect.Min.y), ImVec2(tab_bar->BarRect.Max.x, tab_bar->BarRect.Max.y), IM_COL32(255,0,0,255));
86738690

86748691
int select_dir = 0;
8675-
ImVec4 arrow_col = g.Style.Colors[ImGuiCol_Text];
8692+
ImVec4 arrow_col = g.Style.Colors[ImGuiCol_TabText]; // MicroStrain
86768693
arrow_col.w *= 0.5f;
86778694

8678-
PushStyleColor(ImGuiCol_Text, arrow_col);
8695+
PushStyleColor(ImGuiCol_TabText, arrow_col); // MicroStrain
86798696
PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0));
86808697
const float backup_repeat_delay = g.IO.KeyRepeatDelay;
86818698
const float backup_repeat_rate = g.IO.KeyRepeatRate;
@@ -8732,9 +8749,9 @@ static ImGuiTabItem* ImGui::TabBarTabListPopupButton(ImGuiTabBar* tab_bar)
87328749
window->DC.CursorPos = ImVec2(tab_bar->BarRect.Min.x - g.Style.FramePadding.y, tab_bar->BarRect.Min.y);
87338750
tab_bar->BarRect.Min.x += tab_list_popup_button_width;
87348751

8735-
ImVec4 arrow_col = g.Style.Colors[ImGuiCol_Text];
8752+
ImVec4 arrow_col = g.Style.Colors[ImGuiCol_TabText]; // MicroStrain
87368753
arrow_col.w *= 0.5f;
8737-
PushStyleColor(ImGuiCol_Text, arrow_col);
8754+
PushStyleColor(ImGuiCol_TabText, arrow_col); // MicroStrain
87388755
PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0));
87398756
bool open = BeginCombo("##v", NULL, ImGuiComboFlags_NoPreview | ImGuiComboFlags_HeightLargest);
87408757
PopStyleColor(2);
@@ -9245,7 +9262,7 @@ void ImGui::TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb,
92459262
else if (unsaved_marker_visible)
92469263
{
92479264
const ImRect bullet_bb(button_pos, button_pos + ImVec2(button_sz, button_sz));
9248-
RenderBullet(draw_list, bullet_bb.GetCenter(), GetColorU32(ImGuiCol_Text));
9265+
RenderBullet(draw_list, bullet_bb.GetCenter(), GetColorU32(ImGuiCol_TabText)); // MicroStrain
92499266
}
92509267

92519268
// This is all rather complicated
@@ -9258,7 +9275,10 @@ void ImGui::TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb,
92589275
text_ellipsis_clip_bb.Max.x -= unsaved_marker_visible ? (button_sz * 0.80f) : 0.0f;
92599276
ellipsis_max_x = text_pixel_clip_bb.Max.x;
92609277
}
9278+
9279+
PushStyleColor(ImGuiCol_Text, GetColorU32(ImGuiCol_TabText)); // MicroStrain
92619280
RenderTextEllipsis(draw_list, text_ellipsis_clip_bb.Min, text_ellipsis_clip_bb.Max, text_pixel_clip_bb.Max.x, ellipsis_max_x, label, NULL, &label_size);
9281+
PopStyleColor(); // MicroStrain
92629282

92639283
#if 0
92649284
if (!is_contents_visible)

0 commit comments

Comments
 (0)