WIP: Nodes: experiment with using unity builds for editors/space_node #110598

Draft
Jacques Lucke wants to merge 18 commits from JacquesLucke/blender:space-node-unity-build into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
19 changed files with 621 additions and 235 deletions

View File

@ -89,5 +89,10 @@ endif()
blender_add_lib(bf_editor_space_node "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
if(WITH_UNITY_BUILD)
set_target_properties(bf_editor_space_node PROPERTIES UNITY_BUILD ON)
set_target_properties(bf_editor_space_node PROPERTIES UNITY_BUILD_BATCH_SIZE 100)
endif()
# RNA_prototypes.h dna_type_offsets.h
add_dependencies(bf_editor_space_node bf_rna)

View File

@ -25,8 +25,12 @@
#include "node_intern.hh"
#define FILE_NS add_menu_assets_cc
namespace blender::ed::space_node {
namespace FILE_NS {
static bool node_add_menu_poll(const bContext *C, MenuType * /*mt*/)
{
return CTX_wm_space_node(C);
@ -191,13 +195,14 @@ static void add_root_catalogs_draw(const bContext *C, Menu *menu)
uiItemM(col, "NODE_MT_node_add_catalog_assets", IFACE_(item.get_name().c_str()), ICON_NONE);
});
}
} // namespace FILE_NS
MenuType add_catalog_assets_menu_type()
{
MenuType type{};
STRNCPY(type.idname, "NODE_MT_node_add_catalog_assets");
type.poll = node_add_menu_poll;
type.draw = node_add_catalog_assets_draw;
type.poll = FILE_NS::node_add_menu_poll;
type.draw = FILE_NS::node_add_catalog_assets_draw;
type.listener = asset::asset_reading_region_listen_fn;
return type;
}
@ -206,8 +211,8 @@ MenuType add_root_catalogs_menu_type()
{
MenuType type{};
STRNCPY(type.idname, "NODE_MT_node_add_root_catalogs");
type.poll = node_add_menu_poll;
type.draw = add_root_catalogs_draw;
type.poll = FILE_NS::node_add_menu_poll;
type.draw = FILE_NS::add_root_catalogs_draw;
type.listener = asset::asset_reading_region_listen_fn;
return type;
}
@ -243,3 +248,5 @@ void uiTemplateNodeAssetMenuItems(uiLayout *layout, bContext *C, const char *cat
uiLayoutSetContextPointer(col, "asset_catalog_path", &path_ptr);
uiItemMContents(col, "NODE_MT_node_add_catalog_assets");
}
#undef FILE_NS

View File

