UI: Add Preference for Menu Close on Leave
This PR changes the current behavior that closes menus that are open when your mouse is moved out of its "safe" area (a bit wider than its visible bounds). With this PR applied menus stay open unless you click elsewhere, hover a neighboring menu, press escape, or select an item. Although this PR turns off menu mouse leave, it also adds a preference that can be used to turn it back on. Pull Request: https://projects.blender.org/blender/blender/pulls/145523
This commit is contained in:
committed by
Harley Acheson
parent
80e8493c11
commit
5953ff318c
@@ -344,12 +344,15 @@ class USERPREF_PT_interface_statusbar(InterfacePanel, CenterAlignMixIn, Panel):
|
||||
col.prop(view, "show_statusbar_version", text="Blender Version")
|
||||
|
||||
|
||||
class USERPREF_PT_interface_menus(InterfacePanel, Panel):
|
||||
class USERPREF_PT_interface_menus(InterfacePanel, CenterAlignMixIn, Panel):
|
||||
bl_label = "Menus"
|
||||
bl_options = {'DEFAULT_CLOSED'}
|
||||
|
||||
def draw(self, context):
|
||||
pass
|
||||
def draw_centered(self, context, layout):
|
||||
prefs = context.preferences
|
||||
view = prefs.view
|
||||
col = layout.column()
|
||||
col.prop(view, "menu_close_leave")
|
||||
|
||||
|
||||
class USERPREF_PT_interface_menus_mouse_over(InterfacePanel, CenterAlignMixIn, Panel):
|
||||
|
||||
@@ -1026,7 +1026,7 @@ void blo_do_versions_userdef(UserDef *userdef)
|
||||
|
||||
if (!USER_VERSION_ATLEAST(278, 6)) {
|
||||
/* Clear preference flags for re-use. */
|
||||
userdef->flag &= ~(USER_FLAG_NUMINPUT_ADVANCED | (1 << 2) | USER_FLAG_UNUSED_3 |
|
||||
userdef->flag &= ~(USER_FLAG_NUMINPUT_ADVANCED | (1 << 2) | USER_MENU_CLOSE_LEAVE |
|
||||
USER_FLAG_UNUSED_6 | USER_FLAG_UNUSED_7 | USER_INTERNET_ALLOW |
|
||||
USER_DEVELOPER_UI);
|
||||
userdef->uiflag &= ~USER_HEADER_BOTTOM;
|
||||
|
||||
@@ -11241,7 +11241,8 @@ static int ui_handle_menu_event(bContext *C,
|
||||
menu->menuretval = UI_RETURN_OK;
|
||||
}
|
||||
else {
|
||||
menu->menuretval = UI_RETURN_OUT;
|
||||
menu->menuretval = (U.flag & USER_MENU_CLOSE_LEAVE) ? UI_RETURN_OUT :
|
||||
UI_RETURN_CANCEL;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11339,7 +11340,7 @@ static int ui_handle_menu_event(bContext *C,
|
||||
}
|
||||
|
||||
/* strict check, and include the parent rect */
|
||||
if (!menu->dotowards && !saferct) {
|
||||
if (!menu->dotowards && !saferct && ((U.flag & USER_MENU_CLOSE_LEAVE) || level > 0)) {
|
||||
if (block->flag & UI_BLOCK_OUT_1) {
|
||||
menu->menuretval = UI_RETURN_OK;
|
||||
}
|
||||
|
||||
@@ -331,7 +331,7 @@ static void ui_popup_block_position(wmWindow *window,
|
||||
|
||||
/* when you are outside parent button, safety there should be smaller */
|
||||
|
||||
const int s1 = 40 * UI_SCALE_FAC;
|
||||
const int s1 = (U.flag & USER_MENU_CLOSE_LEAVE) ? 40 * UI_SCALE_FAC : win_size[0];
|
||||
const int s2 = 3 * UI_SCALE_FAC;
|
||||
|
||||
/* parent button to left */
|
||||
|
||||
@@ -685,7 +685,7 @@ typedef enum eUserPref_Flag {
|
||||
USER_AUTOSAVE = (1 << 0),
|
||||
USER_FLAG_NUMINPUT_ADVANCED = (1 << 1),
|
||||
USER_FLAG_RECENT_SEARCHES_DISABLE = (1 << 2),
|
||||
USER_FLAG_UNUSED_3 = (1 << 3), /* cleared */
|
||||
USER_MENU_CLOSE_LEAVE = (1 << 3),
|
||||
USER_FLAG_UNUSED_4 = (1 << 4), /* cleared */
|
||||
USER_TRACKBALL = (1 << 5),
|
||||
USER_FLAG_UNUSED_6 = (1 << 6), /* cleared */
|
||||
|
||||
@@ -5074,6 +5074,11 @@ static void rna_def_userdef_view(BlenderRNA *brna)
|
||||
"Open on Mouse Over",
|
||||
"Open menu buttons and pull-downs automatically when the mouse is hovering");
|
||||
|
||||
prop = RNA_def_property(srna, "menu_close_leave", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, nullptr, "flag", USER_MENU_CLOSE_LEAVE);
|
||||
RNA_def_property_ui_text(
|
||||
prop, "Close Menu on Leave", "Close menus when the mouse is moved out of the region.");
|
||||
|
||||
prop = RNA_def_property(srna, "open_toplevel_delay", PROP_INT, PROP_NONE);
|
||||
RNA_def_property_int_sdna(prop, nullptr, "menuthreshold1");
|
||||
RNA_def_property_range(prop, 1, 40);
|
||||
|
||||
Reference in New Issue
Block a user