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-02-17 22:34:49 +0300
committerHans Goudey <h.goudey@me.com>2021-02-17 22:34:49 +0300
commiteeeb85baf8ab203e913513bffe1831eb05e129c5 (patch)
tree84030e5aa47ac3f8a73e80c28793e7ae716c4905 /source/blender/editors/space_node/node_draw.cc
parentaf824b09c7b3eb4c70dccf116ee0e3790466a352 (diff)
Cleanup: Comment formatting in node_draw.cc
Diffstat (limited to 'source/blender/editors/space_node/node_draw.cc')
-rw-r--r--source/blender/editors/space_node/node_draw.cc269
1 files changed, 129 insertions, 140 deletions
diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc
index aaceadcc011..9e96af5e03d 100644
--- a/source/blender/editors/space_node/node_draw.cc
+++ b/source/blender/editors/space_node/node_draw.cc
@@ -127,11 +127,8 @@ void ED_node_tag_update_id(ID *id)
return;
}
- /* TODO(sergey): With the new dependency graph it
- * should be just enough to only tag ntree itself,
- * all the users of this tree will have update
- * flushed from the tree,
- */
+ /* TODO(sergey): With the new dependency graph it should be just enough to only tag ntree itself.
+ * All the users of this tree will have update flushed from the tree. */
DEG_id_tag_update(&ntree->id, 0);
if (ntree->type == NTREE_SHADER) {
@@ -158,7 +155,7 @@ void ED_node_tag_update_id(ID *id)
WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, id);
}
else if (id == &ntree->id) {
- /* node groups */
+ /* Node groups. */
DEG_id_tag_update(id, 0);
}
}
@@ -176,10 +173,10 @@ void ED_node_tag_update_nodetree(Main *bmain, bNodeTree *ntree, bNode *node)
}
}
- /* look through all datablocks, to support groups */
+ /* Look through all datablocks to support groups. */
if (do_tag_update) {
FOREACH_NODETREE_BEGIN (bmain, tntree, id) {
- /* check if nodetree uses the group */
+ /* Check if nodetree uses the group. */
if (ntreeHasTree(tntree, ntree)) {
ED_node_tag_update_id(id);
}
@@ -195,20 +192,19 @@ void ED_node_tag_update_nodetree(Main *bmain, bNodeTree *ntree, bNode *node)
static bool compare_nodes(const bNode *a, const bNode *b)
{
/* These tell if either the node or any of the parent nodes is selected.
- * A selected parent means an unselected node is also in foreground!
- */
+ * A selected parent means an unselected node is also in foreground! */
bool a_select = (a->flag & NODE_SELECT) != 0, b_select = (b->flag & NODE_SELECT) != 0;
bool a_active = (a->flag & NODE_ACTIVE) != 0, b_active = (b->flag & NODE_ACTIVE) != 0;
- /* if one is an ancestor of the other */
+ /* If one is an ancestor of the other. */
/* XXX there might be a better sorting algorithm for stable topological sort,
- * this is O(n^2) worst case */
+ * this is O(n^2) worst case. */
for (bNode *parent = a->parent; parent; parent = parent->parent) {
- /* if b is an ancestor, it is always behind a */
+ /* If B is an ancestor, it is always behind A. */
if (parent == b) {
return true;
}
- /* any selected ancestor moves the node forward */
+ /* Any selected ancestor moves the node forward. */
if (parent->flag & NODE_ACTIVE) {
a_active = true;
}
@@ -217,11 +213,11 @@ static bool compare_nodes(const bNode *a, const bNode *b)
}
}
for (bNode *parent = b->parent; parent; parent = parent->parent) {
- /* if a is an ancestor, it is always behind b */
+ /* If A is an ancestor, it is always behind B. */
if (parent == a) {
return false;
}
- /* any selected ancestor moves the node forward */
+ /* Any selected ancestor moves the node forward. */
if (parent->flag & NODE_ACTIVE) {
b_active = true;
}
@@ -230,7 +226,7 @@ static bool compare_nodes(const bNode *a, const bNode *b)
}
}
- /* if one of the nodes is in the background and the other not */
+ /* One of the nodes is in the background and the other not. */
if ((a->flag & NODE_BACKGROUND) && !(b->flag & NODE_BACKGROUND)) {
return false;
}
@@ -238,7 +234,7 @@ static bool compare_nodes(const bNode *a, const bNode *b)
return true;
}
- /* if one has a higher selection state (active > selected > nothing) */
+ /* One has a higher selection state (active > selected > nothing). */
if (!b_active && a_active) {
return true;
}
@@ -249,12 +245,13 @@ static bool compare_nodes(const bNode *a, const bNode *b)
return false;
}
-/* Sorts nodes by selection: unselected nodes first, then selected,
- * then the active node at the very end. Relative order is kept intact!
+/**
+ * Sort nodes by selection: unselected nodes first, then selected,
+ * then the active node at the very end. Relative order is kept intact.
*/
void ED_node_sort(bNodeTree *ntree)
{
- /* merge sort is the algorithm of choice here */
+ /* Merge sort is the algorithm of choice here. */
int totnodes = BLI_listbase_count(&ntree->nodes);
int k = 1;
@@ -263,16 +260,16 @@ void ED_node_sort(bNodeTree *ntree)
bNode *first_b = first_a;
do {
- /* setup first_b pointer */
+ /* Set up first_b pointer. */
for (int b = 0; b < k && first_b; b++) {
first_b = first_b->next;
}
- /* all batches merged? */
+ /* All batches merged? */
if (first_b == nullptr) {
break;
}
- /* merge batches */
+ /* Merge batches. */
bNode *node_a = first_a;
bNode *node_b = first_b;
int a = 0;
@@ -291,10 +288,10 @@ void ED_node_sort(bNodeTree *ntree)
}
}
- /* setup first pointers for next batch */
+ /* Set up first pointers for next batch. */
first_b = node_b;
for (; b < k; b++) {
- /* all nodes sorted? */
+ /* All nodes sorted? */
if (first_b == nullptr) {
break;
}
@@ -319,7 +316,7 @@ static void do_node_internal_buttons(bContext *C, void *UNUSED(node_v), int even
static void node_uiblocks_init(const bContext *C, bNodeTree *ntree)
{
- /* add node uiBlocks in drawing order - prevents events going to overlapping nodes */
+ /* Add node uiBlocks in drawing order - prevents events going to overlapping nodes. */
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
/* ui block */
@@ -357,26 +354,28 @@ void node_from_view(const bNode *node, float x, float y, float *rx, float *ry)
nodeFromView(node, x, y, rx, ry);
}
-/* based on settings in node, sets drawing rect info. each redraw! */
+/**
+ * Based on settings and sockets in node, set drawing rect info.
+ */
static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
{
PointerRNA nodeptr;
RNA_pointer_create(&ntree->id, &RNA_Node, node, &nodeptr);
- /* get "global" coords */
+ /* Get "global" coordinates. */
float locx, locy;
node_to_view(node, 0.0f, 0.0f, &locx, &locy);
float dy = locy;
- /* header */
+ /* Header. */
dy -= NODE_DY;
- /* little bit space in top */
+ /* Little bit of space in top. */
if (node->outputs.first) {
dy -= NODE_DYS / 2;
}
- /* output sockets */
+ /* Output sockets. */
bool add_output_space = false;
int buty;
@@ -402,11 +401,11 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
uiLayoutSetActive(layout, false);
}
- /* context pointers for current node and socket */
+ /* Context pointers for current node and socket. */
uiLayoutSetContextPointer(layout, "node", &nodeptr);
uiLayoutSetContextPointer(layout, "socket", &sockptr);
- /* align output buttons to the right */
+ /* Align output buttons to the right. */
uiLayout *row = uiLayoutRow(layout, true);
uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_RIGHT);
const char *socket_label = nodeSocketLabel(nsock);
@@ -415,11 +414,11 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
UI_block_align_end(node->block);
UI_block_layout_resolve(node->block, nullptr, &buty);
- /* ensure minimum socket height in case layout is empty */
+ /* Ensure minimum socket height in case layout is empty. */
buty = min_ii(buty, dy - NODE_DY);
nsock->locx = locx + NODE_WIDTH(node);
- /* place the socket circle in the middle of the layout */
+ /* Place the socket circle in the middle of the layout. */
nsock->locy = 0.5f * (dy + buty);
dy = buty;
@@ -452,8 +451,7 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
node->prvr.ymin = dy - aspect * (NODE_WIDTH(node) - NODE_DY);
}
else {
- /* width correction of image */
- /* XXX huh? (ton) */
+ /* Width correction of image. XXX huh? (ton) */
float dx = (NODE_WIDTH(node) - NODE_DYS) - (NODE_WIDTH(node) - NODE_DYS) / aspect;
node->prvr.ymin = dy - (NODE_WIDTH(node) - NODE_DY);
@@ -464,7 +462,7 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
dy = node->prvr.ymin - NODE_DYS / 2;
- /* make sure that maximums are bigger or equal to minimums */
+ /* Make sure that maximums are bigger or equal to minimums. */
if (node->prvr.xmax < node->prvr.xmin) {
SWAP(float, node->prvr.xmax, node->prvr.xmin);
}
@@ -473,7 +471,7 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
}
}
- /* buttons rect? */
+ /* Buttons rect? */
if (node->typeinfo->draw_buttons && (node->flag & NODE_OPTIONS)) {
dy -= NODE_DYS / 2;
@@ -507,7 +505,7 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
dy = buty - NODE_DYS / 2;
}
- /* input sockets */
+ /* Input sockets. */
LISTBASE_FOREACH (bNodeSocket *, nsock, &node->inputs) {
if (nodeSocketIsHidden(nsock)) {
continue;
@@ -540,7 +538,7 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
uiLayoutSetActive(layout, false);
}
- /* context pointers for current node and socket */
+ /* Context pointers for current node and socket. */
uiLayoutSetContextPointer(layout, "node", &nodeptr);
uiLayoutSetContextPointer(layout, "socket", &sockptr);
@@ -552,11 +550,11 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
UI_block_align_end(node->block);
UI_block_layout_resolve(node->block, nullptr, &buty);
- /* ensure minimum socket height in case layout is empty */
+ /* Ensure minimum socket height in case layout is empty. */
buty = min_ii(buty, dy - NODE_DY);
nsock->locx = locx;
- /* place the socket circle in the middle of the layout */
+ /* Place the socket circle in the middle of the layout. */
nsock->locy = 0.5f * (dy + buty);
dy = buty - multi_input_socket_offset * 0.5;
@@ -565,7 +563,7 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
}
}
- /* little bit space in end */
+ /* Little bit of space in end. */
if (node->inputs.first || (node->flag & (NODE_OPTIONS | NODE_PREVIEW)) == 0) {
dy -= NODE_DYS / 2;
}
@@ -576,8 +574,7 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
node->totr.ymin = min_ff(dy, locy - 2 * NODE_DY);
/* Set the block bounds to clip mouse events from underlying nodes.
- * Add a margin for sockets on each side.
- */
+ * Add a margin for sockets on each side. */
UI_block_bounds_set_explicit(node->block,
node->totr.xmin - NODE_SOCKSIZE,
node->totr.ymin,
@@ -585,16 +582,18 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
node->totr.ymax);
}
-/* based on settings in node, sets drawing rect info. each redraw! */
+/**
+ * Based on settings in node, sets drawing rect info.
+ */
static void node_update_hidden(bNode *node)
{
int totin = 0, totout = 0;
- /* get "global" coords */
+ /* Get "global" coords. */
float locx, locy;
node_to_view(node, 0.0f, 0.0f, &locx, &locy);
- /* calculate minimal radius */
+ /* Calculate minimal radius. */
LISTBASE_FOREACH (bNodeSocket *, nsock, &node->inputs) {
if (!nodeSocketIsHidden(nsock)) {
totin++;
@@ -617,7 +616,7 @@ static void node_update_hidden(bNode *node)
node->totr.ymax = locy + (hiddenrad - 0.5f * NODE_DY);
node->totr.ymin = node->totr.ymax - 2 * hiddenrad;
- /* output sockets */
+ /* Output sockets. */
float rad = (float)M_PI / (1.0f + (float)totout);
float drad = rad;
@@ -629,7 +628,7 @@ static void node_update_hidden(bNode *node)
}
}
- /* input sockets */
+ /* Input sockets. */
rad = drad = -(float)M_PI / (1.0f + (float)totin);
LISTBASE_FOREACH (bNodeSocket *, nsock, &node->inputs) {
@@ -641,8 +640,7 @@ static void node_update_hidden(bNode *node)
}
/* Set the block bounds to clip mouse events from underlying nodes.
- * Add a margin for sockets on each side.
- */
+ * Add a margin for sockets on each side. */
UI_block_bounds_set_explicit(node->block,
node->totr.xmin - NODE_SOCKSIZE,
node->totr.ymin,
@@ -712,9 +710,6 @@ int node_get_colorid(bNode *node)
}
}
-/* note: in cmp_util.c is similar code, for node_compo_pass_on()
- * the same goes for shader and texture nodes. */
-/* note: in node_edit.c is similar code, for untangle node */
static void node_draw_mute_line(const View2D *v2d, const SpaceNode *snode, const bNode *node)
{
GPU_blend(GPU_BLEND_ALPHA);
@@ -726,7 +721,7 @@ static void node_draw_mute_line(const View2D *v2d, const SpaceNode *snode, const
GPU_blend(GPU_BLEND_NONE);
}
-/* flags used in gpu_shader_keyframe_diamond_frag.glsl */
+/* Flags used in gpu_shader_keyframe_diamond_frag.glsl. */
#define MARKER_SHAPE_DIAMOND 0x1
#define MARKER_SHAPE_SQUARE 0xC
#define MARKER_SHAPE_CIRCLE 0x2
@@ -746,7 +741,7 @@ static void node_socket_draw(const bNodeSocket *sock,
{
int flags;
- /* sets shape flags */
+ /* Set shape flags. */
switch (sock->display_shape) {
case SOCK_DISPLAY_SHAPE_DIAMOND:
case SOCK_DISPLAY_SHAPE_DIAMOND_DOT:
@@ -889,7 +884,7 @@ void ED_node_socket_draw(bNodeSocket *sock, const rcti *rect, const float color[
immUniform1f("outline_scale", 0.7f);
immUniform2f("ViewportSize", -1.0f, -1.0f);
- /* Single point */
+ /* Single point. */
immBegin(GPU_PRIM_POINTS, 1);
node_socket_draw(sock,
color,
@@ -930,7 +925,7 @@ static void node_draw_preview_background(rctf *rect)
immUnbindProgram();
}
-/* not a callback */
+/* Not a callback. */
static void node_draw_preview(bNodePreview *preview, rctf *prv)
{
float xrect = BLI_rctf_size_x(prv);
@@ -939,7 +934,7 @@ static void node_draw_preview(bNodePreview *preview, rctf *prv)
float yscale = yrect / ((float)preview->ysize);
float scale;
- /* uniform scale and offset */
+ /* Uniform scale and offset. */
rctf draw_rect = *prv;
if (xscale < yscale) {
float offset = 0.5f * (yrect - ((float)preview->ysize) * xscale);
@@ -957,7 +952,7 @@ static void node_draw_preview(bNodePreview *preview, rctf *prv)
node_draw_preview_background(&draw_rect);
GPU_blend(GPU_BLEND_ALPHA);
- /* premul graphics */
+ /* Premul graphics. */
GPU_blend(GPU_BLEND_ALPHA);
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
@@ -982,13 +977,13 @@ static void node_draw_preview(bNodePreview *preview, rctf *prv)
immUnbindProgram();
}
-/* common handle function for operator buttons that need to select the node first */
+/* Common handle function for operator buttons that need to select the node first. */
static void node_toggle_button_cb(struct bContext *C, void *node_argv, void *op_argv)
{
bNode *node = (bNode *)node_argv;
const char *opname = (const char *)op_argv;
- /* select & activate only the button's node */
+ /* Select & activate only the button's node. */
node_select_single(C, node);
WM_operator_name_call(C, opname, WM_OP_INVOKE_DEFAULT, nullptr);
@@ -1034,7 +1029,7 @@ void node_draw_sockets(const View2D *v2d,
immUniform1f("outline_scale", 0.7f);
immUniform2f("ViewportSize", -1.0f, -1.0f);
- /* set handle size */
+ /* Set handle size. */
float scale;
UI_view2d_scale_get(v2d, &scale, nullptr);
scale *= 2.25f * NODE_SOCKSIZE;
@@ -1043,7 +1038,7 @@ void node_draw_sockets(const View2D *v2d,
immBeginAtMost(GPU_PRIM_POINTS, total_input_len + total_output_len);
}
- /* socket inputs */
+ /* Socket inputs. */
short selected_input_len = 0;
LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) {
if (nodeSocketIsHidden(sock)) {
@@ -1071,7 +1066,7 @@ void node_draw_sockets(const View2D *v2d,
selected);
}
- /* socket outputs */
+ /* Socket outputs. */
short selected_output_len = 0;
if (draw_outputs) {
LISTBASE_FOREACH (bNodeSocket *, sock, &node->outputs) {
@@ -1101,16 +1096,16 @@ void node_draw_sockets(const View2D *v2d,
immEnd();
}
- /* go back and draw selected sockets */
+ /* Go back and draw selected sockets. */
if (selected_input_len + selected_output_len > 0) {
- /* outline for selected sockets */
+ /* Outline for selected sockets. */
selected = true;
immBegin(GPU_PRIM_POINTS, selected_input_len + selected_output_len);
if (selected_input_len) {
- /* socket inputs */
+ /* Socket inputs. */
LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) {
if (nodeSocketIsHidden(sock)) {
continue;
@@ -1128,14 +1123,14 @@ void node_draw_sockets(const View2D *v2d,
scale,
selected);
if (--selected_input_len == 0) {
- break; /* stop as soon as last one is drawn */
+ break; /* Stop as soon as last one is drawn. */
}
}
}
}
if (selected_output_len) {
- /* socket outputs */
+ /* Socket outputs. */
LISTBASE_FOREACH (bNodeSocket *, sock, &node->outputs) {
if (nodeSocketIsHidden(sock)) {
continue;
@@ -1153,7 +1148,7 @@ void node_draw_sockets(const View2D *v2d,
scale,
selected);
if (--selected_output_len == 0) {
- break; /* stop as soon as last one is drawn */
+ break; /* Stop as soon as last one is drawn. */
}
}
}
@@ -1326,17 +1321,16 @@ static void node_draw_basis(const bContext *C,
bNode *node,
bNodeInstanceKey key)
{
- /* float socket_size = NODE_SOCKSIZE*U.dpi/72; */ /* UNUSED */
const float iconbutw = NODE_HEADER_ICON_SIZE;
- /* skip if out of view */
+ /* Skip if out of view. */
if (BLI_rctf_isect(&node->totr, &v2d->cur, nullptr) == false) {
UI_block_end(C, node->block);
node->block = nullptr;
return;
}
- /* shadow */
+ /* Shadow. */
node_draw_shadow(snode, node, BASIS_RAD, 1.0f);
float color[4];
@@ -1367,10 +1361,10 @@ static void node_draw_basis(const bContext *C,
UI_draw_roundbox_aa(&rect, true, BASIS_RAD, color);
}
- /* show/hide icons */
+ /* Show/hide icons. */
float iconofs = rct->xmax - 0.35f * U.widget_unit;
- /* preview */
+ /* Preview. */
if (node->typeinfo->flag & NODE_PREVIEW) {
iconofs -= iconbutw;
UI_block_emboss_set(node->block, UI_EMBOSS_NONE);
@@ -1391,13 +1385,12 @@ static void node_draw_basis(const bContext *C,
UI_but_func_set(but, node_toggle_button_cb, node, (void *)"NODE_OT_preview_toggle");
/* XXX this does not work when node is activated and the operator called right afterwards,
* since active ID is not updated yet (needs to process the notifier).
- * This can only work as visual indicator!
- */
+ * This can only work as visual indicator! */
// if (!(node->flag & (NODE_ACTIVE_ID|NODE_DO_OUTPUT)))
// UI_but_flag_enable(but, UI_BUT_DISABLED);
UI_block_emboss_set(node->block, UI_EMBOSS);
}
- /* group edit */
+ /* Group edit. */
if (node->type == NODE_GROUP) {
iconofs -= iconbutw;
UI_block_emboss_set(node->block, UI_EMBOSS_NONE);
@@ -1440,7 +1433,7 @@ static void node_draw_basis(const bContext *C,
node_add_error_message_button(C, *ntree, *node, *rct, iconofs);
- /* title */
+ /* Title. */
if (node->flag & SELECT) {
UI_GetThemeColor4fv(TH_SELECT, color);
}
@@ -1448,10 +1441,10 @@ static void node_draw_basis(const bContext *C,
UI_GetThemeColorBlendShade4fv(TH_SELECT, color_id, 0.4f, 10, color);
}
- /* open/close entirely? */
+ /* Open/close entirely. */
{
int but_size = U.widget_unit * 0.8f;
- /* XXX button uses a custom triangle draw below, so make it invisible without icon */
+ /* XXX button uses a custom triangle draw below, so make it invisible without icon. */
UI_block_emboss_set(node->block, UI_EMBOSS_NONE);
uiBut *but = uiDefBut(node->block,
UI_BTYPE_BUT_TOGGLE,
@@ -1471,11 +1464,11 @@ static void node_draw_basis(const bContext *C,
UI_block_emboss_set(node->block, UI_EMBOSS);
UI_GetThemeColor4fv(TH_TEXT, color);
- /* custom draw function for this button */
+ /* Custom draw function for this button. */
UI_draw_icon_tri(rct->xmin + 0.65f * U.widget_unit, rct->ymax - NODE_DY / 2.2f, 'v', color);
}
- char showname[128]; /* 128 used below */
+ char showname[128];
nodeLabel(ntree, node, showname, sizeof(showname));
uiBut *but = uiDefBut(node->block,
@@ -1496,9 +1489,9 @@ static void node_draw_basis(const bContext *C,
UI_but_flag_enable(but, UI_BUT_INACTIVE);
}
- /* body */
+ /* Body. */
if (nodeTypeUndefined(node)) {
- /* use warning color to indicate undefined types */
+ /* Use warning color to indicate undefined types. */
UI_GetThemeColor4fv(TH_REDALERT, color);
}
else if (node->flag & NODE_MUTED) {
@@ -1527,7 +1520,7 @@ static void node_draw_basis(const bContext *C,
UI_draw_roundbox_aa(&rect, true, BASIS_RAD, color);
}
- /* outline active and selected emphasis */
+ /* Outline active and selected emphasis. */
if (node->flag & SELECT) {
UI_GetThemeColorShadeAlpha4fv(
(node->flag & NODE_ACTIVE) ? TH_ACTIVE : TH_SELECT, 0, -40, color);
@@ -1536,14 +1529,14 @@ static void node_draw_basis(const bContext *C,
UI_draw_roundbox_aa(rct, false, BASIS_RAD, color);
}
- /* disable lines */
+ /* Disable lines. */
if (node->flag & NODE_MUTED) {
node_draw_mute_line(v2d, snode, node);
}
node_draw_sockets(v2d, C, ntree, node, true, false);
- /* preview */
+ /* Preview. */
bNodeInstanceHash *previews = (bNodeInstanceHash *)CTX_data_pointer_get(C, "node_previews").data;
if (node->flag & NODE_PREVIEW && previews) {
bNodePreview *preview = (bNodePreview *)BKE_node_instance_hash_lookup(previews, key);
@@ -1573,10 +1566,10 @@ static void node_draw_hidden(const bContext *C,
float scale;
UI_view2d_scale_get(v2d, &scale, nullptr);
- /* shadow */
+ /* Shadow. */
node_draw_shadow(snode, node, hiddenrad, 1.0f);
- /* body */
+ /* Body. */
float color[4];
int color_id = node_get_colorid(node);
if (node->flag & NODE_MUTED) {
@@ -1590,7 +1583,7 @@ static void node_draw_hidden(const bContext *C,
UI_draw_roundbox_aa(rct, true, hiddenrad, color);
- /* outline active and selected emphasis */
+ /* Outline active and selected emphasis. */
if (node->flag & SELECT) {
UI_GetThemeColorShadeAlpha4fv(
(node->flag & NODE_ACTIVE) ? TH_ACTIVE : TH_SELECT, 0, -40, color);
@@ -1598,7 +1591,7 @@ static void node_draw_hidden(const bContext *C,
UI_draw_roundbox_aa(rct, false, hiddenrad, color);
}
- /* custom color inline */
+ /* Custom color inline. */
if (node->flag & NODE_CUSTOM_COLOR) {
GPU_blend(GPU_BLEND_ALPHA);
GPU_line_smooth(true);
@@ -1615,7 +1608,7 @@ static void node_draw_hidden(const bContext *C,
GPU_blend(GPU_BLEND_NONE);
}
- /* title */
+ /* Title. */
if (node->flag & SELECT) {
UI_GetThemeColor4fv(TH_SELECT, color);
}
@@ -1623,7 +1616,7 @@ static void node_draw_hidden(const bContext *C,
UI_GetThemeColorBlendShade4fv(TH_SELECT, color_id, 0.4f, 10, color);
}
- /* open entirely icon */
+ /* Open / collapse icon. */
{
int but_size = U.widget_unit * 0.8f;
/* XXX button uses a custom triangle draw below, so make it invisible without icon */
@@ -1646,22 +1639,18 @@ static void node_draw_hidden(const bContext *C,
UI_block_emboss_set(node->block, UI_EMBOSS);
UI_GetThemeColor4fv(TH_TEXT, color);
- /* custom draw function for this button */
+ /* Custom draw function for this button. */
UI_draw_icon_tri(rct->xmin + 0.65f * U.widget_unit, centy, 'h', color);
}
- /* disable lines */
+ /* Disable lines. */
if (node->flag & NODE_MUTED) {
node_draw_mute_line(v2d, snode, node);
}
- char showname[128]; /* 128 is used below */
+ char showname[128];
nodeLabel(ntree, node, showname, sizeof(showname));
- /* XXX - don't print into self! */
- // if (node->flag & NODE_MUTED)
- // BLI_snprintf(showname, sizeof(showname), "[%s]", showname);
-
uiBut *but = uiDefBut(node->block,
UI_BTYPE_LABEL,
0,
@@ -1680,7 +1669,7 @@ static void node_draw_hidden(const bContext *C,
UI_but_flag_enable(but, UI_BUT_INACTIVE);
}
- /* scale widget thing */
+ /* Scale widget thing. */
uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -1738,13 +1727,13 @@ void node_set_cursor(wmWindow *win, SpaceNode *snode, float cursor[2])
if (ntree) {
if (node_find_indicated_socket(snode, &node, &sock, cursor, SOCK_IN | SOCK_OUT)) {
- /* pass */
+ /* Pass. */
}
else {
- /* check nodes front to back */
+ /* Check nodes front to back. */
for (node = (bNode *)ntree->nodes.last; node; node = node->prev) {
if (BLI_rctf_isect_pt(&node->totr, cursor[0], cursor[1])) {
- break; /* first hit on node stops */
+ break; /* First hit on node stops. */
}
}
if (node) {
@@ -1807,13 +1796,13 @@ static void count_mutli_input_socket_links(bNodeTree *ntree, SpaceNode *snode)
void node_update_nodetree(const bContext *C, bNodeTree *ntree)
{
- /* make sure socket "used" tags are correct, for displaying value buttons */
+ /* Make sure socket "used" tags are correct, for displaying value buttons. */
SpaceNode *snode = CTX_wm_space_node(C);
ntreeTagUsedSockets(ntree);
count_mutli_input_socket_links(ntree, snode);
- /* update nodes front to back, so children sizes get updated before parents */
+ /* Update nodes front to back, so children sizes get updated before parents. */
LISTBASE_FOREACH_BACKWARD (bNode *, node, &ntree->nodes) {
node_update(C, ntree, node);
}
@@ -1903,7 +1892,7 @@ void node_draw_nodetree(const bContext *C,
bNodeInstanceKey parent_key)
{
if (ntree == nullptr) {
- return; /* groups... */
+ return; /* Groups. */
}
#ifdef USE_DRAW_TOT_UPDATE
@@ -1912,11 +1901,11 @@ void node_draw_nodetree(const bContext *C,
}
#endif
- /* draw background nodes, last nodes in front */
+ /* Draw background nodes, last nodes in front. */
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
#ifdef USE_DRAW_TOT_UPDATE
- /* unrelated to background nodes, update the v2d->tot,
- * can be anywhere before we draw the scroll bars */
+ /* Unrelated to background nodes, update the v2d->tot,
+ * can be anywhere before we draw the scroll bars. */
BLI_rctf_union(&region->v2d.tot, &node->totr);
#endif
@@ -1928,7 +1917,7 @@ void node_draw_nodetree(const bContext *C,
node_draw(C, region, snode, ntree, node, key);
}
- /* node lines */
+ /* Node lines. */
GPU_blend(GPU_BLEND_ALPHA);
nodelink_batch_start(snode);
@@ -1942,7 +1931,7 @@ void node_draw_nodetree(const bContext *C,
nodelink_batch_end(snode);
GPU_blend(GPU_BLEND_NONE);
- /* draw foreground nodes, last nodes in front */
+ /* Draw foreground nodes, last nodes in front. */
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->flag & NODE_BACKGROUND) {
continue;
@@ -1953,7 +1942,7 @@ void node_draw_nodetree(const bContext *C,
}
}
-/* draw tree path info in lower left corner */
+/* Draw tree path info in lower left corner. */
static void draw_tree_path(SpaceNode *snode)
{
char info[256];
@@ -1968,11 +1957,11 @@ static void snode_setup_v2d(SpaceNode *snode, ARegion *region, const float cente
{
View2D *v2d = &region->v2d;
- /* shift view to node tree center */
+ /* Shift view to node tree center. */
UI_view2d_center_set(v2d, center[0], center[1]);
UI_view2d_view_ortho(v2d);
- /* aspect+font, set each time */
+ /* Aspect + font, set each time. */
snode->runtime->aspect = BLI_rctf_size_x(&v2d->cur) / (float)region->winx;
// XXX snode->curfont = uiSetCurFont_ext(snode->aspect);
}
@@ -1990,14 +1979,14 @@ static void draw_nodetree(const bContext *C,
node_draw_nodetree(C, region, snode, ntree, parent_key);
}
-/* shade the parent node group and add a uiBlock to clip mouse events */
+/* Shade the parent node group and add a `uiBlock` to clip mouse events. */
static void draw_group_overlay(const bContext *C, ARegion *region)
{
const View2D *v2d = &region->v2d;
const rctf rect = v2d->cur;
float color[4];
- /* shade node groups to separate them visually */
+ /* Shade node groups to separate them visually. */
GPU_blend(GPU_BLEND_ALPHA);
UI_GetThemeColorShadeAlpha4fv(TH_NODE_GROUP, 0, 0, color);
@@ -2005,7 +1994,7 @@ static void draw_group_overlay(const bContext *C, ARegion *region)
UI_draw_roundbox_4fv(&rect, true, 0, color);
GPU_blend(GPU_BLEND_NONE);
- /* set the block bounds to clip mouse events from underlying nodes */
+ /* Set the block bounds to clip mouse events from underlying nodes. */
uiBlock *block = UI_block_begin(C, region, "node tree bounds block", UI_EMBOSS);
UI_block_bounds_set_explicit(block, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
UI_block_flag_enable(block, UI_BLOCK_CLIP_EVENTS);
@@ -2043,19 +2032,19 @@ void node_draw_space(const bContext *C, ARegion *region)
ED_region_draw_cb_draw(C, region, REGION_DRAW_PRE_VIEW);
- /* only set once */
+ /* Only set once. */
GPU_blend(GPU_BLEND_ALPHA);
- /* nodes */
+ /* Nodes. */
snode_set_context(C);
- /* draw parent node trees */
+ /* Draw parent node trees. */
if (snode->treepath.last) {
static const int max_depth = 2;
bNodeTreePath *path = (bNodeTreePath *)snode->treepath.last;
- /* update tree path name (drawn in the bottom left) */
+ /* Update tree path name (drawn in the bottom left). */
ID *name_id = (path->nodetree && path->nodetree != snode->nodetree) ? &path->nodetree->id :
snode->id;
@@ -2063,11 +2052,11 @@ void node_draw_space(const bContext *C, ARegion *region)
BLI_strncpy(path->node_name, name_id->name + 2, sizeof(path->node_name));
}
- /* current View2D center, will be set temporarily for parent node trees */
+ /* Current View2D center, will be set temporarily for parent node trees. */
float center[2];
UI_view2d_center_get(v2d, &center[0], &center[1]);
- /* store new view center in path and current edittree */
+ /* Store new view center in path and current edit tree. */
copy_v2_v2(path->view_center, center);
if (snode->edittree) {
copy_v2_v2(snode->edittree->view_center, center);
@@ -2079,7 +2068,7 @@ void node_draw_space(const bContext *C, ARegion *region)
depth++;
}
- /* parent node trees in the background */
+ /* Parent node trees in the background. */
for (int curdepth = depth; curdepth > 0; path = path->next, curdepth--) {
bNodeTree *ntree = path->nodetree;
if (ntree) {
@@ -2091,19 +2080,19 @@ void node_draw_space(const bContext *C, ARegion *region)
}
}
- /* top-level edit tree */
+ /* Top-level edit tree. */
bNodeTree *ntree = path->nodetree;
if (ntree) {
snode_setup_v2d(snode, region, center);
- /* grid, uses theme color based on node path depth */
+ /* Grid, uses theme color based on node path depth. */
UI_view2d_multi_grid_draw(v2d,
(depth > 0 ? TH_NODE_GROUP : TH_GRID),
ED_node_grid_size(),
NODE_GRID_STEPS,
grid_levels);
- /* backdrop */
+ /* Backdrop. */
draw_nodespace_back_pix(C, region, snode, path->parent_key);
{
@@ -2124,7 +2113,7 @@ void node_draw_space(const bContext *C, ARegion *region)
draw_nodetree(C, region, ntree, path->parent_key);
}
- /* temporary links */
+ /* Temporary links. */
GPU_blend(GPU_BLEND_ALPHA);
GPU_line_smooth(true);
LISTBASE_FOREACH (bNodeLinkDrag *, nldrag, &snode->runtime->linkdrag) {
@@ -2136,21 +2125,21 @@ void node_draw_space(const bContext *C, ARegion *region)
GPU_blend(GPU_BLEND_NONE);
if (snode->flag & SNODE_SHOW_GPENCIL) {
- /* draw grease-pencil ('canvas' strokes) */
+ /* Draw grease-pencil annotations. */
ED_annotation_draw_view2d(C, true);
}
}
else {
- /* default grid */
+ /* Default grid. */
UI_view2d_multi_grid_draw(v2d, TH_GRID, ED_node_grid_size(), NODE_GRID_STEPS, grid_levels);
- /* backdrop */
+ /* Backdrop. */
draw_nodespace_back_pix(C, region, snode, NODE_INSTANCE_KEY_NONE);
}
ED_region_draw_cb_draw(C, region, REGION_DRAW_POST_VIEW);
- /* reset view matrix */
+ /* Reset view matrix. */
UI_view2d_view_restore(C);
if (snode->treepath.last) {
@@ -2160,9 +2149,9 @@ void node_draw_space(const bContext *C, ARegion *region)
}
}
- /* tree path info */
+ /* Tree path info. */
draw_tree_path(snode);
- /* scrollers */
+ /* Scrollers. */
UI_view2d_scrollers_draw(v2d, nullptr);
}