@@ -7920,17 +7920,20 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
7920
7920
else if (held && !tab_appearing && IsMouseDragging (0 ))
7921
7921
{
7922
7922
// Drag and drop: re-order tabs
7923
+ int drag_dir = 0 ;
7923
7924
float drag_distance_from_edge_x = 0 .0f ;
7924
7925
if (!g.DragDropActive && ((tab_bar->Flags & ImGuiTabBarFlags_Reorderable) || (docked_window != NULL )))
7925
7926
{
7926
7927
// While moving a tab it will jump on the other side of the mouse, so we also test for MouseDelta.x
7927
7928
if (g.IO .MouseDelta .x < 0 .0f && g.IO .MousePos .x < bb.Min .x )
7928
7929
{
7930
+ drag_dir = -1 ;
7929
7931
drag_distance_from_edge_x = bb.Min .x - g.IO .MousePos .x ;
7930
7932
TabBarQueueReorderFromMousePos (tab_bar, tab, g.IO .MousePos );
7931
7933
}
7932
7934
else if (g.IO .MouseDelta .x > 0 .0f && g.IO .MousePos .x > bb.Max .x )
7933
7935
{
7936
+ drag_dir = +1 ;
7934
7937
drag_distance_from_edge_x = g.IO .MousePos .x - bb.Max .x ;
7935
7938
TabBarQueueReorderFromMousePos (tab_bar, tab, g.IO .MousePos );
7936
7939
}
@@ -7941,20 +7944,18 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
7941
7944
{
7942
7945
// We use a variable threshold to distinguish dragging tabs within a tab bar and extracting them out of the tab bar
7943
7946
bool undocking_tab = (g.DragDropActive && g.DragDropPayload .SourceId == id);
7944
-
7945
7947
if (!undocking_tab) // && (!g.IO.ConfigDockingWithShift || g.IO.KeyShift)
7946
7948
{
7947
7949
float threshold_base = g.FontSize ;
7948
- // float threshold_base = g.IO.ConfigDockingWithShift ? g.FontSize * 0.5f : g.FontSize;
7949
7950
float threshold_x = (threshold_base * 2 .2f );
7950
7951
float threshold_y = (threshold_base * 1 .5f ) + ImClamp ((ImFabs (g.IO .MouseDragMaxDistanceAbs [0 ].x ) - threshold_base * 2 .0f ) * 0 .20f , 0 .0f , threshold_base * 4 .0f );
7951
7952
// GetForegroundDrawList()->AddRect(ImVec2(bb.Min.x - threshold_x, bb.Min.y - threshold_y), ImVec2(bb.Max.x + threshold_x, bb.Max.y + threshold_y), IM_COL32_WHITE); // [DEBUG]
7952
7953
7953
7954
float distance_from_edge_y = ImMax (bb.Min .y - g.IO .MousePos .y , g.IO .MousePos .y - bb.Max .y );
7954
7955
if (distance_from_edge_y >= threshold_y)
7955
7956
undocking_tab = true ;
7956
- else if (drag_distance_from_edge_x > threshold_x)
7957
- if ((tab_bar-> ReorderRequestOffset < 0 && tab_bar->GetTabOrder (tab) == 0 ) || (tab_bar-> ReorderRequestOffset > 0 && tab_bar->GetTabOrder (tab) == tab_bar->Tabs .Size - 1 ))
7957
+ if (drag_distance_from_edge_x > threshold_x)
7958
+ if ((drag_dir < 0 && tab_bar->GetTabOrder (tab) == 0 ) || (drag_dir > 0 && tab_bar->GetTabOrder (tab) == tab_bar->Tabs .Size - 1 ))
7958
7959
undocking_tab = true ;
7959
7960
}
7960
7961
0 commit comments