Skip to content

Commit da36336

Browse files
DctrNoobocornut
authored andcommitted
TabBar, Style: added style option for the size of the Tab-Bar Overline (#7804)
Amend 21bda2e.
1 parent eb72b5a commit da36336

File tree

5 files changed

+13
-4
lines changed

5 files changed

+13
-4
lines changed

docs/CHANGELOG.txt

+2
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ Other changes:
139139
can use the clipper without knowing the amount of items beforehand. (#1311)
140140
In this situation, call ImGuiListClipper::SeekCursorForItem(items_count) as the end of your iteration
141141
loop to position the layout cursor correctly. This is done automatically if provided a count to Begin().
142+
- TabBar, Style: added style.TabBarOverlineSize / ImGuiStyleVar_TabBarOverlineSize to manipulate
143+
thickness of the horizontal line over selectable tabs. [@DctrNoob]
142144
- Style: close button and collapse/window-menu button hover highlight made rectangular instead of round.
143145
- Debug Tools: Added IMGUI_DEBUG_LOG(), ImGui::DebugLog() in public API. (#5855)
144146
Debug log entries add a imgui frame counter prefix + are redirected to ShowDebugLogWindow() and

imgui.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -1269,12 +1269,13 @@ ImGuiStyle::ImGuiStyle()
12691269
TabBorderSize = 0.0f; // Thickness of border around tabs.
12701270
TabMinWidthForCloseButton = 0.0f; // Minimum width for close button to appear on an unselected tab when hovered. Set to 0.0f to always show when hovering, set to FLT_MAX to never show close button unless selected.
12711271
TabBarBorderSize = 1.0f; // Thickness of tab-bar separator, which takes on the tab active color to denote focus.
1272+
TabBarOverlineSize = 2.0f; // Thickness of tab-bar overline, which highlights the selected tab-bar.
12721273
TableAngledHeadersAngle = 35.0f * (IM_PI / 180.0f); // Angle of angled headers (supported values range from -50 degrees to +50 degrees).
12731274
TableAngledHeadersTextAlign = ImVec2(0.5f,0.0f);// Alignment of angled headers within the cell
12741275
ColorButtonPosition = ImGuiDir_Right; // Side of the color button in the ColorEdit4 widget (left/right). Defaults to ImGuiDir_Right.
12751276
ButtonTextAlign = ImVec2(0.5f,0.5f);// Alignment of button text when button is larger than text.
12761277
SelectableTextAlign = ImVec2(0.0f,0.0f);// Alignment of selectable text. Defaults to (0.0f, 0.0f) (top-left aligned). It's generally important to keep this left-aligned if you want to lay multiple items on a same line.
1277-
SeparatorTextBorderSize = 3.0f; // Thickkness of border in SeparatorText()
1278+
SeparatorTextBorderSize = 3.0f; // Thickness of border in SeparatorText()
12781279
SeparatorTextAlign = ImVec2(0.0f,0.5f);// Alignment of text within the separator. Defaults to (0.0f, 0.5f) (left aligned, center).
12791280
SeparatorTextPadding = ImVec2(20.0f,3.f);// Horizontal offset of text from each edge of the separator + spacing on other axis. Generally small values. .y is recommended to be == FramePadding.y.
12801281
DisplayWindowPadding = ImVec2(19,19); // Window position are clamped to be visible within the display area or monitors by at least this amount. Only applies to regular windows.
@@ -1321,6 +1322,7 @@ void ImGuiStyle::ScaleAllSizes(float scale_factor)
13211322
LogSliderDeadzone = ImTrunc(LogSliderDeadzone * scale_factor);
13221323
TabRounding = ImTrunc(TabRounding * scale_factor);
13231324
TabMinWidthForCloseButton = (TabMinWidthForCloseButton != FLT_MAX) ? ImTrunc(TabMinWidthForCloseButton * scale_factor) : FLT_MAX;
1325+
TabBarOverlineSize = ImTrunc(TabBarOverlineSize * scale_factor);
13241326
SeparatorTextPadding = ImTrunc(SeparatorTextPadding * scale_factor);
13251327
DisplayWindowPadding = ImTrunc(DisplayWindowPadding * scale_factor);
13261328
DisplaySafeAreaPadding = ImTrunc(DisplaySafeAreaPadding * scale_factor);
@@ -3274,6 +3276,7 @@ static const ImGuiDataVarInfo GStyleVarInfo[] =
32743276
{ ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, TabRounding) }, // ImGuiStyleVar_TabRounding
32753277
{ ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, TabBorderSize) }, // ImGuiStyleVar_TabBorderSize
32763278
{ ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, TabBarBorderSize) }, // ImGuiStyleVar_TabBarBorderSize
3279+
{ ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, TabBarOverlineSize) }, // ImGuiStyleVar_TabBarOverlineSize
32773280
{ ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, TableAngledHeadersAngle)}, // ImGuiStyleVar_TableAngledHeadersAngle
32783281
{ ImGuiDataType_Float, 2, (ImU32)offsetof(ImGuiStyle, TableAngledHeadersTextAlign)},// ImGuiStyleVar_TableAngledHeadersTextAlign
32793282
{ ImGuiDataType_Float, 2, (ImU32)offsetof(ImGuiStyle, ButtonTextAlign) }, // ImGuiStyleVar_ButtonTextAlign

