[Bf-blender-cvs] [1d636f5e057] master: Cleanup: Comment formatting in node editor

Hans Goudey noreply at git.blender.org
Wed Jan 4 02:04:16 CET 2023


Commit: 1d636f5e057e14806fcfb2bedc584544a7fb44a8
Author: Hans Goudey
Date:   Tue Jan 3 20:02:01 2023 -0500
Branches: master
https://developer.blender.org/rB1d636f5e057e14806fcfb2bedc584544a7fb44a8

Cleanup: Comment formatting in node editor

Also remove an accidentally committed timing print.

===================================================================

M	source/blender/editors/include/ED_node.h
M	source/blender/editors/include/ED_node.hh
M	source/blender/editors/interface/interface_widgets.cc
M	source/blender/editors/space_node/node_add.cc
M	source/blender/editors/space_node/node_draw.cc
M	source/blender/editors/space_node/node_edit.cc
M	source/blender/editors/space_node/node_relationships.cc
M	source/blender/editors/space_node/node_select.cc

===================================================================

diff --git a/source/blender/editors/include/ED_node.h b/source/blender/editors/include/ED_node.h
index dc35ac74524..f996a9f4591 100644
--- a/source/blender/editors/include/ED_node.h
+++ b/source/blender/editors/include/ED_node.h
@@ -78,15 +78,6 @@ void ED_node_draw_snap(
 
 /* node_draw.cc */
 
-/**
- * Draw a single node socket at default size.
- * \note this is only called from external code, internally #node_socket_draw_nested() is used for
- *       optimized drawing of multiple/all sockets of a node.
- */
-void ED_node_socket_draw(struct bNodeSocket *sock,
-                         const struct rcti *rect,
-                         const float color[4],
-                         float scale);
 void ED_node_tree_update(const struct bContext *C);
 void ED_node_tag_update_id(struct ID *id);
 
diff --git a/source/blender/editors/include/ED_node.hh b/source/blender/editors/include/ED_node.hh
index 7b35bbf0b6e..ff88eedb5a4 100644
--- a/source/blender/editors/include/ED_node.hh
+++ b/source/blender/editors/include/ED_node.hh
@@ -9,6 +9,7 @@ struct SpaceNode;
 struct ARegion;
 struct Main;
 struct bNodeTree;
+struct rcti;
 
 namespace blender::ed::space_node {
 
@@ -22,4 +23,11 @@ void node_insert_on_link_flags_set(SpaceNode &snode, const ARegion &region);
 void node_insert_on_link_flags(Main &bmain, SpaceNode &snode);
 void node_insert_on_link_flags_clear(bNodeTree &node_tree);
 
+/**
+ * Draw a single node socket at default size.
+ * \note this is only called from external code, internally #node_socket_draw_nested() is used for
+ *       optimized drawing of multiple/all sockets of a node.
+ */
+void node_socket_draw(bNodeSocket *sock, const rcti *rect, const float color[4], float scale);
+
 }  // namespace blender::ed::space_node
diff --git a/source/blender/editors/interface/interface_widgets.cc b/source/blender/editors/interface/interface_widgets.cc
index ea9bdc8a0d9..3c0b5064d1f 100644
--- a/source/blender/editors/interface/interface_widgets.cc
+++ b/source/blender/editors/interface/interface_widgets.cc
@@ -26,7 +26,7 @@
 
 #include "BLF_api.h"
 
-#include "ED_node.h"
+#include "ED_node.hh"
 
 #include "UI_interface.h"
 #include "UI_interface_icons.h"
@@ -2213,7 +2213,8 @@ static void widget_draw_node_link_socket(const uiWidgetColors *wcol,
     UI_widgetbase_draw_cache_flush();
     GPU_blend(GPU_BLEND_NONE);
 
-    ED_node_socket_draw(static_cast<bNodeSocket *>(but->custom_data), rect, col, scale);
+    blender::ed::space_node::node_socket_draw(
+        static_cast<bNodeSocket *>(but->custom_data), rect, col, scale);
   }
   else {
     widget_draw_icon(but, ICON_LAYER_USED, alpha, rect, wcol->text);
diff --git a/source/blender/editors/space_node/node_add.cc b/source/blender/editors/space_node/node_add.cc
index ce1fe118281..097056b5464 100644
--- a/source/blender/editors/space_node/node_add.cc
+++ b/source/blender/editors/space_node/node_add.cc
@@ -699,8 +699,7 @@ static int node_add_file_exec(bContext *C, wmOperator *op)
   }
 
   /* When adding new image file via drag-drop we need to load imbuf in order
-   * to get proper image source.
-   */
+   * to get proper image source. */
   if (RNA_struct_property_is_set(op->ptr, "filepath")) {
     BKE_image_signal(bmain, ima, nullptr, IMA_SIGNAL_RELOAD);
     WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ima);
@@ -717,7 +716,7 @@ static int node_add_file_invoke(bContext *C, wmOperator *op, const wmEvent *even
   ARegion *region = CTX_wm_region(C);
   SpaceNode *snode = CTX_wm_space_node(C);
 
-  /* convert mouse coordinates to v2d space */
+  /* Convert mouse coordinates to `v2d` space. */
   UI_view2d_region_to_view(&region->v2d,
                            event->mval[0],
                            event->mval[1],
@@ -860,13 +859,12 @@ static int new_node_tree_exec(bContext *C, wmOperator *op)
 
   ntree = ntreeAddTree(bmain, treename, idname);
 
-  /* hook into UI */
+  /* Hook into UI. */
   UI_context_active_but_prop_get_templateID(C, &ptr, &prop);
 
   if (prop) {
-    /* RNA_property_pointer_set increases the user count,
-     * fixed here as the editor is the initial user.
-     */
+    /* #RNA_property_pointer_set increases the user count, fixed here as the editor is the initial
+     * user. */
     id_us_min(&ntree->id);
 
     RNA_id_pointer_create(&ntree->id, &idptr);
diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc
index fcb1d854fa0..12a1fcdebd0 100644
--- a/source/blender/editors/space_node/node_draw.cc
+++ b/source/blender/editors/space_node/node_draw.cc
@@ -59,6 +59,7 @@
 
 #include "ED_gpencil.h"
 #include "ED_node.h"
+#include "ED_node.hh"
 #include "ED_screen.h"
 #include "ED_space_api.h"
 #include "ED_viewer_path.hh"
@@ -84,9 +85,6 @@
 
 namespace geo_log = blender::nodes::geo_eval_log;
 
-using blender::GPointer;
-using blender::Vector;
-
 /**
  * This is passed to many functions which draw the node editor.
  */
@@ -278,7 +276,7 @@ static Array<uiBlock *> node_uiblocks_init(const bContext &C, const Span<bNode *
   for (const int i : nodes.index_range()) {
     const std::string block_name = "node_" + std::string(nodes[i]->name);
     blocks[i] = UI_block_begin(&C, CTX_wm_region(&C), block_name.c_str(), UI_EMBOSS);
-    /* this cancels events for background nodes */
+    /* This cancels events for background nodes. */
     UI_block_flag_enable(blocks[i], UI_BLOCK_CLIP_EVENTS);
   }
 
@@ -1240,12 +1238,8 @@ static void node_socket_draw_nested(const bContext &C,
   UI_block_emboss_set(&block, old_emboss);
 }
 
-}  // namespace blender::ed::space_node
-
-void ED_node_socket_draw(bNodeSocket *sock, const rcti *rect, const float color[4], float scale)
+void node_socket_draw(bNodeSocket *sock, const rcti *rect, const float color[4], float scale)
 {
-  using namespace blender::ed::space_node;
-
   const float size = NODE_SOCKSIZE_DRAW_MULIPLIER * NODE_SOCKSIZE * scale;
   rcti draw_rect = *rect;
   float outline_color[4] = {0};
@@ -1292,10 +1286,6 @@ void ED_node_socket_draw(bNodeSocket *sock, const rcti *rect, const float color[
   GPU_blend(state);
 }
 
-namespace blender::ed::space_node {
-
-/* **************  Socket callbacks *********** */
-
 static void node_draw_preview_background(rctf *rect)
 {
   GPUVertFormat *format = immVertexFormat();
@@ -1526,7 +1516,8 @@ static void node_draw_sockets(const View2D &v2d,
                                   scale,
                                   selected);
           if (--selected_input_len == 0) {
-            break; /* Stop as soon as last one is drawn. */
+            /* Stop as soon as last one is drawn. */
+            break;
           }
         }
       }
@@ -1552,7 +1543,8 @@ static void node_draw_sockets(const View2D &v2d,
                                   scale,
                                   selected);
           if (--selected_output_len == 0) {
-            break; /* Stop as soon as last one is drawn. */
+            /* Stop as soon as last one is drawn. */
+            break;
           }
         }
       }
@@ -2163,11 +2155,6 @@ static void node_draw_basis(const bContext &C,
                     node_toggle_button_cb,
                     POINTER_FROM_INT(node.identifier),
                     (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! */
-    //      if (!(node.flag & (NODE_ACTIVE_ID|NODE_DO_OUTPUT)))
-    //          UI_but_flag_enable(but, UI_BUT_DISABLED);
     UI_block_emboss_set(&block, UI_EMBOSS);
   }
   /* Group edit. */
@@ -2680,28 +2667,28 @@ static void frame_node_prepare_for_draw(bNode &node, Span<bNode *> nodes)
   const float margin = 1.5f * U.widget_unit;
   NodeFrame *data = (NodeFrame *)node.storage;
 
-  /* init rect from current frame size */
+  /* Initialize rect from current frame size. */
   rctf rect;
   node_to_updated_rect(node, rect);
 
-  /* frame can be resized manually only if shrinking is disabled or no children are attached */
+  /* Frame can be resized manually only if shrinking is disabled or no children are attached. */
   data->flag |= NODE_FRAME_RESIZEABLE;
-  /* for shrinking bbox, initialize the rect from first child node */
+  /* For shrinking bounding box, initialize the rect from first child node. */
   bool bbinit = (data->flag & NODE_FRAME_SHRINK);
-  /* fit bounding box to all children */
+  /* Fit bounding box to all children. */
   for (const bNode *tnode : nodes) {
     if (tnode->parent != &node) {
       continue;
     }
 
-    /* add margin to node rect */
+    /* Add margin to node rect. */
     rctf noderect = tnode->runtime->totr;
     noderect.xmin -= margin;
     noderect.xmax += margin;
     noderect.ymin -= margin;
     noderect.ymax += margin;
 
-    /* first child initializes frame */
+    /* First child initializes frame. */
     if (bbinit) {
       bbinit = false;
       rect = noderect;
@@ -2712,7 +2699,7 @@ static void frame_node_prepare_for_draw(bNode &node, Span<bNode *> nodes)
     }
   }
 
-  /* now adjust the frame size from view-space bounding box */
+  /* Now adjust the frame size from view-space bounding box. */
   const float2 offset = node_from_view(node, {rect.xmin, rect.ymax});
   node.offsetx = offset.x;
   node.offsety = offset.y;
@@ -2725,10 +2712,9 @@ static void frame_node_prepare_for_draw(bNode &node, Span<bNode *> nodes)
 
 static void reroute_node_prepare_for_draw(bNode &node)
 {
-  /* get "global" coords */
   const float2 loc = node_to_view(node, float2(0));
 
-  /* reroute node has exactly one input and one output, both in the same place */
+  /* Reroute node has exactly one input and one output, both in the same place. */
   bNodeSocket *socket = (bNodeSocket *)node.outputs.first;
   socket->runtime->locx = loc.x;
   socket->runtime->locy = loc.y;
@@ -2802,10 +2788,10 @@ static void frame_node_draw_label(TreeDrawContext &tree_draw_ctx,
 
   BLF_enable(fontid, BLF_ASPECT);
   BLF_aspect(fontid, aspect, aspect, 1.0f);
-  /* clamp otherwise it can suck up a LOT of memory */
+  /* Clamp. Otherwise it can suck up a LOT of memory. */
   BLF_size(fontid, MIN2(2

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list