Cleanup: Consistency between asset-extended menu UI templates
Define the UI template in the namespace of its own module, and consistently use references and const in those UI template functions.
This commit is contained in:
@@ -725,7 +725,7 @@ MenuType node_group_operator_assets_menu_unassigned()
|
||||
}
|
||||
|
||||
void ui_template_node_operator_asset_menu_items(uiLayout &layout,
|
||||
bContext &C,
|
||||
const bContext &C,
|
||||
const StringRef catalog_path)
|
||||
{
|
||||
bScreen &screen = *CTX_wm_screen(&C);
|
||||
@@ -752,7 +752,7 @@ void ui_template_node_operator_asset_menu_items(uiLayout &layout,
|
||||
uiItemMContents(col, "GEO_MT_node_operator_catalog_assets");
|
||||
}
|
||||
|
||||
void ui_template_node_operator_asset_root_items(uiLayout &layout, bContext &C)
|
||||
void ui_template_node_operator_asset_root_items(uiLayout &layout, const bContext &C)
|
||||
{
|
||||
bScreen &screen = *CTX_wm_screen(&C);
|
||||
const Object *active_object = CTX_data_active_object(&C);
|
||||
|
||||
@@ -40,8 +40,8 @@ MenuType node_group_operator_assets_menu_unassigned();
|
||||
void clear_operator_asset_trees();
|
||||
|
||||
void ui_template_node_operator_asset_menu_items(uiLayout &layout,
|
||||
bContext &C,
|
||||
const bContext &C,
|
||||
StringRef catalog_path);
|
||||
void ui_template_node_operator_asset_root_items(uiLayout &layout, bContext &C);
|
||||
void ui_template_node_operator_asset_root_items(uiLayout &layout, const bContext &C);
|
||||
|
||||
} // namespace blender::ed::geometry
|
||||
|
||||
@@ -53,4 +53,8 @@ std::optional<ObjectAndModifier> get_modifier_for_node_editor(const SpaceNode &s
|
||||
[[nodiscard]] bool push_compute_context_for_tree_path(
|
||||
const SpaceNode &snode, ComputeContextBuilder &compute_context_builder);
|
||||
|
||||
void ui_template_node_asset_menu_items(uiLayout &layout,
|
||||
const bContext &C,
|
||||
StringRef catalog_path);
|
||||
|
||||
} // namespace blender::ed::space_node
|
||||
|
||||
@@ -641,6 +641,8 @@ void ED_object_data_xform_tag_update(XFormObjectData *xod);
|
||||
|
||||
namespace blender::ed::object {
|
||||
|
||||
void ui_template_modifier_asset_menu_items(uiLayout &layout, bContext &C, StringRef catalog_path);
|
||||
void ui_template_modifier_asset_menu_items(uiLayout &layout,
|
||||
const bContext &C,
|
||||
StringRef catalog_path);
|
||||
|
||||
}
|
||||
|
||||
@@ -2584,7 +2584,6 @@ void uiTemplateNodeLink(
|
||||
uiLayout *layout, bContext *C, bNodeTree *ntree, bNode *node, bNodeSocket *input);
|
||||
void uiTemplateNodeView(
|
||||
uiLayout *layout, bContext *C, bNodeTree *ntree, bNode *node, bNodeSocket *input);
|
||||
void uiTemplateNodeAssetMenuItems(uiLayout *layout, bContext *C, const char *catalog_path);
|
||||
void uiTemplateTextureUser(uiLayout *layout, bContext *C);
|
||||
/**
|
||||
* Button to quickly show texture in Properties Editor texture tab.
|
||||
|
||||
@@ -327,7 +327,7 @@ void object_modifier_add_asset_register()
|
||||
}
|
||||
|
||||
void ui_template_modifier_asset_menu_items(uiLayout &layout,
|
||||
bContext &C,
|
||||
const bContext &C,
|
||||
const StringRef catalog_path)
|
||||
{
|
||||
using namespace blender;
|
||||
|
||||
@@ -255,15 +255,12 @@ MenuType add_root_catalogs_menu_type()
|
||||
return type;
|
||||
}
|
||||
|
||||
} // namespace blender::ed::space_node
|
||||
|
||||
void uiTemplateNodeAssetMenuItems(uiLayout *layout, bContext *C, const char *catalog_path)
|
||||
void ui_template_node_asset_menu_items(uiLayout &layout,
|
||||
const bContext &C,
|
||||
const StringRef catalog_path)
|
||||
{
|
||||
using namespace blender;
|
||||
using namespace blender::ed;
|
||||
using namespace blender::ed::space_node;
|
||||
bScreen &screen = *CTX_wm_screen(C);
|
||||
SpaceNode &snode = *CTX_wm_space_node(C);
|
||||
bScreen &screen = *CTX_wm_screen(&C);
|
||||
SpaceNode &snode = *CTX_wm_space_node(&C);
|
||||
if (snode.runtime->assets_for_menu == nullptr) {
|
||||
return;
|
||||
}
|
||||
@@ -281,8 +278,10 @@ void uiTemplateNodeAssetMenuItems(uiLayout *layout, bContext *C, const char *cat
|
||||
if (path_ptr.data == nullptr) {
|
||||
return;
|
||||
}
|
||||
uiItemS(layout);
|
||||
uiLayout *col = uiLayoutColumn(layout, false);
|
||||
uiItemS(&layout);
|
||||
uiLayout *col = uiLayoutColumn(&layout, false);
|
||||
uiLayoutSetContextPointer(col, "asset_catalog_path", &path_ptr);
|
||||
uiItemMContents(col, "NODE_MT_node_add_catalog_assets");
|
||||
}
|
||||
|
||||
} // namespace blender::ed::space_node
|
||||
|
||||
@@ -38,6 +38,7 @@ const EnumPropertyItem rna_enum_icon_items[] = {
|
||||
# include "DNA_asset_types.h"
|
||||
|
||||
# include "ED_geometry.hh"
|
||||
# include "ED_node.hh"
|
||||
# include "ED_object.hh"
|
||||
|
||||
const char *rna_translate_ui_text(
|
||||
@@ -777,13 +778,21 @@ static uiLayout *rna_uiLayoutColumnWithHeading(
|
||||
return uiLayoutColumnWithHeading(layout, align, heading);
|
||||
}
|
||||
|
||||
static void rna_uiLayout_template_node_asset_menu_items(uiLayout *layout,
|
||||
bContext *C,
|
||||
const char *catalog_path)
|
||||
{
|
||||
using namespace blender;
|
||||
ed::space_node::ui_template_node_asset_menu_items(*layout, *C, StringRef(catalog_path));
|
||||
}
|
||||
|
||||
static void rna_uiLayout_template_node_operator_asset_menu_items(uiLayout *layout,
|
||||
bContext *C,
|
||||
const char *catalog_path)
|
||||
{
|
||||
using namespace blender;
|
||||
if (U.experimental.use_node_group_operators) {
|
||||
blender::ed::geometry::ui_template_node_operator_asset_menu_items(
|
||||
*layout, *C, blender::StringRef(catalog_path));
|
||||
ed::geometry::ui_template_node_operator_asset_menu_items(*layout, *C, StringRef(catalog_path));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -791,9 +800,9 @@ static void rna_uiLayout_template_modifier_asset_menu_items(uiLayout *layout,
|
||||
bContext *C,
|
||||
const char *catalog_path)
|
||||
{
|
||||
using namespace blender;
|
||||
if (U.experimental.use_node_group_operators) {
|
||||
blender::ed::object::ui_template_modifier_asset_menu_items(
|
||||
*layout, *C, blender::StringRef(catalog_path));
|
||||
ed::object::ui_template_modifier_asset_menu_items(*layout, *C, StringRef(catalog_path));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1900,7 +1909,8 @@ void RNA_api_ui_layout(StructRNA *srna)
|
||||
parm = RNA_def_pointer(func, "socket", "NodeSocket", "", "");
|
||||
RNA_def_parameter_flags(parm, PropertyFlag(0), PARM_REQUIRED);
|
||||
|
||||
func = RNA_def_function(srna, "template_node_asset_menu_items", "uiTemplateNodeAssetMenuItems");
|
||||
func = RNA_def_function(
|
||||
srna, "template_node_asset_menu_items", "rna_uiLayout_template_node_asset_menu_items");
|
||||
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
|
||||
parm = RNA_def_string(func, "catalog_path", nullptr, 0, "", "");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user