mirror of
https://github.com/ocornut/imgui.git
synced 2026-05-27 11:05:26 +08:00
Internals: minor refactor of TabItemLabelAndCloseButton(), should be no-op.
(minor thing toward #7024)
This commit is contained in:
+7
-7
@@ -10466,13 +10466,13 @@ void ImGui::TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Render text label (with clipping + alpha gradient) + unsaved marker
|
// Render text label (with clipping + alpha gradient) + unsaved marker
|
||||||
ImRect text_pixel_clip_bb(bb.Min.x + frame_padding.x, bb.Min.y + frame_padding.y, bb.Max.x - frame_padding.x, bb.Max.y);
|
ImRect text_ellipsis_clip_bb(bb.Min.x + frame_padding.x, bb.Min.y + frame_padding.y, bb.Max.x - frame_padding.x, bb.Max.y);
|
||||||
ImRect text_ellipsis_clip_bb = text_pixel_clip_bb;
|
float text_pixel_clip_bb_max_x = text_ellipsis_clip_bb.Max.x;
|
||||||
|
|
||||||
// Return clipped state ignoring the close button
|
// Return clipped state ignoring the close button
|
||||||
if (out_text_clipped)
|
if (out_text_clipped)
|
||||||
{
|
{
|
||||||
*out_text_clipped = (text_ellipsis_clip_bb.Min.x + label_size.x) > text_pixel_clip_bb.Max.x;
|
*out_text_clipped = (text_ellipsis_clip_bb.Min.x + label_size.x) > text_pixel_clip_bb_max_x;
|
||||||
//draw_list->AddCircle(text_ellipsis_clip_bb.Min, 3.0f, *out_text_clipped ? IM_COL32(255, 0, 0, 255) : IM_COL32(0, 255, 0, 255));
|
//draw_list->AddCircle(text_ellipsis_clip_bb.Min, 3.0f, *out_text_clipped ? IM_COL32(255, 0, 0, 255) : IM_COL32(0, 255, 0, 255));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -10518,15 +10518,15 @@ void ImGui::TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb,
|
|||||||
// This is all rather complicated
|
// This is all rather complicated
|
||||||
// (the main idea is that because the close button only appears on hover, we don't want it to alter the ellipsis position)
|
// (the main idea is that because the close button only appears on hover, we don't want it to alter the ellipsis position)
|
||||||
// FIXME: if FramePadding is noticeably large, ellipsis_max_x will be wrong here (e.g. #3497), maybe for consistency that parameter of RenderTextEllipsis() shouldn't exist..
|
// FIXME: if FramePadding is noticeably large, ellipsis_max_x will be wrong here (e.g. #3497), maybe for consistency that parameter of RenderTextEllipsis() shouldn't exist..
|
||||||
float ellipsis_max_x = close_button_visible ? text_pixel_clip_bb.Max.x : bb.Max.x - 1.0f;
|
float ellipsis_max_x = close_button_visible ? text_pixel_clip_bb_max_x : bb.Max.x - 1.0f;
|
||||||
if (close_button_visible || unsaved_marker_visible)
|
if (close_button_visible || unsaved_marker_visible)
|
||||||
{
|
{
|
||||||
text_pixel_clip_bb.Max.x -= close_button_visible ? (button_sz) : (button_sz * 0.80f);
|
text_pixel_clip_bb_max_x -= close_button_visible ? (button_sz) : (button_sz * 0.80f);
|
||||||
text_ellipsis_clip_bb.Max.x -= unsaved_marker_visible ? (button_sz * 0.80f) : 0.0f;
|
text_ellipsis_clip_bb.Max.x -= unsaved_marker_visible ? (button_sz * 0.80f) : 0.0f;
|
||||||
ellipsis_max_x = text_pixel_clip_bb.Max.x;
|
ellipsis_max_x = text_pixel_clip_bb_max_x;
|
||||||
}
|
}
|
||||||
LogSetNextTextDecoration("/", "\\");
|
LogSetNextTextDecoration("/", "\\");
|
||||||
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);
|
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);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (!is_contents_visible)
|
if (!is_contents_visible)
|
||||||
|
|||||||
Reference in New Issue
Block a user