@@ -7109,19 +7109,22 @@ bool ImGui::BeginMenuEx(const char* label, const char* icon, bool enabled)
7109
7109
bool moving_toward_child_menu = false ;
7110
7110
ImGuiPopupData* child_popup = (g.BeginPopupStack .Size < g.OpenPopupStack .Size ) ? &g.OpenPopupStack [g.BeginPopupStack .Size ] : NULL ; // Popup candidate (testing below)
7111
7111
ImGuiWindow* child_menu_window = (child_popup && child_popup->Window && child_popup->Window ->ParentWindow == window) ? child_popup->Window : NULL ;
7112
- if (g.HoveredWindow == window && child_menu_window != NULL && !(window-> Flags & ImGuiWindowFlags_MenuBar) )
7112
+ if (g.HoveredWindow == window && child_menu_window != NULL )
7113
7113
{
7114
7114
float ref_unit = g.FontSize ; // FIXME-DPI
7115
+ float child_dir = (window->Pos .x < child_menu_window->Pos .x ) ? 1 .0f : -1 .0f ;
7115
7116
ImRect next_window_rect = child_menu_window->Rect ();
7116
7117
ImVec2 ta = (g.IO .MousePos - g.IO .MouseDelta );
7117
- ImVec2 tb = (window-> Pos . x < child_menu_window-> Pos . x ) ? next_window_rect.GetTL () : next_window_rect.GetTR ();
7118
- ImVec2 tc = (window-> Pos . x < child_menu_window-> Pos . x ) ? next_window_rect.GetBL () : next_window_rect.GetBR ();
7118
+ ImVec2 tb = (child_dir > 0 . 0f ) ? next_window_rect.GetTL () : next_window_rect.GetTR ();
7119
+ ImVec2 tc = (child_dir > 0 . 0f ) ? next_window_rect.GetBL () : next_window_rect.GetBR ();
7119
7120
float extra = ImClamp (ImFabs (ta.x - tb.x ) * 0 .30f , ref_unit * 0 .5f , ref_unit * 2 .5f ); // add a bit of extra slack.
7120
- ta.x += (window->Pos .x < child_menu_window->Pos .x ) ? -0 .5f : +0 .5f ; // to avoid numerical issues (FIXME: ??)
7121
+ ta.x += child_dir * -0 .5f ;
7122
+ tb.x += child_dir * ref_unit;
7123
+ tc.x += child_dir * ref_unit;
7121
7124
tb.y = ta.y + ImMax ((tb.y - extra) - ta.y , -ref_unit * 8 .0f ); // triangle has maximum height to limit the slope and the bias toward large sub-menus
7122
7125
tc.y = ta.y + ImMin ((tc.y + extra) - ta.y , +ref_unit * 8 .0f );
7123
7126
moving_toward_child_menu = ImTriangleContainsPoint (ta, tb, tc, g.IO .MousePos );
7124
- // GetForegroundDrawList()->AddTriangleFilled(ta, tb, tc, moving_toward_other_child_menu ? IM_COL32(0,128,0,128) : IM_COL32(128,0,0,128)); // [DEBUG]
7127
+ // GetForegroundDrawList()->AddTriangleFilled(ta, tb, tc, moving_toward_child_menu ? IM_COL32(0,128,0,128) : IM_COL32(128,0,0,128)); // [DEBUG]
7125
7128
}
7126
7129
7127
7130
// The 'HovereWindow == window' check creates an inconsistency (e.g. moving away from menu slowly tends to hit same window, whereas moving away fast does not)
0 commit comments