imgui.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -1711,6 +1711,7 @@ enum ImGuiStyleVar_
17111711
ImGuiStyleVar_TabRounding, // float TabRounding
17121712
ImGuiStyleVar_TabBorderSize, // float TabBorderSize
17131713
ImGuiStyleVar_TabBarBorderSize, // float TabBarBorderSize
1714+
ImGuiStyleVar_TabBarOverlineSize, // float TabBarOverlineSize
17141715
ImGuiStyleVar_TableAngledHeadersAngle, // float TableAngledHeadersAngle
17151716
ImGuiStyleVar_TableAngledHeadersTextAlign,// ImVec2 TableAngledHeadersTextAlign
17161717
ImGuiStyleVar_ButtonTextAlign, // ImVec2 ButtonTextAlign
@@ -2154,12 +2155,13 @@ struct ImGuiStyle
21542155
float TabBorderSize; // Thickness of border around tabs.
21552156
float TabMinWidthForCloseButton; // Minimum width for close button to appear on an unselected tab when hovered. Set to 0.0f to always show when hovering, set to FLT_MAX to never show close button unless selected.
21562157
float TabBarBorderSize; // Thickness of tab-bar separator, which takes on the tab active color to denote focus.
2158+
float TabBarOverlineSize; // Thickness of tab-bar overline, which highlights the selected tab-bar.
21572159
float TableAngledHeadersAngle; // Angle of angled headers (supported values range from -50.0f degrees to +50.0f degrees).
21582160
ImVec2 TableAngledHeadersTextAlign;// Alignment of angled headers within the cell
21592161
ImGuiDir ColorButtonPosition; // Side of the color button in the ColorEdit4 widget (left/right). Defaults to ImGuiDir_Right.
21602162
ImVec2 ButtonTextAlign; // Alignment of button text when button is larger than text. Defaults to (0.5f, 0.5f) (centered).
21612163
ImVec2 SelectableTextAlign; // Alignment of selectable text. Defaults to (0.0f, 0.0f) (top-left aligned). It's generally important to keep this left-aligned if you want to lay multiple items on a same line.
2162-
float SeparatorTextBorderSize; // Thickkness of border in SeparatorText()
2164+
float SeparatorTextBorderSize; // Thickness of border in SeparatorText()
21632165
ImVec2 SeparatorTextAlign; // Alignment of text within the separator. Defaults to (0.0f, 0.5f) (left aligned, center).
21642166
ImVec2 SeparatorTextPadding; // Horizontal offset of text from each edge of the separator + spacing on other axis. Generally small values. .y is recommended to be == FramePadding.y.
21652167
ImVec2 DisplayWindowPadding; // Apply to regular windows: amount which we enforce to keep visible when moving near edges of your screen.

imgui_demo.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -7633,6 +7633,8 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
76337633
ImGui::SliderFloat("FrameBorderSize", &style.FrameBorderSize, 0.0f, 1.0f, "%.0f");
76347634
ImGui::SliderFloat("TabBorderSize", &style.TabBorderSize, 0.0f, 1.0f, "%.0f");
76357635
ImGui::SliderFloat("TabBarBorderSize", &style.TabBarBorderSize, 0.0f, 2.0f, "%.0f");
7636+
ImGui::SliderFloat("TabBarOverlineSize", &style.TabBarOverlineSize, 0.0f, 2.0f, "%.0f");
7637+
ImGui::SameLine(); HelpMarker("Overline is only drawn over the selected tab when ImGuiTabBarFlags_DrawSelectedOverline is set.");
76367638

76377639
ImGui::SeparatorText("Rounding");
76387640
ImGui::SliderFloat("WindowRounding", &style.WindowRounding, 0.0f, 12.0f, "%.0f");

imgui_widgets.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -9917,13 +9917,13 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
99179917
ImDrawList* display_draw_list = window->DrawList;
99189918
const ImU32 tab_col = GetColorU32((held || hovered) ? ImGuiCol_TabHovered : tab_contents_visible ? (tab_bar_focused ? ImGuiCol_TabSelected : ImGuiCol_TabDimmedSelected) : (tab_bar_focused ? ImGuiCol_Tab : ImGuiCol_TabDimmed));
99199919
TabItemBackground(display_draw_list, bb, flags, tab_col);
9920-
if (tab_contents_visible && (tab_bar->Flags & ImGuiTabBarFlags_DrawSelectedOverline))
9920+
if (tab_contents_visible && (tab_bar->Flags & ImGuiTabBarFlags_DrawSelectedOverline) && style.TabBarOverlineSize > 0.0f)
99219921
{
99229922
float x_offset = IM_TRUNC(0.4f * style.TabRounding);
99239923
if (x_offset < 2.0f * g.CurrentDpiScale)
99249924
x_offset = 0.0f;
99259925
float y_offset = 1.0f * g.CurrentDpiScale;
9926-
display_draw_list->AddLine(bb.GetTL() + ImVec2(x_offset, y_offset), bb.GetTR() + ImVec2(-x_offset, y_offset), GetColorU32(tab_bar_focused ? ImGuiCol_TabSelectedOverline : ImGuiCol_TabDimmedSelectedOverline), 2.0f * g.CurrentDpiScale);
9926+
display_draw_list->AddLine(bb.GetTL() + ImVec2(x_offset, y_offset), bb.GetTR() + ImVec2(-x_offset, y_offset), GetColorU32(tab_bar_focused ? ImGuiCol_TabSelectedOverline : ImGuiCol_TabDimmedSelectedOverline), style.TabBarOverlineSize);
99279927
}
99289928
RenderNavHighlight(bb, id);
99299929

0 commit comments

Comments
 (0)