@ -36,9 +36,12 @@
#include "node_intern.hh"
#define FILE_NS add_node_search_cc
struct bContext;
namespace blender::ed::space_node {
namespace FILE_NS {
struct AddNodeSearchStorage {
float2 cursor;
@ -307,12 +310,16 @@ static uiBlock *create_search_popup_block(bContext *C, ARegion *region, void *ar
UI_block_bounds_set_popup(block, 0.3f * U.widget_unit, offset);
return block;
}
} // namespace FILE_NS
void invoke_add_node_search_menu(bContext &C, const float2 &cursor, const bool use_transform)
{
AddNodeSearchStorage *storage = new AddNodeSearchStorage{cursor, use_transform};
FILE_NS::AddNodeSearchStorage *storage = new FILE_NS::AddNodeSearchStorage{cursor,
use_transform};
/* Use the "_ex" variant with `can_refresh` false to avoid a double free when closing Blender. */
UI_popup_block_invoke_ex(&C, create_search_popup_block, storage, nullptr, false);
UI_popup_block_invoke_ex(&C, FILE_NS::create_search_popup_block, storage, nullptr, false);
}
} // namespace blender::ed::space_node
#undef FILE_NS

View File

@ -27,7 +27,10 @@
#include "node_intern.hh"
#define FILE_NS clipboard_cc
namespace blender::ed::space_node {
namespace FILE_NS {
struct NodeClipboardItem {
bNode *node;
@ -167,6 +170,7 @@ static int node_clipboard_copy_exec(bContext *C, wmOperator * /*op*/)
return OPERATOR_FINISHED;
}
} // namespace FILE_NS
void NODE_OT_clipboard_copy(wmOperatorType *ot)
{
@ -174,7 +178,7 @@ void NODE_OT_clipboard_copy(wmOperatorType *ot)
ot->description = "Copy the selected nodes to the internal clipboard";
ot->idname = "NODE_OT_clipboard_copy";
ot->exec = node_clipboard_copy_exec;
ot->exec = FILE_NS::node_clipboard_copy_exec;
ot->poll = ED_operator_node_active;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@ -185,6 +189,7 @@ void NODE_OT_clipboard_copy(wmOperatorType *ot)
/* -------------------------------------------------------------------- */
/** \name Paste
* \{ */
namespace FILE_NS {
static int node_clipboard_paste_exec(bContext *C, wmOperator *op)
{
@ -326,6 +331,7 @@ static int node_clipboard_paste_invoke(bContext *C, wmOperator *op, const wmEven
RNA_float_set_array(op->ptr, "offset", cursor);
return node_clipboard_paste_exec(C, op);
}
} // namespace FILE_NS
void NODE_OT_clipboard_paste(wmOperatorType *ot)
{
@ -333,8 +339,8 @@ void NODE_OT_clipboard_paste(wmOperatorType *ot)
ot->description = "Paste nodes from the internal clipboard to the active node tree";
ot->idname = "NODE_OT_clipboard_paste";
ot->invoke = node_clipboard_paste_invoke;
ot->exec = node_clipboard_paste_exec;
ot->invoke = FILE_NS::node_clipboard_paste_invoke;
ot->exec = FILE_NS::node_clipboard_paste_exec;
ot->poll = ED_operator_node_editable;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@ -361,7 +367,9 @@ void NODE_OT_clipboard_paste(wmOperatorType *ot)
void ED_node_clipboard_free()
{
using namespace blender::ed::space_node;
NodeClipboard &clipboard = get_node_clipboard();
FILE_NS::NodeClipboard &clipboard = FILE_NS::get_node_clipboard();
clipboard.validate();
clipboard.clear();
}
#undef FILE_NS

View File

@ -67,6 +67,8 @@
#include "NOD_texture.h"
#include "node_intern.hh" /* own include */
#define FILE_NS drawnode_cc
namespace blender::ed::space_node {
/* Default flags for uiItemR(). Name is kept short since this is used a lot in this file. */
@ -74,6 +76,8 @@ namespace blender::ed::space_node {
/* ****************** SOCKET BUTTON DRAW FUNCTIONS ***************** */
namespace FILE_NS {
static void node_socket_button_label(bContext * /*C*/,
uiLayout *layout,
PointerRNA * /*ptr*/,
@ -147,7 +151,7 @@ static void node_buts_curvefloat(uiLayout *layout, bContext * /*C*/, PointerRNA
{
uiTemplateCurveMapping(layout, ptr, "mapping", 0, false, false, false, false);
}
} // namespace FILE_NS
} // namespace blender::ed::space_node
#define SAMPLE_FLT_ISNONE FLT_MAX
@ -165,6 +169,7 @@ void ED_node_sample_set(const float col[4])
namespace blender::ed::space_node {
namespace FILE_NS {
static void node_buts_curvecol(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
bNode *node = (bNode *)ptr->data;
@ -220,6 +225,7 @@ static void node_buts_combsep_color(uiLayout *layout, bContext * /*C*/, PointerR
{
uiItemR(layout, ptr, "mode", DEFAULT_FLAGS, "", ICON_NONE);
}
} // namespace FILE_NS
NodeResizeDirection node_get_resize_direction(const SpaceNode &snode,
const bNode *node,
@ -281,6 +287,7 @@ NodeResizeDirection node_get_resize_direction(const SpaceNode &snode,
/* ****************** BUTTON CALLBACKS FOR COMMON NODES ***************** */
namespace FILE_NS {
static void node_draw_buttons_group(uiLayout *layout, bContext *C, PointerRNA *ptr)
{
uiTemplateIDBrowse(
@ -1140,6 +1147,7 @@ static void node_socket_undefined_interface_draw_color(bContext * /*C*/,
r_color[2] = 0.0f;
r_color[3] = 1.0f;
}
} // namespace FILE_NS
/** \} */
@ -1159,21 +1167,22 @@ void ED_node_init_butfuncs()
NodeTypeUndefined.draw_buttons = nullptr;
NodeTypeUndefined.draw_buttons_ex = nullptr;
NodeSocketTypeUndefined.draw = node_socket_undefined_draw;
NodeSocketTypeUndefined.draw_color = node_socket_undefined_draw_color;
NodeSocketTypeUndefined.interface_draw = node_socket_undefined_interface_draw;
NodeSocketTypeUndefined.interface_draw_color = node_socket_undefined_interface_draw_color;
NodeSocketTypeUndefined.draw = FILE_NS::node_socket_undefined_draw;
NodeSocketTypeUndefined.draw_color = FILE_NS::node_socket_undefined_draw_color;
NodeSocketTypeUndefined.interface_draw = FILE_NS::node_socket_undefined_interface_draw;
NodeSocketTypeUndefined.interface_draw_color =
FILE_NS::node_socket_undefined_interface_draw_color;
/* node type ui functions */
NODE_TYPES_BEGIN (ntype) {
node_common_set_butfunc(ntype);
FILE_NS::node_common_set_butfunc(ntype);
node_composit_set_butfunc(ntype);
node_shader_set_butfunc(ntype);
node_texture_set_butfunc(ntype);
FILE_NS::node_composit_set_butfunc(ntype);
FILE_NS::node_shader_set_butfunc(ntype);
FILE_NS::node_texture_set_butfunc(ntype);
/* define update callbacks for socket properties */
node_template_properties_update(ntype);
FILE_NS::node_template_properties_update(ntype);
}
NODE_TYPES_END;
}
@ -1182,11 +1191,13 @@ void ED_init_custom_node_type(bNodeType * /*ntype*/) {}
void ED_init_custom_node_socket_type(bNodeSocketType *stype)
{
stype->draw = blender::ed::space_node::node_socket_button_label;
stype->draw = blender::ed::space_node::FILE_NS::node_socket_button_label;
}
namespace blender::ed::space_node {
namespace FILE_NS {
static const float virtual_node_socket_color[4] = {0.2, 0.2, 0.2, 1.0};
/* maps standard socket integer type to a color */
@ -1500,23 +1511,23 @@ static void node_socket_virtual_draw_color(bContext * /*C*/,
{
copy_v4_v4(r_color, virtual_node_socket_color);
}
} // namespace FILE_NS
} // namespace blender::ed::space_node
void ED_init_standard_node_socket_type(bNodeSocketType *stype)
{
using namespace blender::ed::space_node;
stype->draw = std_node_socket_draw;
stype->draw_color = std_node_socket_draw_color;
stype->interface_draw = std_node_socket_interface_draw;
stype->interface_draw_color = std_node_socket_interface_draw_color;
stype->draw = FILE_NS::std_node_socket_draw;
stype->draw_color = FILE_NS::std_node_socket_draw_color;
stype->interface_draw = FILE_NS::std_node_socket_interface_draw;
stype->interface_draw_color = FILE_NS::std_node_socket_interface_draw_color;
}
void ED_init_node_socket_type_virtual(bNodeSocketType *stype)
{
using namespace blender::ed::space_node;
stype->draw = node_socket_button_label;
stype->draw_color = node_socket_virtual_draw_color;
stype->draw = FILE_NS::node_socket_button_label;
stype->draw_color = FILE_NS::node_socket_virtual_draw_color;
}
void ED_node_type_draw_color(const char *idname, float *r_color)
@ -1532,8 +1543,8 @@ void ED_node_type_draw_color(const char *idname, float *r_color)
return;
}
BLI_assert(typeinfo->type < ARRAY_SIZE(std_node_socket_colors));
copy_v4_v4(r_color, std_node_socket_colors[typeinfo->type]);
BLI_assert(typeinfo->type < ARRAY_SIZE(FILE_NS::std_node_socket_colors));
copy_v4_v4(r_color, FILE_NS::std_node_socket_colors[typeinfo->type]);
}
namespace blender::ed::space_node {
@ -1629,6 +1640,7 @@ void draw_nodespace_back_pix(const bContext &C,
GPU_matrix_pop();
}
namespace FILE_NS {
static float2 socket_link_connection_location(const bNode &node,
const bNodeSocket &socket,
const bNodeLink &link)
@ -1686,11 +1698,12 @@ static bool node_link_draw_is_visible(const View2D &v2d, const std::array<float2
}
return true;
}
} // namespace FILE_NS
void node_link_bezier_points_evaluated(const bNodeLink &link,
std::array<float2, NODE_LINK_RESOL + 1> &coords)
{
const std::array<float2, 4> points = node_link_bezier_points(link);
const std::array<float2, 4> points = FILE_NS::node_link_bezier_points(link);
/* The extra +1 in size is required by these functions and would be removed ideally. */
BKE_curve_forward_diff_bezier(points[0].x,
@ -1714,6 +1727,8 @@ void node_link_bezier_points_evaluated(const bNodeLink &link,
#define LINK_WIDTH (2.5f * UI_SCALE_FAC)
#define ARROW_SIZE (7 * UI_SCALE_FAC)
namespace FILE_NS {
/* Reroute arrow shape and mute bar. These are expanded here and shrunk in the glsl code.
* See: gpu_shader_2D_nodelink_vert.glsl */
static float arrow_verts[3][2] = {{-1.0f, 1.0f}, {0.0f, 0.0f}, {-1.0f, -1.0f}};
@ -1953,18 +1968,20 @@ static void nodelink_batch_draw(const SpaceNode &snode)
GPU_blend(GPU_BLEND_NONE);
}
} // namespace FILE_NS
void nodelink_batch_start(SpaceNode & /*snode*/)
{
g_batch_link.enabled = true;
FILE_NS::g_batch_link.enabled = true;
}
void nodelink_batch_end(SpaceNode &snode)
{
nodelink_batch_draw(snode);
g_batch_link.enabled = false;
FILE_NS::nodelink_batch_draw(snode);
FILE_NS::g_batch_link.enabled = false;
}
namespace FILE_NS {
struct NodeLinkDrawConfig {
int th_col1;
int th_col2;
@ -2191,7 +2208,7 @@ static void node_draw_link_bezier_ex(const SpaceNode &snode,
GPU_uniformbuf_free(ubo);
}
}
} // namespace FILE_NS
void node_draw_link_bezier(const bContext &C,
const View2D &v2d,
const SpaceNode &snode,
@ -2201,14 +2218,14 @@ void node_draw_link_bezier(const bContext &C,
const int th_col3,
const bool selected)
{
const std::array<float2, 4> points = node_link_bezier_points(link);
if (!node_link_draw_is_visible(v2d, points)) {
const std::array<float2, 4> points = FILE_NS::node_link_bezier_points(link);
if (!FILE_NS::node_link_draw_is_visible(v2d, points)) {
return;
}
const NodeLinkDrawConfig draw_config = nodelink_get_draw_config(
const FILE_NS::NodeLinkDrawConfig draw_config = FILE_NS::nodelink_get_draw_config(
C, v2d, snode, link, th_col1, th_col2, th_col3, selected);
node_draw_link_bezier_ex(snode, draw_config, points);
FILE_NS::node_draw_link_bezier_ex(snode, draw_config, points);
}
void node_draw_link(const bContext &C,
@ -2264,11 +2281,12 @@ std::array<float2, 4> node_link_bezier_points_dragged(const SpaceNode &snode,
const float2 cursor = snode.runtime->cursor * UI_SCALE_FAC;
std::array<float2, 4> points;
points[0] = link.fromsock ?
socket_link_connection_location(*link.fromnode, *link.fromsock, link) :
FILE_NS::socket_link_connection_location(*link.fromnode, *link.fromsock, link) :
cursor;
points[3] = link.tosock ? socket_link_connection_location(*link.tonode, *link.tosock, link) :
cursor;
calculate_inner_link_bezier_points(points);
points[3] = link.tosock ?
FILE_NS::socket_link_connection_location(*link.tonode, *link.tosock, link) :
cursor;
FILE_NS::calculate_inner_link_bezier_points(points);
return points;
}
@ -2283,7 +2301,7 @@ void node_draw_link_dragged(const bContext &C,
const std::array<float2, 4> points = node_link_bezier_points_dragged(snode, link);
const NodeLinkDrawConfig draw_config = nodelink_get_draw_config(
const FILE_NS::NodeLinkDrawConfig draw_config = FILE_NS::nodelink_get_draw_config(
C, v2d, snode, link, TH_ACTIVE, TH_ACTIVE, TH_WIRE, true);
/* End marker outline. */
node_draw_link_end_markers(link, draw_config, points, true);
@ -2319,3 +2337,5 @@ void ED_node_draw_snap(View2D *v2d, const float cent[2], float size, NodeBorder
immEnd();
}
#undef FILE_NS

View File

@ -33,10 +33,14 @@
#include "node_intern.hh"
#define FILE_NS link_drag_search_cc
using blender::nodes::SocketLinkOperation;
namespace blender::ed::space_node {
namespace FILE_NS {
struct LinkDragSearchStorage {
bNode &from_node;
bNodeSocket &from_socket;
@ -470,15 +474,19 @@ static uiBlock *create_search_popup_block(bContext *C, ARegion *region, void *ar
UI_block_bounds_set_popup(block, 0.3f * U.widget_unit, offset);
return block;
}
} // namespace FILE_NS
void invoke_node_link_drag_add_menu(bContext &C,
bNode &node,
bNodeSocket &socket,
const float2 &cursor)
{
LinkDragSearchStorage *storage = new LinkDragSearchStorage{node, socket, cursor};
FILE_NS::LinkDragSearchStorage *storage = new FILE_NS::LinkDragSearchStorage{
node, socket, cursor};
/* Use the "_ex" variant with `can_refresh` false to avoid a double free when closing Blender. */
UI_popup_block_invoke_ex(&C, create_search_popup_block, storage, nullptr, false);
UI_popup_block_invoke_ex(&C, FILE_NS::create_search_popup_block, storage, nullptr, false);
}
} // namespace blender::ed::space_node
#undef FILE_NS

View File

@ -50,8 +50,12 @@
#include "node_intern.hh" /* own include */
#define FILE_NS node_add_cc
namespace blender::ed::space_node {
namespace FILE_NS {
/* -------------------------------------------------------------------- */
/** \name Utilities
* \{ */
@ -61,6 +65,7 @@ static void position_node_based_on_mouse(bNode &node, const float2 &location)
node.locx = location.x - NODE_DY * 1.5f / UI_SCALE_FAC;
node.locy = location.y + NODE_DY * 0.5f / UI_SCALE_FAC;
}
} // namespace FILE_NS
bNode *add_node(const bContext &C, const StringRef idname, const float2 &location)
{
@ -75,7 +80,7 @@ bNode *add_node(const bContext &C, const StringRef idname, const float2 &locatio
bNode *node = nodeAddNode(&C, &node_tree, idname_str.c_str());
BLI_assert(node && node->typeinfo);
position_node_based_on_mouse(*node, location);
FILE_NS::position_node_based_on_mouse(*node, location);
nodeSetSelected(node, true);
ED_node_set_active(&bmain, &snode, &node_tree, node, nullptr);
@ -95,7 +100,7 @@ bNode *add_static_node(const bContext &C, int type, const float2 &location)
bNode *node = nodeAddStaticNode(&C, &node_tree, type);
BLI_assert(node && node->typeinfo);
position_node_based_on_mouse(*node, location);
FILE_NS::position_node_based_on_mouse(*node, location);
nodeSetSelected(node, true);
ED_node_set_active(&bmain, &snode, &node_tree, node, nullptr);
@ -127,6 +132,8 @@ std::optional<float2> link_path_intersection(const bNodeLink &link, const Span<f
return std::nullopt;
}
namespace FILE_NS {
struct RerouteCutsForSocket {
/* The output socket's owner node. */
bNode *from_node;
@ -220,6 +227,7 @@ static int add_reroute_exec(bContext *C, wmOperator *op)
ED_node_tree_propagate_change(C, CTX_data_main(C), &ntree);
return OPERATOR_FINISHED;
}
} // namespace FILE_NS
void NODE_OT_add_reroute(wmOperatorType *ot)
{
@ -229,7 +237,7 @@ void NODE_OT_add_reroute(wmOperatorType *ot)
ot->invoke = WM_gesture_lines_invoke;
ot->modal = WM_gesture_lines_modal;
ot->exec = add_reroute_exec;
ot->exec = FILE_NS::add_reroute_exec;
ot->cancel = WM_gesture_lines_cancel;
ot->poll = ED_operator_node_editable;
@ -250,6 +258,7 @@ void NODE_OT_add_reroute(wmOperatorType *ot)
/* -------------------------------------------------------------------- */
/** \name Add Node Group Operator
* \{ */
namespace FILE_NS {
static bool node_group_add_poll(const bNodeTree &node_tree,
const bNodeTree &node_group,
@ -353,7 +362,7 @@ static int node_add_group_invoke(bContext *C, wmOperator *op, const wmEvent *eve
return node_add_group_exec(C, op);
}
} // namespace FILE_NS
void NODE_OT_add_group(wmOperatorType *ot)
{
/* identifiers */
@ -362,9 +371,9 @@ void NODE_OT_add_group(wmOperatorType *ot)
ot->idname = "NODE_OT_add_group";
/* callbacks */
ot->exec = node_add_group_exec;
ot->invoke = node_add_group_invoke;
ot->poll = node_add_group_poll;
ot->exec = FILE_NS::node_add_group_exec;
ot->invoke = FILE_NS::node_add_group_invoke;
ot->poll = FILE_NS::node_add_group_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
@ -377,6 +386,7 @@ void NODE_OT_add_group(wmOperatorType *ot)
/* -------------------------------------------------------------------- */
/** \name Add Node Group Asset Operator
* \{ */
namespace FILE_NS {
static bool add_node_group_asset(const bContext &C,
const asset_system::AssetRepresentation &asset,
@ -467,6 +477,7 @@ static char *node_add_group_asset_get_description(bContext *C,
}
return BLI_strdup(DATA_(asset_data.description));
}
} // namespace FILE_NS
void NODE_OT_add_group_asset(wmOperatorType *ot)
{
@ -474,9 +485,9 @@ void NODE_OT_add_group_asset(wmOperatorType *ot)
ot->description = "Add a node group asset to the active node tree";
ot->idname = "NODE_OT_add_group_asset";
ot->invoke = node_add_group_asset_invoke;
ot->poll = node_add_group_poll;
ot->get_description = node_add_group_asset_get_description;
ot->invoke = FILE_NS::node_add_group_asset_invoke;
ot->poll = FILE_NS::node_add_group_poll;
ot->get_description = FILE_NS::node_add_group_asset_get_description;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
}
@ -486,6 +497,7 @@ void NODE_OT_add_group_asset(wmOperatorType *ot)
/* -------------------------------------------------------------------- */
/** \name Add Node Object Operator
* \{ */
namespace FILE_NS {
static int node_add_object_exec(bContext *C, wmOperator *op)
{
@ -549,6 +561,7 @@ static bool node_add_object_poll(bContext *C)
return ED_operator_node_editable(C) && ELEM(snode->nodetree->type, NTREE_GEOMETRY) &&
!UI_but_active_drop_name(C);
}
} // namespace FILE_NS
void NODE_OT_add_object(wmOperatorType *ot)
{
@ -558,9 +571,9 @@ void NODE_OT_add_object(wmOperatorType *ot)
ot->idname = "NODE_OT_add_object";
/* callbacks */
ot->exec = node_add_object_exec;
ot->invoke = node_add_object_invoke;
ot->poll = node_add_object_poll;
ot->exec = FILE_NS::node_add_object_exec;
ot->invoke = FILE_NS::node_add_object_invoke;
ot->poll = FILE_NS::node_add_object_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
@ -574,6 +587,8 @@ void NODE_OT_add_object(wmOperatorType *ot)
/** \name Add Node Collection Operator
* \{ */
namespace FILE_NS {
static int node_add_collection_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
@ -636,7 +651,7 @@ static bool node_add_collection_poll(bContext *C)
return ED_operator_node_editable(C) && ELEM(snode->nodetree->type, NTREE_GEOMETRY) &&
!UI_but_active_drop_name(C);
}
} // namespace FILE_NS
void NODE_OT_add_collection(wmOperatorType *ot)
{
/* identifiers */
@ -645,9 +660,9 @@ void NODE_OT_add_collection(wmOperatorType *ot)
ot->idname = "NODE_OT_add_collection";
/* callbacks */
ot->exec = node_add_collection_exec;
ot->invoke = node_add_collection_invoke;
ot->poll = node_add_collection_poll;
ot->exec = FILE_NS::node_add_collection_exec;
ot->invoke = FILE_NS::node_add_collection_invoke;
ot->poll = FILE_NS::node_add_collection_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
@ -660,6 +675,7 @@ void NODE_OT_add_collection(wmOperatorType *ot)
/* -------------------------------------------------------------------- */
/** \name Add File Node Operator
* \{ */
namespace FILE_NS {
static bool node_add_file_poll(bContext *C)
{
@ -749,7 +765,7 @@ static int node_add_file_invoke(bContext *C, wmOperator *op, const wmEvent *even
}
return WM_operator_filesel(C, op, event);
}
} // namespace FILE_NS
void NODE_OT_add_file(wmOperatorType *ot)
{
/* identifiers */
@ -758,9 +774,9 @@ void NODE_OT_add_file(wmOperatorType *ot)
ot->idname = "NODE_OT_add_file";
/* callbacks */
ot->exec = node_add_file_exec;
ot->invoke = node_add_file_invoke;
ot->poll = node_add_file_poll;
ot->exec = FILE_NS::node_add_file_exec;
ot->invoke = FILE_NS::node_add_file_invoke;
ot->poll = FILE_NS::node_add_file_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@ -781,6 +797,8 @@ void NODE_OT_add_file(wmOperatorType *ot)
/** \name Add Mask Node Operator
* \{ */
namespace FILE_NS {
static bool node_add_mask_poll(bContext *C)
{
SpaceNode *snode = CTX_wm_space_node(C);
@ -815,6 +833,7 @@ static int node_add_mask_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
} // namespace FILE_NS
void NODE_OT_add_mask(wmOperatorType *ot)
{
@ -824,8 +843,8 @@ void NODE_OT_add_mask(wmOperatorType *ot)
ot->idname = "NODE_OT_add_mask";
/* callbacks */
ot->exec = node_add_mask_exec;
ot->poll = node_add_mask_poll;
ot->exec = FILE_NS::node_add_mask_exec;
ot->poll = FILE_NS::node_add_mask_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
@ -838,6 +857,7 @@ void NODE_OT_add_mask(wmOperatorType *ot)
/* -------------------------------------------------------------------- */
/** \name New Node Tree Operator
* \{ */
namespace FILE_NS {
static int new_node_tree_exec(bContext *C, wmOperator *op)
{
@ -907,6 +927,7 @@ static const EnumPropertyItem *new_node_tree_type_itemf(bContext * /*C*/,
{
return rna_node_tree_type_itemf(nullptr, nullptr, r_free);
}
} // namespace FILE_NS
void NODE_OT_new_node_tree(wmOperatorType *ot)
{
@ -918,13 +939,13 @@ void NODE_OT_new_node_tree(wmOperatorType *ot)
ot->description = "Create a new node tree";
/* api callbacks */
ot->exec = new_node_tree_exec;
ot->exec = FILE_NS::new_node_tree_exec;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
prop = RNA_def_enum(ot->srna, "type", DummyRNA_NULL_items, 0, "Tree Type", "");
RNA_def_enum_funcs(prop, new_node_tree_type_itemf);
RNA_def_enum_funcs(prop, FILE_NS::new_node_tree_type_itemf);
RNA_def_string(ot->srna, "name", "NodeTree", MAX_ID_NAME - 2, "Name", "");
}
@ -934,6 +955,8 @@ void NODE_OT_new_node_tree(wmOperatorType *ot)
/** \name Add Node Search
* \{ */
namespace FILE_NS {
static int node_add_search_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
const ARegion &region = *CTX_wm_region(C);
@ -945,14 +968,14 @@ static int node_add_search_invoke(bContext *C, wmOperator *op, const wmEvent *ev
return OPERATOR_FINISHED;
}
} // namespace FILE_NS
void NODE_OT_add_search(wmOperatorType *ot)
{
ot->name = "Search and Add Node";
ot->idname = "NODE_OT_add_search";
ot->description = "Search for nodes and add one to the active tree";
ot->invoke = node_add_search_invoke;
ot->invoke = FILE_NS::node_add_search_invoke;
ot->poll = ED_operator_node_editable;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@ -964,3 +987,5 @@ void NODE_OT_add_search(wmOperatorType *ot)
/** \} */
} // namespace blender::ed::space_node
#undef FILE_NS

View File

@ -29,9 +29,12 @@
#include "node_intern.hh"
#define FILE_NS node_context_path_cc
struct Material;
namespace blender::ed::space_node {
namespace FILE_NS {
static void context_path_add_object_data(Vector<ui::ContextPathItem> &path, Object &object)
{
@ -139,6 +142,7 @@ static void get_context_path_node_geometry(const bContext &C,
context_path_add_node_tree_and_node_groups(snode, path);
}
}
} // namespace FILE_NS
Vector<ui::ContextPathItem> context_path_for_space_node(const bContext &C)
{
@ -150,16 +154,18 @@ Vector<ui::ContextPathItem> context_path_for_space_node(const bContext &C)
Vector<ui::ContextPathItem> context_path;
if (snode->edittree->type == NTREE_GEOMETRY) {
get_context_path_node_geometry(C, *snode, context_path);
FILE_NS::get_context_path_node_geometry(C, *snode, context_path);
}
else if (snode->edittree->type == NTREE_SHADER) {
get_context_path_node_shader(C, *snode, context_path);
FILE_NS::get_context_path_node_shader(C, *snode, context_path);
}
else if (snode->edittree->type == NTREE_COMPOSIT) {
get_context_path_node_compositor(C, *snode, context_path);
FILE_NS::get_context_path_node_compositor(C, *snode, context_path);
}
return context_path;
}
} // namespace blender::ed::space_node
#undef FILE_NS

View File

@ -96,6 +96,8 @@
#include <fmt/format.h>
#define FILE_NS node_draw_cc
namespace geo_log = blender::nodes::geo_eval_log;
using blender::bke::bNodeTreeZone;
using blender::bke::bNodeTreeZones;
@ -140,6 +142,8 @@ void ED_node_tree_update(const bContext *C)
}
}
namespace FILE_NS {
/* id is supposed to contain a node tree */
static bNodeTree *node_tree_from_ID(ID *id)
{
@ -152,10 +156,11 @@ static bNodeTree *node_tree_from_ID(ID *id)
return nullptr;
}
} // namespace FILE_NS
void ED_node_tag_update_id(ID *id)
{
bNodeTree *ntree = node_tree_from_ID(id);
bNodeTree *ntree = FILE_NS::node_tree_from_ID(id);
if (id == nullptr || ntree == nullptr) {
return;
}
@ -194,6 +199,7 @@ void ED_node_tag_update_id(ID *id)
}
namespace blender::ed::space_node {
namespace FILE_NS {
static const char *node_socket_get_translation_context(const bNodeSocket &socket)
{
@ -278,11 +284,12 @@ static bool compare_node_depth(const bNode *a, const bNode *b)
return false;
}
} // namespace FILE_NS
void node_sort(bNodeTree &ntree)
{
Array<bNode *> sort_nodes = ntree.all_nodes();
std::stable_sort(sort_nodes.begin(), sort_nodes.end(), compare_node_depth);
std::stable_sort(sort_nodes.begin(), sort_nodes.end(), FILE_NS::compare_node_depth);
/* If nothing was changed, exit early. Otherwise the node tree's runtime
* node vector needs to be rebuilt, since it cannot be reordered in place. */
@ -301,6 +308,8 @@ void node_sort(bNodeTree &ntree)
}
}
namespace FILE_NS {
static Array<uiBlock *> node_uiblocks_init(const bContext &C, const Span<bNode *> nodes)
{
Array<uiBlock *> blocks(nodes.size());
@ -314,6 +323,7 @@ static Array<uiBlock *> node_uiblocks_init(const bContext &C, const Span<bNode *
return blocks;
}
} // namespace FILE_NS
float2 node_to_view(const bNode &node, const float2 &co)
{
@ -339,6 +349,8 @@ float2 node_from_view(const bNode &node, const float2 &co)
;
}
namespace FILE_NS {
/**
* Based on settings and sockets in node, set drawing rect info.
*/
@ -774,6 +786,7 @@ static void node_socket_outline_color_get(const bool selected,
r_outline_color[3] = 1.0f;
}
}
} // namespace FILE_NS
void node_socket_color_get(const bContext &C,
const bNodeTree &ntree,
@ -789,6 +802,8 @@ void node_socket_color_get(const bContext &C,
sock.typeinfo->draw_color((bContext *)&C, &ptr, &node_ptr, r_color);
}
namespace FILE_NS {
static void create_inspection_string_for_generic_value(const bNodeSocket &socket,
const GPointer value,
std::stringstream &ss)
@ -1183,10 +1198,11 @@ static void node_socket_add_tooltip_in_node_editor(const bNodeTree &ntree,
nullptr,
nullptr);
}
} // namespace FILE_NS
void node_socket_add_tooltip(const bNodeTree &ntree, const bNodeSocket &sock, uiLayout &layout)
{
if (!node_socket_has_tooltip(ntree, sock)) {
if (!FILE_NS::node_socket_has_tooltip(ntree, sock)) {
return;
}
@ -1204,13 +1220,15 @@ void node_socket_add_tooltip(const bNodeTree &ntree, const bNodeSocket &sock, ui
[](bContext *C, void *argN, const char * /*tip*/) {
SocketTooltipData *data = static_cast<SocketTooltipData *>(argN);
const SpaceNode *snode = CTX_wm_space_node(C);
return node_socket_get_tooltip(snode, *data->ntree, *data->socket);
return FILE_NS::node_socket_get_tooltip(snode, *data->ntree, *data->socket);
},
data,
MEM_dupallocN,
MEM_freeN);
}
namespace FILE_NS {
static void node_socket_draw_nested(const bContext &C,
const bNodeTree &ntree,
PointerRNA &node_ptr,
@ -1282,13 +1300,14 @@ static void node_socket_draw_nested(const bContext &C,
UI_block_emboss_set(&block, old_emboss);
}
} // namespace FILE_NS
void node_socket_draw(bNodeSocket *sock, const rcti *rect, const float color[4], float scale)
{
const float size = NODE_SOCKSIZE_DRAW_MULIPLIER * NODE_SOCKSIZE * scale;
rcti draw_rect = *rect;
float outline_color[4] = {0};
node_socket_outline_color_get(sock->flag & SELECT, sock->type, outline_color);
FILE_NS::node_socket_outline_color_get(sock->flag & SELECT, sock->type, outline_color);
BLI_rcti_resize(&draw_rect, size, size);
@ -1310,17 +1329,17 @@ void node_socket_draw(bNodeSocket *sock, const rcti *rect, const float color[4],
/* Single point. */
immBegin(GPU_PRIM_POINTS, 1);
node_socket_draw(*sock,
color,
outline_color,
BLI_rcti_size_y(&draw_rect),
BLI_rcti_cent_x(&draw_rect),
BLI_rcti_cent_y(&draw_rect),
pos_id,
col_id,
shape_id,
size_id,
outline_col_id);
FILE_NS::node_socket_draw(*sock,
color,
outline_color,
BLI_rcti_size_y(&draw_rect),
BLI_rcti_cent_x(&draw_rect),
BLI_rcti_cent_y(&draw_rect),
pos_id,
col_id,
shape_id,
size_id,
outline_col_id);
immEnd();
immUnbindProgram();
@ -1329,6 +1348,7 @@ void node_socket_draw(bNodeSocket *sock, const rcti *rect, const float color[4],
/* Restore. */
GPU_blend(state);
}
namespace FILE_NS {
static void node_draw_preview_background(rctf *rect)
{
@ -2720,6 +2740,7 @@ static void node_draw_hidden(const bContext &C,
UI_block_end(&C, &block);
UI_block_draw(&C, &block);
}
} // namespace FILE_NS
int node_get_resize_cursor(NodeResizeDirection directions)
{
@ -2735,6 +2756,8 @@ int node_get_resize_cursor(NodeResizeDirection directions)
return WM_CURSOR_EDIT;
}
namespace FILE_NS {
static const bNode *find_node_under_cursor(SpaceNode &snode, const float2 &cursor)
{
const Span<bNode *> nodes = snode.edittree->all_nodes();
@ -2748,6 +2771,7 @@ static const bNode *find_node_under_cursor(SpaceNode &snode, const float2 &curso
}
return nullptr;
}
} // namespace FILE_NS
void node_set_cursor(wmWindow &win, SpaceNode &snode, const float2 &cursor)
{
@ -2760,7 +2784,7 @@ void node_set_cursor(wmWindow &win, SpaceNode &snode, const float2 &cursor)
WM_cursor_set(&win, WM_CURSOR_DEFAULT);
return;
}
const bNode *node = find_node_under_cursor(snode, cursor);
const bNode *node = FILE_NS::find_node_under_cursor(snode, cursor);
if (!node) {
WM_cursor_set(&win, WM_CURSOR_DEFAULT);
return;
@ -2780,6 +2804,8 @@ void node_set_cursor(wmWindow &win, SpaceNode &snode, const float2 &cursor)
WM_cursor_set(&win, node_get_resize_cursor(dir));
}
namespace FILE_NS {
static void count_multi_input_socket_links(bNodeTree &ntree, SpaceNode &snode)
{
for (bNode *node : ntree.all_nodes()) {
@ -3509,6 +3535,7 @@ static void draw_background_color(const SpaceNode &snode)
mul_v3_fl(color, 1.0f + bright_factor * depth);
GPU_clear_color(color[0], color[1], color[2], 1.0);
}
} // namespace FILE_NS
void node_draw_space(const bContext &C, ARegion &region)
{
@ -3523,7 +3550,7 @@ void node_draw_space(const bContext &C, ARegion &region)
GPU_framebuffer_bind_no_srgb(framebuffer_overlay);
UI_view2d_view_ortho(&v2d);
draw_background_color(snode);
FILE_NS::draw_background_color(snode);
GPU_depth_test(GPU_DEPTH_NONE);
GPU_scissor_test(true);
@ -3573,7 +3600,7 @@ void node_draw_space(const bContext &C, ARegion &region)
/* Top-level edit tree. */
bNodeTree *ntree = path->nodetree;
if (ntree) {
snode_setup_v2d(snode, region, center);
FILE_NS::snode_setup_v2d(snode, region, center);
/* Backdrop. */
draw_nodespace_back_pix(C, region, snode, path->parent_key);
@ -3593,7 +3620,7 @@ void node_draw_space(const bContext &C, ARegion &region)
GPU_matrix_projection_set(original_proj);
}
draw_nodetree(C, region, *ntree, path->parent_key);
FILE_NS::draw_nodetree(C, region, *ntree, path->parent_key);
}
/* Temporary links. */
@ -3631,7 +3658,7 @@ void node_draw_space(const bContext &C, ARegion &region)
/* Draw context path. */
if (snode.overlay.flag & SN_OVERLAY_SHOW_PATH && snode.edittree) {
draw_tree_path(C, region);
FILE_NS::draw_tree_path(C, region);
}
}
@ -3640,3 +3667,5 @@ void node_draw_space(const bContext &C, ARegion &region)
}
} // namespace blender::ed::space_node
#undef FILE_NS

View File

@ -72,7 +72,10 @@
#include "NOD_texture.h"
#include "node_intern.hh" /* own include */
#define FILE_NS node_edit_cc
namespace blender::ed::space_node {
namespace FILE_NS {
#define USE_ESC_COMPO
@ -103,6 +106,7 @@ struct CompoJob {
float *progress;
bool cancelled;
};
} // namespace FILE_NS
float node_socket_calculate_height(const bNodeSocket &socket)
{
@ -123,6 +127,7 @@ float2 node_link_calculate_multi_input_position(const float2 &socket_position,
return {socket_position.x, socket_position.y - offset + index * NODE_MULTI_INPUT_LINK_GAP};
}
namespace FILE_NS {
static void compo_tag_output_nodes(bNodeTree *nodetree, int recalc_flags)
{
for (bNode *node : nodetree->all_nodes()) {
@ -330,6 +335,7 @@ static void compo_completejob(void *cjv)
Scene *scene = cj->scene;
BKE_callback_exec_id(bmain, &scene->id, BKE_CB_EVT_COMPOSITE_POST);
}
} // namespace FILE_NS
/** \} */
@ -365,25 +371,25 @@ void ED_node_composite_job(const bContext *C, bNodeTree *nodetree, Scene *scene_
"Compositing",
WM_JOB_EXCL_RENDER | WM_JOB_PROGRESS,
WM_JOB_TYPE_COMPOSITE);
CompoJob *cj = MEM_cnew<CompoJob>("compo job");
FILE_NS::CompoJob *cj = MEM_cnew<FILE_NS::CompoJob>("compo job");
/* Custom data for preview thread. */
cj->bmain = bmain;
cj->scene = scene;
cj->view_layer = view_layer;
cj->ntree = nodetree;
cj->recalc_flags = compo_get_recalc_flags(C);
cj->recalc_flags = FILE_NS::compo_get_recalc_flags(C);
/* Set up job. */
WM_jobs_customdata_set(wm_job, cj, compo_freejob);
WM_jobs_customdata_set(wm_job, cj, FILE_NS::compo_freejob);
WM_jobs_timer(wm_job, 0.1, NC_SCENE | ND_COMPO_RESULT, NC_SCENE | ND_COMPO_RESULT);
WM_jobs_callbacks_ex(wm_job,
compo_startjob,
compo_initjob,
compo_updatejob,
FILE_NS::compo_startjob,
FILE_NS::compo_initjob,
FILE_NS::compo_updatejob,
nullptr,
compo_completejob,
compo_canceljob);
FILE_NS::compo_completejob,
FILE_NS::compo_canceljob);
WM_jobs_start(CTX_wm_manager(C), wm_job);
}
@ -418,6 +424,7 @@ bool composite_node_editable(bContext *C)
return false;
}
namespace FILE_NS {
static void send_notifiers_after_tree_change(ID *id, bNodeTree *ntree)
{
WM_main_add_notifier(NC_NODE | NA_EDITED, nullptr);
@ -443,6 +450,7 @@ static void send_notifiers_after_tree_change(ID *id, bNodeTree *ntree)
WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, id);
}
}
} // namespace FILE_NS
/** \} */
@ -457,13 +465,13 @@ void ED_node_tree_propagate_change(const bContext *C, Main *bmain, bNodeTree *ro
if (C != nullptr) {
SpaceNode *snode = CTX_wm_space_node(C);
if (snode != nullptr && root_ntree != nullptr) {
blender::ed::space_node::send_notifiers_after_tree_change(snode->id, root_ntree);
blender::ed::space_node::FILE_NS::send_notifiers_after_tree_change(snode->id, root_ntree);
}
}
NodeTreeUpdateExtraParams params = {nullptr};
params.tree_changed_fn = [](ID *id, bNodeTree *ntree, void * /*user_data*/) {
blender::ed::space_node::send_notifiers_after_tree_change(id, ntree);
blender::ed::space_node::FILE_NS::send_notifiers_after_tree_change(id, ntree);
DEG_id_tag_update(&ntree->id, ID_RECALC_COPY_ON_WRITE);
};
params.tree_output_changed_fn = [](ID * /*id*/, bNodeTree *ntree, void * /*user_data*/) {
@ -843,6 +851,7 @@ void ED_node_post_apply_transform(bContext * /*C*/, bNodeTree * /*ntree*/)
/** \} */
namespace blender::ed::space_node {
namespace FILE_NS {
/* -------------------------------------------------------------------- */
/** \name Node Generic
@ -1060,6 +1069,7 @@ static void node_resize_cancel(bContext *C, wmOperator *op)
{
node_resize_exit(C, op, true);
}
} // namespace FILE_NS
void NODE_OT_resize(wmOperatorType *ot)
{
@ -1069,10 +1079,10 @@ void NODE_OT_resize(wmOperatorType *ot)
ot->description = "Resize a node";
/* api callbacks */
ot->invoke = node_resize_invoke;
ot->modal = node_resize_modal;
ot->invoke = FILE_NS::node_resize_invoke;
ot->modal = FILE_NS::node_resize_modal;
ot->poll = ED_operator_node_active;
ot->cancel = node_resize_cancel;
ot->cancel = FILE_NS::node_resize_cancel;
/* flags */
ot->flag = OPTYPE_BLOCKING;
@ -1124,6 +1134,8 @@ void node_set_hidden_sockets(bNode *node, int set)
}
}
namespace FILE_NS {
static bool cursor_isect_multi_input_socket(const float2 &cursor, const bNodeSocket &socket)
{
const float node_socket_height = node_socket_calculate_height(socket);
@ -1144,6 +1156,7 @@ static bool cursor_isect_multi_input_socket(const float2 &cursor, const bNodeSoc
}
return false;
}
} // namespace FILE_NS
bNodeSocket *node_find_indicated_socket(SpaceNode &snode,
const float2 &cursor,
@ -1180,14 +1193,14 @@ bNodeSocket *node_find_indicated_socket(SpaceNode &snode,
if (sock->is_visible()) {
const float2 location = sock->runtime->location;
if (sock->flag & SOCK_MULTI_INPUT && !(node.flag & NODE_HIDDEN)) {
if (cursor_isect_multi_input_socket(cursor, *sock)) {
if (!socket_is_occluded(location, node, snode)) {
if (FILE_NS::cursor_isect_multi_input_socket(cursor, *sock)) {
if (!FILE_NS::socket_is_occluded(location, node, snode)) {
return sock;
}
}
}
else if (BLI_rctf_isect_pt(&rect, location.x, location.y)) {
if (!socket_is_occluded(location, node, snode)) {
if (!FILE_NS::socket_is_occluded(location, node, snode)) {
return sock;
}
}
@ -1199,7 +1212,7 @@ bNodeSocket *node_find_indicated_socket(SpaceNode &snode,
if (sock->is_visible()) {
const float2 location = sock->runtime->location;
if (BLI_rctf_isect_pt(&rect, location.x, location.y)) {
if (!socket_is_occluded(location, node, snode)) {
if (!FILE_NS::socket_is_occluded(location, node, snode)) {
return sock;
}
}
@ -1248,6 +1261,8 @@ bool node_link_is_hidden_or_dimmed(const View2D &v2d, const bNodeLink &link)
/** \name Node Duplicate Operator
* \{ */
namespace FILE_NS {
static void node_duplicate_reparent_recursive(bNodeTree *ntree,
const Map<bNode *, bNode *> &node_map,
bNode *node)
@ -1271,6 +1286,7 @@ static void node_duplicate_reparent_recursive(bNodeTree *ntree,
nodeAttachNode(ntree, node_map.lookup(node), node_map.lookup(parent));
}
}
} // namespace FILE_NS
void remap_node_pairing(bNodeTree &dst_tree, const Map<const bNode *, bNode *> &node_map)
{
@ -1314,6 +1330,8 @@ void remap_node_pairing(bNodeTree &dst_tree, const Map<const bNode *, bNode *> &
}
}
namespace FILE_NS {
static int node_duplicate_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
@ -1425,6 +1443,8 @@ static int node_duplicate_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
} // namespace FILE_NS
void NODE_OT_duplicate(wmOperatorType *ot)
{
PropertyRNA *prop;
@ -1435,7 +1455,7 @@ void NODE_OT_duplicate(wmOperatorType *ot)
ot->idname = "NODE_OT_duplicate";
/* api callbacks */
ot->exec = node_duplicate_exec;
ot->exec = FILE_NS::node_duplicate_exec;
ot->poll = ED_operator_node_editable;
/* flags */
@ -1452,6 +1472,8 @@ void NODE_OT_duplicate(wmOperatorType *ot)
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
namespace FILE_NS {
/* Goes over all scenes, reads render layers. */
static int node_read_viewlayers_exec(bContext *C, wmOperator * /*op*/)
{
@ -1487,6 +1509,7 @@ static int node_read_viewlayers_exec(bContext *C, wmOperator * /*op*/)
return OPERATOR_FINISHED;
}
} // namespace FILE_NS
void NODE_OT_read_viewlayers(wmOperatorType *ot)
{
@ -1494,7 +1517,7 @@ void NODE_OT_read_viewlayers(wmOperatorType *ot)
ot->idname = "NODE_OT_read_viewlayers";
ot->description = "Read all render layers of all used scenes";
ot->exec = node_read_viewlayers_exec;
ot->exec = FILE_NS::node_read_viewlayers_exec;
ot->poll = composite_node_active;
}
@ -1557,6 +1580,8 @@ void NODE_OT_render_changed(wmOperatorType *ot)
/** \name Node Hide Operator
* \{ */
namespace FILE_NS {
/**
* Toggles the flag on all selected nodes. If the flag is set on all nodes it is unset.
* If the flag is not set on all nodes, it is set.
@ -1622,6 +1647,7 @@ static int node_hide_toggle_exec(bContext *C, wmOperator * /*op*/)
return OPERATOR_FINISHED;
}
} // namespace FILE_NS
void NODE_OT_hide_toggle(wmOperatorType *ot)
{
@ -1631,13 +1657,15 @@ void NODE_OT_hide_toggle(wmOperatorType *ot)
ot->idname = "NODE_OT_hide_toggle";
/* callbacks */
ot->exec = node_hide_toggle_exec;
ot->exec = FILE_NS::node_hide_toggle_exec;
ot->poll = ED_operator_node_active;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
namespace FILE_NS {
static int node_preview_toggle_exec(bContext *C, wmOperator * /*op*/)
{
SpaceNode *snode = CTX_wm_space_node(C);
@ -1656,6 +1684,8 @@ static int node_preview_toggle_exec(bContext *C, wmOperator * /*op*/)
return OPERATOR_FINISHED;
}
} // namespace FILE_NS
void NODE_OT_preview_toggle(wmOperatorType *ot)
{
/* identifiers */
@ -1664,12 +1694,13 @@ void NODE_OT_preview_toggle(wmOperatorType *ot)
ot->idname = "NODE_OT_preview_toggle";
/* callbacks */
ot->exec = node_preview_toggle_exec;
ot->exec = FILE_NS::node_preview_toggle_exec;
ot->poll = composite_node_active;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
namespace FILE_NS {
static int node_deactivate_viewer_exec(bContext *C, wmOperator * /*op*/)
{
@ -1695,6 +1726,7 @@ static int node_deactivate_viewer_exec(bContext *C, wmOperator * /*op*/)
return OPERATOR_FINISHED;
}
} // namespace FILE_NS
void NODE_OT_deactivate_viewer(wmOperatorType *ot)
{
@ -1704,13 +1736,14 @@ void NODE_OT_deactivate_viewer(wmOperatorType *ot)
ot->idname = __func__;
/* callbacks */
ot->exec = node_deactivate_viewer_exec;
ot->exec = FILE_NS::node_deactivate_viewer_exec;
ot->poll = ED_operator_node_active;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
namespace FILE_NS {
static int node_options_toggle_exec(bContext *C, wmOperator * /*op*/)
{
SpaceNode *snode = CTX_wm_space_node(C);
@ -1726,7 +1759,7 @@ static int node_options_toggle_exec(bContext *C, wmOperator * /*op*/)
return OPERATOR_FINISHED;
}
} // namespace FILE_NS
void NODE_OT_options_toggle(wmOperatorType *ot)
{
/* identifiers */
@ -1735,12 +1768,13 @@ void NODE_OT_options_toggle(wmOperatorType *ot)
ot->idname = "NODE_OT_options_toggle";
/* callbacks */
ot->exec = node_options_toggle_exec;
ot->exec = FILE_NS::node_options_toggle_exec;
ot->poll = ED_operator_node_active;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
namespace FILE_NS {
static int node_socket_toggle_exec(bContext *C, wmOperator * /*op*/)
{
@ -1776,7 +1810,7 @@ static int node_socket_toggle_exec(bContext *C, wmOperator * /*op*/)
return OPERATOR_FINISHED;
}
} // namespace FILE_NS
void NODE_OT_hide_socket_toggle(wmOperatorType *ot)
{
/* identifiers */
@ -1785,7 +1819,7 @@ void NODE_OT_hide_socket_toggle(wmOperatorType *ot)
ot->idname = "NODE_OT_hide_socket_toggle";
/* callbacks */
ot->exec = node_socket_toggle_exec;
ot->exec = FILE_NS::node_socket_toggle_exec;
ot->poll = ED_operator_node_active;
/* flags */
@ -1797,7 +1831,7 @@ void NODE_OT_hide_socket_toggle(wmOperatorType *ot)
/* -------------------------------------------------------------------- */
/** \name Node Mute Operator
* \{ */
namespace FILE_NS {
static int node_mute_exec(bContext *C, wmOperator * /*op*/)
{
Main *bmain = CTX_data_main(C);
@ -1816,6 +1850,7 @@ static int node_mute_exec(bContext *C, wmOperator * /*op*/)
return OPERATOR_FINISHED;
}
} // namespace FILE_NS
void NODE_OT_mute_toggle(wmOperatorType *ot)
{
@ -1825,7 +1860,7 @@ void NODE_OT_mute_toggle(wmOperatorType *ot)
ot->idname = "NODE_OT_mute_toggle";
/* callbacks */
ot->exec = node_mute_exec;
ot->exec = FILE_NS::node_mute_exec;
ot->poll = ED_operator_node_editable;
/* flags */
@ -1837,6 +1872,7 @@ void NODE_OT_mute_toggle(wmOperatorType *ot)
/* -------------------------------------------------------------------- */
/** \name Node Delete Operator
* \{ */
namespace FILE_NS {
static int node_delete_exec(bContext *C, wmOperator * /*op*/)
{
@ -1858,7 +1894,7 @@ static int node_delete_exec(bContext *C, wmOperator * /*op*/)
return OPERATOR_FINISHED;
}
} // namespace FILE_NS
void NODE_OT_delete(wmOperatorType *ot)
{
/* identifiers */
@ -1867,7 +1903,7 @@ void NODE_OT_delete(wmOperatorType *ot)
ot->idname = "NODE_OT_delete";
/* api callbacks */
ot->exec = node_delete_exec;
ot->exec = FILE_NS::node_delete_exec;
ot->poll = ED_operator_node_editable;
/* flags */
@ -1880,6 +1916,8 @@ void NODE_OT_delete(wmOperatorType *ot)
/** \name Node Switch View
* \{ */
namespace FILE_NS {
static bool node_switch_view_poll(bContext *C)
{
SpaceNode *snode = CTX_wm_space_node(C);
@ -1906,6 +1944,7 @@ static int node_switch_view_exec(bContext *C, wmOperator * /*op*/)
return OPERATOR_FINISHED;
}
} // namespace FILE_NS
void NODE_OT_switch_view_update(wmOperatorType *ot)
{
@ -1915,8 +1954,8 @@ void NODE_OT_switch_view_update(wmOperatorType *ot)
ot->idname = "NODE_OT_switch_view_update";
/* api callbacks */
ot->exec = node_switch_view_exec;
ot->poll = node_switch_view_poll;
ot->exec = FILE_NS::node_switch_view_exec;
ot->poll = FILE_NS::node_switch_view_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@ -1928,6 +1967,8 @@ void NODE_OT_switch_view_update(wmOperatorType *ot)
/** \name Node Delete with Reconnect Operator
* \{ */
namespace FILE_NS {
static int node_delete_reconnect_exec(bContext *C, wmOperator * /*op*/)
{
Main *bmain = CTX_data_main(C);
@ -1949,7 +1990,7 @@ static int node_delete_reconnect_exec(bContext *C, wmOperator * /*op*/)
return OPERATOR_FINISHED;
}
} // namespace FILE_NS
void NODE_OT_delete_reconnect(wmOperatorType *ot)
{
/* identifiers */
@ -1958,7 +1999,7 @@ void NODE_OT_delete_reconnect(wmOperatorType *ot)
ot->idname = "NODE_OT_delete_reconnect";
/* api callbacks */
ot->exec = node_delete_reconnect_exec;
ot->exec = FILE_NS::node_delete_reconnect_exec;
ot->poll = ED_operator_node_editable;
/* flags */
@ -1970,6 +2011,7 @@ void NODE_OT_delete_reconnect(wmOperatorType *ot)
/* -------------------------------------------------------------------- */
/** \name Node File Output Add Socket Operator
* \{ */
namespace FILE_NS {
static int node_output_file_add_socket_exec(bContext *C, wmOperator *op)
{
@ -2000,7 +2042,7 @@ static int node_output_file_add_socket_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
} // namespace FILE_NS
void NODE_OT_output_file_add_socket(wmOperatorType *ot)
{
/* identifiers */
@ -2009,7 +2051,7 @@ void NODE_OT_output_file_add_socket(wmOperatorType *ot)
ot->idname = "NODE_OT_output_file_add_socket";
/* callbacks */
ot->exec = node_output_file_add_socket_exec;
ot->exec = FILE_NS::node_output_file_add_socket_exec;
ot->poll = composite_node_editable;
/* flags */
@ -2025,6 +2067,8 @@ void NODE_OT_output_file_add_socket(wmOperatorType *ot)
/** \name Node Multi File Output Remove Socket Operator
* \{ */
namespace FILE_NS {
static int node_output_file_remove_active_socket_exec(bContext *C, wmOperator * /*op*/)
{
SpaceNode *snode = CTX_wm_space_node(C);
@ -2053,6 +2097,7 @@ static int node_output_file_remove_active_socket_exec(bContext *C, wmOperator *
return OPERATOR_FINISHED;
}
} // namespace FILE_NS
void NODE_OT_output_file_remove_active_socket(wmOperatorType *ot)
{
@ -2062,7 +2107,7 @@ void NODE_OT_output_file_remove_active_socket(wmOperatorType *ot)
ot->idname = "NODE_OT_output_file_remove_active_socket";
/* callbacks */
ot->exec = node_output_file_remove_active_socket_exec;
ot->exec = FILE_NS::node_output_file_remove_active_socket_exec;
ot->poll = composite_node_editable;
/* flags */
@ -2075,6 +2120,8 @@ void NODE_OT_output_file_remove_active_socket(wmOperatorType *ot)
/** \name Node Multi File Output Move Socket Node
* \{ */
namespace FILE_NS {
static int node_output_file_move_active_socket_exec(bContext *C, wmOperator *op)
{
SpaceNode *snode = CTX_wm_space_node(C);
@ -2125,6 +2172,7 @@ static int node_output_file_move_active_socket_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
} // namespace FILE_NS
void NODE_OT_output_file_move_active_socket(wmOperatorType *ot)
{
@ -2137,7 +2185,7 @@ void NODE_OT_output_file_move_active_socket(wmOperatorType *ot)
ot->idname = "NODE_OT_output_file_move_active_socket";
/* callbacks */
ot->exec = node_output_file_move_active_socket_exec;
ot->exec = FILE_NS::node_output_file_move_active_socket_exec;
ot->poll = composite_node_editable;
/* flags */
@ -2152,6 +2200,8 @@ void NODE_OT_output_file_move_active_socket(wmOperatorType *ot)
/** \name Node Copy Node Color Operator
* \{ */
namespace FILE_NS {
static int node_copy_color_exec(bContext *C, wmOperator * /*op*/)
{
SpaceNode &snode = *CTX_wm_space_node(C);
@ -2179,6 +2229,8 @@ static int node_copy_color_exec(bContext *C, wmOperator * /*op*/)
return OPERATOR_FINISHED;
}
} // namespace FILE_NS
void NODE_OT_node_copy_color(wmOperatorType *ot)
{
/* identifiers */
@ -2187,7 +2239,7 @@ void NODE_OT_node_copy_color(wmOperatorType *ot)
ot->idname = "NODE_OT_node_copy_color";
/* api callbacks */
ot->exec = node_copy_color_exec;
ot->exec = FILE_NS::node_copy_color_exec;
ot->poll = ED_operator_node_editable;
/* flags */
@ -2200,6 +2252,8 @@ void NODE_OT_node_copy_color(wmOperatorType *ot)
/** \name Node-Tree Add Interface Socket Operator
* \{ */
namespace FILE_NS {
static bNodeSocket *ntree_get_active_interface_socket(const ListBase *lb)
{
LISTBASE_FOREACH (bNodeSocket *, socket, lb) {
@ -2252,6 +2306,7 @@ static int ntree_socket_add_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
} // namespace FILE_NS
void NODE_OT_tree_socket_add(wmOperatorType *ot)
{
@ -2261,7 +2316,7 @@ void NODE_OT_tree_socket_add(wmOperatorType *ot)
ot->idname = "NODE_OT_tree_socket_add";
/* api callbacks */
ot->exec = ntree_socket_add_exec;
ot->exec = FILE_NS::ntree_socket_add_exec;
ot->poll = ED_operator_node_editable;
/* flags */
@ -2276,6 +2331,8 @@ void NODE_OT_tree_socket_add(wmOperatorType *ot)
/** \name Node-Tree Remove Interface Socket Operator
* \{ */
namespace FILE_NS {
static int ntree_socket_remove_exec(bContext *C, wmOperator *op)
{
SpaceNode *snode = CTX_wm_space_node(C);
@ -2303,6 +2360,7 @@ static int ntree_socket_remove_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
} // namespace FILE_NS
void NODE_OT_tree_socket_remove(wmOperatorType *ot)
{
@ -2312,7 +2370,7 @@ void NODE_OT_tree_socket_remove(wmOperatorType *ot)
ot->idname = "NODE_OT_tree_socket_remove";
/* api callbacks */
ot->exec = ntree_socket_remove_exec;
ot->exec = FILE_NS::ntree_socket_remove_exec;
ot->poll = ED_operator_node_editable;
/* flags */
@ -2326,6 +2384,8 @@ void NODE_OT_tree_socket_remove(wmOperatorType *ot)
/** \name Node-Tree Change Interface Socket Type Operator
* \{ */
namespace FILE_NS {
static int ntree_socket_change_type_exec(bContext *C, wmOperator *op)
{
SpaceNode *snode = CTX_wm_space_node(C);
@ -2403,6 +2463,7 @@ static const EnumPropertyItem *socket_change_type_itemf(bContext *C,
return rna_node_socket_type_itemf(snode->edittree->typeinfo, socket_change_poll_type, r_free);
}
} // namespace FILE_NS
void NODE_OT_tree_socket_change_type(wmOperatorType *ot)
{
@ -2415,7 +2476,7 @@ void NODE_OT_tree_socket_change_type(wmOperatorType *ot)
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = ntree_socket_change_type_exec;
ot->exec = FILE_NS::ntree_socket_change_type_exec;
ot->poll = ED_operator_node_editable;
/* flags */
@ -2423,7 +2484,7 @@ void NODE_OT_tree_socket_change_type(wmOperatorType *ot)
RNA_def_enum(ot->srna, "in_out", rna_enum_node_socket_in_out_items, SOCK_IN, "Socket Type", "");
prop = RNA_def_enum(ot->srna, "socket_type", DummyRNA_DEFAULT_items, 0, "Socket Type", "");
RNA_def_enum_funcs(prop, socket_change_type_itemf);
RNA_def_enum_funcs(prop, FILE_NS::socket_change_type_itemf);
ot->prop = prop;
}
@ -2433,6 +2494,8 @@ void NODE_OT_tree_socket_change_type(wmOperatorType *ot)
/** \name Node-Tree Change Interface Socket Subtype Operator
* \{ */
namespace FILE_NS {
static int ntree_socket_change_subtype_exec(bContext *C, wmOperator *op)
{
Main *main = CTX_data_main(C);
@ -2558,6 +2621,7 @@ static bool ntree_socket_change_subtype_poll(bContext *C)
}
return !socket_type_get_subtypes(eNodeSocketDatatype(io_socket->type)).is_empty();
}
} // namespace FILE_NS
void NODE_OT_tree_socket_change_subtype(wmOperatorType *ot)
{
@ -2566,14 +2630,14 @@ void NODE_OT_tree_socket_change_subtype(wmOperatorType *ot)
ot->idname = "NODE_OT_tree_socket_change_subtype";
ot->invoke = WM_menu_invoke;
ot->exec = ntree_socket_change_subtype_exec;
ot->poll = ntree_socket_change_subtype_poll;
ot->exec = FILE_NS::ntree_socket_change_subtype_exec;
ot->poll = FILE_NS::ntree_socket_change_subtype_poll;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
ot->prop = RNA_def_enum(
ot->srna, "socket_subtype", DummyRNA_DEFAULT_items, 0, "Socket Subtype", "");
RNA_def_enum_funcs(ot->prop, socket_change_subtype_itemf);
RNA_def_enum_funcs(ot->prop, FILE_NS::socket_change_subtype_itemf);
}
/** \} */
@ -2582,6 +2646,8 @@ void NODE_OT_tree_socket_change_subtype(wmOperatorType *ot)
/** \name Node-Tree Move Interface Socket Operator
* \{ */
namespace FILE_NS {
static const EnumPropertyItem move_direction_items[] = {
{1, "UP", 0, "Up", ""},
{2, "DOWN", 0, "Down", ""},
@ -2637,6 +2703,7 @@ static int ntree_socket_move_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
} // namespace FILE_NS
void NODE_OT_tree_socket_move(wmOperatorType *ot)
{
@ -2646,13 +2713,13 @@ void NODE_OT_tree_socket_move(wmOperatorType *ot)
ot->idname = "NODE_OT_tree_socket_move";
/* api callbacks */
ot->exec = ntree_socket_move_exec;
ot->exec = FILE_NS::ntree_socket_move_exec;
ot->poll = ED_operator_node_editable;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_enum(ot->srna, "direction", move_direction_items, 1, "Direction", "");
RNA_def_enum(ot->srna, "direction", FILE_NS::move_direction_items, 1, "Direction", "");
RNA_def_enum(ot->srna, "in_out", rna_enum_node_socket_in_out_items, SOCK_IN, "Socket Type", "");
}
@ -2662,6 +2729,8 @@ void NODE_OT_tree_socket_move(wmOperatorType *ot)
/** \name Node Shader Script Update
* \{ */
namespace FILE_NS {
static bool node_shader_script_update_poll(bContext *C)
{
Scene *scene = CTX_data_scene(C);
@ -2785,6 +2854,7 @@ static int node_shader_script_update_exec(bContext *C, wmOperator *op)
return (found) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
} // namespace FILE_NS
void NODE_OT_shader_script_update(wmOperatorType *ot)
{
@ -2794,8 +2864,8 @@ void NODE_OT_shader_script_update(wmOperatorType *ot)
ot->idname = "NODE_OT_shader_script_update";
/* api callbacks */
ot->exec = node_shader_script_update_exec;
ot->poll = node_shader_script_update_poll;
ot->exec = FILE_NS::node_shader_script_update_exec;
ot->poll = FILE_NS::node_shader_script_update_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@ -2807,6 +2877,8 @@ void NODE_OT_shader_script_update(wmOperatorType *ot)
/** \name Node Viewer Border
* \{ */
namespace FILE_NS {
static void viewer_border_corner_to_backdrop(SpaceNode *snode,
ARegion *region,
int x,
@ -2878,6 +2950,7 @@ static int viewer_border_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
} // namespace FILE_NS
void NODE_OT_viewer_border(wmOperatorType *ot)
{
@ -2888,7 +2961,7 @@ void NODE_OT_viewer_border(wmOperatorType *ot)
/* api callbacks */
ot->invoke = WM_gesture_box_invoke;
ot->exec = viewer_border_exec;
ot->exec = FILE_NS::viewer_border_exec;
ot->modal = WM_gesture_box_modal;
ot->cancel = WM_gesture_box_cancel;
ot->poll = composite_node_active;
@ -2900,6 +2973,8 @@ void NODE_OT_viewer_border(wmOperatorType *ot)
WM_operator_properties_gesture_box(ot);
}
namespace FILE_NS {
static int clear_viewer_border_exec(bContext *C, wmOperator * /*op*/)
{
SpaceNode *snode = CTX_wm_space_node(C);
@ -2911,6 +2986,7 @@ static int clear_viewer_border_exec(bContext *C, wmOperator * /*op*/)
return OPERATOR_FINISHED;
}
} // namespace FILE_NS
void NODE_OT_clear_viewer_border(wmOperatorType *ot)
{
@ -2920,7 +2996,7 @@ void NODE_OT_clear_viewer_border(wmOperatorType *ot)
ot->idname = "NODE_OT_clear_viewer_border";
/* api callbacks */
ot->exec = clear_viewer_border_exec;
ot->exec = FILE_NS::clear_viewer_border_exec;
ot->poll = composite_node_active;
/* flags */
@ -2933,6 +3009,7 @@ void NODE_OT_clear_viewer_border(wmOperatorType *ot)
/** \name Cryptomatte Add Socket
* \{ */
namespace FILE_NS {
static int node_cryptomatte_add_socket_exec(bContext *C, wmOperator * /*op*/)
{
SpaceNode *snode = CTX_wm_space_node(C);
@ -2959,6 +3036,7 @@ static int node_cryptomatte_add_socket_exec(bContext *C, wmOperator * /*op*/)
return OPERATOR_FINISHED;
}
} // namespace FILE_NS
void NODE_OT_cryptomatte_layer_add(wmOperatorType *ot)
{
@ -2968,7 +3046,7 @@ void NODE_OT_cryptomatte_layer_add(wmOperatorType *ot)
ot->idname = "NODE_OT_cryptomatte_layer_add";
/* callbacks */
ot->exec = node_cryptomatte_add_socket_exec;
ot->exec = FILE_NS::node_cryptomatte_add_socket_exec;
ot->poll = composite_node_editable;
/* flags */
@ -2980,6 +3058,7 @@ void NODE_OT_cryptomatte_layer_add(wmOperatorType *ot)
/* -------------------------------------------------------------------- */
/** \name Cryptomatte Remove Socket
* \{ */
namespace FILE_NS {
static int node_cryptomatte_remove_socket_exec(bContext *C, wmOperator * /*op*/)
{
@ -3009,6 +3088,7 @@ static int node_cryptomatte_remove_socket_exec(bContext *C, wmOperator * /*op*/)
return OPERATOR_FINISHED;
}
} // namespace FILE_NS
void NODE_OT_cryptomatte_layer_remove(wmOperatorType *ot)
{
@ -3018,7 +3098,7 @@ void NODE_OT_cryptomatte_layer_remove(wmOperatorType *ot)
ot->idname = "NODE_OT_cryptomatte_layer_remove";
/* callbacks */
ot->exec = node_cryptomatte_remove_socket_exec;
ot->exec = FILE_NS::node_cryptomatte_remove_socket_exec;
ot->poll = composite_node_editable;
/* flags */
@ -3028,3 +3108,5 @@ void NODE_OT_cryptomatte_layer_remove(wmOperatorType *ot)
/** \} */
} // namespace blender::ed::space_node
#undef FILE_NS

View File

@ -38,9 +38,12 @@
#include "node_intern.hh"
#define FILE_NS node_geometry_attribute_search_cc
using blender::nodes::geo_eval_log::GeometryAttributeInfo;
namespace blender::ed::space_node {
namespace FILE_NS {
struct AttributeSearchData {
int32_t node_id;
@ -235,6 +238,7 @@ static void attribute_search_exec_fn(bContext *C, void *data_v, void *item_v)
ED_undo_push(C, "Assign Attribute Name");
}
} // namespace FILE_NS
void node_geometry_add_attribute_search_button(const bContext & /*C*/,
const bNode &node,
@ -261,7 +265,7 @@ void node_geometry_add_attribute_search_button(const bContext & /*C*/,
"");
const bNodeSocket &socket = *static_cast<const bNodeSocket *>(socket_ptr.data);
AttributeSearchData *data = MEM_new<AttributeSearchData>(__func__);
FILE_NS::AttributeSearchData *data = MEM_new<FILE_NS::AttributeSearchData>(__func__);
data->node_id = node.identifier;
STRNCPY(data->socket_identifier, socket.identifier);
@ -269,12 +273,14 @@ void node_geometry_add_attribute_search_button(const bContext & /*C*/,
UI_but_func_search_set_sep_string(but, UI_MENU_ARROW_SEP);
UI_but_func_search_set(but,
nullptr,
attribute_search_update_fn,
FILE_NS::attribute_search_update_fn,
static_cast<void *>(data),
true,
nullptr,
attribute_search_exec_fn,
FILE_NS::attribute_search_exec_fn,
nullptr);
}
} // namespace blender::ed::space_node
#undef FILE_NS

View File

@ -32,12 +32,16 @@
#include "node_intern.hh"
#define FILE_NS node_gizmo_cc
namespace blender::ed::space_node {
/* -------------------------------------------------------------------- */
/** \name Local Utilities
* \{ */
namespace FILE_NS {
static void node_gizmo_calc_matrix_space(const SpaceNode *snode,
const ARegion *region,
float matrix_space[4][4])
@ -169,6 +173,8 @@ static void WIDGETGROUP_node_transform_refresh(const bContext *C, wmGizmoGroup *
BKE_image_release_ibuf(ima, ibuf, lock);
}
} // namespace FILE_NS
void NODE_GGT_backdrop_transform(wmGizmoGroupType *gzgt)
{
gzgt->name = "Backdrop Transform Widget";
@ -176,10 +182,10 @@ void NODE_GGT_backdrop_transform(wmGizmoGroupType *gzgt)
gzgt->flag |= WM_GIZMOGROUPTYPE_PERSISTENT;
gzgt->poll = WIDGETGROUP_node_transform_poll;
gzgt->setup = WIDGETGROUP_node_transform_setup;
gzgt->poll = FILE_NS::WIDGETGROUP_node_transform_poll;
gzgt->setup = FILE_NS::WIDGETGROUP_node_transform_setup;
gzgt->setup_keymap = WM_gizmogroup_setup_keymap_generic_maybe_drag;
gzgt->refresh = WIDGETGROUP_node_transform_refresh;
gzgt->refresh = FILE_NS::WIDGETGROUP_node_transform_refresh;
}
/** \} */
@ -188,6 +194,8 @@ void NODE_GGT_backdrop_transform(wmGizmoGroupType *gzgt)
/** \name Crop Gizmo
* \{ */
namespace FILE_NS {
struct NodeCropWidgetGroup {
wmGizmo *border;
@ -380,6 +388,8 @@ static void WIDGETGROUP_node_crop_refresh(const bContext *C, wmGizmoGroup *gzgro
BKE_image_release_ibuf(ima, ibuf, lock);
}
} // namespace FILE_NS
void NODE_GGT_backdrop_crop(wmGizmoGroupType *gzgt)
{
gzgt->name = "Backdrop Crop Widget";
@ -387,11 +397,11 @@ void NODE_GGT_backdrop_crop(wmGizmoGroupType *gzgt)
gzgt->flag |= WM_GIZMOGROUPTYPE_PERSISTENT;
gzgt->poll = WIDGETGROUP_node_crop_poll;
gzgt->setup = WIDGETGROUP_node_crop_setup;
gzgt->poll = FILE_NS::WIDGETGROUP_node_crop_poll;
gzgt->setup = FILE_NS::WIDGETGROUP_node_crop_setup;
gzgt->setup_keymap = WM_gizmogroup_setup_keymap_generic_maybe_drag;
gzgt->draw_prepare = WIDGETGROUP_node_crop_draw_prepare;
gzgt->refresh = WIDGETGROUP_node_crop_refresh;
gzgt->draw_prepare = FILE_NS::WIDGETGROUP_node_crop_draw_prepare;
gzgt->refresh = FILE_NS::WIDGETGROUP_node_crop_refresh;
}
/** \} */
@ -400,6 +410,8 @@ void NODE_GGT_backdrop_crop(wmGizmoGroupType *gzgt)
/** \name Sun Beams
* \{ */
namespace FILE_NS {
struct NodeSunBeamsWidgetGroup {
wmGizmo *gizmo;
@ -485,6 +497,8 @@ static void WIDGETGROUP_node_sbeam_refresh(const bContext *C, wmGizmoGroup *gzgr
BKE_image_release_ibuf(ima, ibuf, lock);
}
} // namespace FILE_NS
void NODE_GGT_backdrop_sun_beams(wmGizmoGroupType *gzgt)
{
gzgt->name = "Sun Beams Widget";
@ -492,11 +506,11 @@ void NODE_GGT_backdrop_sun_beams(wmGizmoGroupType *gzgt)
gzgt->flag |= WM_GIZMOGROUPTYPE_PERSISTENT;
gzgt->poll = WIDGETGROUP_node_sbeam_poll;
gzgt->setup = WIDGETGROUP_node_sbeam_setup;
gzgt->poll = FILE_NS::WIDGETGROUP_node_sbeam_poll;
gzgt->setup = FILE_NS::WIDGETGROUP_node_sbeam_setup;
gzgt->setup_keymap = WM_gizmogroup_setup_keymap_generic_maybe_drag;
gzgt->draw_prepare = WIDGETGROUP_node_sbeam_draw_prepare;
gzgt->refresh = WIDGETGROUP_node_sbeam_refresh;
gzgt->draw_prepare = FILE_NS::WIDGETGROUP_node_sbeam_draw_prepare;
gzgt->refresh = FILE_NS::WIDGETGROUP_node_sbeam_refresh;
}
/** \} */
@ -505,6 +519,8 @@ void NODE_GGT_backdrop_sun_beams(wmGizmoGroupType *gzgt)
/** \name Corner Pin
* \{ */
namespace FILE_NS {
struct NodeCornerPinWidgetGroup {
wmGizmo *gizmos[4];
@ -607,6 +623,8 @@ static void WIDGETGROUP_node_corner_pin_refresh(const bContext *C, wmGizmoGroup
BKE_image_release_ibuf(ima, ibuf, lock);
}
} // namespace FILE_NS
void NODE_GGT_backdrop_corner_pin(wmGizmoGroupType *gzgt)
{
gzgt->name = "Corner Pin Widget";
@ -614,13 +632,15 @@ void NODE_GGT_backdrop_corner_pin(wmGizmoGroupType *gzgt)
gzgt->flag |= WM_GIZMOGROUPTYPE_PERSISTENT;
gzgt->poll = WIDGETGROUP_node_corner_pin_poll;
gzgt->setup = WIDGETGROUP_node_corner_pin_setup;
gzgt->poll = FILE_NS::WIDGETGROUP_node_corner_pin_poll;
gzgt->setup = FILE_NS::WIDGETGROUP_node_corner_pin_setup;
gzgt->setup_keymap = WM_gizmogroup_setup_keymap_generic_maybe_drag;
gzgt->draw_prepare = WIDGETGROUP_node_corner_pin_draw_prepare;
gzgt->refresh = WIDGETGROUP_node_corner_pin_refresh;
gzgt->draw_prepare = FILE_NS::WIDGETGROUP_node_corner_pin_draw_prepare;
gzgt->refresh = FILE_NS::WIDGETGROUP_node_corner_pin_refresh;
}
/** \} */
} // namespace blender::ed::space_node
#undef FILE_NS

View File

@ -61,7 +61,10 @@
#include "node_intern.hh" /* own include */
#define FILE_NS node_group_cc
namespace blender::ed::space_node {
namespace FILE_NS {
/* -------------------------------------------------------------------- */
/** \name Local Utilities
@ -109,6 +112,7 @@ static const char *group_ntree_idname(bContext *C)
SpaceNode *snode = CTX_wm_space_node(C);
return snode->tree_idname;
}
} // namespace FILE_NS
const char *node_group_idname(bContext *C)
{
@ -130,6 +134,7 @@ const char *node_group_idname(bContext *C)
return "";
}
namespace FILE_NS {
static bNode *node_group_get_active(bContext *C, const char *node_idname)
{
SpaceNode *snode = CTX_wm_space_node(C);
@ -208,6 +213,7 @@ static int node_group_edit_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
} // namespace FILE_NS
void NODE_OT_group_edit(wmOperatorType *ot)
{
@ -217,8 +223,8 @@ void NODE_OT_group_edit(wmOperatorType *ot)
ot->idname = "NODE_OT_group_edit";
/* api callbacks */
ot->exec = node_group_edit_exec;
ot->poll = node_group_operator_active_poll;
ot->exec = FILE_NS::node_group_edit_exec;
ot->poll = FILE_NS::node_group_operator_active_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@ -232,6 +238,8 @@ void NODE_OT_group_edit(wmOperatorType *ot)
/** \name Ungroup Operator
* \{ */
namespace FILE_NS {
/**
* The given paths will be owned by the returned instance.
* Both pointers are allowed to point to the same string.
@ -491,6 +499,7 @@ static int node_group_ungroup_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
} // namespace FILE_NS
void NODE_OT_group_ungroup(wmOperatorType *ot)
{
@ -500,8 +509,8 @@ void NODE_OT_group_ungroup(wmOperatorType *ot)
ot->idname = "NODE_OT_group_ungroup";
/* api callbacks */
ot->exec = node_group_ungroup_exec;
ot->poll = node_group_operator_editable;
ot->exec = FILE_NS::node_group_ungroup_exec;
ot->poll = FILE_NS::node_group_operator_editable;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@ -513,6 +522,8 @@ void NODE_OT_group_ungroup(wmOperatorType *ot)
/** \name Separate Operator
* \{ */
namespace FILE_NS {
/**
* \return True if successful.
*/
@ -698,6 +709,8 @@ static int node_group_separate_invoke(bContext *C, wmOperator * /*op*/, const wm
return OPERATOR_INTERFACE;
}
} // namespace FILE_NS
void NODE_OT_group_separate(wmOperatorType *ot)
{
/* identifiers */
@ -706,14 +719,15 @@ void NODE_OT_group_separate(wmOperatorType *ot)
ot->idname = "NODE_OT_group_separate";
/* api callbacks */
ot->invoke = node_group_separate_invoke;
ot->exec = node_group_separate_exec;
ot->poll = node_group_operator_editable;
ot->invoke = FILE_NS::node_group_separate_invoke;
ot->exec = FILE_NS::node_group_separate_exec;
ot->poll = FILE_NS::node_group_operator_editable;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_enum(ot->srna, "type", node_group_separate_types, NODE_GS_COPY, "Type", "");
RNA_def_enum(
ot->srna, "type", FILE_NS::node_group_separate_types, FILE_NS::NODE_GS_COPY, "Type", "");
}
/** \} */
@ -722,6 +736,8 @@ void NODE_OT_group_separate(wmOperatorType *ot)
/** \name Make Group Operator
* \{ */
namespace FILE_NS {
static VectorSet<bNode *> get_nodes_to_group(bNodeTree &node_tree, bNode *group_node)
{
VectorSet<bNode *> nodes_to_group = get_selected_nodes(node_tree);
@ -1286,6 +1302,8 @@ static int node_group_make_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
} // namespace FILE_NS
void NODE_OT_group_make(wmOperatorType *ot)
{
/* identifiers */
@ -1294,8 +1312,8 @@ void NODE_OT_group_make(wmOperatorType *ot)
ot->idname = "NODE_OT_group_make";
/* api callbacks */
ot->exec = node_group_make_exec;
ot->poll = node_group_operator_editable;
ot->exec = FILE_NS::node_group_make_exec;
ot->poll = FILE_NS::node_group_operator_editable;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@ -1307,6 +1325,8 @@ void NODE_OT_group_make(wmOperatorType *ot)
/** \name Group Insert Operator
* \{ */
namespace FILE_NS {
static int node_group_insert_exec(bContext *C, wmOperator *op)
{
SpaceNode *snode = CTX_wm_space_node(C);
@ -1346,6 +1366,7 @@ static int node_group_insert_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
} // namespace FILE_NS
void NODE_OT_group_insert(wmOperatorType *ot)
{
@ -1355,8 +1376,8 @@ void NODE_OT_group_insert(wmOperatorType *ot)
ot->idname = "NODE_OT_group_insert";
/* api callbacks */
ot->exec = node_group_insert_exec;
ot->poll = node_group_operator_editable;
ot->exec = FILE_NS::node_group_insert_exec;
ot->poll = FILE_NS::node_group_operator_editable;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@ -1365,3 +1386,5 @@ void NODE_OT_group_insert(wmOperatorType *ot)
/** \} */
} // namespace blender::ed::space_node
#undef FILE_NS

View File

@ -54,6 +54,8 @@
#include "node_intern.hh" /* own include */
#define FILE_NS node_relationships_cc
struct NodeInsertOfsData {
bNodeTree *ntree;
bNode *insert; /* Inserted node. */
@ -69,6 +71,8 @@ namespace blender::ed::space_node {
bNodeSocket *get_main_socket(bNodeTree &ntree, bNode &node, eNodeSocketInOut in_out);
namespace FILE_NS {
static void clear_picking_highlight(ListBase *links)
{
LISTBASE_FOREACH (bNodeLink *, link, links) {
@ -313,6 +317,7 @@ static void sort_multi_input_socket_links_with_drag(bNodeSocket &socket,
links[i].link->multi_input_socket_index = i;
}
}
} // namespace FILE_NS
void update_multi_input_indices_for_removed_links(bNode &node)
{
@ -331,6 +336,8 @@ void update_multi_input_indices_for_removed_links(bNode &node)
}
}
namespace FILE_NS {
static void snode_autoconnect(SpaceNode &snode, const bool allow_multiple, const bool replace)
{
bNodeTree *ntree = snode.edittree;
@ -743,6 +750,7 @@ static bool node_active_link_viewer_poll(bContext *C)
SpaceNode *snode = CTX_wm_space_node(C);
return ED_node_is_compositor(snode) || ED_node_is_geometry(snode);
}
} // namespace FILE_NS
void NODE_OT_link_viewer(wmOperatorType *ot)
{
@ -752,8 +760,8 @@ void NODE_OT_link_viewer(wmOperatorType *ot)
ot->idname = "NODE_OT_link_viewer";
/* api callbacks */
ot->exec = node_active_link_viewer_exec;
ot->poll = node_active_link_viewer_poll;
ot->exec = FILE_NS::node_active_link_viewer_exec;
ot->poll = FILE_NS::node_active_link_viewer_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@ -765,6 +773,8 @@ void NODE_OT_link_viewer(wmOperatorType *ot)
/** \name Add Link Operator
* \{ */
namespace FILE_NS {
/**
* Check if any of the dragged links are connected to a socket on the side that they are dragged
* from.
@ -1201,13 +1211,15 @@ enum class NodeLinkAction : int {
Confirm,
};
} // namespace FILE_NS
wmKeyMap *node_link_modal_keymap(wmKeyConfig *keyconf)
{
static const EnumPropertyItem modal_items[] = {
{int(NodeLinkAction::Begin), "BEGIN", 0, "Drag Node-link", ""},
{int(NodeLinkAction::Confirm), "CONFIRM", 0, "Confirm Link", ""},
{int(NodeLinkAction::Cancel), "CANCEL", 0, "Cancel", ""},
{int(NodeLinkAction::Swap), "SWAP", 0, "Swap Links", ""},
{int(FILE_NS::NodeLinkAction::Begin), "BEGIN", 0, "Drag Node-link", ""},
{int(FILE_NS::NodeLinkAction::Confirm), "CONFIRM", 0, "Confirm Link", ""},
{int(FILE_NS::NodeLinkAction::Cancel), "CANCEL", 0, "Cancel", ""},
{int(FILE_NS::NodeLinkAction::Swap), "SWAP", 0, "Swap Links", ""},
{0, nullptr, 0, nullptr, nullptr},
};
@ -1225,6 +1237,8 @@ wmKeyMap *node_link_modal_keymap(wmKeyConfig *keyconf)
return keymap;
}
namespace FILE_NS {
static int node_link_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
bNodeLinkDrag &nldrag = *static_cast<bNodeLinkDrag *>(op->customdata);
@ -1404,6 +1418,8 @@ static int node_link_invoke(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
} // namespace FILE_NS
void NODE_OT_link(wmOperatorType *ot)
{
/* identifiers */
@ -1412,10 +1428,10 @@ void NODE_OT_link(wmOperatorType *ot)
ot->description = "Use the mouse to create a link between two nodes";
/* api callbacks */
ot->invoke = node_link_invoke;
ot->modal = node_link_modal;
ot->invoke = FILE_NS::node_link_invoke;
ot->modal = FILE_NS::node_link_modal;
ot->poll = ED_operator_node_editable;
ot->cancel = node_link_cancel;
ot->cancel = FILE_NS::node_link_cancel;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
@ -1447,6 +1463,8 @@ void NODE_OT_link(wmOperatorType *ot)
/** \name Make Link Operator
* \{ */
namespace FILE_NS {
/* Makes a link between selected output and input sockets. */
static int node_make_link_exec(bContext *C, wmOperator *op)
{
@ -1468,6 +1486,8 @@ static int node_make_link_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
} // namespace FILE_NS
void NODE_OT_link_make(wmOperatorType *ot)
{
/* identifiers */
@ -1476,7 +1496,7 @@ void NODE_OT_link_make(wmOperatorType *ot)
ot->idname = "NODE_OT_link_make";
/* callbacks */
ot->exec = node_make_link_exec;
ot->exec = FILE_NS::node_make_link_exec;
/* XXX we need a special poll which checks that there are selected input/output sockets. */
ot->poll = ED_operator_node_editable;
@ -1493,6 +1513,8 @@ void NODE_OT_link_make(wmOperatorType *ot)
/** \name Cut Link Operator
* \{ */
namespace FILE_NS {
static int cut_links_exec(bContext *C, wmOperator *op)
{
Main &bmain = *CTX_data_main(C);
@ -1560,6 +1582,8 @@ static int cut_links_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
} // namespace FILE_NS
void NODE_OT_links_cut(wmOperatorType *ot)
{
ot->name = "Cut Links";
@ -1568,7 +1592,7 @@ void NODE_OT_links_cut(wmOperatorType *ot)
ot->invoke = WM_gesture_lines_invoke;
ot->modal = WM_gesture_lines_modal;
ot->exec = cut_links_exec;
ot->exec = FILE_NS::cut_links_exec;
ot->cancel = WM_gesture_lines_cancel;
ot->poll = ED_operator_node_editable;
@ -1601,6 +1625,8 @@ bool all_links_muted(const bNodeSocket &socket)
return true;
}
namespace FILE_NS {
static int mute_links_exec(bContext *C, wmOperator *op)
{
Main &bmain = *CTX_data_main(C);
@ -1686,6 +1712,8 @@ static int mute_links_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
} // namespace FILE_NS
void NODE_OT_links_mute(wmOperatorType *ot)
{
ot->name = "Mute Links";
@ -1694,7 +1722,7 @@ void NODE_OT_links_mute(wmOperatorType *ot)
ot->invoke = WM_gesture_lines_invoke;
ot->modal = WM_gesture_lines_modal;
ot->exec = mute_links_exec;
ot->exec = FILE_NS::mute_links_exec;
ot->cancel = WM_gesture_lines_cancel;
ot->poll = ED_operator_node_editable;
@ -1717,6 +1745,8 @@ void NODE_OT_links_mute(wmOperatorType *ot)
/** \name Detach Links Operator
* \{ */
namespace FILE_NS {
static int detach_links_exec(bContext *C, wmOperator * /*op*/)
{
SpaceNode &snode = *CTX_wm_space_node(C);
@ -1734,6 +1764,8 @@ static int detach_links_exec(bContext *C, wmOperator * /*op*/)
return OPERATOR_FINISHED;
}
} // namespace FILE_NS
void NODE_OT_links_detach(wmOperatorType *ot)
{
ot->name = "Detach Links";
@ -1741,7 +1773,7 @@ void NODE_OT_links_detach(wmOperatorType *ot)
ot->description =
"Remove all links to selected nodes, and try to connect neighbor nodes together";
ot->exec = detach_links_exec;
ot->exec = FILE_NS::detach_links_exec;
ot->poll = ED_operator_node_editable;
/* flags */
@ -1754,6 +1786,8 @@ void NODE_OT_links_detach(wmOperatorType *ot)
/** \name Set Parent Operator
* \{ */
namespace FILE_NS {
static int node_parent_set_exec(bContext *C, wmOperator * /*op*/)
{
SpaceNode &snode = *CTX_wm_space_node(C);
@ -1779,6 +1813,8 @@ static int node_parent_set_exec(bContext *C, wmOperator * /*op*/)
return OPERATOR_FINISHED;
}
} // namespace FILE_NS
void NODE_OT_parent_set(wmOperatorType *ot)
{
/* identifiers */
@ -1787,7 +1823,7 @@ void NODE_OT_parent_set(wmOperatorType *ot)
ot->idname = "NODE_OT_parent_set";
/* api callbacks */
ot->exec = node_parent_set_exec;
ot->exec = FILE_NS::node_parent_set_exec;
ot->poll = ED_operator_node_editable;
/* flags */
@ -1800,6 +1836,8 @@ void NODE_OT_parent_set(wmOperatorType *ot)
/** \name Join Nodes Operator
* \{ */
namespace FILE_NS {
struct NodeJoinState {
bool done;
bool descendent;
@ -1867,6 +1905,8 @@ static int node_join_exec(bContext *C, wmOperator * /*op*/)
return OPERATOR_FINISHED;
}
} // namespace FILE_NS
void NODE_OT_join(wmOperatorType *ot)
{
/* identifiers */
@ -1875,7 +1915,7 @@ void NODE_OT_join(wmOperatorType *ot)
ot->idname = "NODE_OT_join";
/* api callbacks */
ot->exec = node_join_exec;
ot->exec = FILE_NS::node_join_exec;
ot->poll = ED_operator_node_editable;
/* flags */
@ -1888,6 +1928,8 @@ void NODE_OT_join(wmOperatorType *ot)
/** \name Attach Operator
* \{ */
namespace FILE_NS {
static bNode *node_find_frame_to_attach(ARegion &region,
const bNodeTree &ntree,
const int2 mouse_xy)
@ -1951,6 +1993,8 @@ static int node_attach_invoke(bContext *C, wmOperator * /*op*/, const wmEvent *e
return OPERATOR_FINISHED;
}
} // namespace FILE_NS
void NODE_OT_attach(wmOperatorType *ot)
{
/* identifiers */
@ -1960,7 +2004,7 @@ void NODE_OT_attach(wmOperatorType *ot)
/* api callbacks */
ot->invoke = node_attach_invoke;
ot->invoke = FILE_NS::node_attach_invoke;
ot->poll = ED_operator_node_editable;
/* flags */
@ -1973,6 +2017,8 @@ void NODE_OT_attach(wmOperatorType *ot)
/** \name Detach Operator
* \{ */
namespace FILE_NS {
struct NodeDetachstate {
bool done;
bool descendent;
@ -2026,6 +2072,8 @@ static int node_detach_exec(bContext *C, wmOperator * /*op*/)
return OPERATOR_FINISHED;
}
} // namespace FILE_NS
void NODE_OT_detach(wmOperatorType *ot)
{
/* identifiers */
@ -2034,7 +2082,7 @@ void NODE_OT_detach(wmOperatorType *ot)
ot->idname = "NODE_OT_detach";
/* api callbacks */
ot->exec = node_detach_exec;
ot->exec = FILE_NS::node_detach_exec;
ot->poll = ED_operator_node_editable;
/* flags */
@ -2047,6 +2095,8 @@ void NODE_OT_detach(wmOperatorType *ot)
/** \name Automatic Node Insert on Dragging
* \{ */
namespace FILE_NS {
static bNode *get_selected_node_for_insertion(bNodeTree &node_tree)
{
bNode *selected_node = nullptr;
@ -2081,6 +2131,8 @@ static bNode *get_selected_node_for_insertion(bNodeTree &node_tree)
return selected_node;
}
} // namespace FILE_NS
void node_insert_on_link_flags_set(SpaceNode &snode, const ARegion &region)
{
bNodeTree &node_tree = *snode.edittree;
@ -2088,7 +2140,7 @@ void node_insert_on_link_flags_set(SpaceNode &snode, const ARegion &region)
node_insert_on_link_flags_clear(node_tree);
bNode *node_to_insert = get_selected_node_for_insertion(node_tree);
bNode *node_to_insert = FILE_NS::get_selected_node_for_insertion(node_tree);
if (!node_to_insert) {
return;
}
@ -2143,7 +2195,7 @@ void node_insert_on_link_flags(Main &bmain, SpaceNode &snode)
{
bNodeTree &node_tree = *snode.edittree;
node_tree.ensure_topology_cache();
bNode *node_to_insert = get_selected_node_for_insertion(node_tree);
bNode *node_to_insert = FILE_NS::get_selected_node_for_insertion(node_tree);
if (!node_to_insert) {
return;
}
@ -2222,6 +2274,8 @@ void node_insert_on_link_flags(Main &bmain, SpaceNode &snode)
/** \name Node Insert Offset Operator
* \{ */
namespace FILE_NS {
static int get_main_socket_priority(const bNodeSocket *socket)
{
switch ((eNodeSocketDatatype)socket->type) {
@ -2250,6 +2304,7 @@ static int get_main_socket_priority(const bNodeSocket *socket)
}
return -1;
}
} // namespace FILE_NS
/** Get the "main" socket based on the node declaration or an heuristic. */
bNodeSocket *get_main_socket(bNodeTree &ntree, bNode &node, eNodeSocketInOut in_out)
@ -2280,13 +2335,13 @@ bNodeSocket *get_main_socket(bNodeTree &ntree, bNode &node, eNodeSocketInOut in_
if (sock->flag & SOCK_UNAVAIL) {
continue;
}
maxpriority = max_ii(get_main_socket_priority(sock), maxpriority);
maxpriority = max_ii(FILE_NS::get_main_socket_priority(sock), maxpriority);
}
/* Try all priorities, starting from 'highest'. */
for (int priority = maxpriority; priority >= 0; priority--) {
LISTBASE_FOREACH (bNodeSocket *, sock, sockets) {
if (!!sock->is_visible() && priority == get_main_socket_priority(sock)) {
if (!!sock->is_visible() && priority == FILE_NS::get_main_socket_priority(sock)) {
return sock;
}
}
@ -2298,7 +2353,7 @@ bNodeSocket *get_main_socket(bNodeTree &ntree, bNode &node, eNodeSocketInOut in_
if (sock->flag & SOCK_UNAVAIL) {
continue;
}
if (priority == get_main_socket_priority(sock)) {
if (priority == FILE_NS::get_main_socket_priority(sock)) {
sock->flag &= ~SOCK_HIDDEN;
return sock;
}
@ -2308,6 +2363,8 @@ bNodeSocket *get_main_socket(bNodeTree &ntree, bNode &node, eNodeSocketInOut in_
return nullptr;
}
namespace FILE_NS {
static bool node_parents_offset_flag_enable_cb(bNode *parent, void * /*userdata*/)
{
/* NODE_TEST is used to flag nodes that shouldn't be offset (again) */
@ -2619,6 +2676,8 @@ static int node_insert_offset_invoke(bContext *C, wmOperator *op, const wmEvent
return OPERATOR_RUNNING_MODAL;
}
} // namespace FILE_NS
void NODE_OT_insert_offset(wmOperatorType *ot)
{
/* identifiers */
@ -2627,8 +2686,8 @@ void NODE_OT_insert_offset(wmOperatorType *ot)
ot->idname = "NODE_OT_insert_offset";
/* callbacks */
ot->invoke = node_insert_offset_invoke;
ot->modal = node_insert_offset_modal;
ot->invoke = FILE_NS::node_insert_offset_invoke;
ot->modal = FILE_NS::node_insert_offset_modal;
ot->poll = ED_operator_node_editable;
/* flags */
@ -2638,3 +2697,5 @@ void NODE_OT_insert_offset(wmOperatorType *ot)
/** \} */
} // namespace blender::ed::space_node
#undef FILE_NS

View File

@ -50,7 +50,10 @@
#include "node_intern.hh" /* own include */
#define FILE_NS node_select_cc
namespace blender::ed::space_node {
namespace FILE_NS {
static bool is_event_over_node_or_socket(const bContext &C, const wmEvent &event);
@ -84,6 +87,7 @@ static bool has_workbench_in_texture_color(const wmWindowManager *wm,
}
return false;
}
} // namespace FILE_NS
/* -------------------------------------------------------------------- */
/** \name Public Node Selection API
@ -106,9 +110,10 @@ rctf node_frame_rect_inside(const SpaceNode &snode, const bNode &node)
bool node_or_socket_isect_event(const bContext &C, const wmEvent &event)
{
return is_event_over_node_or_socket(C, event);
return FILE_NS::is_event_over_node_or_socket(C, event);
}
namespace FILE_NS {
static bool node_frame_select_isect_mouse(const SpaceNode &snode,
const bNode &node,
const float2 &mouse)
@ -199,6 +204,7 @@ static bool is_event_over_node_or_socket(const bContext &C, const wmEvent &event
UI_view2d_region_to_view(&region.v2d, mval.x, mval.y, &mouse.x, &mouse.y);
return is_position_over_node_or_socket(snode, mouse);
}
} // namespace FILE_NS
void node_socket_select(bNode *node, bNodeSocket &sock)
{
@ -237,6 +243,7 @@ void node_socket_deselect(bNode *node, bNodeSocket &sock, const bool deselect_no
}
}
namespace FILE_NS {
static void node_socket_toggle(bNode *node, bNodeSocket &sock, bool deselect_node)
{
if (sock.flag & SELECT) {
@ -246,6 +253,7 @@ static void node_socket_toggle(bNode *node, bNodeSocket &sock, bool deselect_nod
node_socket_select(node, sock);
}
}
} // namespace FILE_NS
void node_deselect_all(bNodeTree &node_tree)
{
@ -357,6 +365,8 @@ VectorSet<bNode *> get_selected_nodes(bNodeTree &node_tree)
/** \name Select Grouped Operator
* \{ */
namespace FILE_NS {
/* Return true if we need redraw, otherwise false. */
static bool node_select_grouped_type(bNodeTree &node_tree, bNode &node_act)
@ -479,15 +489,16 @@ static int node_select_grouped_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
} // namespace FILE_NS
void NODE_OT_select_grouped(wmOperatorType *ot)
{
PropertyRNA *prop;
static const EnumPropertyItem prop_select_grouped_types[] = {
{NODE_SELECT_GROUPED_TYPE, "TYPE", 0, "Type", ""},
{NODE_SELECT_GROUPED_COLOR, "COLOR", 0, "Color", ""},
{NODE_SELECT_GROUPED_PREFIX, "PREFIX", 0, "Prefix", ""},
{NODE_SELECT_GROUPED_SUFIX, "SUFFIX", 0, "Suffix", ""},
{FILE_NS::NODE_SELECT_GROUPED_TYPE, "TYPE", 0, "Type", ""},
{FILE_NS::NODE_SELECT_GROUPED_COLOR, "COLOR", 0, "Color", ""},
{FILE_NS::NODE_SELECT_GROUPED_PREFIX, "PREFIX", 0, "Prefix", ""},
{FILE_NS::NODE_SELECT_GROUPED_SUFIX, "SUFFIX", 0, "Suffix", ""},
{0, nullptr, 0, nullptr, nullptr},
};
@ -498,7 +509,7 @@ void NODE_OT_select_grouped(wmOperatorType *ot)
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = node_select_grouped_exec;
ot->exec = FILE_NS::node_select_grouped_exec;
ot->poll = ED_operator_node_active;
/* flags */
@ -541,13 +552,14 @@ void node_select_single(bContext &C, bNode &node)
ED_node_set_active_viewer_key(&snode);
node_sort(node_tree);
if (active_texture_changed && has_workbench_in_texture_color(wm, scene, ob)) {
if (active_texture_changed && FILE_NS::has_workbench_in_texture_color(wm, scene, ob)) {
DEG_id_tag_update(&node_tree.id, ID_RECALC_COPY_ON_WRITE);
}
WM_event_add_notifier(&C, NC_NODE | NA_SELECTED, nullptr);
}
namespace FILE_NS {
static bool node_mouse_select(bContext *C,
wmOperator *op,
const int2 mval,
@ -737,6 +749,7 @@ static int node_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
return WM_operator_flag_only_pass_through_on_press(retval, event);
}
} // namespace FILE_NS
void NODE_OT_select(wmOperatorType *ot)
{
@ -748,8 +761,8 @@ void NODE_OT_select(wmOperatorType *ot)
ot->description = "Select the node under the cursor";
/* api callbacks */
ot->exec = node_select_exec;
ot->invoke = node_select_invoke;
ot->exec = FILE_NS::node_select_exec;
ot->invoke = FILE_NS::node_select_invoke;
ot->poll = ED_operator_node_active;
ot->get_name = ED_select_pick_get_name;
@ -786,6 +799,7 @@ void NODE_OT_select(wmOperatorType *ot)
/** \name Box Select Operator
* \{ */
namespace FILE_NS {
static int node_box_select_exec(bContext *C, wmOperator *op)
{
SpaceNode &snode = *CTX_wm_space_node(C);
@ -846,6 +860,7 @@ static int node_box_select_invoke(bContext *C, wmOperator *op, const wmEvent *ev
return WM_gesture_box_invoke(C, op, event);
}
} // namespace FILE_NS
void NODE_OT_select_box(wmOperatorType *ot)
{
@ -855,8 +870,8 @@ void NODE_OT_select_box(wmOperatorType *ot)
ot->description = "Use box selection to select nodes";
/* api callbacks */
ot->invoke = node_box_select_invoke;
ot->exec = node_box_select_exec;
ot->invoke = FILE_NS::node_box_select_invoke;
ot->exec = FILE_NS::node_box_select_exec;
ot->modal = WM_gesture_box_modal;
ot->cancel = WM_gesture_box_cancel;
@ -882,6 +897,7 @@ void NODE_OT_select_box(wmOperatorType *ot)
/** \name Circle Select Operator
* \{ */
namespace FILE_NS {
static int node_circleselect_exec(bContext *C, wmOperator *op)
{
SpaceNode *snode = CTX_wm_space_node(C);
@ -936,6 +952,7 @@ static int node_circleselect_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
} // namespace FILE_NS
void NODE_OT_select_circle(wmOperatorType *ot)
{
@ -946,7 +963,7 @@ void NODE_OT_select_circle(wmOperatorType *ot)
/* api callbacks */
ot->invoke = WM_gesture_circle_invoke;
ot->exec = node_circleselect_exec;
ot->exec = FILE_NS::node_circleselect_exec;
ot->modal = WM_gesture_circle_modal;
ot->poll = ED_operator_node_active;
ot->get_name = ED_select_circle_get_name;
@ -965,6 +982,8 @@ void NODE_OT_select_circle(wmOperatorType *ot)
/** \name Lasso Select Operator
* \{ */
namespace FILE_NS {
static int node_lasso_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
const bool tweak = RNA_boolean_get(op->ptr, "tweak");
@ -1061,6 +1080,7 @@ static int node_lasso_select_exec(bContext *C, wmOperator *op)
}
return OPERATOR_PASS_THROUGH;
}
} // namespace FILE_NS
void NODE_OT_select_lasso(wmOperatorType *ot)
{
@ -1070,9 +1090,9 @@ void NODE_OT_select_lasso(wmOperatorType *ot)
ot->idname = "NODE_OT_select_lasso";
/* api callbacks */
ot->invoke = node_lasso_select_invoke;
ot->invoke = FILE_NS::node_lasso_select_invoke;
ot->modal = WM_gesture_lasso_modal;
ot->exec = node_lasso_select_exec;
ot->exec = FILE_NS::node_lasso_select_exec;
ot->poll = ED_operator_node_active;
ot->cancel = WM_gesture_lasso_cancel;
@ -1096,6 +1116,8 @@ void NODE_OT_select_lasso(wmOperatorType *ot)
/** \name (De)select All Operator
* \{ */
namespace FILE_NS {
static bool any_node_selected(const bNodeTree &node_tree)
{
for (const bNode *node : node_tree.all_nodes()) {
@ -1144,6 +1166,7 @@ static int node_select_all_exec(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, nullptr);
return OPERATOR_FINISHED;
}
} // namespace FILE_NS
void NODE_OT_select_all(wmOperatorType *ot)
{
@ -1153,7 +1176,7 @@ void NODE_OT_select_all(wmOperatorType *ot)
ot->idname = "NODE_OT_select_all";
/* api callbacks */
ot->exec = node_select_all_exec;
ot->exec = FILE_NS::node_select_all_exec;
ot->poll = ED_operator_node_active;
/* flags */
@ -1168,6 +1191,8 @@ void NODE_OT_select_all(wmOperatorType *ot)
/** \name Select Linked To Operator
* \{ */
namespace FILE_NS {
static int node_select_linked_to_exec(bContext *C, wmOperator * /*op*/)
{
SpaceNode &snode = *CTX_wm_space_node(C);
@ -1196,6 +1221,7 @@ static int node_select_linked_to_exec(bContext *C, wmOperator * /*op*/)
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, nullptr);
return OPERATOR_FINISHED;
}
} // namespace FILE_NS
void NODE_OT_select_linked_to(wmOperatorType *ot)
{
@ -1205,7 +1231,7 @@ void NODE_OT_select_linked_to(wmOperatorType *ot)
ot->idname = "NODE_OT_select_linked_to";
/* api callbacks */
ot->exec = node_select_linked_to_exec;
ot->exec = FILE_NS::node_select_linked_to_exec;
ot->poll = ED_operator_node_active;
/* flags */
@ -1218,6 +1244,8 @@ void NODE_OT_select_linked_to(wmOperatorType *ot)
/** \name Select Linked From Operator
* \{ */
namespace FILE_NS {
static int node_select_linked_from_exec(bContext *C, wmOperator * /*op*/)
{
SpaceNode &snode = *CTX_wm_space_node(C);
@ -1246,6 +1274,7 @@ static int node_select_linked_from_exec(bContext *C, wmOperator * /*op*/)
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, nullptr);
return OPERATOR_FINISHED;
}
} // namespace FILE_NS
void NODE_OT_select_linked_from(wmOperatorType *ot)
{
@ -1255,7 +1284,7 @@ void NODE_OT_select_linked_from(wmOperatorType *ot)
ot->idname = "NODE_OT_select_linked_from";
/* api callbacks */
ot->exec = node_select_linked_from_exec;
ot->exec = FILE_NS::node_select_linked_from_exec;
ot->poll = ED_operator_node_active;
/* flags */
@ -1268,6 +1297,8 @@ void NODE_OT_select_linked_from(wmOperatorType *ot)
/** \name Select Same Type Step Operator
* \{ */
namespace FILE_NS {
static bool nodes_are_same_type_for_select(const bNode &a, const bNode &b)
{
return a.type == b.type;
@ -1314,6 +1345,7 @@ static int node_select_same_type_step_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
} // namespace FILE_NS
void NODE_OT_select_same_type_step(wmOperatorType *ot)
{
@ -1323,7 +1355,7 @@ void NODE_OT_select_same_type_step(wmOperatorType *ot)
ot->idname = "NODE_OT_select_same_type_step";
/* api callbacks */
ot->exec = node_select_same_type_step_exec;
ot->exec = FILE_NS::node_select_same_type_step_exec;
ot->poll = ED_operator_node_active;
/* flags */
@ -1338,6 +1370,8 @@ void NODE_OT_select_same_type_step(wmOperatorType *ot)
/** \name Find Node by Name Operator
* \{ */
namespace FILE_NS {
static void node_find_create_label(const bNode *node, char *str, int str_maxncpy)
{
if (node->label[0]) {
@ -1452,6 +1486,8 @@ static int node_find_node_invoke(bContext *C, wmOperator *op, const wmEvent * /*
return OPERATOR_CANCELLED;
}
} // namespace FILE_NS
void NODE_OT_find_node(wmOperatorType *ot)
{
/* identifiers */
@ -1460,7 +1496,7 @@ void NODE_OT_find_node(wmOperatorType *ot)
ot->idname = "NODE_OT_find_node";
/* api callbacks */
ot->invoke = node_find_node_invoke;
ot->invoke = FILE_NS::node_find_node_invoke;
ot->poll = ED_operator_node_active;
/* flags */
@ -1470,3 +1506,5 @@ void NODE_OT_find_node(wmOperatorType *ot)
/** \} */
} // namespace blender::ed::space_node
#undef FILE_NS

View File

@ -43,9 +43,12 @@
#include "ED_undo.h"
#define FILE_NS node_templates_cc
using blender::nodes::NodeDeclaration;
namespace blender::ed::space_node {
namespace FILE_NS {
/************************* Node Socket Manipulation **************************/
@ -714,12 +717,14 @@ static void ui_template_node_link_menu(bContext *C, uiLayout *layout, void *but_
ui_node_menu_column(arg, NODE_CLASS_GROUP, N_("Group"));
}
} // namespace FILE_NS
} // namespace blender::ed::space_node
void uiTemplateNodeLink(
uiLayout *layout, bContext *C, bNodeTree *ntree, bNode *node, bNodeSocket *input)
{
using namespace blender::ed::space_node;
using namespace blender::ed::space_node::FILE_NS;
uiBlock *block = uiLayoutGetBlock(layout);
NodeLinkArg *arg;
@ -763,6 +768,7 @@ void uiTemplateNodeLink(
}
namespace blender::ed::space_node {
namespace FILE_NS {
/**************************** Node Tree Layout *******************************/
@ -917,12 +923,14 @@ static void ui_node_draw_input(
node.flag &= ~NODE_TEST;
}
} // namespace FILE_NS
} // namespace blender::ed::space_node
void uiTemplateNodeView(
uiLayout *layout, bContext *C, bNodeTree *ntree, bNode *node, bNodeSocket *input)
{
using namespace blender::ed::space_node;
using namespace blender::ed::space_node::FILE_NS;
bNode *tnode;
@ -942,3 +950,5 @@ void uiTemplateNodeView(
ui_node_draw_node(*layout, *C, *ntree, *node, 0);
}
}
#undef FILE_NS

View File

@ -41,6 +41,8 @@
#include "node_intern.hh" /* own include */
#define FILE_NS node_view_cc
namespace blender::ed::space_node {
/* -------------------------------------------------------------------- */
@ -108,6 +110,7 @@ bool space_node_view_flag(
return true;
}
namespace FILE_NS {
static int node_view_all_exec(bContext *C, wmOperator *op)
{
ARegion *region = CTX_wm_region(C);
@ -123,6 +126,7 @@ static int node_view_all_exec(bContext *C, wmOperator *op)
}
return OPERATOR_CANCELLED;
}
} // namespace FILE_NS
void NODE_OT_view_all(wmOperatorType *ot)
{
@ -132,7 +136,7 @@ void NODE_OT_view_all(wmOperatorType *ot)
ot->description = "Resize view so you can see all nodes";
/* api callbacks */
ot->exec = node_view_all_exec;
ot->exec = FILE_NS::node_view_all_exec;
ot->poll = ED_operator_node_active;
/* flags */
@ -145,6 +149,7 @@ void NODE_OT_view_all(wmOperatorType *ot)
/** \name View Selected Operator
* \{ */
namespace FILE_NS {
static int node_view_selected_exec(bContext *C, wmOperator *op)
{
ARegion *region = CTX_wm_region(C);
@ -156,6 +161,7 @@ static int node_view_selected_exec(bContext *C, wmOperator *op)
}
return OPERATOR_CANCELLED;
}
} // namespace FILE_NS
void NODE_OT_view_selected(wmOperatorType *ot)
{
@ -165,7 +171,7 @@ void NODE_OT_view_selected(wmOperatorType *ot)
ot->description = "Resize view so you can see selected nodes";
/* api callbacks */
ot->exec = node_view_selected_exec;
ot->exec = FILE_NS::node_view_selected_exec;
ot->poll = ED_operator_node_active;
/* flags */
@ -178,6 +184,7 @@ void NODE_OT_view_selected(wmOperatorType *ot)
/** \name Background Image Operators
* \{ */
namespace FILE_NS {
struct NodeViewMove {
int2 mvalo;
int xmin, ymin, xmax, ymax;
@ -280,6 +287,7 @@ static void snode_bg_viewmove_cancel(bContext * /*C*/, wmOperator *op)
MEM_freeN(op->customdata);
op->customdata = nullptr;
}
} // namespace FILE_NS
void NODE_OT_backimage_move(wmOperatorType *ot)
{
@ -289,10 +297,10 @@ void NODE_OT_backimage_move(wmOperatorType *ot)
ot->idname = "NODE_OT_backimage_move";
/* api callbacks */
ot->invoke = snode_bg_viewmove_invoke;
ot->modal = snode_bg_viewmove_modal;
ot->invoke = FILE_NS::snode_bg_viewmove_invoke;
ot->modal = FILE_NS::snode_bg_viewmove_modal;
ot->poll = composite_node_active;
ot->cancel = snode_bg_viewmove_cancel;
ot->cancel = FILE_NS::snode_bg_viewmove_cancel;
/* flags */
ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_CURSOR_XY;
@ -304,6 +312,7 @@ void NODE_OT_backimage_move(wmOperatorType *ot)
/** \name Background Image Zoom
* \{ */
namespace FILE_NS {
static int backimage_zoom_exec(bContext *C, wmOperator *op)
{
SpaceNode *snode = CTX_wm_space_node(C);
@ -317,6 +326,7 @@ static int backimage_zoom_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
} // namespace FILE_NS
void NODE_OT_backimage_zoom(wmOperatorType *ot)
{
@ -327,7 +337,7 @@ void NODE_OT_backimage_zoom(wmOperatorType *ot)
ot->description = "Zoom in/out the background image";
/* api callbacks */
ot->exec = backimage_zoom_exec;
ot->exec = FILE_NS::backimage_zoom_exec;
ot->poll = composite_node_active;
/* flags */
@ -343,6 +353,7 @@ void NODE_OT_backimage_zoom(wmOperatorType *ot)
/** \name Background Image Fit
* \{ */
namespace FILE_NS {
static int backimage_fit_exec(bContext *C, wmOperator * /*op*/)
{
Main *bmain = CTX_data_main(C);
@ -382,6 +393,7 @@ static int backimage_fit_exec(bContext *C, wmOperator * /*op*/)
return OPERATOR_FINISHED;
}
} // namespace FILE_NS
void NODE_OT_backimage_fit(wmOperatorType *ot)
{
@ -392,7 +404,7 @@ void NODE_OT_backimage_fit(wmOperatorType *ot)
ot->description = "Fit the background image to the view";
/* api callbacks */
ot->exec = backimage_fit_exec;
ot->exec = FILE_NS::backimage_fit_exec;
ot->poll = composite_node_active;
/* flags */
@ -405,6 +417,7 @@ void NODE_OT_backimage_fit(wmOperatorType *ot)
/** \name Sample Backdrop Operator
* \{ */
namespace FILE_NS {
struct ImageSampleInfo {
ARegionType *art;
void *draw_handle;
@ -438,6 +451,7 @@ static void sample_draw(const bContext *C, ARegion *region, void *arg_info)
}
}
} // namespace FILE_NS
} // namespace blender::ed::space_node
bool ED_space_node_get_position(
@ -523,6 +537,7 @@ bool ED_space_node_color_sample(
}
namespace blender::ed::space_node {
namespace FILE_NS {
static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event)
{
@ -670,6 +685,7 @@ static void sample_cancel(bContext *C, wmOperator *op)
{
sample_exit(C, op);
}
} // namespace FILE_NS
void NODE_OT_backimage_sample(wmOperatorType *ot)
{
@ -679,9 +695,9 @@ void NODE_OT_backimage_sample(wmOperatorType *ot)
ot->description = "Use mouse to sample background image";
/* api callbacks */
ot->invoke = sample_invoke;
ot->modal = sample_modal;
ot->cancel = sample_cancel;
ot->invoke = FILE_NS::sample_invoke;
ot->modal = FILE_NS::sample_modal;
ot->cancel = FILE_NS::sample_cancel;
ot->poll = ED_operator_node_active;
/* flags */
@ -691,3 +707,5 @@ void NODE_OT_backimage_sample(wmOperatorType *ot)
/** \} */
} // namespace blender::ed::space_node
#undef FILE_NS

View File

@ -45,6 +45,8 @@
#include "node_intern.hh" /* own include */
#define FILE_NS space_node_cc
using blender::float2;
/* ******************** tree path ********************* */
@ -235,6 +237,7 @@ float2 space_node_group_offset(const SpaceNode &snode)
/* ******************** default callbacks for node space ***************** */
namespace FILE_NS {
static SpaceLink *node_create(const ScrArea * /*area*/, const Scene * /*scene*/)
{
SpaceNode *snode = MEM_cnew<SpaceNode>("initnode");
@ -853,6 +856,7 @@ static void node_region_listener(const wmRegionListenerParams *params)
}
}
} // namespace FILE_NS
} // namespace blender::ed::space_node
/* Outside of blender namespace to avoid Python documentation build error with `ctypes`. */
@ -862,6 +866,7 @@ const char *node_context_dir[] = {
};
namespace blender::ed::space_node {
namespace FILE_NS {
static int /*eContextResult*/ node_context(const bContext *C,
const char *member,
@ -1116,11 +1121,13 @@ static void node_space_blend_write(BlendWriter *writer, SpaceLink *sl)
}
}
} // namespace FILE_NS
} // namespace blender::ed::space_node
void ED_spacetype_node()
{
using namespace blender::ed::space_node;
using namespace blender::ed::space_node::FILE_NS;
SpaceType *st = MEM_cnew<SpaceType>("spacetype node");
ARegionType *art;
@ -1202,3 +1209,5 @@ void ED_spacetype_node()
BKE_spacetype_register(st);
}
#undef FILE_NS

View File

@ -6,6 +6,10 @@
* \ingroup gpu
*/
#ifndef GPU_SHADER
# pragma once
#endif
#ifndef USE_GPU_SHADER_CREATE_INFO
# include "GPU_shader_shared_utils.h"