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:
authorSiddhartha Jejurkar <f20180617@goa.bits-pilani.ac.in>2021-12-17 16:01:32 +0300
committerSiddhartha Jejurkar <f20180617@goa.bits-pilani.ac.in>2021-12-17 16:01:32 +0300
commitdbc41b30f88b96f7d8c6e995b17f5930eb55cc77 (patch)
treec6c495328443ea3621e5df2ef483b0e0dd504496 /source/blender/editors/space_node/node_intern.hh
parent99a2af76d10e05a18987be5d554ada197b1ca086 (diff)
parent7c9e4099854a4fc8eab4db97173c1aacd25f9e08 (diff)
Merge branch 'master' into soc-2021-uv-edge-select-supportsoc-2021-uv-edge-select-support
Diffstat (limited to 'source/blender/editors/space_node/node_intern.hh')
-rw-r--r--source/blender/editors/space_node/node_intern.hh272
1 files changed, 144 insertions, 128 deletions
diff --git a/source/blender/editors/space_node/node_intern.hh b/source/blender/editors/space_node/node_intern.hh
index 436df70429b..2e55bb0cb28 100644
--- a/source/blender/editors/space_node/node_intern.hh
+++ b/source/blender/editors/space_node/node_intern.hh
@@ -23,16 +23,14 @@
#pragma once
-#include "BKE_node.h"
-#include "UI_interface.h"
-#include "UI_view2d.h"
-
+#include "BLI_float2.hh"
#include "BLI_vector.hh"
-#include "UI_interface.hh"
-#include <stddef.h> /* for size_t */
+#include "BKE_node.h"
-/* internal exports only */
+#include "UI_interface.h"
+#include "UI_interface.hh"
+#include "UI_view2d.h"
struct ARegion;
struct ARegionType;
@@ -45,26 +43,39 @@ struct bNodeLink;
struct bNodeSocket;
struct wmGizmoGroupType;
struct wmKeyConfig;
+namespace blender {
+struct float2;
+}
struct wmWindow;
-/* temp data to pass on to modal */
+/** Temporary data used in node link drag modal operator. */
struct bNodeLinkDrag {
- struct bNodeLinkDrag *next, *prev;
-
- /* List of links dragged by the operator.
- * NOTE: This is a list of LinkData structs on top of the actual bNodeLinks.
- * This way the links can be added to the node tree while being stored in this list.
- */
- ListBase links;
+ /** Links dragged by the operator. */
+ blender::Vector<bNodeLink *> links;
bool from_multi_input_socket;
- int in_out;
+ eNodeSocketInOut in_out;
+
+ /** Draw handler for the "+" icon when dragging a link in empty space. */
+ void *draw_handle;
/** Temporarily stores the last picked link from multi-input socket operator. */
- struct bNodeLink *last_picked_multi_input_socket_link;
+ bNodeLink *last_picked_multi_input_socket_link;
+
+ /**
+ * Temporarily stores the last hovered socket for multi-input socket operator.
+ * Store it to recalculate sorting after it is no longer hovered.
+ */
+ bNode *last_node_hovered_while_dragging_a_link;
+
+ /* The cursor position, used for drawing a + icon when dragging a node link. */
+ std::array<int, 2> cursor;
- /** Temporarily stores the last hovered socket for multi-input socket operator.
- * Store it to recalculate sorting after it is no longer hovered. */
- struct bNode *last_node_hovered_while_dragging_a_link;
+ /** The node the drag started at. */
+ bNode *start_node;
+ /** The socket the drag started at. */
+ bNodeSocket *start_socket;
+ /** The number of links connected to the #start_socket when the drag started. */
+ int start_link_count;
/* Data for edge panning */
View2DEdgePanData pan_data;
@@ -74,83 +85,68 @@ struct SpaceNode_Runtime {
float aspect;
/** Mouse position for drawing socket-less links and adding nodes. */
- float cursor[2];
+ blender::float2 cursor;
/** For auto compositing. */
bool recalc;
/** Temporary data for modal linking operator. */
- struct ListBase linkdrag;
+ std::unique_ptr<bNodeLinkDrag> linkdrag;
/* XXX hack for translate_attach op-macros to pass data from transform op to insert_offset op */
/** Temporary data for node insert offset (in UI called Auto-offset). */
struct NodeInsertOfsData *iofsd;
};
-/* space_node.c */
-
-/* transform between View2Ds in the tree path */
-void space_node_group_offset(SpaceNode *snode, float *x, float *y);
-
-/* node_draw.cc */
-float node_socket_calculate_height(const bNodeSocket *socket);
-void node_link_calculate_multi_input_position(const float socket_x,
- const float socket_y,
- const int index,
- const int total_inputs,
- float r[2]);
-
-int node_get_colorid(bNode *node);
-int node_get_resize_cursor(int directions);
-void node_draw_shadow(const SpaceNode *snode, const bNode *node, float radius, float alpha);
-void node_draw_default(const bContext *C,
- ARegion *region,
- SpaceNode *snode,
- bNodeTree *ntree,
- bNode *node,
- bNodeInstanceKey key);
-void node_draw_sockets(const View2D *v2d,
- const bContext *C,
- bNodeTree *ntree,
- bNode *node,
- bool draw_outputs,
- bool select_all);
-void node_update_default(const bContext *C, bNodeTree *ntree, bNode *node);
-int node_select_area_default(bNode *node, int x, int y);
-int node_tweak_area_default(bNode *node, int x, int y);
-void node_socket_color_get(const bContext *C,
- bNodeTree *ntree,
- PointerRNA *node_ptr,
- bNodeSocket *sock,
+enum NodeResizeDirection {
+ NODE_RESIZE_NONE = 0,
+ NODE_RESIZE_TOP = (1 << 0),
+ NODE_RESIZE_BOTTOM = (1 << 1),
+ NODE_RESIZE_RIGHT = (1 << 2),
+ NODE_RESIZE_LEFT = (1 << 3),
+};
+ENUM_OPERATORS(NodeResizeDirection, NODE_RESIZE_LEFT);
+
+/**
+ * Transform between View2Ds in the tree path.
+ */
+blender::float2 space_node_group_offset(const SpaceNode &snode);
+
+float node_socket_calculate_height(const bNodeSocket &socket);
+blender::float2 node_link_calculate_multi_input_position(const blender::float2 &socket_position,
+ int index,
+ int total_inputs);
+
+int node_get_resize_cursor(NodeResizeDirection directions);
+NodeResizeDirection node_get_resize_direction(const bNode *node, const int x, const int y);
+/**
+ * Usual convention here would be #node_socket_get_color(),
+ * but that's already used (for setting a color property socket).
+ */
+void node_socket_color_get(const bContext &C,
+ const bNodeTree &ntree,
+ PointerRNA &node_ptr,
+ const bNodeSocket &sock,
float r_color[4]);
-void node_update_nodetree(const bContext *C, bNodeTree *ntree);
-void node_draw_nodetree(const bContext *C,
- ARegion *region,
- SpaceNode *snode,
- bNodeTree *ntree,
- bNodeInstanceKey parent_key);
-void node_draw_space(const bContext *C, ARegion *region);
-
-void node_set_cursor(wmWindow *win, SpaceNode *snode, float cursor[2]);
+void node_draw_space(const bContext &C, ARegion &region);
+
+void node_set_cursor(wmWindow &win, SpaceNode &snode, const blender::float2 &cursor);
/* DPI scaled coords */
-void node_to_view(const bNode *node, float x, float y, float *rx, float *ry);
-void node_to_updated_rect(const bNode *node, rctf *r_rect);
-void node_from_view(const bNode *node, float x, float y, float *rx, float *ry);
+blender::float2 node_to_view(const bNode &node, const blender::float2 &co);
+void node_to_updated_rect(const bNode &node, rctf &r_rect);
+blender::float2 node_from_view(const bNode &node, const blender::float2 &co);
-/* node_toolbar.c */
void node_toolbar_register(ARegionType *art);
-/* node_ops.c */
void node_operatortypes(void);
void node_keymap(wmKeyConfig *keyconf);
-/* node_select.c */
-void node_deselect_all(SpaceNode *snode);
-void node_socket_select(bNode *node, bNodeSocket *sock);
-void node_socket_deselect(bNode *node, bNodeSocket *sock, const bool deselect_node);
-void node_deselect_all_input_sockets(SpaceNode *snode, const bool deselect_nodes);
-void node_deselect_all_output_sockets(SpaceNode *snode, const bool deselect_nodes);
-void node_select_single(bContext *C, bNode *node);
+void node_deselect_all(SpaceNode &snode);
+void node_socket_select(bNode *node, bNodeSocket &sock);
+void node_socket_deselect(bNode *node, bNodeSocket &sock, const bool deselect_node);
+void node_deselect_all_input_sockets(SpaceNode &snode, const bool deselect_nodes);
+void node_deselect_all_output_sockets(SpaceNode &snode, const bool deselect_nodes);
+void node_select_single(bContext &C, bNode &node);
void NODE_OT_select(wmOperatorType *ot);
void NODE_OT_select_all(wmOperatorType *ot);
@@ -163,9 +159,8 @@ void NODE_OT_select_grouped(wmOperatorType *ot);
void NODE_OT_select_same_type_step(wmOperatorType *ot);
void NODE_OT_find_node(wmOperatorType *ot);
-/* node_view.c */
-int space_node_view_flag(
- bContext *C, SpaceNode *snode, ARegion *region, const int node_flag, const int smooth_viewtx);
+bool space_node_view_flag(
+ bContext &C, SpaceNode &snode, ARegion &region, int node_flag, int smooth_viewtx);
void NODE_OT_view_all(wmOperatorType *ot);
void NODE_OT_view_selected(wmOperatorType *ot);
@@ -176,37 +171,50 @@ void NODE_OT_backimage_zoom(wmOperatorType *ot);
void NODE_OT_backimage_fit(wmOperatorType *ot);
void NODE_OT_backimage_sample(wmOperatorType *ot);
-/* drawnode.c */
-void nodelink_batch_start(SpaceNode *snode);
-void nodelink_batch_end(SpaceNode *snode);
-
-void node_draw_link(const bContext *C,
- const View2D *v2d,
- const SpaceNode *snode,
- const bNodeLink *link);
-void node_draw_link_bezier(const bContext *C,
- const View2D *v2d,
- const SpaceNode *snode,
- const bNodeLink *link,
+void nodelink_batch_start(SpaceNode &snode);
+void nodelink_batch_end(SpaceNode &snode);
+
+/**
+ * \note this is used for fake links in groups too.
+ */
+void node_draw_link(const bContext &C,
+ const View2D &v2d,
+ const SpaceNode &snode,
+ const bNodeLink &link);
+/**
+ * Don't do shadows if th_col3 is -1.
+ */
+void node_draw_link_bezier(const bContext &C,
+ const View2D &v2d,
+ const SpaceNode &snode,
+ const bNodeLink &link,
int th_col1,
int th_col2,
int th_col3);
+/** If v2d not nullptr, it clips and returns 0 if not visible. */
bool node_link_bezier_points(const View2D *v2d,
const SpaceNode *snode,
- const bNodeLink *link,
+ const bNodeLink &link,
float coord_array[][2],
const int resol);
+/**
+ * Return quadratic beziers points for a given nodelink and clip if v2d is not nullptr.
+ */
bool node_link_bezier_handles(const View2D *v2d,
const SpaceNode *snode,
- const bNodeLink *link,
+ const bNodeLink &ink,
float vec[4][2]);
-void draw_nodespace_back_pix(const bContext *C,
- ARegion *region,
- SpaceNode *snode,
+void draw_nodespace_back_pix(const bContext &C,
+ ARegion &region,
+ SpaceNode &snode,
bNodeInstanceKey parent_key);
-/* node_add.c */
-bNode *node_add_node(const bContext *C, const char *idname, int type, float locx, float locy);
+/**
+ * XXX Does some additional initialization on top of #nodeAddNode
+ * Can be used with both custom and static nodes,
+ * if `idname == nullptr` the static int type will be used instead.
+ */
+bNode *node_add_node(const bContext &C, const char *idname, int type, float locx, float locy);
void NODE_OT_add_reroute(wmOperatorType *ot);
void NODE_OT_add_group(wmOperatorType *ot);
void NODE_OT_add_object(wmOperatorType *ot);
@@ -216,7 +224,6 @@ void NODE_OT_add_file(wmOperatorType *ot);
void NODE_OT_add_mask(wmOperatorType *ot);
void NODE_OT_new_node_tree(wmOperatorType *ot);
-/* node_group.c */
const char *node_group_idname(bContext *C);
void NODE_OT_group_make(wmOperatorType *ot);
void NODE_OT_group_insert(wmOperatorType *ot);
@@ -224,12 +231,11 @@ void NODE_OT_group_ungroup(wmOperatorType *ot);
void NODE_OT_group_separate(wmOperatorType *ot);
void NODE_OT_group_edit(wmOperatorType *ot);
-/* node_relationships.c */
-void sort_multi_input_socket_links(SpaceNode *snode,
- bNode *node,
+void sort_multi_input_socket_links(SpaceNode &snode,
+ bNode &node,
bNodeLink *drag_link,
- float cursor[2]);
-bool node_connected_to_output(Main *bmain, bNodeTree *ntree, bNode *node);
+ const blender::float2 *cursor);
+bool node_connected_to_output(Main &bmain, bNodeTree &ntree, bNode &node);
void NODE_OT_link(wmOperatorType *ot);
void NODE_OT_link_make(wmOperatorType *ot);
@@ -246,22 +252,27 @@ void NODE_OT_link_viewer(wmOperatorType *ot);
void NODE_OT_insert_offset(wmOperatorType *ot);
-/* node_edit.c */
-void snode_notify(bContext *C, SpaceNode *snode);
-void snode_dag_update(bContext *C, SpaceNode *snode);
-void snode_set_context(const bContext *C);
+void snode_notify(bContext &C, SpaceNode &snode);
+void snode_dag_update(bContext &C, SpaceNode &snode);
+void snode_set_context(const bContext &C);
-void snode_update(SpaceNode *snode, bNode *node);
+void snode_update(SpaceNode &snode, bNode *node);
+/** Operator poll callback. */
bool composite_node_active(bContext *C);
+/** Operator poll callback. */
bool composite_node_editable(bContext *C);
bool node_has_hidden_sockets(bNode *node);
void node_set_hidden_sockets(SpaceNode *snode, bNode *node, int set);
int node_render_changed_exec(bContext *, wmOperator *);
-bool node_find_indicated_socket(
- SpaceNode *snode, bNode **nodep, bNodeSocket **sockp, const float cursor[2], int in_out);
-float node_link_dim_factor(const View2D *v2d, const bNodeLink *link);
-bool node_link_is_hidden_or_dimmed(const View2D *v2d, const bNodeLink *link);
+/** Type is #SOCK_IN and/or #SOCK_OUT. */
+bool node_find_indicated_socket(SpaceNode &snode,
+ bNode **nodep,
+ bNodeSocket **sockp,
+ const blender::float2 &cursor,
+ eNodeSocketInOut in_out);
+float node_link_dim_factor(const View2D &v2d, const bNodeLink &link);
+bool node_link_is_hidden_or_dimmed(const View2D &v2d, const bNodeLink &link);
void NODE_OT_duplicate(wmOperatorType *ot);
void NODE_OT_delete(wmOperatorType *ot);
@@ -284,7 +295,9 @@ void NODE_OT_output_file_move_active_socket(wmOperatorType *ot);
void NODE_OT_switch_view_update(wmOperatorType *ot);
-/* NOTE: clipboard_cut is a simple macro of copy + delete. */
+/**
+ * \note clipboard_cut is a simple macro of copy + delete.
+ */
void NODE_OT_clipboard_copy(wmOperatorType *ot);
void NODE_OT_clipboard_paste(wmOperatorType *ot);
@@ -298,7 +311,6 @@ void NODE_OT_shader_script_update(wmOperatorType *ot);
void NODE_OT_viewer_border(wmOperatorType *ot);
void NODE_OT_clear_viewer_border(wmOperatorType *ot);
-/* node_widgets.c */
void NODE_GGT_backdrop_transform(wmGizmoGroupType *gzgt);
void NODE_GGT_backdrop_crop(wmGizmoGroupType *gzgt);
void NODE_GGT_backdrop_sun_beams(wmGizmoGroupType *gzgt);
@@ -307,25 +319,22 @@ void NODE_GGT_backdrop_corner_pin(wmGizmoGroupType *gzgt);
void NODE_OT_cryptomatte_layer_add(wmOperatorType *ot);
void NODE_OT_cryptomatte_layer_remove(wmOperatorType *ot);
-/* node_geometry_attribute_search.cc */
-void node_geometry_add_attribute_search_button(const bContext *C,
- const bNodeTree *node_tree,
- const bNode *node,
- PointerRNA *socket_ptr,
- uiLayout *layout);
+void node_geometry_add_attribute_search_button(const bContext &C,
+ const bNodeTree &node_tree,
+ const bNode &node,
+ PointerRNA &socket_ptr,
+ uiLayout &layout);
extern const char *node_context_dir[];
-/* XXXXXX */
-
/* Nodes draw without dpi - the view zoom is flexible. */
#define HIDDEN_RAD (0.75f * U.widget_unit)
#define BASIS_RAD (0.2f * U.widget_unit)
#define NODE_DYS (U.widget_unit / 2)
#define NODE_DY U.widget_unit
#define NODE_SOCKDY (0.1f * U.widget_unit)
-#define NODE_WIDTH(node) (node->width * UI_DPI_FAC)
-#define NODE_HEIGHT(node) (node->height * UI_DPI_FAC)
+#define NODE_WIDTH(node) (node.width * UI_DPI_FAC)
+#define NODE_HEIGHT(node) (node.height * UI_DPI_FAC)
#define NODE_MARGIN_X (1.2f * U.widget_unit)
#define NODE_SOCKSIZE (0.25f * U.widget_unit)
#define NODE_MULTI_INPUT_LINK_GAP (0.25f * U.widget_unit)
@@ -333,5 +342,12 @@ extern const char *node_context_dir[];
#define NODE_LINK_RESOL 12
namespace blender::ed::space_node {
+
Vector<ui::ContextPathItem> context_path_for_space_node(const bContext &C);
-}
+
+void invoke_node_link_drag_add_menu(bContext &C,
+ bNode &node,
+ bNodeSocket &socket,
+ const float2 &cursor);
+
+} // namespace blender::ed::space_node