@@ -399,6 +399,15 @@ typedef struct Header {
|
||||
|
||||
/* menu types */
|
||||
|
||||
enum class MenuTypeFlag {
|
||||
/**
|
||||
* Whether the menu depends on data retrieved via #CTX_data_pointer_get. If it is context
|
||||
* dependent, menu search has to scan it in different contexts.
|
||||
*/
|
||||
ContextDependent = (1 << 0),
|
||||
};
|
||||
ENUM_OPERATORS(MenuTypeFlag, MenuTypeFlag::ContextDependent)
|
||||
|
||||
typedef struct MenuType {
|
||||
struct MenuType *next, *prev;
|
||||
|
||||
@@ -414,11 +423,7 @@ typedef struct MenuType {
|
||||
void (*draw)(const struct bContext *C, struct Menu *menu);
|
||||
void (*listener)(const wmRegionListenerParams *params);
|
||||
|
||||
/**
|
||||
* True if the menu depends on data retrieved via #CTX_data_pointer_get. If it is context
|
||||
* dependent, menu search has to scan it in different contexts.
|
||||
*/
|
||||
bool context_dependent;
|
||||
MenuTypeFlag flag;
|
||||
|
||||
/* RNA integration */
|
||||
ExtensionRNA rna_ext;
|
||||
|
||||
@@ -642,7 +642,7 @@ MenuType node_group_operator_assets_menu()
|
||||
type.poll = asset_menu_poll;
|
||||
type.draw = node_add_catalog_assets_draw;
|
||||
type.listener = asset::asset_reading_region_listen_fn;
|
||||
type.context_dependent = true;
|
||||
type.flag = MenuTypeFlag::ContextDependent;
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
@@ -701,7 +701,8 @@ static MenuSearch_Data *menu_items_from_ui_create(
|
||||
/* pass */
|
||||
}
|
||||
else if ((mt_from_but = UI_but_menutype_get(but))) {
|
||||
const bool uses_context = but->context && mt_from_but->context_dependent;
|
||||
const bool uses_context = but->context &&
|
||||
bool(mt_from_but->flag & MenuTypeFlag::ContextDependent);
|
||||
const bool tagged_first_time = menu_tagged.add(mt_from_but);
|
||||
const bool scan_submenu = tagged_first_time || uses_context;
|
||||
|
||||
|
||||
@@ -262,7 +262,7 @@ static MenuType modifier_add_catalog_assets_menu_type()
|
||||
STRNCPY(type.idname, "OBJECT_MT_add_modifier_catalog_assets");
|
||||
type.draw = catalog_assets_draw;
|
||||
type.listener = asset::asset_reading_region_listen_fn;
|
||||
type.context_dependent = true;
|
||||
type.flag = MenuTypeFlag::ContextDependent;
|
||||
return type;
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ static MenuType modifier_add_root_catalogs_menu_type()
|
||||
STRNCPY(type.idname, "OBJECT_MT_modifier_add_root_catalogs");
|
||||
type.draw = root_catalogs_draw;
|
||||
type.listener = asset::asset_reading_region_listen_fn;
|
||||
type.context_dependent = true;
|
||||
type.flag = MenuTypeFlag::ContextDependent;
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
@@ -188,7 +188,7 @@ MenuType add_catalog_assets_menu_type()
|
||||
type.poll = node_add_menu_poll;
|
||||
type.draw = node_add_catalog_assets_draw;
|
||||
type.listener = asset::asset_reading_region_listen_fn;
|
||||
type.context_dependent = true;
|
||||
type.flag = MenuTypeFlag::ContextDependent;
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user