mirror of
https://github.com/ocornut/imgui.git
synced 2025-02-02 12:37:20 +01:00
Tabs, Style: reworked selected overline rendering to better accommodate for rounded tabs. (#8334)
This commit is contained in:
parent
e8779a67b1
commit
7ae7c90790
@ -54,6 +54,10 @@ Other changes:
|
|||||||
- Windows: legacy SetWindowFontScale() is properly inherited by nested child
|
- Windows: legacy SetWindowFontScale() is properly inherited by nested child
|
||||||
windows. Note that an upcoming major release should make this obsolete,
|
windows. Note that an upcoming major release should make this obsolete,
|
||||||
but in the meanwhile it works better now. (#2701, #8138, #1018)
|
but in the meanwhile it works better now. (#2701, #8138, #1018)
|
||||||
|
- Tabs, Style: reworked selected overline rendering to better accommodate
|
||||||
|
for rounded tabs. Reduced default thickness (style.TabBarOverlineSize),
|
||||||
|
increased default rounding (style.TabRounding). (#8334) [@Kian738, @ocornut]
|
||||||
|
styles as the current look is not right (but ImGuiCol_TabSelectedOverline stays the same).
|
||||||
- Examples: DirectX12: Reduced number of frame in flight from 3 to 2 in
|
- Examples: DirectX12: Reduced number of frame in flight from 3 to 2 in
|
||||||
provided example, to reduce latency.
|
provided example, to reduce latency.
|
||||||
- Examples: Vulkan: better handle VK_SUBOPTIMAL_KHR being returned by
|
- Examples: Vulkan: better handle VK_SUBOPTIMAL_KHR being returned by
|
||||||
|
@ -1334,11 +1334,11 @@ ImGuiStyle::ImGuiStyle()
|
|||||||
GrabMinSize = 12.0f; // Minimum width/height of a grab box for slider/scrollbar
|
GrabMinSize = 12.0f; // Minimum width/height of a grab box for slider/scrollbar
|
||||||
GrabRounding = 0.0f; // Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs.
|
GrabRounding = 0.0f; // Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs.
|
||||||
LogSliderDeadzone = 4.0f; // The size in pixels of the dead-zone around zero on logarithmic sliders that cross zero.
|
LogSliderDeadzone = 4.0f; // The size in pixels of the dead-zone around zero on logarithmic sliders that cross zero.
|
||||||
TabRounding = 4.0f; // Radius of upper corners of a tab. Set to 0.0f to have rectangular tabs.
|
TabRounding = 5.0f; // Radius of upper corners of a tab. Set to 0.0f to have rectangular tabs.
|
||||||
TabBorderSize = 0.0f; // Thickness of border around tabs.
|
TabBorderSize = 0.0f; // Thickness of border around tabs.
|
||||||
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.
|
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.
|
||||||
TabBarBorderSize = 1.0f; // Thickness of tab-bar separator, which takes on the tab active color to denote focus.
|
TabBarBorderSize = 1.0f; // Thickness of tab-bar separator, which takes on the tab active color to denote focus.
|
||||||
TabBarOverlineSize = 2.0f; // Thickness of tab-bar overline, which highlights the selected tab-bar.
|
TabBarOverlineSize = 1.0f; // Thickness of tab-bar overline, which highlights the selected tab-bar.
|
||||||
TableAngledHeadersAngle = 35.0f * (IM_PI / 180.0f); // Angle of angled headers (supported values range from -50 degrees to +50 degrees).
|
TableAngledHeadersAngle = 35.0f * (IM_PI / 180.0f); // Angle of angled headers (supported values range from -50 degrees to +50 degrees).
|
||||||
TableAngledHeadersTextAlign = ImVec2(0.5f,0.0f);// Alignment of angled headers within the cell
|
TableAngledHeadersTextAlign = ImVec2(0.5f,0.0f);// Alignment of angled headers within the cell
|
||||||
ColorButtonPosition = ImGuiDir_Right; // Side of the color button in the ColorEdit4 widget (left/right). Defaults to ImGuiDir_Right.
|
ColorButtonPosition = ImGuiDir_Right; // Side of the color button in the ColorEdit4 widget (left/right). Defaults to ImGuiDir_Right.
|
||||||
|
@ -7966,7 +7966,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
|||||||
ImGui::SliderFloat("FrameBorderSize", &style.FrameBorderSize, 0.0f, 1.0f, "%.0f");
|
ImGui::SliderFloat("FrameBorderSize", &style.FrameBorderSize, 0.0f, 1.0f, "%.0f");
|
||||||
ImGui::SliderFloat("TabBorderSize", &style.TabBorderSize, 0.0f, 1.0f, "%.0f");
|
ImGui::SliderFloat("TabBorderSize", &style.TabBorderSize, 0.0f, 1.0f, "%.0f");
|
||||||
ImGui::SliderFloat("TabBarBorderSize", &style.TabBarBorderSize, 0.0f, 2.0f, "%.0f");
|
ImGui::SliderFloat("TabBarBorderSize", &style.TabBarBorderSize, 0.0f, 2.0f, "%.0f");
|
||||||
ImGui::SliderFloat("TabBarOverlineSize", &style.TabBarOverlineSize, 0.0f, 2.0f, "%.0f");
|
ImGui::SliderFloat("TabBarOverlineSize", &style.TabBarOverlineSize, 0.0f, 3.0f, "%.0f");
|
||||||
ImGui::SameLine(); HelpMarker("Overline is only drawn over the selected tab when ImGuiTabBarFlags_DrawSelectedOverline is set.");
|
ImGui::SameLine(); HelpMarker("Overline is only drawn over the selected tab when ImGuiTabBarFlags_DrawSelectedOverline is set.");
|
||||||
|
|
||||||
ImGui::SeparatorText("Rounding");
|
ImGui::SeparatorText("Rounding");
|
||||||
|
@ -10150,11 +10150,21 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
|
|||||||
TabItemBackground(display_draw_list, bb, flags, tab_col);
|
TabItemBackground(display_draw_list, bb, flags, tab_col);
|
||||||
if (tab_contents_visible && (tab_bar->Flags & ImGuiTabBarFlags_DrawSelectedOverline) && style.TabBarOverlineSize > 0.0f)
|
if (tab_contents_visible && (tab_bar->Flags & ImGuiTabBarFlags_DrawSelectedOverline) && style.TabBarOverlineSize > 0.0f)
|
||||||
{
|
{
|
||||||
float x_offset = IM_TRUNC(0.4f * style.TabRounding);
|
// Might be moved to TabItemBackground() ?
|
||||||
if (x_offset < 2.0f * g.CurrentDpiScale)
|
ImVec2 tl = bb.GetTL() + ImVec2(0, 1.0f * g.CurrentDpiScale);
|
||||||
x_offset = 0.0f;
|
ImVec2 tr = bb.GetTR() + ImVec2(0, 1.0f * g.CurrentDpiScale);
|
||||||
float y_offset = 1.0f * g.CurrentDpiScale;
|
ImU32 overline_col = GetColorU32(tab_bar_focused ? ImGuiCol_TabSelectedOverline : ImGuiCol_TabDimmedSelectedOverline);
|
||||||
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);
|
if (style.TabRounding > 0.0f)
|
||||||
|
{
|
||||||
|
float rounding = style.TabRounding;
|
||||||
|
display_draw_list->PathArcToFast(tl + ImVec2(+rounding, +rounding), rounding, 7, 9);
|
||||||
|
display_draw_list->PathArcToFast(tr + ImVec2(-rounding, +rounding), rounding, 9, 11);
|
||||||
|
display_draw_list->PathStroke(overline_col, 0, style.TabBarOverlineSize);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
display_draw_list->AddLine(tl - ImVec2(0.5f, 0.5f), tr - ImVec2(0.5f, 0.5f), overline_col, style.TabBarOverlineSize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
RenderNavCursor(bb, id);
|
RenderNavCursor(bb, id);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user