TabBar: Amend previous commit. Fix tab reordering when tab bar has scrolling.

Some tidying up with helpers + honor 16-bit offsets as with other tab bar features (unlikely single reorder can reach that but consistent)
This commit is contained in:
ocornut
2021-03-25 18:35:24 +01:00
parent 475c0fcc39
commit 688e06490e
3 changed files with 49 additions and 56 deletions

View File

@ -1885,6 +1885,7 @@ enum ImGuiTabBarFlagsPrivate_
// Extend ImGuiTabItemFlags_
enum ImGuiTabItemFlagsPrivate_
{
ImGuiTabItemFlags_SectionMask_ = ImGuiTabItemFlags_Leading | ImGuiTabItemFlags_Trailing,
ImGuiTabItemFlags_NoCloseButton = 1 << 20, // Track whether p_open was set or not (we'll need this info on the next frame to recompute ContentWidth during layout)
ImGuiTabItemFlags_Button = 1 << 21 // Used by TabItemButton, change the tab item behavior to mimic a button
};
@ -1930,7 +1931,7 @@ struct ImGuiTabBar
float ScrollingRectMinX;
float ScrollingRectMaxX;
ImGuiID ReorderRequestTabId;
ImS8 ReorderRequestDir;
ImS16 ReorderRequestOffset;
ImS8 BeginCount;
bool WantLayout;
bool VisibleTabWasSubmitted;
@ -2422,7 +2423,7 @@ namespace ImGui
IMGUI_API ImGuiTabItem* TabBarFindTabByID(ImGuiTabBar* tab_bar, ImGuiID tab_id);
IMGUI_API void TabBarRemoveTab(ImGuiTabBar* tab_bar, ImGuiID tab_id);
IMGUI_API void TabBarCloseTab(ImGuiTabBar* tab_bar, ImGuiTabItem* tab);
IMGUI_API void TabBarQueueReorder(ImGuiTabBar* tab_bar, const ImGuiTabItem* tab, int dir);
IMGUI_API void TabBarQueueReorder(ImGuiTabBar* tab_bar, const ImGuiTabItem* tab, int offset);
IMGUI_API void TabBarQueueReorderFromMousePos(ImGuiTabBar* tab_bar, const ImGuiTabItem* tab, ImVec2 mouse_pos);
IMGUI_API bool TabBarProcessReorder(ImGuiTabBar* tab_bar);
IMGUI_API bool TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open, ImGuiTabItemFlags flags);