|
@@ -7618,6 +7618,12 @@ void ImGui::EndTabBar()
|
|
|
g.CurrentTabBar = g.CurrentTabBarStack.empty() ? NULL : GetTabBarFromTabBarRef(g.CurrentTabBarStack.back());
|
|
|
}
|
|
|
|
|
|
+// Scrolling happens only in the central section (leading/trailing sections are not scrolling)
|
|
|
+static float TabBarCalcScrollableWidth(ImGuiTabBar* tab_bar, ImGuiTabBarSection* sections)
|
|
|
+{
|
|
|
+ return tab_bar->BarRect.GetWidth() - sections[0].Width - sections[2].Width - sections[1].Spacing;
|
|
|
+}
|
|
|
+
|
|
|
// This is called only once a frame before by the first call to ItemTab()
|
|
|
// The reason we're not calling it in BeginTabBar() is to leave a chance to the user to call the SetTabItemClosed() functions.
|
|
|
static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
|
|
@@ -7820,9 +7826,23 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
|
|
|
tab_bar->VisibleTabId = tab_bar->SelectedTabId;
|
|
|
tab_bar->VisibleTabWasSubmitted = false;
|
|
|
|
|
|
- // Update scrolling
|
|
|
+ // Apply request requests
|
|
|
if (scroll_to_tab_id != 0)
|
|
|
TabBarScrollToTab(tab_bar, scroll_to_tab_id, sections);
|
|
|
+ else if ((tab_bar->Flags & ImGuiTabBarFlags_FittingPolicyScroll) && IsMouseHoveringRect(tab_bar->BarRect.Min, tab_bar->BarRect.Max, true) && IsWindowContentHoverable(g.CurrentWindow))
|
|
|
+ {
|
|
|
+ const float wheel = g.IO.MouseWheelRequestAxisSwap ? g.IO.MouseWheel : g.IO.MouseWheelH;
|
|
|
+ const ImGuiKey wheel_key = g.IO.MouseWheelRequestAxisSwap ? ImGuiKey_MouseWheelY : ImGuiKey_MouseWheelX;
|
|
|
+ if (TestKeyOwner(wheel_key, tab_bar->ID) && wheel != 0.0f)
|
|
|
+ {
|
|
|
+ const float scroll_step = wheel * TabBarCalcScrollableWidth(tab_bar, sections) / 3.0f;
|
|
|
+ tab_bar->ScrollingTargetDistToVisibility = 0.0f;
|
|
|
+ tab_bar->ScrollingTarget = TabBarScrollClamp(tab_bar, tab_bar->ScrollingTarget - scroll_step);
|
|
|
+ }
|
|
|
+ SetKeyOwner(wheel_key, tab_bar->ID);
|
|
|
+ }
|
|
|
+
|
|
|
+ // Update scrolling
|
|
|
tab_bar->ScrollingAnim = TabBarScrollClamp(tab_bar, tab_bar->ScrollingAnim);
|
|
|
tab_bar->ScrollingTarget = TabBarScrollClamp(tab_bar, tab_bar->ScrollingTarget);
|
|
|
if (tab_bar->ScrollingAnim != tab_bar->ScrollingTarget)
|
|
@@ -7959,8 +7979,7 @@ static void ImGui::TabBarScrollToTab(ImGuiTabBar* tab_bar, ImGuiID tab_id, ImGui
|
|
|
int order = TabBarGetTabOrder(tab_bar, tab);
|
|
|
|
|
|
// Scrolling happens only in the central section (leading/trailing sections are not scrolling)
|
|
|
- // FIXME: This is all confusing.
|
|
|
- float scrollable_width = tab_bar->BarRect.GetWidth() - sections[0].Width - sections[2].Width - sections[1].Spacing;
|
|
|
+ float scrollable_width = TabBarCalcScrollableWidth(tab_bar, sections);
|
|
|
|
|
|
// We make all tabs positions all relative Sections[0].Width to make code simpler
|
|
|
float tab_x1 = tab->Offset - sections[0].Width + (order > sections[0].TabCount - 1 ? -margin : 0.0f);
|