Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2021-12-03 19:05:59 +0300
committerHans Goudey <h.goudey@me.com>2021-12-03 19:05:59 +0300
commitcb0fbe1fde4753a8521e3972e5fcaf852ea20f4c (patch)
tree95ab08b491eabad595802d33aa07dfd6ee553a7b /source/blender/editors
parentab927f5ca7a35393ea28de56e7a8d2a938c5de34 (diff)
Cleanup: Use typed enum for node resize direction
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/space_node/drawnode.cc13
-rw-r--r--source/blender/editors/space_node/node_draw.cc4
-rw-r--r--source/blender/editors/space_node/node_edit.cc15
-rw-r--r--source/blender/editors/space_node/node_intern.hh2
4 files changed, 18 insertions, 16 deletions
diff --git a/source/blender/editors/space_node/drawnode.cc b/source/blender/editors/space_node/drawnode.cc
index 97fa93ab0bc..0602bc7e124 100644
--- a/source/blender/editors/space_node/drawnode.cc
+++ b/source/blender/editors/space_node/drawnode.cc
@@ -250,7 +250,7 @@ static void node_buts_math(uiLayout *layout, bContext *UNUSED(C), PointerRNA *pt
uiItemR(layout, ptr, "use_clamp", DEFAULT_FLAGS, nullptr, ICON_NONE);
}
-static int node_resize_area_default(bNode *node, int x, int y)
+static NodeResizeDirection node_resize_area_default(bNode *node, const int x, const int y)
{
if (node->flag & NODE_HIDDEN) {
rctf totr = node->totr;
@@ -260,12 +260,12 @@ static int node_resize_area_default(bNode *node, int x, int y)
return NODE_RESIZE_RIGHT;
}
- return 0;
+ return NODE_RESIZE_NONE;
}
const float size = NODE_RESIZE_MARGIN;
rctf totr = node->totr;
- int dir = 0;
+ NodeResizeDirection dir = NODE_RESIZE_NONE;
if (x >= totr.xmax - size && x < totr.xmax && y >= totr.ymin && y < totr.ymax) {
dir |= NODE_RESIZE_RIGHT;
@@ -478,18 +478,19 @@ static void node_draw_frame(const bContext *C,
node->block = nullptr;
}
-static int node_resize_area_frame(bNode *node, int x, int y)
+static NodeResizeDirection node_resize_area_frame(bNode *node, const int x, const int y)
{
const float size = 10.0f;
NodeFrame *data = (NodeFrame *)node->storage;
rctf totr = node->totr;
- int dir = 0;
/* shrinking frame size is determined by child nodes */
if (!(data->flag & NODE_FRAME_RESIZEABLE)) {
- return 0;
+ return NODE_RESIZE_NONE;
}
+ NodeResizeDirection dir = NODE_RESIZE_NONE;
+
if (x >= totr.xmax - size && x < totr.xmax && y >= totr.ymin && y < totr.ymax) {
dir |= NODE_RESIZE_RIGHT;
}
diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc
index dcdfd909d9d..6452dc54544 100644
--- a/source/blender/editors/space_node/node_draw.cc
+++ b/source/blender/editors/space_node/node_draw.cc
@@ -2284,7 +2284,7 @@ static void node_draw_hidden(const bContext *C,
node->block = nullptr;
}
-int node_get_resize_cursor(int directions)
+int node_get_resize_cursor(NodeResizeDirection directions)
{
if (directions == 0) {
return WM_CURSOR_DEFAULT;
@@ -2317,7 +2317,7 @@ void node_set_cursor(wmWindow *win, SpaceNode *snode, float cursor[2])
}
}
if (node) {
- int dir = node->typeinfo->resize_area_func(node, cursor[0], cursor[1]);
+ NodeResizeDirection dir = node->typeinfo->resize_area_func(node, cursor[0], cursor[1]);
wmcursor = node_get_resize_cursor(dir);
}
}
diff --git a/source/blender/editors/space_node/node_edit.cc b/source/blender/editors/space_node/node_edit.cc
index 30c9f7ea56b..e6dae26e174 100644
--- a/source/blender/editors/space_node/node_edit.cc
+++ b/source/blender/editors/space_node/node_edit.cc
@@ -938,13 +938,15 @@ struct NodeSizeWidget {
int directions;
};
-static void node_resize_init(
- bContext *C, wmOperator *op, const wmEvent *UNUSED(event), bNode *node, int dir)
+static void node_resize_init(bContext *C,
+ wmOperator *op,
+ const wmEvent *UNUSED(event),
+ bNode *node,
+ NodeResizeDirection dir)
{
SpaceNode *snode = CTX_wm_space_node(C);
- NodeSizeWidget *nsw = (NodeSizeWidget *)MEM_callocN(sizeof(NodeSizeWidget),
- "size widget op data");
+ NodeSizeWidget *nsw = (NodeSizeWidget *)MEM_callocN(sizeof(NodeSizeWidget), __func__);
op->customdata = nsw;
nsw->mxstart = snode->runtime->cursor[0] * UI_DPI_FAC;
@@ -1090,15 +1092,14 @@ static int node_resize_invoke(bContext *C, wmOperator *op, const wmEvent *event)
SpaceNode *snode = CTX_wm_space_node(C);
ARegion *region = CTX_wm_region(C);
bNode *node = nodeGetActive(snode->edittree);
- int dir;
if (node) {
float cursor[2];
/* convert mouse coordinates to v2d space */
UI_view2d_region_to_view(&region->v2d, event->mval[0], event->mval[1], &cursor[0], &cursor[1]);
- dir = node->typeinfo->resize_area_func(node, cursor[0], cursor[1]);
- if (dir != 0) {
+ const NodeResizeDirection dir = node->typeinfo->resize_area_func(node, cursor[0], cursor[1]);
+ if (dir != NODE_RESIZE_NONE) {
node_resize_init(C, op, event, node, dir);
return OPERATOR_RUNNING_MODAL;
}
diff --git a/source/blender/editors/space_node/node_intern.hh b/source/blender/editors/space_node/node_intern.hh
index 6dc57c1fb79..7a1bd918745 100644
--- a/source/blender/editors/space_node/node_intern.hh
+++ b/source/blender/editors/space_node/node_intern.hh
@@ -97,7 +97,7 @@ void node_link_calculate_multi_input_position(const float socket_x,
int node_get_colorid(bNode *node);
void node_draw_extra_info_panel(const SpaceNode *snode, const bNode *node);
-int node_get_resize_cursor(int directions);
+int node_get_resize_cursor(NodeResizeDirection directions);
void node_draw_shadow(const SpaceNode *snode, const bNode *node, float radius, float alpha);
void node_draw_default(const bContext *C,
ARegion *region,