Tabs: Fixed border (when enabled) so it is aligned correctly mid-pixel and appears as bright as other borders.

This commit is contained in:
omar 2019-02-07 12:06:48 +01:00
parent 29d38b59d0
commit 1b63ded8fa
2 changed files with 13 additions and 7 deletions

View file

@ -50,6 +50,7 @@ Other Changes:
- Tabs: Added ImGuiTabBarFlags_TabListPopupButton flag to show a popup button on manual tab bars. (#261, #351) - Tabs: Added ImGuiTabBarFlags_TabListPopupButton flag to show a popup button on manual tab bars. (#261, #351)
- Tabs: Removed ImGuiTabBarFlags_NoTabListPopupButton which was available in 1.67 but actually had zero use. - Tabs: Removed ImGuiTabBarFlags_NoTabListPopupButton which was available in 1.67 but actually had zero use.
- Tabs: Fixed a minor clipping glitch when changing style's FramePadding from frame to frame. - Tabs: Fixed a minor clipping glitch when changing style's FramePadding from frame to frame.
- Tabs: Fixed border (when enabled) so it is aligned correctly mid-pixel and appears as bright as other borders.
- Menus: Tweaked horizontal overlap between parent and child menu (to help convey relative depth) - Menus: Tweaked horizontal overlap between parent and child menu (to help convey relative depth)
from using style.ItemSpacing.x to style.ItemInnerSpacing.x, the later being expected to be smaller. (#1086) from using style.ItemSpacing.x to style.ItemInnerSpacing.x, the later being expected to be smaller. (#1086)
- RadioButton: Fixed label horizontal alignment to precisely match Checkbox(). - RadioButton: Fixed label horizontal alignment to precisely match Checkbox().

View file

@ -6281,7 +6281,7 @@ static ImGuiTabItem* ImGui::TabBarTabListPopupButton(ImGuiTabBar* tab_bar)
// - TabItemEx() [Internal] // - TabItemEx() [Internal]
// - SetTabItemClosed() // - SetTabItemClosed()
// - TabItemCalcSize() [Internal] // - TabItemCalcSize() [Internal]
// - TabItemRenderBackground() [Internal] // - TabItemBackground() [Internal]
// - TabItemLabelAndCloseButton() [Internal] // - TabItemLabelAndCloseButton() [Internal]
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
@ -6465,7 +6465,7 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
// Enlarge tab display when hovering // Enlarge tab display when hovering
bb.Max.x = bb.Min.x + (float)(int)ImLerp(bb.GetWidth(), tab->WidthContents, ImSaturate((g.HoveredIdNotActiveTimer - 0.40f) * 6.0f)); bb.Max.x = bb.Min.x + (float)(int)ImLerp(bb.GetWidth(), tab->WidthContents, ImSaturate((g.HoveredIdNotActiveTimer - 0.40f) * 6.0f));
display_draw_list = GetOverlayDrawList(window); display_draw_list = GetOverlayDrawList(window);
TabItemRenderBackground(display_draw_list, bb, flags, GetColorU32(ImGuiCol_TitleBgActive)); TabItemBackground(display_draw_list, bb, flags, GetColorU32(ImGuiCol_TitleBgActive));
} }
#endif #endif
@ -6540,16 +6540,21 @@ void ImGui::TabItemBackground(ImDrawList* draw_list, const ImRect& bb, ImGuiTabI
IM_UNUSED(flags); IM_UNUSED(flags);
IM_ASSERT(width > 0.0f); IM_ASSERT(width > 0.0f);
const float rounding = ImMax(0.0f, ImMin(g.Style.TabRounding, width * 0.5f - 1.0f)); const float rounding = ImMax(0.0f, ImMin(g.Style.TabRounding, width * 0.5f - 1.0f));
float y1 = bb.Min.y + 1.0f; const float y1 = bb.Min.y + 1.0f;
float y2 = bb.Max.y - 1.0f; const float y2 = bb.Max.y - 1.0f;
draw_list->PathLineTo(ImVec2(bb.Min.x, y2)); draw_list->PathLineTo(ImVec2(bb.Min.x, y2));
draw_list->PathArcToFast(ImVec2(bb.Min.x + rounding, y1 + rounding), rounding, 6, 9); draw_list->PathArcToFast(ImVec2(bb.Min.x + rounding, y1 + rounding), rounding, 6, 9);
draw_list->PathArcToFast(ImVec2(bb.Max.x - rounding, y1 + rounding), rounding, 9, 12); draw_list->PathArcToFast(ImVec2(bb.Max.x - rounding, y1 + rounding), rounding, 9, 12);
draw_list->PathLineTo(ImVec2(bb.Max.x, y2)); draw_list->PathLineTo(ImVec2(bb.Max.x, y2));
draw_list->AddConvexPolyFilled(draw_list->_Path.Data, draw_list->_Path.Size, col); draw_list->PathFillConvex(col);
if (g.Style.TabBorderSize > 0.0f) if (g.Style.TabBorderSize > 0.0f)
draw_list->AddPolyline(draw_list->_Path.Data, draw_list->_Path.Size, GetColorU32(ImGuiCol_Border), false, g.Style.TabBorderSize); {
draw_list->PathClear(); draw_list->PathLineTo(ImVec2(bb.Min.x + 0.5f, y2));
draw_list->PathArcToFast(ImVec2(bb.Min.x + rounding + 0.5f, y1 + rounding + 0.5f), rounding, 6, 9);
draw_list->PathArcToFast(ImVec2(bb.Max.x - rounding - 0.5f, y1 + rounding + 0.5f), rounding, 9, 12);
draw_list->PathLineTo(ImVec2(bb.Max.x - 0.5f, y2));
draw_list->PathStroke(GetColorU32(ImGuiCol_Border), false, g.Style.TabBorderSize);
}
} }
// Render text label (with custom clipping) + Unsaved Document marker + Close Button logic // Render text label (with custom clipping) + Unsaved Document marker + Close Button logic