|
@@ -6761,7 +6761,7 @@ bool ImGui::MenuItem(const char* label, const char* shortcut, bool* p_selected,
|
|
// - TabBarFindTabById() [Internal]
|
|
// - TabBarFindTabById() [Internal]
|
|
// - TabBarRemoveTab() [Internal]
|
|
// - TabBarRemoveTab() [Internal]
|
|
// - TabBarCloseTab() [Internal]
|
|
// - TabBarCloseTab() [Internal]
|
|
-// - TabBarScrollClamp()v
|
|
|
|
|
|
+// - TabBarScrollClamp() [Internal]
|
|
// - TabBarScrollToTab() [Internal]
|
|
// - TabBarScrollToTab() [Internal]
|
|
// - TabBarQueueChangeTabOrder() [Internal]
|
|
// - TabBarQueueChangeTabOrder() [Internal]
|
|
// - TabBarScrollingButtons() [Internal]
|
|
// - TabBarScrollingButtons() [Internal]
|
|
@@ -6785,7 +6785,7 @@ ImGuiTabBar::ImGuiTabBar()
|
|
SelectedTabId = NextSelectedTabId = VisibleTabId = 0;
|
|
SelectedTabId = NextSelectedTabId = VisibleTabId = 0;
|
|
CurrFrameVisible = PrevFrameVisible = -1;
|
|
CurrFrameVisible = PrevFrameVisible = -1;
|
|
LastTabContentHeight = 0.0f;
|
|
LastTabContentHeight = 0.0f;
|
|
- OffsetMax = OffsetMaxIdeal = OffsetNextTab = 0.0f;
|
|
|
|
|
|
+ WidthAllTabs = WidthAllTabsIdeal = OffsetNextTab = 0.0f;
|
|
ScrollingAnim = ScrollingTarget = ScrollingTargetDistToVisibility = ScrollingSpeed = 0.0f;
|
|
ScrollingAnim = ScrollingTarget = ScrollingTargetDistToVisibility = ScrollingSpeed = 0.0f;
|
|
Flags = ImGuiTabBarFlags_None;
|
|
Flags = ImGuiTabBarFlags_None;
|
|
ReorderRequestTabId = 0;
|
|
ReorderRequestTabId = 0;
|
|
@@ -6951,23 +6951,9 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
|
|
// Process order change request (we could probably process it when requested but it's just saner to do it in a single spot).
|
|
// Process order change request (we could probably process it when requested but it's just saner to do it in a single spot).
|
|
if (tab_bar->ReorderRequestTabId != 0)
|
|
if (tab_bar->ReorderRequestTabId != 0)
|
|
{
|
|
{
|
|
- if (ImGuiTabItem* tab1 = TabBarFindTabByID(tab_bar, tab_bar->ReorderRequestTabId))
|
|
|
|
- {
|
|
|
|
- //IM_ASSERT(tab_bar->Flags & ImGuiTabBarFlags_Reorderable); // <- this may happen when using debug tools
|
|
|
|
- int tab2_order = tab_bar->GetTabOrder(tab1) + tab_bar->ReorderRequestDir;
|
|
|
|
- if (tab2_order >= 0 && tab2_order < tab_bar->Tabs.Size)
|
|
|
|
- {
|
|
|
|
- ImGuiTabItem* tab2 = &tab_bar->Tabs[tab2_order];
|
|
|
|
- ImGuiTabItem item_tmp = *tab1;
|
|
|
|
- *tab1 = *tab2;
|
|
|
|
- *tab2 = item_tmp;
|
|
|
|
- if (tab2->ID == tab_bar->SelectedTabId)
|
|
|
|
- scroll_track_selected_tab_id = tab2->ID;
|
|
|
|
- tab1 = tab2 = NULL;
|
|
|
|
- }
|
|
|
|
- if (tab_bar->Flags & ImGuiTabBarFlags_SaveSettings)
|
|
|
|
- MarkIniSettingsDirty();
|
|
|
|
- }
|
|
|
|
|
|
+ if (TabBarProcessReorder(tab_bar))
|
|
|
|
+ if (tab_bar->ReorderRequestTabId == tab_bar->SelectedTabId)
|
|
|
|
+ scroll_track_selected_tab_id = tab_bar->ReorderRequestTabId;
|
|
tab_bar->ReorderRequestTabId = 0;
|
|
tab_bar->ReorderRequestTabId = 0;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -7041,11 +7027,11 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
|
|
offset_x += tab->Width + g.Style.ItemInnerSpacing.x;
|
|
offset_x += tab->Width + g.Style.ItemInnerSpacing.x;
|
|
offset_x_ideal += tab->ContentWidth + g.Style.ItemInnerSpacing.x;
|
|
offset_x_ideal += tab->ContentWidth + g.Style.ItemInnerSpacing.x;
|
|
}
|
|
}
|
|
- tab_bar->OffsetMax = ImMax(offset_x - g.Style.ItemInnerSpacing.x, 0.0f);
|
|
|
|
- tab_bar->OffsetMaxIdeal = ImMax(offset_x_ideal - g.Style.ItemInnerSpacing.x, 0.0f);
|
|
|
|
|
|
+ tab_bar->WidthAllTabs = ImMax(offset_x - g.Style.ItemInnerSpacing.x, 0.0f);
|
|
|
|
+ tab_bar->WidthAllTabsIdeal = ImMax(offset_x_ideal - g.Style.ItemInnerSpacing.x, 0.0f);
|
|
|
|
|
|
// Horizontal scrolling buttons
|
|
// Horizontal scrolling buttons
|
|
- const bool scrolling_buttons = (tab_bar->OffsetMax > tab_bar->BarRect.GetWidth() && tab_bar->Tabs.Size > 1) && !(tab_bar->Flags & ImGuiTabBarFlags_NoTabListScrollingButtons) && (tab_bar->Flags & ImGuiTabBarFlags_FittingPolicyScroll);
|
|
|
|
|
|
+ const bool scrolling_buttons = (tab_bar->WidthAllTabs > tab_bar->BarRect.GetWidth() && tab_bar->Tabs.Size > 1) && !(tab_bar->Flags & ImGuiTabBarFlags_NoTabListScrollingButtons) && (tab_bar->Flags & ImGuiTabBarFlags_FittingPolicyScroll);
|
|
if (scrolling_buttons)
|
|
if (scrolling_buttons)
|
|
if (ImGuiTabItem* tab_to_select = TabBarScrollingButtons(tab_bar)) // NB: Will alter BarRect.Max.x!
|
|
if (ImGuiTabItem* tab_to_select = TabBarScrollingButtons(tab_bar)) // NB: Will alter BarRect.Max.x!
|
|
scroll_track_selected_tab_id = tab_bar->SelectedTabId = tab_to_select->ID;
|
|
scroll_track_selected_tab_id = tab_bar->SelectedTabId = tab_to_select->ID;
|
|
@@ -7087,7 +7073,7 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
|
|
// Actual layout in host window (we don't do it in BeginTabBar() so as not to waste an extra frame)
|
|
// Actual layout in host window (we don't do it in BeginTabBar() so as not to waste an extra frame)
|
|
ImGuiWindow* window = g.CurrentWindow;
|
|
ImGuiWindow* window = g.CurrentWindow;
|
|
window->DC.CursorPos = tab_bar->BarRect.Min;
|
|
window->DC.CursorPos = tab_bar->BarRect.Min;
|
|
- ItemSize(ImVec2(tab_bar->OffsetMaxIdeal, tab_bar->BarRect.GetHeight()), tab_bar->FramePadding.y);
|
|
|
|
|
|
+ ItemSize(ImVec2(tab_bar->WidthAllTabsIdeal, tab_bar->BarRect.GetHeight()), tab_bar->FramePadding.y);
|
|
}
|
|
}
|
|
|
|
|
|
// Dockables uses Name/ID in the global namespace. Non-dockable items use the ID stack.
|
|
// Dockables uses Name/ID in the global namespace. Non-dockable items use the ID stack.
|
|
@@ -7150,7 +7136,7 @@ void ImGui::TabBarCloseTab(ImGuiTabBar* tab_bar, ImGuiTabItem* tab)
|
|
|
|
|
|
static float ImGui::TabBarScrollClamp(ImGuiTabBar* tab_bar, float scrolling)
|
|
static float ImGui::TabBarScrollClamp(ImGuiTabBar* tab_bar, float scrolling)
|
|
{
|
|
{
|
|
- scrolling = ImMin(scrolling, tab_bar->OffsetMax - tab_bar->BarRect.GetWidth());
|
|
|
|
|
|
+ scrolling = ImMin(scrolling, tab_bar->WidthAllTabs - tab_bar->BarRect.GetWidth());
|
|
return ImMax(scrolling, 0.0f);
|
|
return ImMax(scrolling, 0.0f);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -7174,7 +7160,7 @@ static void ImGui::TabBarScrollToTab(ImGuiTabBar* tab_bar, ImGuiTabItem* tab)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-void ImGui::TabBarQueueChangeTabOrder(ImGuiTabBar* tab_bar, const ImGuiTabItem* tab, int dir)
|
|
|
|
|
|
+void ImGui::TabBarQueueReorder(ImGuiTabBar* tab_bar, const ImGuiTabItem* tab, int dir)
|
|
{
|
|
{
|
|
IM_ASSERT(dir == -1 || dir == +1);
|
|
IM_ASSERT(dir == -1 || dir == +1);
|
|
IM_ASSERT(tab_bar->ReorderRequestTabId == 0);
|
|
IM_ASSERT(tab_bar->ReorderRequestTabId == 0);
|
|
@@ -7182,6 +7168,28 @@ void ImGui::TabBarQueueChangeTabOrder(ImGuiTabBar* tab_bar, const ImGuiTabItem*
|
|
tab_bar->ReorderRequestDir = (ImS8)dir;
|
|
tab_bar->ReorderRequestDir = (ImS8)dir;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+bool ImGui::TabBarProcessReorder(ImGuiTabBar* tab_bar)
|
|
|
|
+{
|
|
|
|
+ ImGuiTabItem* tab1 = TabBarFindTabByID(tab_bar, tab_bar->ReorderRequestTabId);
|
|
|
|
+ if (!tab1)
|
|
|
|
+ return false;
|
|
|
|
+
|
|
|
|
+ //IM_ASSERT(tab_bar->Flags & ImGuiTabBarFlags_Reorderable); // <- this may happen when using debug tools
|
|
|
|
+ int tab2_order = tab_bar->GetTabOrder(tab1) + tab_bar->ReorderRequestDir;
|
|
|
|
+ if (tab2_order < 0 || tab2_order >= tab_bar->Tabs.Size)
|
|
|
|
+ return false;
|
|
|
|
+
|
|
|
|
+ ImGuiTabItem* tab2 = &tab_bar->Tabs[tab2_order];
|
|
|
|
+ ImGuiTabItem item_tmp = *tab1;
|
|
|
|
+ *tab1 = *tab2;
|
|
|
|
+ *tab2 = item_tmp;
|
|
|
|
+ tab1 = tab2 = NULL;
|
|
|
|
+
|
|
|
|
+ if (tab_bar->Flags & ImGuiTabBarFlags_SaveSettings)
|
|
|
|
+ MarkIniSettingsDirty();
|
|
|
|
+ return true;
|
|
|
|
+}
|
|
|
|
+
|
|
static ImGuiTabItem* ImGui::TabBarScrollingButtons(ImGuiTabBar* tab_bar)
|
|
static ImGuiTabItem* ImGui::TabBarScrollingButtons(ImGuiTabBar* tab_bar)
|
|
{
|
|
{
|
|
ImGuiContext& g = *GImGui;
|
|
ImGuiContext& g = *GImGui;
|
|
@@ -7293,7 +7301,7 @@ bool ImGui::BeginTabItem(const char* label, bool* p_open, ImGuiTabItemFlags f
|
|
ImGuiTabBar* tab_bar = g.CurrentTabBar;
|
|
ImGuiTabBar* tab_bar = g.CurrentTabBar;
|
|
if (tab_bar == NULL)
|
|
if (tab_bar == NULL)
|
|
{
|
|
{
|
|
- IM_ASSERT_USER_ERROR(tab_bar, "BeginTabItem() Needs to be called between BeginTabBar() and EndTabBar()!");
|
|
|
|
|
|
+ IM_ASSERT_USER_ERROR(tab_bar, "Needs to be called between BeginTabBar() and EndTabBar()!");
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
bool ret = TabItemEx(tab_bar, label, p_open, flags);
|
|
bool ret = TabItemEx(tab_bar, label, p_open, flags);
|
|
@@ -7315,7 +7323,7 @@ void ImGui::EndTabItem()
|
|
ImGuiTabBar* tab_bar = g.CurrentTabBar;
|
|
ImGuiTabBar* tab_bar = g.CurrentTabBar;
|
|
if (tab_bar == NULL)
|
|
if (tab_bar == NULL)
|
|
{
|
|
{
|
|
- IM_ASSERT(tab_bar != NULL && "Needs to be called between BeginTabBar() and EndTabBar()!");
|
|
|
|
|
|
+ IM_ASSERT_USER_ERROR(tab_bar != NULL, "Needs to be called between BeginTabBar() and EndTabBar()!");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
IM_ASSERT(tab_bar->LastTabItemIdx >= 0);
|
|
IM_ASSERT(tab_bar->LastTabItemIdx >= 0);
|
|
@@ -7471,12 +7479,12 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
|
|
if (g.IO.MouseDelta.x < 0.0f && g.IO.MousePos.x < bb.Min.x)
|
|
if (g.IO.MouseDelta.x < 0.0f && g.IO.MousePos.x < bb.Min.x)
|
|
{
|
|
{
|
|
if (tab_bar->Flags & ImGuiTabBarFlags_Reorderable)
|
|
if (tab_bar->Flags & ImGuiTabBarFlags_Reorderable)
|
|
- TabBarQueueChangeTabOrder(tab_bar, tab, -1);
|
|
|
|
|
|
+ TabBarQueueReorder(tab_bar, tab, -1);
|
|
}
|
|
}
|
|
else if (g.IO.MouseDelta.x > 0.0f && g.IO.MousePos.x > bb.Max.x)
|
|
else if (g.IO.MouseDelta.x > 0.0f && g.IO.MousePos.x > bb.Max.x)
|
|
{
|
|
{
|
|
if (tab_bar->Flags & ImGuiTabBarFlags_Reorderable)
|
|
if (tab_bar->Flags & ImGuiTabBarFlags_Reorderable)
|
|
- TabBarQueueChangeTabOrder(tab_bar, tab, +1);
|
|
|
|
|
|
+ TabBarQueueReorder(tab_bar, tab, +1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|