mirror of
https://github.com/shadps4-emu/ext-imgui.git
synced 2024-11-23 18:29:42 +00:00
TabBar: Tweak shrinking policy so that while resizing tabs that don't need shrinking keep their initial width more precisely.
Has been the case before but adding support for SetNextItemWidth() #5262 made this more noticeable.
This commit is contained in:
parent
4b97296148
commit
c4b9101759
@ -106,6 +106,8 @@ Other Changes:
|
|||||||
- Inputs: Fixed IsMouseClicked() repeat mode rate being half of keyboard repeat rate.
|
- Inputs: Fixed IsMouseClicked() repeat mode rate being half of keyboard repeat rate.
|
||||||
- ColorEdit: Fixed text baseline alignment after a SameLine() after a ColorEdit() with visible label.
|
- ColorEdit: Fixed text baseline alignment after a SameLine() after a ColorEdit() with visible label.
|
||||||
- TabBar: TabItem() now reacts to SetNextItemWidth() and SetNextItemOpen(true). (#5262)
|
- TabBar: TabItem() now reacts to SetNextItemWidth() and SetNextItemOpen(true). (#5262)
|
||||||
|
- TabBar: Tweak shrinking policy so that while resizing tabs that don't need shrinking keep their
|
||||||
|
initial width more precisely (without the occasional +1 worth of width).
|
||||||
- Menus: Adjusted BeginMenu() closing logic so hovering void or non-MenuItem() in parent window
|
- Menus: Adjusted BeginMenu() closing logic so hovering void or non-MenuItem() in parent window
|
||||||
always lead to menu closure. Fixes using items that are not MenuItem() or BeginItem() at the root
|
always lead to menu closure. Fixes using items that are not MenuItem() or BeginItem() at the root
|
||||||
level of a popup with a child menu opened.
|
level of a popup with a child menu opened.
|
||||||
|
@ -1150,6 +1150,7 @@ struct ImGuiShrinkWidthItem
|
|||||||
{
|
{
|
||||||
int Index;
|
int Index;
|
||||||
float Width;
|
float Width;
|
||||||
|
float InitialWidth;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ImGuiPtrOrIndex
|
struct ImGuiPtrOrIndex
|
||||||
|
@ -1540,7 +1540,7 @@ void ImGui::ShrinkWidths(ImGuiShrinkWidthItem* items, int count, float width_exc
|
|||||||
width_excess -= width_to_remove_per_item * count_same_width;
|
width_excess -= width_to_remove_per_item * count_same_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Round width and redistribute remainder left-to-right (could make it an option of the function?)
|
// Round width and redistribute remainder
|
||||||
// Ensure that e.g. the right-most tab of a shrunk tab-bar always reaches exactly at the same distance from the right-most edge of the tab bar separator.
|
// Ensure that e.g. the right-most tab of a shrunk tab-bar always reaches exactly at the same distance from the right-most edge of the tab bar separator.
|
||||||
width_excess = 0.0f;
|
width_excess = 0.0f;
|
||||||
for (int n = 0; n < count; n++)
|
for (int n = 0; n < count; n++)
|
||||||
@ -1549,10 +1549,13 @@ void ImGui::ShrinkWidths(ImGuiShrinkWidthItem* items, int count, float width_exc
|
|||||||
width_excess += items[n].Width - width_rounded;
|
width_excess += items[n].Width - width_rounded;
|
||||||
items[n].Width = width_rounded;
|
items[n].Width = width_rounded;
|
||||||
}
|
}
|
||||||
if (width_excess > 0.0f)
|
while (width_excess > 0.0f)
|
||||||
for (int n = 0; n < count; n++)
|
for (int n = 0; n < count; n++)
|
||||||
if (items[n].Index < (int)(width_excess + 0.01f))
|
if (items[n].Width + 1.0f <= items[n].InitialWidth)
|
||||||
|
{
|
||||||
items[n].Width += 1.0f;
|
items[n].Width += 1.0f;
|
||||||
|
width_excess -= 1.0f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
@ -7557,9 +7560,9 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
|
|||||||
|
|
||||||
// Store data so we can build an array sorted by width if we need to shrink tabs down
|
// Store data so we can build an array sorted by width if we need to shrink tabs down
|
||||||
IM_MSVC_WARNING_SUPPRESS(6385);
|
IM_MSVC_WARNING_SUPPRESS(6385);
|
||||||
int shrink_buffer_index = shrink_buffer_indexes[section_n]++;
|
ImGuiShrinkWidthItem* shrink_width_item = &g.ShrinkWidthBuffer[shrink_buffer_indexes[section_n]++];
|
||||||
g.ShrinkWidthBuffer[shrink_buffer_index].Index = tab_n;
|
shrink_width_item->Index = tab_n;
|
||||||
g.ShrinkWidthBuffer[shrink_buffer_index].Width = tab->ContentWidth;
|
shrink_width_item->Width = shrink_width_item->InitialWidth = tab->ContentWidth;
|
||||||
|
|
||||||
IM_ASSERT(tab->ContentWidth > 0.0f);
|
IM_ASSERT(tab->ContentWidth > 0.0f);
|
||||||
tab->Width = tab->ContentWidth;
|
tab->Width = tab->ContentWidth;
|
||||||
|
Loading…
Reference in New Issue
Block a user