mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-22 15:46:35 +00:00
Tab Bar: Fixed a small bug where scrolling buttons (with ImGuiTabBarFlags_FittingPolicyScroll) would generate an unnecessary extra draw call.
This commit is contained in:
parent
afc1099fb5
commit
27d0c3afa9
@ -82,6 +82,8 @@ Other Changes:
|
||||
(This is also necessary to support full multi/range-select/drag and drop operations.)
|
||||
- Tab Bar: Keep tab item close button visible while dragging a tab (independent of hovering state).
|
||||
- Tab Bar: Fixed a small bug where closing a tab that is not selected would leave a tab hole for a frame.
|
||||
- Tab Bar: Fixed a small bug where scrolling buttons (with ImGuiTabBarFlags_FittingPolicyScroll) would
|
||||
generate an unnecessary extra draw call.
|
||||
- Tab Bar: Fixed a small bug where toggling a tab bar from Reorderable to not Reorderable would leave
|
||||
tabs reordered in the tab list popup. [@Xipiryon]
|
||||
- Columns: Fix inverted ClipRect being passed to renderer when using certain primitives inside of
|
||||
|
@ -7234,13 +7234,6 @@ static ImGuiTabItem* ImGui::TabBarScrollingButtons(ImGuiTabBar* tab_bar)
|
||||
const ImVec2 backup_cursor_pos = window->DC.CursorPos;
|
||||
//window->DrawList->AddRect(ImVec2(tab_bar->BarRect.Max.x - scrolling_buttons_width, tab_bar->BarRect.Min.y), ImVec2(tab_bar->BarRect.Max.x, tab_bar->BarRect.Max.y), IM_COL32(255,0,0,255));
|
||||
|
||||
const ImRect avail_bar_rect = tab_bar->BarRect;
|
||||
bool want_clip_rect = !avail_bar_rect.Contains(ImRect(window->DC.CursorPos, window->DC.CursorPos + ImVec2(scrolling_buttons_width, 0.0f)));
|
||||
if (want_clip_rect)
|
||||
PushClipRect(tab_bar->BarRect.Min, tab_bar->BarRect.Max + ImVec2(g.Style.ItemInnerSpacing.x, 0.0f), true);
|
||||
|
||||
ImGuiTabItem* tab_to_select = NULL;
|
||||
|
||||
int select_dir = 0;
|
||||
ImVec4 arrow_col = g.Style.Colors[ImGuiCol_Text];
|
||||
arrow_col.w *= 0.5f;
|
||||
@ -7251,30 +7244,29 @@ static ImGuiTabItem* ImGui::TabBarScrollingButtons(ImGuiTabBar* tab_bar)
|
||||
const float backup_repeat_rate = g.IO.KeyRepeatRate;
|
||||
g.IO.KeyRepeatDelay = 0.250f;
|
||||
g.IO.KeyRepeatRate = 0.200f;
|
||||
window->DC.CursorPos = ImVec2(tab_bar->BarRect.Max.x - scrolling_buttons_width, tab_bar->BarRect.Min.y);
|
||||
float x = ImMax(tab_bar->BarRect.Min.x, tab_bar->BarRect.Max.x - scrolling_buttons_width);
|
||||
window->DC.CursorPos = ImVec2(x, tab_bar->BarRect.Min.y);
|
||||
if (ArrowButtonEx("##<", ImGuiDir_Left, arrow_button_size, ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_Repeat))
|
||||
select_dir = -1;
|
||||
window->DC.CursorPos = ImVec2(tab_bar->BarRect.Max.x - scrolling_buttons_width + arrow_button_size.x, tab_bar->BarRect.Min.y);
|
||||
window->DC.CursorPos = ImVec2(x + arrow_button_size.x, tab_bar->BarRect.Min.y);
|
||||
if (ArrowButtonEx("##>", ImGuiDir_Right, arrow_button_size, ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_Repeat))
|
||||
select_dir = +1;
|
||||
PopStyleColor(2);
|
||||
g.IO.KeyRepeatRate = backup_repeat_rate;
|
||||
g.IO.KeyRepeatDelay = backup_repeat_delay;
|
||||
|
||||
if (want_clip_rect)
|
||||
PopClipRect();
|
||||
|
||||
ImGuiTabItem* tab_to_scroll_to = NULL;
|
||||
if (select_dir != 0)
|
||||
if (ImGuiTabItem* tab_item = TabBarFindTabByID(tab_bar, tab_bar->SelectedTabId))
|
||||
{
|
||||
int selected_order = tab_bar->GetTabOrder(tab_item);
|
||||
int target_order = selected_order + select_dir;
|
||||
tab_to_select = &tab_bar->Tabs[(target_order >= 0 && target_order < tab_bar->Tabs.Size) ? target_order : selected_order]; // If we are at the end of the list, still scroll to make our tab visible
|
||||
tab_to_scroll_to = &tab_bar->Tabs[(target_order >= 0 && target_order < tab_bar->Tabs.Size) ? target_order : selected_order]; // If we are at the end of the list, still scroll to make our tab visible
|
||||
}
|
||||
window->DC.CursorPos = backup_cursor_pos;
|
||||
tab_bar->BarRect.Max.x -= scrolling_buttons_width + 1.0f;
|
||||
|
||||
return tab_to_select;
|
||||
return tab_to_scroll_to;
|
||||
}
|
||||
|
||||
static ImGuiTabItem* ImGui::TabBarTabListPopupButton(ImGuiTabBar* tab_bar)
|
||||
|
Loading…
Reference in New Issue
Block a user