MCPcopy Create free account
hub / github.com/Wemino/MarkerPatch / TabBarProcessReorder

Method TabBarProcessReorder

include/imgui/imgui_widgets.cpp:10380–10409  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10378}
10379
10380bool ImGui::TabBarProcessReorder(ImGuiTabBar* tab_bar)
10381{
10382 ImGuiTabItem* tab1 = TabBarFindTabByID(tab_bar, tab_bar->ReorderRequestTabId);
10383 if (tab1 == NULL || (tab1->Flags & ImGuiTabItemFlags_NoReorder))
10384 return false;
10385
10386 //IM_ASSERT(tab_bar->Flags & ImGuiTabBarFlags_Reorderable); // <- this may happen when using debug tools
10387 int tab2_order = TabBarGetTabOrder(tab_bar, tab1) + tab_bar->ReorderRequestOffset;
10388 if (tab2_order < 0 || tab2_order >= tab_bar->Tabs.Size)
10389 return false;
10390
10391 // Reordered tabs must share the same section
10392 // (Note: TabBarQueueReorderFromMousePos() also has a similar test but since we allow direct calls to TabBarQueueReorder() we do it here too)
10393 ImGuiTabItem* tab2 = &tab_bar->Tabs[tab2_order];
10394 if (tab2->Flags & ImGuiTabItemFlags_NoReorder)
10395 return false;
10396 if ((tab1->Flags & ImGuiTabItemFlags_SectionMask_) != (tab2->Flags & ImGuiTabItemFlags_SectionMask_))
10397 return false;
10398
10399 ImGuiTabItem item_tmp = *tab1;
10400 ImGuiTabItem* src_tab = (tab_bar->ReorderRequestOffset > 0) ? tab1 + 1 : tab2;
10401 ImGuiTabItem* dst_tab = (tab_bar->ReorderRequestOffset > 0) ? tab1 : tab2 + 1;
10402 const int move_count = (tab_bar->ReorderRequestOffset > 0) ? tab_bar->ReorderRequestOffset : -tab_bar->ReorderRequestOffset;
10403 memmove(dst_tab, src_tab, move_count * sizeof(ImGuiTabItem));
10404 *tab2 = item_tmp;
10405
10406 if (tab_bar->Flags & ImGuiTabBarFlags_SaveSettings)
10407 MarkIniSettingsDirty();
10408 return true;
10409}
10410
10411static ImGuiTabItem* ImGui::TabBarScrollingButtons(ImGuiTabBar* tab_bar)
10412{

Callers

nothing calls this directly

Calls 1

TabBarGetTabOrderFunction · 0.85

Tested by

no test coverage detected