[Bf-blender-cvs] [ab9c34e7e7c] master: Fix T104316: Width of headerless panels on regions with overlap

2023-02-03 Thread Leon Schittek
Commit: ab9c34e7e7c3c71100b6a075b39a25a05d9f2726
Author: Leon Schittek
Date:   Fri Feb 3 21:40:13 2023 +0100
Branches: master
https://developer.blender.org/rBab9c34e7e7c3c71100b6a075b39a25a05d9f2726

Fix T104316: Width of headerless panels on regions with overlap

In some cases panels without headers were drawn too wide in sidebars
with region overlap.

Instead of always using the maximum width the view allows, headerless
panels now also use the width calculated in
`panel_draw_width_from_max_width_get`. The function already returns the
correct width in all cases and also takes care of insetting the panels,
when their backdrop needs to be drawn, which is necessary for headerless
panels, too, when there is region overlap.

Reviewed By: Hans Goudey

Differential Revision: http://developer.blender.org/D17194

===

M   source/blender/editors/screen/area.c

===

diff --git a/source/blender/editors/screen/area.c 
b/source/blender/editors/screen/area.c
index 305439724d0..c3df23500d4 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -2946,7 +2946,7 @@ void ED_region_panels_layout_ex(const bContext *C,
 margin_x = category_tabs_width;
   }
 
-  const int width_no_header = BLI_rctf_size_x(&v2d->cur) - margin_x;
+  const int max_panel_width = BLI_rctf_size_x(&v2d->cur) - margin_x;
   /* Works out to 10 * UI_UNIT_X or 20 * UI_UNIT_X. */
   const int em = (region->type->prefsizex) ? 10 : 20;
 
@@ -2974,22 +2974,14 @@ void ED_region_panels_layout_ex(const bContext *C,
 continue;
   }
 }
-const int width = panel_draw_width_from_max_width_get(region, pt, 
width_no_header);
+const int width = panel_draw_width_from_max_width_get(region, pt, 
max_panel_width);
 
 if (panel && UI_panel_is_dragging(panel)) {
   /* Prevent View2d.tot rectangle size changes while dragging panels. */
   update_tot_size = false;
 }
 
-ed_panel_draw(C,
-  region,
-  ®ion->panels,
-  pt,
-  panel,
-  (pt->flag & PANEL_TYPE_NO_HEADER) ? width_no_header : width,
-  em,
-  NULL,
-  search_filter);
+ed_panel_draw(C, region, ®ion->panels, pt, panel, width, em, NULL, 
search_filter);
   }
 
   /* Draw "poly-instantiated" panels that don't have a 1 to 1 correspondence 
with their types. */
@@ -3005,7 +2997,7 @@ void ED_region_panels_layout_ex(const bContext *C,
   !STREQ(category, panel->type->category)) {
 continue;
   }
-  const int width = panel_draw_width_from_max_width_get(region, 
panel->type, width_no_header);
+  const int width = panel_draw_width_from_max_width_get(region, 
panel->type, max_panel_width);
 
   if (panel && UI_panel_is_dragging(panel)) {
 /* Prevent View2d.tot rectangle size changes while dragging panels. */
@@ -3021,7 +3013,7 @@ void ED_region_panels_layout_ex(const bContext *C,
 ®ion->panels,
 panel->type,
 panel,
-(panel->type->flag & PANEL_TYPE_NO_HEADER) ? 
width_no_header : width,
+width,
 em,
 unique_panel_str,
 search_filter);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [89aae4ac82e] master: Node Editor: Controlled node link swapping

2023-01-28 Thread Leon Schittek
Commit: 89aae4ac82e0f58c79b70d1faaa37fa8a5877cf5
Author: Leon Schittek
Date:   Sat Jan 28 10:07:29 2023 +0100
Branches: master
https://developer.blender.org/rB89aae4ac82e0f58c79b70d1faaa37fa8a5877cf5

Node Editor: Controlled node link swapping

Allow to explicitly swap node links by pressing the alt-key while
reconnecting node links. This replaces the old auto-swapping based on
matching prefixes in socket names.

The new behavior works as follows:

* By default plugging links into already occupied (single input)
  sockets will connect the dragged link and remove the existing one.
* Pressing the alt-key while dragging an existing node link from one
  socket to another socket that is already connected will swap the
  links' destinations.
* Pressing the alt-key while dragging a new node link into an already
  linked socket will try to reconnect the existing links into another
  socket of the same type and remove the links, if no matching socket
  is found on the node. This is similar to the old auto-swapping.

Swapping links from or to multi input sockets is not supported.

This commit also makes the link drag tooltip better visible, when using
light themes by using the text theme color.

Reviewed By: Hans Goudey, Simon Thommes

Differential Revision: https://developer.blender.org/D16244

===

M   source/blender/blenkernel/BKE_node.h
M   source/blender/editors/space_node/node_intern.hh
M   source/blender/editors/space_node/node_relationships.cc
M   source/blender/nodes/intern/node_util.cc
M   source/blender/nodes/intern/node_util.h

===

diff --git a/source/blender/blenkernel/BKE_node.h 
b/source/blender/blenkernel/BKE_node.h
index d57857bfdf3..c358f56c0d9 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -298,7 +298,7 @@ typedef struct bNodeType {
 const struct bNodeTree *nodetree,
 const char **r_disabled_hint);
 
-  /* optional handling of link insertion. Returns false if the link shouldn't 
be created. */
+  /* Optional handling of link insertion. Returns false if the link shouldn't 
be created. */
   bool (*insert_link)(struct bNodeTree *ntree, struct bNode *node, struct 
bNodeLink *link);
 
   void (*free_self)(struct bNodeType *ntype);
diff --git a/source/blender/editors/space_node/node_intern.hh 
b/source/blender/editors/space_node/node_intern.hh
index f9804144fb0..5be29e6f336 100644
--- a/source/blender/editors/space_node/node_intern.hh
+++ b/source/blender/editors/space_node/node_intern.hh
@@ -44,18 +44,24 @@ struct bNodeLinkDrag {
   Vector links;
   eNodeSocketInOut in_out;
 
-  /** Draw handler for the "+" icon when dragging a link in empty space. */
+  /** Draw handler for the tooltip icon when dragging a link in empty space. */
   void *draw_handle;
 
   /** Temporarily stores the last picked link from multi-input socket 
operator. */
   bNodeLink *last_picked_multi_input_socket_link;
 
   /**
-   * Temporarily stores the last hovered socket for multi-input socket 
operator.
+   * Temporarily stores the last hovered node for multi-input socket operator.
* Store it to recalculate sorting after it is no longer hovered.
*/
   bNode *last_node_hovered_while_dragging_a_link;
 
+  /**
+   * Temporarily stores the currently hovered socket for link swapping to 
allow reliably swap links
+   * even when dragging multiple links at once. `nullptr`, when no socket is 
hovered.
+   */
+  bNodeSocket *hovered_socket;
+
   /* The cursor position, used for drawing a + icon when dragging a node link. 
*/
   std::array cursor;
 
@@ -66,6 +72,8 @@ struct bNodeLinkDrag {
   /** The number of links connected to the #start_socket when the drag 
started. */
   int start_link_count;
 
+  bool swap_links = false;
+
   /* Data for edge panning */
   View2DEdgePanData pan_data;
 };
diff --git a/source/blender/editors/space_node/node_relationships.cc 
b/source/blender/editors/space_node/node_relationships.cc
index a591c8308a4..9f37233840b 100644
--- a/source/blender/editors/space_node/node_relationships.cc
+++ b/source/blender/editors/space_node/node_relationships.cc
@@ -785,6 +785,9 @@ static bool should_create_drag_link_search_menu(const 
bNodeTree &node_tree,
   if (!dragged_links_are_detached(nldrag)) {
 return false;
   }
+  if (nldrag.swap_links) {
+return false;
+  }
   /* Don't create the search menu if the drag is disconnecting a link from an 
input node. */
   if (nldrag.start_socket->in_out == SOCK_IN && nldrag.start_link_count > 0) {
 return false;
@@ -799,18 +802,29 @@ static bool should_create_drag_link_search_menu(const 
bNodeTree &node_tree,
   return true;
 }
 
+static bool need_drag_link_tooltip(const bNodeTree &node_tree, const 
bNodeLinkDrag &nldrag)
+{
+  return nldrag.swap_lin

[Bf-blender-cvs] [68625431d5d] master: Geometry Nodes: Adjust modifier UI to put field toggles on the right

2023-01-20 Thread Leon Schittek
Commit: 68625431d5d0b2e178df506fc0fabe81e9b44fcb
Author: Leon Schittek
Date:   Fri Jan 20 17:41:34 2023 -0600
Branches: master
https://developer.blender.org/rB68625431d5d0b2e178df506fc0fabe81e9b44fcb

Geometry Nodes: Adjust modifier UI to put field toggles on the right

This also fixes the layout of boolean properties with the field toggle
visible. This was discussed in the most recent geometry nodes submodule
meeting.

===

M   source/blender/modifiers/intern/MOD_nodes.cc

===

diff --git a/source/blender/modifiers/intern/MOD_nodes.cc 
b/source/blender/modifiers/intern/MOD_nodes.cc
index 9c63ee7ce15..e487abc4248 100644
--- a/source/blender/modifiers/intern/MOD_nodes.cc
+++ b/source/blender/modifiers/intern/MOD_nodes.cc
@@ -1580,7 +1580,9 @@ static void add_attribute_search_or_value_buttons(const 
bContext &C,
   uiLayout *split = uiLayoutSplit(layout, 0.4f, false);
   uiLayout *name_row = uiLayoutRow(split, false);
   uiLayoutSetAlignment(name_row, UI_LAYOUT_ALIGN_RIGHT);
-  if (socket.type == SOCK_BOOLEAN) {
+
+  const int use_attribute = RNA_int_get(md_ptr, 
rna_path_use_attribute.c_str()) != 0;
+  if (socket.type == SOCK_BOOLEAN && !use_attribute) {
 uiItemL(name_row, "", ICON_NONE);
   }
   else {
@@ -1589,7 +1591,18 @@ static void add_attribute_search_or_value_buttons(const 
bContext &C,
 
   uiLayout *prop_row = uiLayoutRow(split, true);
   if (socket.type == SOCK_BOOLEAN) {
-uiLayoutSetAlignment(prop_row, UI_LAYOUT_ALIGN_LEFT);
+uiLayoutSetPropSep(prop_row, false);
+uiLayoutSetAlignment(prop_row, UI_LAYOUT_ALIGN_EXPAND);
+  }
+
+  if (use_attribute) {
+add_attribute_search_button(C, prop_row, nmd, md_ptr, 
rna_path_attribute_name, socket, false);
+uiItemL(layout, "", ICON_BLANK1);
+  }
+  else {
+const char *name = socket.type == SOCK_BOOLEAN ? socket.name : "";
+uiItemR(prop_row, md_ptr, rna_path.c_str(), 0, name, ICON_NONE);
+uiItemDecoratorR(layout, md_ptr, rna_path.c_str(), -1);
   }
 
   PointerRNA props;
@@ -1603,16 +1616,6 @@ static void add_attribute_search_or_value_buttons(const 
bContext &C,
   &props);
   RNA_string_set(&props, "modifier_name", nmd.modifier.name);
   RNA_string_set(&props, "prop_path", rna_path_use_attribute.c_str());
-
-  const int use_attribute = RNA_int_get(md_ptr, 
rna_path_use_attribute.c_str()) != 0;
-  if (use_attribute) {
-add_attribute_search_button(C, prop_row, nmd, md_ptr, 
rna_path_attribute_name, socket, false);
-  }
-  else {
-const char *name = socket.type == SOCK_BOOLEAN ? socket.name : "";
-uiItemR(prop_row, md_ptr, rna_path.c_str(), 0, name, ICON_NONE);
-uiItemDecoratorR(layout, md_ptr, rna_path.c_str(), -1);
-  }
 }
 
 /* Drawing the properties manually with #uiItemR instead of #uiDefAutoButsRNA 
allows using
@@ -1678,6 +1681,9 @@ static void draw_property_for_socket(const bContext &C,
   }
 }
   }
+  if (!input_has_attribute_toggle(*nmd->node_group, socket_index)) {
+uiItemL(row, "", ICON_BLANK1);
+  }
 }
 
 static void draw_property_for_output_socket(const bContext &C,

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [891fe70d7f0] master: Fix T103739: Nodes pasted at wrong position with UI scale

2023-01-09 Thread Leon Schittek
Commit: 891fe70d7f0a84573b94379d067f00fb0469b0c2
Author: Leon Schittek
Date:   Mon Jan 9 11:37:27 2023 -0500
Branches: master
https://developer.blender.org/rB891fe70d7f0a84573b94379d067f00fb0469b0c2

Fix T103739: Nodes pasted at wrong position with UI scale

===

M   source/blender/editors/space_node/clipboard.cc

===

diff --git a/source/blender/editors/space_node/clipboard.cc 
b/source/blender/editors/space_node/clipboard.cc
index beda081eec8..95c1c25e343 100644
--- a/source/blender/editors/space_node/clipboard.cc
+++ b/source/blender/editors/space_node/clipboard.cc
@@ -257,11 +257,10 @@ static int node_clipboard_paste_exec(bContext *C, 
wmOperator *op)
 }
 /* DPI factor needs to be removed when computing a View2D offset from 
drawing rects. */
 center /= clipboard.nodes.size();
-center /= UI_DPI_FAC;
 
 float2 mouse_location;
 RNA_property_float_get_array(op->ptr, offset_prop, mouse_location);
-const float2 offset = mouse_location - center;
+const float2 offset = (mouse_location - center) / UI_DPI_FAC;
 
 for (bNode *new_node : node_map.values()) {
   new_node->locx += offset.x;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [85990c877cb] master: Merge branch 'blender-v3.4-release'

2022-11-21 Thread Leon Schittek
Commit: 85990c877cb6529660de19d8eb831803e2e22aa1
Author: Leon Schittek
Date:   Mon Nov 21 11:45:12 2022 +0100
Branches: master
https://developer.blender.org/rB85990c877cb6529660de19d8eb831803e2e22aa1

Merge branch 'blender-v3.4-release'

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [b75946bcb6a] blender-v3.4-release: Fix T102620: Display dynamic socket label in uiTemplateNodeView

2022-11-21 Thread Leon Schittek
Commit: b75946bcb6ab14cd37f6be5dbbf0b14d74d297e8
Author: Leon Schittek
Date:   Mon Nov 21 11:39:58 2022 +0100
Branches: blender-v3.4-release
https://developer.blender.org/rBb75946bcb6ab14cd37f6be5dbbf0b14d74d297e8

Fix T102620: Display dynamic socket label in uiTemplateNodeView

Some nodes, like Combine Color or the math nodes, label sockets
differently depending on the mode to be more descriptive.
`uiTemplateNodeView` now also uses this dynamic label rather than the
socket's name for labeling in the UI so the shown labels always match
the ones on the node itself.

Reviewed By: Hans Goudey

Differential Revision: http://developer.blender.org/D16563

===

M   source/blender/editors/space_node/node_templates.cc

===

diff --git a/source/blender/editors/space_node/node_templates.cc 
b/source/blender/editors/space_node/node_templates.cc
index 1b7eadd336a..0027a965267 100644
--- a/source/blender/editors/space_node/node_templates.cc
+++ b/source/blender/editors/space_node/node_templates.cc
@@ -830,7 +830,7 @@ static void ui_node_draw_input(
 
 sub = uiLayoutRow(sub, true);
 uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_RIGHT);
-uiItemL(sub, IFACE_(input.name), ICON_NONE);
+uiItemL(sub, IFACE_(nodeSocketLabel(&input)), ICON_NONE);
   }
 
   if (dependency_loop) {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [dfb157f9c43] master: Merge branch 'blender-v3.4-release'

2022-11-19 Thread Leon Schittek
Commit: dfb157f9c43bbe1679373bf959879b3e04ef8533
Author: Leon Schittek
Date:   Sat Nov 19 19:09:49 2022 +0100
Branches: master
https://developer.blender.org/rBdfb157f9c43bbe1679373bf959879b3e04ef8533

Merge branch 'blender-v3.4-release'

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [331e8007ed4] blender-v3.4-release: Fix T102520: Positioning of nodes added via search

2022-11-19 Thread Leon Schittek
Commit: 331e8007ed403ea30bc74f2eeaa40399212a5a18
Author: Leon Schittek
Date:   Sat Nov 19 19:03:38 2022 +0100
Branches: blender-v3.4-release
https://developer.blender.org/rB331e8007ed403ea30bc74f2eeaa40399212a5a18

Fix T102520: Positioning of nodes added via search

Always position the nodes added with the node search at the point where
the search operator was invoked by ensuring the operator context is the
main node editor region.

This was an unintended change of rBbdb57541475f, caused by the operator
now getting the cursor position in region space. So when the operator
was called from the menu, it would get the cursor position in the
region space of the menu, which lead to an offset when adding the node
since it expected the coordinates to be in the space of the node editor.

Setting the correct operator context also fixes inconsistent transform
sensitivity depending on zoom when adding nodes via the search in the
menu which has been an issue since as far back as Blender 2.79.

Also includes a small fix for the vertical offset of nodes added by the
search which varied depending on the UI scale. Same fix as in
rB998ffcbf096e.

Reviewed By: Hans Goudey

Differential Revision: http://developer.blender.org/D16555

===

M   release/scripts/startup/bl_ui/space_node.py
M   source/blender/editors/space_node/add_node_search.cc

===

diff --git a/release/scripts/startup/bl_ui/space_node.py 
b/release/scripts/startup/bl_ui/space_node.py
index 593c6400529..90744d9f359 100644
--- a/release/scripts/startup/bl_ui/space_node.py
+++ b/release/scripts/startup/bl_ui/space_node.py
@@ -219,7 +219,7 @@ class NODE_MT_add(bpy.types.Menu):
 import nodeitems_utils
 
 layout = self.layout
-layout.operator_context = 'INVOKE_DEFAULT'
+layout.operator_context = 'INVOKE_REGION_WIN'
 
 snode = context.space_data
 if snode.tree_type == 'GeometryNodeTree':
diff --git a/source/blender/editors/space_node/add_node_search.cc 
b/source/blender/editors/space_node/add_node_search.cc
index 28e18c20f46..eccc6848b8e 100644
--- a/source/blender/editors/space_node/add_node_search.cc
+++ b/source/blender/editors/space_node/add_node_search.cc
@@ -256,7 +256,7 @@ static void add_node_search_exec_fn(bContext *C, void 
*arg1, void *arg2)
   }
 
   new_node->locx = storage.cursor.x / UI_DPI_FAC;
-  new_node->locy = storage.cursor.y / UI_DPI_FAC + 20 * UI_DPI_FAC;
+  new_node->locy = storage.cursor.y / UI_DPI_FAC + 20;
 
   nodeSetSelected(new_node, true);
   nodeSetActive(&node_tree, new_node);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [8d77973dd76] master: Fix T99125: Curve mapping widget removes all vector points

2022-11-17 Thread Leon Schittek
Commit: 8d77973dd76c4913ae394eedb633c9d307a92851
Author: Leon Schittek
Date:   Thu Nov 17 21:54:30 2022 +0100
Branches: master
https://developer.blender.org/rB8d77973dd76c4913ae394eedb633c9d307a92851

Fix T99125: Curve mapping widget removes all vector points

Add a new flag value `CUMA_REMOVE` to explicitly tag duplicate points
for removal. This prevents a bug where all curve points with vector
handles were deleted, when removing duplicate curve points while
updating the widget. This happened, because the flag value used to tag
points for removal was the same as the value of `CUMA_HANDLE_VECTOR`
used to store the handle type of the curve point.

Reviewed By: Hans Goudey

Differential Revision: http://developer.blender.org/D16463

===

M   source/blender/blenkernel/intern/colortools.c
M   source/blender/makesdna/DNA_color_types.h

===

diff --git a/source/blender/blenkernel/intern/colortools.c 
b/source/blender/blenkernel/intern/colortools.c
index 837eb892056..882abe6cc8d 100644
--- a/source/blender/blenkernel/intern/colortools.c
+++ b/source/blender/blenkernel/intern/colortools.c
@@ -908,13 +908,13 @@ void BKE_curvemapping_changed(CurveMapping *cumap, const 
bool rem_doubles)
   dy = cmp[a].y - cmp[a + 1].y;
   if (sqrtf(dx * dx + dy * dy) < thresh) {
 if (a == 0) {
-  cmp[a + 1].flag |= CUMA_HANDLE_VECTOR;
+  cmp[a + 1].flag |= CUMA_REMOVE;
   if (cmp[a + 1].flag & CUMA_SELECT) {
 cmp[a].flag |= CUMA_SELECT;
   }
 }
 else {
-  cmp[a].flag |= CUMA_HANDLE_VECTOR;
+  cmp[a].flag |= CUMA_REMOVE;
   if (cmp[a].flag & CUMA_SELECT) {
 cmp[a + 1].flag |= CUMA_SELECT;
   }
@@ -923,7 +923,7 @@ void BKE_curvemapping_changed(CurveMapping *cumap, const 
bool rem_doubles)
   }
 }
 if (a != cuma->totpoint - 1) {
-  BKE_curvemap_remove(cuma, 2);
+  BKE_curvemap_remove(cuma, CUMA_REMOVE);
 }
   }
   curvemap_make_table(cumap, cuma);
diff --git a/source/blender/makesdna/DNA_color_types.h 
b/source/blender/makesdna/DNA_color_types.h
index 4eb64290032..d3b7c37ab0e 100644
--- a/source/blender/makesdna/DNA_color_types.h
+++ b/source/blender/makesdna/DNA_color_types.h
@@ -35,6 +35,8 @@ enum {
   CUMA_SELECT = (1 << 0),
   CUMA_HANDLE_VECTOR = (1 << 1),
   CUMA_HANDLE_AUTO_ANIM = (1 << 2),
+  /** Temporary tag for point deletion. */
+  CUMA_REMOVE = (1 << 3),
 };
 
 typedef struct CurveMap {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [9de35e396bf] blender-v3.4-release: Fix T99125: Curve mapping widget removes all vector points

2022-11-17 Thread Leon Schittek
Commit: 9de35e396bfd1b4b44847d0fb6be86a7e788f703
Author: Leon Schittek
Date:   Thu Nov 17 21:54:30 2022 +0100
Branches: blender-v3.4-release
https://developer.blender.org/rB9de35e396bfd1b4b44847d0fb6be86a7e788f703

Fix T99125: Curve mapping widget removes all vector points

Add a new flag value `CUMA_REMOVE` to explicitly tag duplicate points
for removal. This prevents a bug where all curve points with vector
handles were deleted, when removing duplicate curve points while
updating the widget. This happened, because the flag value used to tag
points for removal was the same as the value of `CUMA_HANDLE_VECTOR`
used to store the handle type of the curve point.

Reviewed By: Hans Goudey

Differential Revision: http://developer.blender.org/D16463

===

M   source/blender/blenkernel/intern/colortools.c
M   source/blender/makesdna/DNA_color_types.h

===

diff --git a/source/blender/blenkernel/intern/colortools.c 
b/source/blender/blenkernel/intern/colortools.c
index 837eb892056..882abe6cc8d 100644
--- a/source/blender/blenkernel/intern/colortools.c
+++ b/source/blender/blenkernel/intern/colortools.c
@@ -908,13 +908,13 @@ void BKE_curvemapping_changed(CurveMapping *cumap, const 
bool rem_doubles)
   dy = cmp[a].y - cmp[a + 1].y;
   if (sqrtf(dx * dx + dy * dy) < thresh) {
 if (a == 0) {
-  cmp[a + 1].flag |= CUMA_HANDLE_VECTOR;
+  cmp[a + 1].flag |= CUMA_REMOVE;
   if (cmp[a + 1].flag & CUMA_SELECT) {
 cmp[a].flag |= CUMA_SELECT;
   }
 }
 else {
-  cmp[a].flag |= CUMA_HANDLE_VECTOR;
+  cmp[a].flag |= CUMA_REMOVE;
   if (cmp[a].flag & CUMA_SELECT) {
 cmp[a + 1].flag |= CUMA_SELECT;
   }
@@ -923,7 +923,7 @@ void BKE_curvemapping_changed(CurveMapping *cumap, const 
bool rem_doubles)
   }
 }
 if (a != cuma->totpoint - 1) {
-  BKE_curvemap_remove(cuma, 2);
+  BKE_curvemap_remove(cuma, CUMA_REMOVE);
 }
   }
   curvemap_make_table(cumap, cuma);
diff --git a/source/blender/makesdna/DNA_color_types.h 
b/source/blender/makesdna/DNA_color_types.h
index 4eb64290032..d3b7c37ab0e 100644
--- a/source/blender/makesdna/DNA_color_types.h
+++ b/source/blender/makesdna/DNA_color_types.h
@@ -35,6 +35,8 @@ enum {
   CUMA_SELECT = (1 << 0),
   CUMA_HANDLE_VECTOR = (1 << 1),
   CUMA_HANDLE_AUTO_ANIM = (1 << 2),
+  /** Temporary tag for point deletion. */
+  CUMA_REMOVE = (1 << 3),
 };
 
 typedef struct CurveMap {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [c932fd79ac0] master: Merge branch 'blender-v3.4-release'

2022-11-09 Thread Leon Schittek
Commit: c932fd79ac0af751f0d6b5e0c58d5b7c01af2138
Author: Leon Schittek
Date:   Wed Nov 9 22:38:25 2022 +0100
Branches: master
https://developer.blender.org/rBc932fd79ac0af751f0d6b5e0c58d5b7c01af2138

Merge branch 'blender-v3.4-release'

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [c8cec113536] blender-v3.4-release: Fix T102385: Set frame node active after joining nodes

2022-11-09 Thread Leon Schittek
Commit: c8cec113536c6d931847b08b03745f90c34a0339
Author: Leon Schittek
Date:   Wed Nov 9 22:26:03 2022 +0100
Branches: blender-v3.4-release
https://developer.blender.org/rBc8cec113536c6d931847b08b03745f90c34a0339

Fix T102385: Set frame node active after joining nodes

Set the created frame node to be the active node when joining nodes
with the `NODE_OT_join` operator.

This behavior was unintentonaly changed in rB545fb528d5e1 when the
operator's execute function was simplified by utilizing the node tree
topology cache.

Reviewed By: Hans Goudey

Differential Revision: http://developer.blender.org/D16440

===

M   source/blender/editors/space_node/node_relationships.cc

===

diff --git a/source/blender/editors/space_node/node_relationships.cc 
b/source/blender/editors/space_node/node_relationships.cc
index 637c795d4d7..8eeba8727dc 100644
--- a/source/blender/editors/space_node/node_relationships.cc
+++ b/source/blender/editors/space_node/node_relationships.cc
@@ -1678,6 +1678,7 @@ static int node_join_exec(bContext *C, wmOperator * 
/*op*/)
   const Set selected_nodes = get_selected_nodes(ntree);
 
   bNode *frame_node = nodeAddStaticNode(C, &ntree, NODE_FRAME);
+  nodeSetActive(&ntree, frame_node);
 
   /* reset tags */
   LISTBASE_FOREACH (bNode *, node, &ntree.nodes) {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [8eab23bc66e] master: Geometry Nodes: Fix alignment of exposed properties in the modifier

2022-11-08 Thread Leon Schittek
Commit: 8eab23bc66e06b9c5a496e0f7865403094e1799b
Author: Leon Schittek
Date:   Tue Nov 8 19:09:28 2022 +0100
Branches: master
https://developer.blender.org/rB8eab23bc66e06b9c5a496e0f7865403094e1799b

Geometry Nodes: Fix alignment of exposed properties in the modifier

The spacing and alignment of the properties in the geometry nodes
modifier could vary depending on the type of the socket or
whether the input can accept attributes.
Wrapping each property in its own `row` layout allows us to make
the spacing and alignment between them consistent.

Reviewed By: Hans Goudey

Differential Revision: http://developer.blender.org/D16417

===

M   source/blender/modifiers/intern/MOD_nodes.cc

===

diff --git a/source/blender/modifiers/intern/MOD_nodes.cc 
b/source/blender/modifiers/intern/MOD_nodes.cc
index c032ee35639..15d7e494c04 100644
--- a/source/blender/modifiers/intern/MOD_nodes.cc
+++ b/source/blender/modifiers/intern/MOD_nodes.cc
@@ -1542,15 +1542,18 @@ static void add_attribute_search_or_value_buttons(const 
bContext &C,
   const std::string rna_path_attribute_name = "[\"" + 
std::string(socket_id_esc) +
   attribute_name_suffix + "\"]";
 
+  /* We're handling this manually in this case. */
+  uiLayoutSetPropDecorate(layout, false);
+
   uiLayout *split = uiLayoutSplit(layout, 0.4f, false);
   uiLayout *name_row = uiLayoutRow(split, false);
   uiLayoutSetAlignment(name_row, UI_LAYOUT_ALIGN_RIGHT);
   uiItemL(name_row, socket.name, ICON_NONE);
 
-  uiLayout *row = uiLayoutRow(split, true);
+  uiLayout *prop_row = uiLayoutRow(split, true);
 
   PointerRNA props;
-  uiItemFullO(row,
+  uiItemFullO(prop_row,
   "object.geometry_nodes_input_attribute_toggle",
   "",
   ICON_SPREADSHEET,
@@ -1563,12 +1566,12 @@ static void add_attribute_search_or_value_buttons(const 
bContext &C,
 
   const int use_attribute = RNA_int_get(md_ptr, 
rna_path_use_attribute.c_str()) != 0;
   if (use_attribute) {
-add_attribute_search_button(C, row, nmd, md_ptr, rna_path_attribute_name, 
socket, false);
-uiItemL(row, "", ICON_BLANK1);
+add_attribute_search_button(C, prop_row, nmd, md_ptr, 
rna_path_attribute_name, socket, false);
+uiItemL(layout, "", ICON_BLANK1);
   }
   else {
-uiItemR(row, md_ptr, rna_path.c_str(), 0, "", ICON_NONE);
-uiItemDecoratorR(row, md_ptr, rna_path.c_str(), -1);
+uiItemR(prop_row, md_ptr, rna_path.c_str(), 0, "", ICON_NONE);
+uiItemDecoratorR(layout, md_ptr, rna_path.c_str(), -1);
   }
 }
 
@@ -1598,44 +1601,39 @@ static void draw_property_for_socket(const bContext &C,
   char rna_path[sizeof(socket_id_esc) + 4];
   BLI_snprintf(rna_path, ARRAY_SIZE(rna_path), "[\"%s\"]", socket_id_esc);
 
+  uiLayout *row = uiLayoutRow(layout, true);
+  uiLayoutSetPropDecorate(row, true);
+
   /* Use #uiItemPointerR to draw pointer properties because #uiItemR would not 
have enough
* information about what type of ID to select for editing the values. This 
is because
* pointer IDProperties contain no information about their type. */
   switch (socket.type) {
 case SOCK_OBJECT: {
-  uiItemPointerR(
-  layout, md_ptr, rna_path, bmain_ptr, "objects", socket.name, 
ICON_OBJECT_DATA);
+  uiItemPointerR(row, md_ptr, rna_path, bmain_ptr, "objects", socket.name, 
ICON_OBJECT_DATA);
   break;
 }
 case SOCK_COLLECTION: {
-  uiItemPointerR(layout,
- md_ptr,
- rna_path,
- bmain_ptr,
- "collections",
- socket.name,
- ICON_OUTLINER_COLLECTION);
+  uiItemPointerR(
+  row, md_ptr, rna_path, bmain_ptr, "collections", socket.name, 
ICON_OUTLINER_COLLECTION);
   break;
 }
 case SOCK_MATERIAL: {
-  uiItemPointerR(layout, md_ptr, rna_path, bmain_ptr, "materials", 
socket.name, ICON_MATERIAL);
+  uiItemPointerR(row, md_ptr, rna_path, bmain_ptr, "materials", 
socket.name, ICON_MATERIAL);
   break;
 }
 case SOCK_TEXTURE: {
-  uiItemPointerR(layout, md_ptr, rna_path, bmain_ptr, "textures", 
socket.name, ICON_TEXTURE);
+  uiItemPointerR(row, md_ptr, rna_path, bmain_ptr, "textures", 
socket.name, ICON_TEXTURE);
   break;
 }
 case SOCK_IMAGE: {
-  uiItemPointerR(layout, md_ptr, rna_path, bmain_ptr, "images", 
socket.name, ICON_IMAGE);
+  uiItemPointerR(row, md_ptr, rna_path, bmain_ptr, "images", socket.name, 
ICON_IMAGE);
   break;
 }
 default: {
   if (input_has_attribute_toggle(*nmd->node_group, socket_index)) {
- 

[Bf-blender-cvs] [fd352160253] blender-v3.4-release: Geometry Nodes: Fix alignment of exposed properties in the modifier

2022-11-08 Thread Leon Schittek
Commit: fd352160253c57f14e9ce5aaf8009305fd8bc63d
Author: Leon Schittek
Date:   Tue Nov 8 19:09:28 2022 +0100
Branches: blender-v3.4-release
https://developer.blender.org/rBfd352160253c57f14e9ce5aaf8009305fd8bc63d

Geometry Nodes: Fix alignment of exposed properties in the modifier

The spacing and alignment of the properties in the geometry nodes
modifier could vary depending on the type of the socket or
whether the input can accept attributes.
Wrapping each property in its own `row` layout allows us to make
the spacing and alignment between them consistent.

Reviewed By: Hans Goudey

Differential Revision: http://developer.blender.org/D16417

===

M   source/blender/modifiers/intern/MOD_nodes.cc

===

diff --git a/source/blender/modifiers/intern/MOD_nodes.cc 
b/source/blender/modifiers/intern/MOD_nodes.cc
index c032ee35639..15d7e494c04 100644
--- a/source/blender/modifiers/intern/MOD_nodes.cc
+++ b/source/blender/modifiers/intern/MOD_nodes.cc
@@ -1542,15 +1542,18 @@ static void add_attribute_search_or_value_buttons(const 
bContext &C,
   const std::string rna_path_attribute_name = "[\"" + 
std::string(socket_id_esc) +
   attribute_name_suffix + "\"]";
 
+  /* We're handling this manually in this case. */
+  uiLayoutSetPropDecorate(layout, false);
+
   uiLayout *split = uiLayoutSplit(layout, 0.4f, false);
   uiLayout *name_row = uiLayoutRow(split, false);
   uiLayoutSetAlignment(name_row, UI_LAYOUT_ALIGN_RIGHT);
   uiItemL(name_row, socket.name, ICON_NONE);
 
-  uiLayout *row = uiLayoutRow(split, true);
+  uiLayout *prop_row = uiLayoutRow(split, true);
 
   PointerRNA props;
-  uiItemFullO(row,
+  uiItemFullO(prop_row,
   "object.geometry_nodes_input_attribute_toggle",
   "",
   ICON_SPREADSHEET,
@@ -1563,12 +1566,12 @@ static void add_attribute_search_or_value_buttons(const 
bContext &C,
 
   const int use_attribute = RNA_int_get(md_ptr, 
rna_path_use_attribute.c_str()) != 0;
   if (use_attribute) {
-add_attribute_search_button(C, row, nmd, md_ptr, rna_path_attribute_name, 
socket, false);
-uiItemL(row, "", ICON_BLANK1);
+add_attribute_search_button(C, prop_row, nmd, md_ptr, 
rna_path_attribute_name, socket, false);
+uiItemL(layout, "", ICON_BLANK1);
   }
   else {
-uiItemR(row, md_ptr, rna_path.c_str(), 0, "", ICON_NONE);
-uiItemDecoratorR(row, md_ptr, rna_path.c_str(), -1);
+uiItemR(prop_row, md_ptr, rna_path.c_str(), 0, "", ICON_NONE);
+uiItemDecoratorR(layout, md_ptr, rna_path.c_str(), -1);
   }
 }
 
@@ -1598,44 +1601,39 @@ static void draw_property_for_socket(const bContext &C,
   char rna_path[sizeof(socket_id_esc) + 4];
   BLI_snprintf(rna_path, ARRAY_SIZE(rna_path), "[\"%s\"]", socket_id_esc);
 
+  uiLayout *row = uiLayoutRow(layout, true);
+  uiLayoutSetPropDecorate(row, true);
+
   /* Use #uiItemPointerR to draw pointer properties because #uiItemR would not 
have enough
* information about what type of ID to select for editing the values. This 
is because
* pointer IDProperties contain no information about their type. */
   switch (socket.type) {
 case SOCK_OBJECT: {
-  uiItemPointerR(
-  layout, md_ptr, rna_path, bmain_ptr, "objects", socket.name, 
ICON_OBJECT_DATA);
+  uiItemPointerR(row, md_ptr, rna_path, bmain_ptr, "objects", socket.name, 
ICON_OBJECT_DATA);
   break;
 }
 case SOCK_COLLECTION: {
-  uiItemPointerR(layout,
- md_ptr,
- rna_path,
- bmain_ptr,
- "collections",
- socket.name,
- ICON_OUTLINER_COLLECTION);
+  uiItemPointerR(
+  row, md_ptr, rna_path, bmain_ptr, "collections", socket.name, 
ICON_OUTLINER_COLLECTION);
   break;
 }
 case SOCK_MATERIAL: {
-  uiItemPointerR(layout, md_ptr, rna_path, bmain_ptr, "materials", 
socket.name, ICON_MATERIAL);
+  uiItemPointerR(row, md_ptr, rna_path, bmain_ptr, "materials", 
socket.name, ICON_MATERIAL);
   break;
 }
 case SOCK_TEXTURE: {
-  uiItemPointerR(layout, md_ptr, rna_path, bmain_ptr, "textures", 
socket.name, ICON_TEXTURE);
+  uiItemPointerR(row, md_ptr, rna_path, bmain_ptr, "textures", 
socket.name, ICON_TEXTURE);
   break;
 }
 case SOCK_IMAGE: {
-  uiItemPointerR(layout, md_ptr, rna_path, bmain_ptr, "images", 
socket.name, ICON_IMAGE);
+  uiItemPointerR(row, md_ptr, rna_path, bmain_ptr, "images", socket.name, 
ICON_IMAGE);
   break;
 }
 default: {
   if (input_has_attribute_toggle(*nmd->node_group, socket_index)) {
- 

[Bf-blender-cvs] [707c7de21f0] master: Fix T101628: Correct frame node intersection in add reroute operator

2022-10-05 Thread Leon Schittek
Commit: 707c7de21f0bc9a1ca4e71ef4819dafada5542ac
Author: Leon Schittek
Date:   Thu Oct 6 07:32:04 2022 +0200
Branches: master
https://developer.blender.org/rB707c7de21f0bc9a1ca4e71ef4819dafada5542ac

Fix T101628: Correct frame node intersection in add reroute operator

Fix reroute nodes added via the cut link gesture being parented to the
wrong frame node.

The frame's bounds that are used for the intersection test with the
newly added reroute are in view space, but the reroute's location was
given in the node tree's coordinate space, when the add reroute
operator was recently refactored (56193eccf646).

Reviewed By: Hans Goudey

Differential Revision: http://developer.blender.org/D16163

===

M   source/blender/editors/space_node/node_add.cc

===

diff --git a/source/blender/editors/space_node/node_add.cc 
b/source/blender/editors/space_node/node_add.cc
index 943fc99a7f6..07eecff320a 100644
--- a/source/blender/editors/space_node/node_add.cc
+++ b/source/blender/editors/space_node/node_add.cc
@@ -194,15 +194,16 @@ static int add_reroute_exec(bContext *C, wmOperator *op)
 }
 
 /* Place the new reroute at the average location of all connected cuts. */
-const float2 loc = std::accumulate(cuts.values().begin(), 
cuts.values().end(), float2(0)) /
-   cuts.size() / UI_DPI_FAC;
-reroute->locx = loc.x;
-reroute->locy = loc.y;
+const float2 insert_point = std::accumulate(
+cuts.values().begin(), 
cuts.values().end(), float2(0)) /
+cuts.size();
+reroute->locx = insert_point.x / UI_DPI_FAC;
+reroute->locy = insert_point.y / UI_DPI_FAC;
 
 /* Attach the reroute node to frame nodes behind it. */
 for (const int i : frame_nodes.index_range()) {
   bNode *frame_node = frame_nodes.last(i);
-  if (BLI_rctf_isect_pt_v(&frame_node->totr, loc)) {
+  if (BLI_rctf_isect_pt_v(&frame_node->totr, insert_point)) {
 nodeAttachNode(reroute, frame_node);
 break;
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [67308d73a4f] master: Node Editor: Adjust node link curving

2022-09-23 Thread Leon Schittek
Commit: 67308d73a4f9ec34ef42ad22d48dad5840a8a5fd
Author: Leon Schittek
Date:   Fri Sep 23 17:54:27 2022 +0200
Branches: master
https://developer.blender.org/rB67308d73a4f9ec34ef42ad22d48dad5840a8a5fd

Node Editor: Adjust node link curving

Clamp node link curving when the link is close to horizontal to prevent
overshooting at the ends.

Reviewed By: Pablo Vazquez, Hans Goudey

Differential Revision: http://developer.blender.org/D16041

===

M   source/blender/editors/space_node/drawnode.cc

===

diff --git a/source/blender/editors/space_node/drawnode.cc 
b/source/blender/editors/space_node/drawnode.cc
index fbbdd40e92e..b2510df9105 100644
--- a/source/blender/editors/space_node/drawnode.cc
+++ b/source/blender/editors/space_node/drawnode.cc
@@ -1604,12 +1604,19 @@ static void 
calculate_inner_link_bezier_points(std::array &points)
 points[2] = math::interpolate(points[0], points[3], 2.0f / 3.0f);
   }
   else {
-const float dist = curving * 0.1f * math::distance(points[0].x, 
points[3].x);
+const float dist_x = math::distance(points[0].x, points[3].x);
+const float dist_y = math::distance(points[0].y, points[3].y);
 
-points[1].x = points[0].x + dist;
+/* Reduce the handle offset when the link endpoints are close to 
horizontal. */
+const float slope = safe_divide(dist_y, dist_x);
+const float clamp_factor = math::min(1.0f, slope * (4.5f - 0.25f * 
float(curving)));
+
+const float handle_offset = curving * 0.1f * dist_x * clamp_factor;
+
+points[1].x = points[0].x + handle_offset;
 points[1].y = points[0].y;
 
-points[2].x = points[3].x - dist;
+points[2].x = points[3].x - handle_offset;
 points[2].y = points[3].y;
   }
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [4932d833f16] temp-T97352-3d-texturing-seam-bleeding-b2: Fix: Prevent clipping of node drop shadow

2022-09-20 Thread Leon Schittek
Commit: 4932d833f165871e60bc5eda466b359e1caa6582
Author: Leon Schittek
Date:   Sun Sep 18 20:39:14 2022 +0200
Branches: temp-T97352-3d-texturing-seam-bleeding-b2
https://developer.blender.org/rB4932d833f165871e60bc5eda466b359e1caa6582

Fix: Prevent clipping of node drop shadow

Fix clipping artifacts of node drop shadows that could occur
on hidden nodes, when using higher UI scaling.

Reviewed By: Hans Goudey

Differential Revision: http://developer.blender.org/D16007

===

M   source/blender/editors/interface/interface_draw.c

===

diff --git a/source/blender/editors/interface/interface_draw.c 
b/source/blender/editors/interface/interface_draw.c
index 190830568e3..f1a324c411a 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -2307,9 +2307,6 @@ void UI_draw_box_shadow(const rctf *rect, uchar alpha)
 void ui_draw_dropshadow(
 const rctf *rct, float radius, float aspect, float alpha, int 
UNUSED(select))
 {
-  const float max_radius = (BLI_rctf_size_y(rct) - 10.0f) * 0.5f;
-  const float rad = min_ff(radius, max_radius);
-
   /* This undoes the scale of the view for higher zoom factors to clamp the 
shadow size. */
   const float clamped_aspect = smoothminf(aspect, 1.0f, 0.5f);
 
@@ -2317,6 +2314,9 @@ void ui_draw_dropshadow(
   const float shadow_offset = 0.5f * U.widget_unit * clamped_aspect;
   const float shadow_alpha = 0.5f * alpha;
 
+  const float max_radius = (BLI_rctf_size_y(rct) - shadow_offset) * 0.5f;
+  const float rad = min_ff(radius, max_radius);
+
   GPU_blend(GPU_BLEND_ALPHA);
 
   uiWidgetBaseParameters widget_params = {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [d5e65790ec2] temp-T97352-3d-texturing-seam-bleeding-b2: Fix: Make node position consistent when added through link drag search

2022-09-20 Thread Leon Schittek
Commit: d5e65790ec24667d89d28e686ba739bcfd135892
Author: Leon Schittek
Date:   Sun Sep 18 20:18:50 2022 +0200
Branches: temp-T97352-3d-texturing-seam-bleeding-b2
https://developer.blender.org/rBd5e65790ec24667d89d28e686ba739bcfd135892

Fix: Make node position consistent when added through link drag search

The node position is specified in the coordinate space of the node
editor. The cursor position has to be divided by `UI_DPI_FAC` since it's
in view space but the offset is independent of any ui scaling.

Reviewed By: Hans Goudey

Differential Revision: http://developer.blender.org/D16006

===

M   source/blender/editors/space_node/link_drag_search.cc

===

diff --git a/source/blender/editors/space_node/link_drag_search.cc 
b/source/blender/editors/space_node/link_drag_search.cc
index f1387da97b5..03bd0b5b36a 100644
--- a/source/blender/editors/space_node/link_drag_search.cc
+++ b/source/blender/editors/space_node/link_drag_search.cc
@@ -214,7 +214,7 @@ static void link_drag_search_exec_fn(bContext *C, void 
*arg1, void *arg2)
   bNode *new_node = new_nodes.first();
 
   new_node->locx = storage.cursor.x / UI_DPI_FAC;
-  new_node->locy = storage.cursor.y / UI_DPI_FAC + 20 * UI_DPI_FAC;
+  new_node->locy = storage.cursor.y / UI_DPI_FAC + 20;
   if (storage.in_out() == SOCK_IN) {
 new_node->locx -= new_node->width;
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [53c92efd5a5] master: Fix: Prevent clipping of node drop shadow

2022-09-18 Thread Leon Schittek
Commit: 53c92efd5a524ae6fd9172cdb23b5e787456f498
Author: Leon Schittek
Date:   Sun Sep 18 20:39:14 2022 +0200
Branches: master
https://developer.blender.org/rB53c92efd5a524ae6fd9172cdb23b5e787456f498

Fix: Prevent clipping of node drop shadow

Fix clipping artifacts of node drop shadows that could occur
on hidden nodes, when using higher UI scaling.

Reviewed By: Hans Goudey

Differential Revision: http://developer.blender.org/D16007

===

M   source/blender/editors/interface/interface_draw.c

===

diff --git a/source/blender/editors/interface/interface_draw.c 
b/source/blender/editors/interface/interface_draw.c
index 190830568e3..f1a324c411a 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -2307,9 +2307,6 @@ void UI_draw_box_shadow(const rctf *rect, uchar alpha)
 void ui_draw_dropshadow(
 const rctf *rct, float radius, float aspect, float alpha, int 
UNUSED(select))
 {
-  const float max_radius = (BLI_rctf_size_y(rct) - 10.0f) * 0.5f;
-  const float rad = min_ff(radius, max_radius);
-
   /* This undoes the scale of the view for higher zoom factors to clamp the 
shadow size. */
   const float clamped_aspect = smoothminf(aspect, 1.0f, 0.5f);
 
@@ -2317,6 +2314,9 @@ void ui_draw_dropshadow(
   const float shadow_offset = 0.5f * U.widget_unit * clamped_aspect;
   const float shadow_alpha = 0.5f * alpha;
 
+  const float max_radius = (BLI_rctf_size_y(rct) - shadow_offset) * 0.5f;
+  const float rad = min_ff(radius, max_radius);
+
   GPU_blend(GPU_BLEND_ALPHA);
 
   uiWidgetBaseParameters widget_params = {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [998ffcbf096] master: Fix: Make node position consistent when added through link drag search

2022-09-18 Thread Leon Schittek
Commit: 998ffcbf096eb1f2dd04ac8c762db1f6074a1c8a
Author: Leon Schittek
Date:   Sun Sep 18 20:18:50 2022 +0200
Branches: master
https://developer.blender.org/rB998ffcbf096eb1f2dd04ac8c762db1f6074a1c8a

Fix: Make node position consistent when added through link drag search

The node position is specified in the coordinate space of the node
editor. The cursor position has to be divided by `UI_DPI_FAC` since it's
in view space but the offset is independent of any ui scaling.

Reviewed By: Hans Goudey

Differential Revision: http://developer.blender.org/D16006

===

M   source/blender/editors/space_node/link_drag_search.cc

===

diff --git a/source/blender/editors/space_node/link_drag_search.cc 
b/source/blender/editors/space_node/link_drag_search.cc
index f1387da97b5..03bd0b5b36a 100644
--- a/source/blender/editors/space_node/link_drag_search.cc
+++ b/source/blender/editors/space_node/link_drag_search.cc
@@ -214,7 +214,7 @@ static void link_drag_search_exec_fn(bContext *C, void 
*arg1, void *arg2)
   bNode *new_node = new_nodes.first();
 
   new_node->locx = storage.cursor.x / UI_DPI_FAC;
-  new_node->locy = storage.cursor.y / UI_DPI_FAC + 20 * UI_DPI_FAC;
+  new_node->locy = storage.cursor.y / UI_DPI_FAC + 20;
   if (storage.in_out() == SOCK_IN) {
 new_node->locx -= new_node->width;
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [9a86255da8d] master: Node Editor: Visual tweaks to node links

2022-09-01 Thread Leon Schittek
Commit: 9a86255da8dcf0737dd664abf153c2544803788b
Author: Leon Schittek
Date:   Thu Sep 1 19:46:19 2022 +0200
Branches: master
https://developer.blender.org/rB9a86255da8dcf0737dd664abf153c2544803788b

Node Editor: Visual tweaks to node links

Several visual tweaks to node links to make them overall fit in
better with the look of the node editor:

- Change the link thickness with the zoom level to a certain degree.
- Remove the fuzziness of the node link and its shadow/outline.
- The link outline color can now be made transparent.
- Add circles at the end of dragged links when connecting to sockets.
- Improve the banding of the color interpolation along the link.
- Adjust the spacing of dashes along straight node links.

Reviewed By: Pablo Vazquez, Hans Goudey

Differential Revision: http://developer.blender.org/D15036

===

M   source/blender/editors/space_node/drawnode.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_intern.hh
M   source/blender/gpu/shaders/gpu_shader_2D_nodelink_frag.glsl
M   source/blender/gpu/shaders/gpu_shader_2D_nodelink_vert.glsl
M   source/blender/gpu/shaders/infos/gpu_shader_2D_nodelink_info.hh
M   source/blender/makesrna/intern/rna_userdef.c

===

diff --git a/source/blender/editors/space_node/drawnode.cc 
b/source/blender/editors/space_node/drawnode.cc
index e8325d658ca..262b33dc0a3 100644
--- a/source/blender/editors/space_node/drawnode.cc
+++ b/source/blender/editors/space_node/drawnode.cc
@@ -6,6 +6,7 @@
  * \brief lower level node drawing for nodes (boarders, headers etc), also 
node layout.
  */
 
+#include "BLI_color.hh"
 #include "BLI_system.h"
 #include "BLI_threads.h"
 
@@ -1639,8 +1640,8 @@ bool node_link_bezier_handles(const View2D *v2d,
 
   if (curving == 0) {
 /* Straight line: align all points. */
-mid_v2_v2v2(vec[1], vec[0], vec[3]);
-mid_v2_v2v2(vec[2], vec[1], vec[3]);
+interp_v2_v2v2(vec[1], vec[0], vec[3], 1.0f / 3.0f);
+interp_v2_v2v2(vec[2], vec[0], vec[3], 2.0f / 3.0f);
 return true;
   }
 
@@ -1938,27 +1939,38 @@ void nodelink_batch_end(SpaceNode &snode)
   g_batch_link.enabled = false;
 }
 
+struct NodeLinkDrawConfig {
+  int th_col1;
+  int th_col2;
+  int th_col3;
+
+  ColorTheme4f start_color;
+  ColorTheme4f end_color;
+  ColorTheme4f outline_color;
+
+  bool drawarrow;
+  bool drawmuted;
+  bool highlighted;
+
+  float dim_factor;
+  float thickness;
+  float dash_factor;
+  float dash_alpha;
+};
+
 static void nodelink_batch_add_link(const SpaceNode &snode,
 const float2 &p0,
 const float2 &p1,
 const float2 &p2,
 const float2 &p3,
-int th_col1,
-int th_col2,
-int th_col3,
-const float start_color[4],
-const float end_color[4],
-bool drawarrow,
-bool drawmuted,
-float dim_factor,
-float thickness,
-float dash_factor,
-float dash_alpha)
+const NodeLinkDrawConfig &draw_config)
 {
   /* Only allow these colors. If more is needed, you need to modify the shader 
accordingly. */
-  BLI_assert(ELEM(th_col1, TH_WIRE_INNER, TH_WIRE, TH_ACTIVE, TH_EDGE_SELECT, 
TH_REDALERT));
-  BLI_assert(ELEM(th_col2, TH_WIRE_INNER, TH_WIRE, TH_ACTIVE, TH_EDGE_SELECT, 
TH_REDALERT));
-  BLI_assert(ELEM(th_col3, TH_WIRE, TH_REDALERT, -1));
+  BLI_assert(
+  ELEM(draw_config.th_col1, TH_WIRE_INNER, TH_WIRE, TH_ACTIVE, 
TH_EDGE_SELECT, TH_REDALERT));
+  BLI_assert(
+  ELEM(draw_config.th_col2, TH_WIRE_INNER, TH_WIRE, TH_ACTIVE, 
TH_EDGE_SELECT, TH_REDALERT));
+  BLI_assert(ELEM(draw_config.th_col3, TH_WIRE, TH_REDALERT, -1));
 
   g_batch_link.count++;
   copy_v2_v2((float *)GPU_vertbuf_raw_step(&g_batch_link.p0_step), p0);
@@ -1966,161 +1978,218 @@ static void nodelink_batch_add_link(const SpaceNode 
&snode,
   copy_v2_v2((float *)GPU_vertbuf_raw_step(&g_batch_link.p2_step), p2);
   copy_v2_v2((float *)GPU_vertbuf_raw_step(&g_batch_link.p3_step), p3);
   char *colid = (char *)GPU_vertbuf_raw_step(&g_batch_link.colid_step);
-  colid[0] = nodelink_get_color_id(th_col1);
-  colid[1] = nodelink_get_color_id(th_col2);
-  colid[2] = nodelink_get_color_id(th_col3);
-  colid[3] = drawarrow;
-  copy_v4_v4((float *)GPU_vertbuf_raw_step(&g_batch_

[Bf-blender-cvs] [563404d8ad4] master: Fix T100430: Restore larger node socket snap hitbox

2022-08-21 Thread Leon Schittek
Commit: 563404d8ad44a03443b54c51e502b108fcd42555
Author: Leon Schittek
Date:   Sun Aug 21 10:12:50 2022 +0200
Branches: master
https://developer.blender.org/rB563404d8ad44a03443b54c51e502b108fcd42555

Fix T100430: Restore larger node socket snap hitbox

Restore old hitbox for connecting links to sockets.

Commit rBd9d97db018d2 improved the node socket snapping when nodes
are close together by decreasing the tolerance around the cursor when
checking for nodes in front, that might occlude the socket.
In doing so it also reduced the hitbox of the node socket itself that
extended outside of the node.

This commit restores the old node socket hitbox while keeping the
improved behavior when nodes are close together with the following
changes:
1) When looking for the socket under the cursor, iterate through the
nodes front to back, which prioritizes node sockets in the foreground.
2) Instead of checking for another node underneath the cursor it checks
if the socket is actually occluded by another node.

The way the occlusion test for sockets is tweaked you can now connect to
sockets that are only partially occluded, which is a bit more forgiving
than previously.

Reviewed By: Hans Goudey

Differential Revision: http://developer.blender.org/D15731

===

M   source/blender/editors/space_node/node_edit.cc

===

diff --git a/source/blender/editors/space_node/node_edit.cc 
b/source/blender/editors/space_node/node_edit.cc
index 0b1f2037292..1e01373029d 100644
--- a/source/blender/editors/space_node/node_edit.cc
+++ b/source/blender/editors/space_node/node_edit.cc
@@ -913,15 +913,24 @@ static void edit_node_properties_get(
 /** \name Node Generic
  * \{ */
 
-/* is rct in visible part of node? */
-static bNode *visible_node(SpaceNode &snode, const rctf &rct)
+static bool socket_is_occluded(const bNodeSocket &sock,
+   const bNode &node_the_socket_belongs_to,
+   const SpaceNode &snode)
 {
   LISTBASE_FOREACH_BACKWARD (bNode *, node, &snode.edittree->nodes) {
-if (BLI_rctf_isect(&node->totr, &rct, nullptr)) {
-  return node;
+if (node == &node_the_socket_belongs_to) {
+  /* Nodes after this one are underneath and can't occlude the socket. */
+  return false;
+}
+
+rctf socket_hitbox;
+const float socket_hitbox_radius = NODE_SOCKSIZE - 0.1f * U.widget_unit;
+BLI_rctf_init_pt_radius(&socket_hitbox, float2(sock.locx, sock.locy), 
socket_hitbox_radius);
+if (BLI_rctf_inside_rctf(&node->totr, &socket_hitbox)) {
+  return true;
 }
   }
-  return nullptr;
+  return false;
 }
 
 /** \} */
@@ -1216,10 +1225,8 @@ bool node_find_indicated_socket(SpaceNode &snode,
   *sockp = nullptr;
 
   /* check if we click in a socket */
-  LISTBASE_FOREACH (bNode *, node, &snode.edittree->nodes) {
+  LISTBASE_FOREACH_BACKWARD (bNode *, node, &snode.edittree->nodes) {
 BLI_rctf_init_pt_radius(&rect, cursor, size_sock_padded);
-rctf node_visible;
-BLI_rctf_init_pt_radius(&node_visible, cursor, size_sock_padded);
 
 if (!(node->flag & NODE_HIDDEN)) {
   /* extra padding inside and out - allow dragging on the text areas too */
@@ -1238,7 +1245,7 @@ bool node_find_indicated_socket(SpaceNode &snode,
 if (!nodeSocketIsHidden(sock)) {
   if (sock->flag & SOCK_MULTI_INPUT && !(node->flag & NODE_HIDDEN)) {
 if (cursor_isect_multi_input_socket(cursor, *sock)) {
-  if (node == visible_node(snode, node_visible)) {
+  if (!socket_is_occluded(*sock, *node, snode)) {
 *nodep = node;
 *sockp = sock;
 return true;
@@ -1246,7 +1253,7 @@ bool node_find_indicated_socket(SpaceNode &snode,
 }
   }
   else if (BLI_rctf_isect_pt(&rect, sock->locx, sock->locy)) {
-if (node == visible_node(snode, node_visible)) {
+if (!socket_is_occluded(*sock, *node, snode)) {
   *nodep = node;
   *sockp = sock;
   return true;
@@ -1259,7 +1266,7 @@ bool node_find_indicated_socket(SpaceNode &snode,
   LISTBASE_FOREACH (bNodeSocket *, sock, &node->outputs) {
 if (!nodeSocketIsHidden(sock)) {
   if (BLI_rctf_isect_pt(&rect, sock->locx, sock->locy)) {
-if (node == visible_node(snode, node_visible)) {
+if (!socket_is_occluded(*sock, *node, snode)) {
   *nodep = node;
   *sockp = sock;
   return true;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [a0c28a80548] blender-v3.3-release: Fix T100430: Restore larger node socket snap hitbox

2022-08-21 Thread Leon Schittek
Commit: a0c28a805483afb9f34199789d19c51d9811ff84
Author: Leon Schittek
Date:   Sun Aug 21 10:12:50 2022 +0200
Branches: blender-v3.3-release
https://developer.blender.org/rBa0c28a805483afb9f34199789d19c51d9811ff84

Fix T100430: Restore larger node socket snap hitbox

Restore old hitbox for connecting links to sockets.

Commit rBd9d97db018d2 improved the node socket snapping when nodes
are close together by decreasing the tolerance around the cursor when
checking for nodes in front, that might occlude the socket.
In doing so it also reduced the hitbox of the node socket itself that
extended outside of the node.

This commit restores the old node socket hitbox while keeping the
improved behavior when nodes are close together with the following
changes:
1) When looking for the socket under the cursor, iterate through the
nodes front to back, which prioritizes node sockets in the foreground.
2) Instead of checking for another node underneath the cursor it checks
if the socket is actually occluded by another node.

The way the occlusion test for sockets is tweaked you can now connect to
sockets that are only partially occluded, which is a bit more forgiving
than previously.

Reviewed By: Hans Goudey

Differential Revision: http://developer.blender.org/D15731

===

M   source/blender/editors/space_node/node_edit.cc

===

diff --git a/source/blender/editors/space_node/node_edit.cc 
b/source/blender/editors/space_node/node_edit.cc
index 0b1f2037292..1e01373029d 100644
--- a/source/blender/editors/space_node/node_edit.cc
+++ b/source/blender/editors/space_node/node_edit.cc
@@ -913,15 +913,24 @@ static void edit_node_properties_get(
 /** \name Node Generic
  * \{ */
 
-/* is rct in visible part of node? */
-static bNode *visible_node(SpaceNode &snode, const rctf &rct)
+static bool socket_is_occluded(const bNodeSocket &sock,
+   const bNode &node_the_socket_belongs_to,
+   const SpaceNode &snode)
 {
   LISTBASE_FOREACH_BACKWARD (bNode *, node, &snode.edittree->nodes) {
-if (BLI_rctf_isect(&node->totr, &rct, nullptr)) {
-  return node;
+if (node == &node_the_socket_belongs_to) {
+  /* Nodes after this one are underneath and can't occlude the socket. */
+  return false;
+}
+
+rctf socket_hitbox;
+const float socket_hitbox_radius = NODE_SOCKSIZE - 0.1f * U.widget_unit;
+BLI_rctf_init_pt_radius(&socket_hitbox, float2(sock.locx, sock.locy), 
socket_hitbox_radius);
+if (BLI_rctf_inside_rctf(&node->totr, &socket_hitbox)) {
+  return true;
 }
   }
-  return nullptr;
+  return false;
 }
 
 /** \} */
@@ -1216,10 +1225,8 @@ bool node_find_indicated_socket(SpaceNode &snode,
   *sockp = nullptr;
 
   /* check if we click in a socket */
-  LISTBASE_FOREACH (bNode *, node, &snode.edittree->nodes) {
+  LISTBASE_FOREACH_BACKWARD (bNode *, node, &snode.edittree->nodes) {
 BLI_rctf_init_pt_radius(&rect, cursor, size_sock_padded);
-rctf node_visible;
-BLI_rctf_init_pt_radius(&node_visible, cursor, size_sock_padded);
 
 if (!(node->flag & NODE_HIDDEN)) {
   /* extra padding inside and out - allow dragging on the text areas too */
@@ -1238,7 +1245,7 @@ bool node_find_indicated_socket(SpaceNode &snode,
 if (!nodeSocketIsHidden(sock)) {
   if (sock->flag & SOCK_MULTI_INPUT && !(node->flag & NODE_HIDDEN)) {
 if (cursor_isect_multi_input_socket(cursor, *sock)) {
-  if (node == visible_node(snode, node_visible)) {
+  if (!socket_is_occluded(*sock, *node, snode)) {
 *nodep = node;
 *sockp = sock;
 return true;
@@ -1246,7 +1253,7 @@ bool node_find_indicated_socket(SpaceNode &snode,
 }
   }
   else if (BLI_rctf_isect_pt(&rect, sock->locx, sock->locy)) {
-if (node == visible_node(snode, node_visible)) {
+if (!socket_is_occluded(*sock, *node, snode)) {
   *nodep = node;
   *sockp = sock;
   return true;
@@ -1259,7 +1266,7 @@ bool node_find_indicated_socket(SpaceNode &snode,
   LISTBASE_FOREACH (bNodeSocket *, sock, &node->outputs) {
 if (!nodeSocketIsHidden(sock)) {
   if (BLI_rctf_isect_pt(&rect, sock->locx, sock->locy)) {
-if (node == visible_node(snode, node_visible)) {
+if (!socket_is_occluded(*sock, *node, snode)) {
   *nodep = node;
   *sockp = sock;
   return true;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [03d39a04a3a] master: Fix T97002: Preserve multi socket link order

2022-04-18 Thread Leon Schittek
Commit: 03d39a04a3a29b7eb464ca2ae39c69757ee9f6c2
Author: Leon Schittek
Date:   Mon Apr 18 22:28:03 2022 +0200
Branches: master
https://developer.blender.org/rB03d39a04a3a29b7eb464ca2ae39c69757ee9f6c2

Fix T97002: Preserve multi socket link order

Preserve multi socket link order when copying nodes or adding a new
group input sockets by linking directly to multi inputs from the group
input node's extension socket.

This is done by also copying the `multi_input_socket_index` when
the new links are created by copying existing or temporary links.

Reviewed By: Hans Goudey

Differential Revision: http://developer.blender.org/D14535

===

M   source/blender/editors/space_node/node_edit.cc
M   source/blender/nodes/intern/node_common.cc

===

diff --git a/source/blender/editors/space_node/node_edit.cc 
b/source/blender/editors/space_node/node_edit.cc
index 9d83f977fe0..2d7972e2291 100644
--- a/source/blender/editors/space_node/node_edit.cc
+++ b/source/blender/editors/space_node/node_edit.cc
@@ -1306,6 +1306,11 @@ static int node_duplicate_exec(bContext *C, wmOperator 
*op)
   newlink->flag = link->flag;
   newlink->tonode = node_map.lookup(link->tonode);
   newlink->tosock = socket_map.lookup(link->tosock);
+
+  if (link->tosock->flag & SOCK_MULTI_INPUT) {
+newlink->multi_input_socket_index = link->multi_input_socket_index;
+  }
+
   if (link->fromnode && (link->fromnode->flag & NODE_SELECT)) {
 newlink->fromnode = node_map.lookup(link->fromnode);
 newlink->fromsock = socket_map.lookup(link->fromsock);
diff --git a/source/blender/nodes/intern/node_common.cc 
b/source/blender/nodes/intern/node_common.cc
index c4befd5828c..abbfe4b823d 100644
--- a/source/blender/nodes/intern/node_common.cc
+++ b/source/blender/nodes/intern/node_common.cc
@@ -476,7 +476,10 @@ void node_group_input_update(bNodeTree *ntree, bNode *node)
 
 /* redirect links from the extension socket */
 for (link = (bNodeLink *)tmplinks.first; link; link = link->next) {
-  nodeAddLink(ntree, node, newsock, link->tonode, link->tosock);
+  bNodeLink *newlink = nodeAddLink(ntree, node, newsock, link->tonode, 
link->tosock);
+  if (newlink->tosock->flag & SOCK_MULTI_INPUT) {
+newlink->multi_input_socket_index = link->multi_input_socket_index;
+  }
 }
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [9a67f9173b1] master: Cleanup: Improve variable naming

2022-03-31 Thread Leon Schittek
Commit: 9a67f9173b168f1fed88ad1eb59c9e7623c1eca7
Author: Leon Schittek
Date:   Fri Apr 1 07:05:50 2022 +0200
Branches: master
https://developer.blender.org/rB9a67f9173b168f1fed88ad1eb59c9e7623c1eca7

Cleanup: Improve variable naming

The variable `ofs` in `widget_numslider` was referring to the radius.
`rad` is more clear and consistent with the other widget functions.

===

M   source/blender/editors/interface/interface_widgets.c

===

diff --git a/source/blender/editors/interface/interface_widgets.c 
b/source/blender/editors/interface/interface_widgets.c
index ca07c97b987..a16c24f63cd 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -3745,8 +3745,8 @@ static void widget_numslider(
   widget_init(&wtb1);
 
   /* Backdrop first. */
-  const float ofs = widget_radius_from_zoom(zoom, wcol);
-  round_box_edges(&wtb, roundboxalign, rect, ofs);
+  const float rad = widget_radius_from_zoom(zoom, wcol);
+  round_box_edges(&wtb, roundboxalign, rect, rad);
 
   wtb.draw_outline = false;
   widgetbase_draw(&wtb, wcol);
@@ -3803,9 +3803,9 @@ static void widget_numslider(
 factor_ui = factor * width;
 /* The rectangle width needs to be at least twice the corner radius for 
the round corners
  * to be drawn properly. */
-const float min_width = 2.0f * ofs;
+const float min_width = 2.0f * rad;
 
-if (factor_ui > width - ofs) {
+if (factor_ui > width - rad) {
   /* Left part + middle part + right part. */
   factor_discard = factor;
 }
@@ -3821,7 +3821,7 @@ static void widget_numslider(
   factor_discard = factor_ui / min_width;
 }
 
-round_box_edges(&wtb1, roundboxalign_slider, &rect1, ofs);
+round_box_edges(&wtb1, roundboxalign_slider, &rect1, rad);
 wtb1.draw_outline = false;
 widgetbase_set_uniform_discard_factor(&wtb1, factor_discard);
 widgetbase_draw(&wtb1, wcol);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [aab9047f9d6] master: Fix T88785: Keep value slider from clipping

2022-03-31 Thread Leon Schittek
Commit: aab9047f9d6234dc4e692cb062541f85c80cc64e
Author: Leon Schittek
Date:   Fri Apr 1 06:51:22 2022 +0200
Branches: master
https://developer.blender.org/rBaab9047f9d6234dc4e692cb062541f85c80cc64e

Fix T88785: Keep value slider from clipping

Keep the value slider from clipping through rounded corners for
low values by ensuring the width of the slider rectangle is at least
twice the corner radius.

Reviewed By: Hans Goudey

Differential Revision: https://developer.blender.org/D11474

===

M   source/blender/editors/interface/interface_widgets.c

===

diff --git a/source/blender/editors/interface/interface_widgets.c 
b/source/blender/editors/interface/interface_widgets.c
index 23883feed71..ca07c97b987 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -3801,21 +3801,24 @@ static void widget_numslider(
 
 const float width = (float)BLI_rcti_size_x(rect);
 factor_ui = factor * width;
+/* The rectangle width needs to be at least twice the corner radius for 
the round corners
+ * to be drawn properly. */
+const float min_width = 2.0f * ofs;
 
-if (factor_ui <= ofs) {
-  /* Left part only. */
-  roundboxalign_slider &= ~(UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT);
-  rect1.xmax = rect1.xmin + ofs;
-  factor_discard = factor_ui / ofs;
+if (factor_ui > width - ofs) {
+  /* Left part + middle part + right part. */
+  factor_discard = factor;
 }
-else if (factor_ui <= width - ofs) {
+else if (factor_ui > min_width) {
   /* Left part + middle part. */
   roundboxalign_slider &= ~(UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT);
   rect1.xmax = rect1.xmin + factor_ui;
 }
 else {
-  /* Left part + middle part + right part. */
-  factor_discard = factor;
+  /* Left part */
+  roundboxalign_slider &= ~(UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT);
+  rect1.xmax = rect1.xmin + min_width;
+  factor_discard = factor_ui / min_width;
 }
 
 round_box_edges(&wtb1, roundboxalign_slider, &rect1, ofs);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [4edde244da3] master: Nodes: Cut hidden links when creating node groups

2022-03-30 Thread Leon Schittek
Commit: 4edde244da3371f098e44fcf814e9be3a7485b3f
Author: Leon Schittek
Date:   Wed Mar 30 23:07:11 2022 +0200
Branches: master
https://developer.blender.org/rB4edde244da3371f098e44fcf814e9be3a7485b3f

Nodes: Cut hidden links when creating node groups

Add a check to the creation of node groups to remove hidden links
that are connected to the outside of the node group. This avoids
creating sockets in the group's interface that aren't (visibly)
connected to anything within the node group.

Reviewed By: Jacques Lucke, Hans Goudey

Differential Revision: https://developer.blender.org/D14249

===

M   source/blender/editors/space_node/node_group.cc

===

diff --git a/source/blender/editors/space_node/node_group.cc 
b/source/blender/editors/space_node/node_group.cc
index 789476a8179..8d5ae12fd93 100644
--- a/source/blender/editors/space_node/node_group.cc
+++ b/source/blender/editors/space_node/node_group.cc
@@ -841,6 +841,12 @@ static void node_group_make_insert_selected(const bContext 
&C, bNodeTree &ntree,
   nodeRemLink(&ntree, link);
 }
 else if (toselect && !fromselect) {
+  /* Remove hidden links to not create unconnected sockets in the 
interface. */
+  if (nodeLinkIsHidden(link)){
+nodeRemLink(&ntree, link);
+continue;
+  }
+
   bNodeSocket *link_sock;
   bNode *link_node;
   node_socket_skip_reroutes(&ntree.links, link->tonode, link->tosock, 
&link_node, &link_sock);
@@ -861,6 +867,12 @@ static void node_group_make_insert_selected(const bContext 
&C, bNodeTree &ntree,
   link->tosock = node_group_find_input_socket(gnode, iosock->identifier);
 }
 else if (fromselect && !toselect) {
+  /* Remove hidden links to not create unconnected sockets in the 
interface. */
+  if (nodeLinkIsHidden(link)){
+nodeRemLink(&ntree, link);
+continue;
+  }
+
   /* First check whether the source of this link is already connected to 
an output.
* If yes, reuse that output instead of duplicating it. */
   bool connected = false;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [26700320389] master: UI: Improve node editor dot background

2022-03-30 Thread Leon Schittek
Commit: 26700320389cdc82c48ac3a33b215427522fe2b8
Author: Leon Schittek
Date:   Wed Mar 30 21:21:57 2022 +0200
Branches: master
https://developer.blender.org/rB26700320389cdc82c48ac3a33b215427522fe2b8

UI: Improve node editor dot background

This commit makes the dot grid used as background in the node editor
more visually stable when zooming in and out.

The dot grid now uses a continuously subdividing pattern, where
each level of subdivision divides the previous five times, similar to
the line grid in the 3D viewport.

The maximum for the "Grid Levels" theme setting is changed to 3, since
any further subdivisions are too small to be visible.
The "Grid Levels" value for the default themes "Blender Dark" and
"Blender Light" is therefore changed to 3, as well.

Reviewed By: Hans Goudey, Pablo Vazquez

Differential Revision: http://developer.blender.org/D13302

===

M   release/datafiles/userdef/userdef_default_theme.c
M   release/scripts/presets/interface_theme/Blender_Light.xml
M   source/blender/blenkernel/BKE_blender_version.h
M   source/blender/blenloader/intern/versioning_userdef.c
M   source/blender/editors/include/ED_node.h
M   source/blender/editors/include/UI_view2d.h
M   source/blender/editors/interface/view2d.c
M   source/blender/makesrna/intern/rna_userdef.c

===

diff --git a/release/datafiles/userdef/userdef_default_theme.c 
b/release/datafiles/userdef/userdef_default_theme.c
index 292080ef629..08f91781aa0 100644
--- a/release/datafiles/userdef/userdef_default_theme.c
+++ b/release/datafiles/userdef/userdef_default_theme.c
@@ -833,7 +833,7 @@ const bTheme U_theme_default = {
 .outline_width = 1,
 .facedot_size = 4,
 .noodle_curving = 4,
-.grid_levels = 7,
+.grid_levels = 3,
 .dash_alpha = 0.5f,
 .syntaxl = RGBA(0x303030ff),
 .syntaxs = RGBA(0x973c3cff),
diff --git a/release/scripts/presets/interface_theme/Blender_Light.xml 
b/release/scripts/presets/interface_theme/Blender_Light.xml
index 9a315763c8b..49955bc3ff9 100644
--- a/release/scripts/presets/interface_theme/Blender_Light.xml
+++ b/release/scripts/presets/interface_theme/Blender_Light.xml
@@ -955,7 +955,7 @@
 matte_node="#977474"
 distor_node="#749797"
 noodle_curving="4"
-grid_levels="7"
+grid_levels="3"
 dash_alpha="0.5"
 input_node="#cb3d4a"
 output_node="#cb3d4a"
diff --git a/source/blender/blenkernel/BKE_blender_version.h 
b/source/blender/blenkernel/BKE_blender_version.h
index 7686fce3aca..604c8cb7a06 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -25,7 +25,7 @@ extern "C" {
 
 /* Blender file format version. */
 #define BLENDER_FILE_VERSION BLENDER_VERSION
-#define BLENDER_FILE_SUBVERSION 7
+#define BLENDER_FILE_SUBVERSION 8
 
 /* Minimum Blender version that supports reading file written with the current
  * version. Older Blender versions will test this and show a warning if the 
file
diff --git a/source/blender/blenloader/intern/versioning_userdef.c 
b/source/blender/blenloader/intern/versioning_userdef.c
index 3b966fe5358..ec76f516780 100644
--- a/source/blender/blenloader/intern/versioning_userdef.c
+++ b/source/blender/blenloader/intern/versioning_userdef.c
@@ -324,6 +324,10 @@ static void do_versions_theme(const UserDef *userdef, 
bTheme *btheme)
   if (!USER_VERSION_ATLEAST(301, 2)) {
 FROM_DEFAULT_V4_UCHAR(space_sequencer.mask);
   }
+
+  if (!USER_VERSION_ATLEAST(302, 8)) {
+btheme->space_node.grid_levels = U_theme_default.space_node.grid_levels;
+  }
   /**
* Versioning code until next subversion bump goes here.
*
diff --git a/source/blender/editors/include/ED_node.h 
b/source/blender/editors/include/ED_node.h
index 8c9fa7e4494..c30b8c5ec6a 100644
--- a/source/blender/editors/include/ED_node.h
+++ b/source/blender/editors/include/ED_node.h
@@ -33,7 +33,7 @@ typedef enum {
   NODE_RIGHT = 8,
 } NodeBorder;
 
-#define NODE_GRID_STEP_SIZE 10
+#define NODE_GRID_STEP_SIZE U.widget_unit /* Based on the grid nodes snap to. 
*/
 #define NODE_EDGE_PAN_INSIDE_PAD 2
 #define NODE_EDGE_PAN_OUTSIDE_PAD 0 /* Disable clamping for node panning, use 
whole screen. */
 #define NODE_EDGE_PAN_SPEED_RAMP 1
diff --git a/source/blender/editors/include/UI_view2d.h 
b/source/blender/editors/include/UI_view2d.h
index b69d3008f1d..4282465c0ca 100644
--- a/source/blender/editors/include/UI_view2d.h
+++ b/source/blender/editors/include/UI_view2d.h
@@ -178,12 +178,12 @@ void UI_view2d_multi_grid_draw(
  * \param grid_color_id: The theme color used for the points. Faded 
dynamically based on zoom.
  * \param min_step: The base size of the grid. At different zoom levels, the 
visi

[Bf-blender-cvs] [ee1d5fb9e46] master: UI: Fix cosmetic papercuts of the reroute node

2022-03-29 Thread Leon Schittek
Commit: ee1d5fb9e4671a60fc3083dde78c227d9ef73aa2
Author: Leon Schittek
Date:   Tue Mar 29 23:39:50 2022 +0200
Branches: master
https://developer.blender.org/rBee1d5fb9e4671a60fc3083dde78c227d9ef73aa2

UI: Fix cosmetic papercuts of the reroute node

Fix small cosmetic issues with the reroute node:
1. Remove special case that allowed curved links to attach vertically.
2. Center align the reroute node's label.

The vertically attached node links could lead to kinks in the otherwise
smooth curves. This would break the visual flow and make the link
potentially intersect the node's label.

The center alignment of the label gives more consistent results for
different label lengths and also reduces the chance of the label
interfering with the node links.

Reviewed By: Hans Goudey, Pablo Vazquez

Differential Revision: D14457

===

M   source/blender/editors/space_node/drawnode.cc
M   source/blender/editors/space_node/node_draw.cc

===

diff --git a/source/blender/editors/space_node/drawnode.cc 
b/source/blender/editors/space_node/drawnode.cc
index 365a17c0a04..d4b7640cfe3 100644
--- a/source/blender/editors/space_node/drawnode.cc
+++ b/source/blender/editors/space_node/drawnode.cc
@@ -1556,7 +1556,6 @@ bool node_link_bezier_handles(const View2D *v2d,
   }
 
   /* in v0 and v3 we put begin/end points */
-  int toreroute, fromreroute;
   if (link.fromsock) {
 vec[0][0] = link.fromsock->locx;
 vec[0][1] = link.fromsock->locy;
@@ -1567,14 +1566,12 @@ bool node_link_bezier_handles(const View2D *v2d,
   link.fromsock->total_inputs);
   copy_v2_v2(vec[0], position);
 }
-fromreroute = (link.fromnode && link.fromnode->type == NODE_REROUTE);
   }
   else {
 if (snode == nullptr) {
   return false;
 }
 copy_v2_v2(vec[0], cursor);
-fromreroute = 0;
   }
   if (link.tosock) {
 vec[3][0] = link.tosock->locx;
@@ -1586,14 +1583,12 @@ bool node_link_bezier_handles(const View2D *v2d,
   link.tosock->total_inputs);
   copy_v2_v2(vec[3], position);
 }
-toreroute = (link.tonode && link.tonode->type == NODE_REROUTE);
   }
   else {
 if (snode == nullptr) {
   return false;
 }
 copy_v2_v2(vec[3], cursor);
-toreroute = 0;
   }
 
   /* may be called outside of drawing (so pass spacetype) */
@@ -1607,37 +1602,12 @@ bool node_link_bezier_handles(const View2D *v2d,
   }
 
   const float dist = curving * 0.10f * fabsf(vec[0][0] - vec[3][0]);
-  const float deltax = vec[3][0] - vec[0][0];
-  const float deltay = vec[3][1] - vec[0][1];
-  /* check direction later, for top sockets */
-  if (fromreroute) {
-if (fabsf(deltax) > fabsf(deltay)) {
-  vec[1][1] = vec[0][1];
-  vec[1][0] = vec[0][0] + (deltax > 0 ? dist : -dist);
-}
-else {
-  vec[1][0] = vec[0][0];
-  vec[1][1] = vec[0][1] + (deltay > 0 ? dist : -dist);
-}
-  }
-  else {
-vec[1][0] = vec[0][0] + dist;
-vec[1][1] = vec[0][1];
-  }
-  if (toreroute) {
-if (fabsf(deltax) > fabsf(deltay)) {
-  vec[2][1] = vec[3][1];
-  vec[2][0] = vec[3][0] + (deltax > 0 ? -dist : dist);
-}
-else {
-  vec[2][0] = vec[3][0];
-  vec[2][1] = vec[3][1] + (deltay > 0 ? -dist : dist);
-}
-  }
-  else {
-vec[2][0] = vec[3][0] - dist;
-vec[2][1] = vec[3][1];
-  }
+
+  vec[1][0] = vec[0][0] + dist;
+  vec[1][1] = vec[0][1];
+
+  vec[2][0] = vec[3][0] - dist;
+  vec[2][1] = vec[3][1];
 
   if (v2d && min_(vec[0][0], vec[1][0], vec[2][0], vec[3][0]) > 
v2d->cur.xmax) {
 return false; /* clipped */
diff --git a/source/blender/editors/space_node/node_draw.cc 
b/source/blender/editors/space_node/node_draw.cc
index 7f0c426922b..d39304284ad 100644
--- a/source/blender/editors/space_node/node_draw.cc
+++ b/source/blender/editors/space_node/node_draw.cc
@@ -2574,20 +2574,14 @@ static void reroute_node_draw(
   if (node.label[0] != '\0') {
 /* draw title (node label) */
 BLI_strncpy(showname, node.label, sizeof(showname));
-uiDefBut(&block,
- UI_BTYPE_LABEL,
- 0,
- showname,
- (int)(rct.xmin - NODE_DYS),
- (int)(rct.ymax),
- (short)512,
- (short)NODE_DY,
- nullptr,
- 0,
- 0,
- 0,
- 0,
- nullptr);
+const short width = 512;
+const int x = BLI_rctf_cent_x(&node.totr) - (width / 2);
+const int y = node.totr.ymax;
+
+uiBut *label_but = uiDefBut(
+&block, UI_BTYPE_LABEL, 0, showname, x, y, width, (short)NODE_DY, 
NULL, 0, 0, 0, 0, NULL);
+
+UI_but_drawflag_disable(label_but, UI_BUT_TEXT_LEFT);
   }
 
   /* only draw input socket. as they all are placed on the same position.

___
Bf-

[Bf-blender-cvs] [08b4b657b64] master: Geometry Nodes: Don't create node tree when adding nodes modifier

2022-03-29 Thread Leon Schittek
Commit: 08b4b657b64fe8632f532e732cebdaec73264d66
Author: Leon Schittek
Date:   Tue Mar 29 22:28:02 2022 +0200
Branches: master
https://developer.blender.org/rB08b4b657b64fe8632f532e732cebdaec73264d66

Geometry Nodes: Don't create node tree when adding nodes modifier

Don't always create a new geometry nodes node tree when adding a
geometry nodes modifier.

This avoids files getting cluttered with empty and unused geometry node
trees that are created every time a nodes modifier is added to an
object - even if only to apply an already existing.
This is also more consistent with other modifiers that also don't
automatically create new data blocks.

The new modifier still automatically gets populated with a new node
tree when adding it via the "New" button in the header of the
geometry nodes editor.

Reviewed By: Hans Goudey, Dalai Felinto, Pablo Vazquez

Differential Revision: D14458

===

M   release/scripts/startup/bl_operators/geometry_nodes.py
M   source/blender/editors/object/object_modifier.c
M   source/blender/modifiers/MOD_nodes.h
M   source/blender/modifiers/intern/MOD_nodes.cc

===

diff --git a/release/scripts/startup/bl_operators/geometry_nodes.py 
b/release/scripts/startup/bl_operators/geometry_nodes.py
index 3616bf52540..746b1800757 100644
--- a/release/scripts/startup/bl_operators/geometry_nodes.py
+++ b/release/scripts/startup/bl_operators/geometry_nodes.py
@@ -50,6 +50,9 @@ class NewGeometryNodesModifier(Operator):
 if not modifier:
 return {'CANCELLED'}
 
+group = geometry_node_group_empty_new()
+modifier.node_group = group
+
 return {'FINISHED'}
 
 
diff --git a/source/blender/editors/object/object_modifier.c 
b/source/blender/editors/object/object_modifier.c
index 9039556ea93..0e09fbb7ea4 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -219,9 +219,6 @@ ModifierData *ED_object_modifier_add(
   /* ensure skin-node customdata exists */
   BKE_mesh_ensure_skin_customdata(ob->data);
 }
-else if (type == eModifierType_Nodes) {
-  MOD_nodes_init(bmain, (NodesModifierData *)new_md);
-}
   }
 
   BKE_object_modifier_set_active(ob, new_md);
diff --git a/source/blender/modifiers/MOD_nodes.h 
b/source/blender/modifiers/MOD_nodes.h
index 053fb6e3244..4a3ccd8ecd1 100644
--- a/source/blender/modifiers/MOD_nodes.h
+++ b/source/blender/modifiers/MOD_nodes.h
@@ -17,8 +17,6 @@ extern "C" {
  */
 void MOD_nodes_update_interface(struct Object *object, struct 
NodesModifierData *nmd);
 
-void MOD_nodes_init(struct Main *bmain, struct NodesModifierData *nmd);
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/source/blender/modifiers/intern/MOD_nodes.cc 
b/source/blender/modifiers/intern/MOD_nodes.cc
index e94f8e50fec..182405652a6 100644
--- a/source/blender/modifiers/intern/MOD_nodes.cc
+++ b/source/blender/modifiers/intern/MOD_nodes.cc
@@ -732,33 +732,6 @@ void MOD_nodes_update_interface(Object *object, 
NodesModifierData *nmd)
   DEG_id_tag_update(&object->id, ID_RECALC_GEOMETRY);
 }
 
-void MOD_nodes_init(Main *bmain, NodesModifierData *nmd)
-{
-  bNodeTree *ntree = ntreeAddTree(bmain, "Geometry Nodes", 
ntreeType_Geometry->idname);
-  nmd->node_group = ntree;
-
-  ntreeAddSocketInterface(ntree, SOCK_IN, "NodeSocketGeometry", "Geometry");
-  ntreeAddSocketInterface(ntree, SOCK_OUT, "NodeSocketGeometry", "Geometry");
-
-  bNode *group_input_node = nodeAddStaticNode(nullptr, ntree, 
NODE_GROUP_INPUT);
-  bNode *group_output_node = nodeAddStaticNode(nullptr, ntree, 
NODE_GROUP_OUTPUT);
-
-  nodeSetSelected(group_input_node, false);
-  nodeSetSelected(group_output_node, false);
-
-  group_input_node->locx = -200 - group_input_node->width;
-  group_output_node->locx = 200;
-  group_output_node->flag |= NODE_DO_OUTPUT;
-
-  nodeAddLink(ntree,
-  group_output_node,
-  (bNodeSocket *)group_output_node->inputs.first,
-  group_input_node,
-  (bNodeSocket *)group_input_node->outputs.first);
-
-  BKE_ntree_update_main_tree(bmain, ntree, nullptr);
-}
-
 static void initialize_group_input(NodesModifierData &nmd,
const OutputSocketRef &socket,
void *r_value)

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [7de3caa05d8] master: Fix: Drag link search doesn't always connect to socket

2022-03-22 Thread Leon Schittek
Commit: 7de3caa05d8de4aa9cf83bbeaaa298785f2366f8
Author: Leon Schittek
Date:   Tue Mar 22 09:57:50 2022 -0500
Branches: master
https://developer.blender.org/rB7de3caa05d8de4aa9cf83bbeaaa298785f2366f8

Fix: Drag link search doesn't always connect to socket

Connecting to some sockets of a few nodes via the drag link search
would fail and trigger an assert, because the picked socket wasn't
available. This was due to some sockets only being available with
certain settings.

This patch fixes these cases by adding the availability conditions of
the socket to the node declaration with the `make_available` method
or manually adding a `node_link_gather_search` function.

Differential Revision: https://developer.blender.org/D14283

===

M   source/blender/nodes/function/nodes/node_fn_rotate_euler.cc
M   source/blender/nodes/geometry/nodes/node_geo_curve_primitive_arc.cc
M   source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc
M   source/blender/nodes/geometry/nodes/node_geo_curve_primitive_line.cc
M   
source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc
M   source/blender/nodes/geometry/nodes/node_geo_scale_elements.cc
M   source/blender/nodes/shader/nodes/node_shader_tex_sky.cc
M   source/blender/nodes/shader/nodes/node_shader_vector_rotate.cc

===

diff --git a/source/blender/nodes/function/nodes/node_fn_rotate_euler.cc 
b/source/blender/nodes/function/nodes/node_fn_rotate_euler.cc
index 3718ce6f359..a4fc1a6bfd1 100644
--- a/source/blender/nodes/function/nodes/node_fn_rotate_euler.cc
+++ b/source/blender/nodes/function/nodes/node_fn_rotate_euler.cc
@@ -15,11 +15,20 @@ namespace blender::nodes::node_fn_rotate_euler_cc {
 
 static void fn_node_rotate_euler_declare(NodeDeclarationBuilder &b)
 {
+  auto enable_axis_angle = [](bNode &node) {
+node.custom1 = FN_NODE_ROTATE_EULER_TYPE_AXIS_ANGLE;
+  };
+
   b.is_function_node();
   b.add_input(N_("Rotation")).subtype(PROP_EULER).hide_value();
-  b.add_input(N_("Rotate By")).subtype(PROP_EULER);
-  b.add_input(N_("Axis")).default_value({0.0, 0.0, 
1.0}).subtype(PROP_XYZ);
-  b.add_input(N_("Angle")).subtype(PROP_ANGLE);
+  b.add_input(N_("Rotate 
By")).subtype(PROP_EULER).make_available([](bNode &node) {
+node.custom1 = FN_NODE_ROTATE_EULER_TYPE_EULER;
+  });
+  b.add_input(N_("Axis"))
+  .default_value({0.0, 0.0, 1.0})
+  .subtype(PROP_XYZ)
+  .make_available(enable_axis_angle);
+  
b.add_input(N_("Angle")).subtype(PROP_ANGLE).make_available(enable_axis_angle);
   b.add_output(N_("Rotation"));
 }
 
diff --git 
a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_arc.cc 
b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_arc.cc
index 6c7d7ed375b..38d81c54933 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_arc.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_arc.cc
@@ -17,6 +17,13 @@ NODE_STORAGE_FUNCS(NodeGeometryCurvePrimitiveArc)
 
 static void node_declare(NodeDeclarationBuilder &b)
 {
+  auto enable_points = [](bNode &node) {
+node_storage(node).mode = GEO_NODE_CURVE_PRIMITIVE_ARC_TYPE_POINTS;
+  };
+  auto enable_radius = [](bNode &node) {
+node_storage(node).mode = GEO_NODE_CURVE_PRIMITIVE_ARC_TYPE_RADIUS;
+  };
+
   b.add_input(N_("Resolution"))
   .default_value(16)
   .min(2)
@@ -26,34 +33,41 @@ static void node_declare(NodeDeclarationBuilder &b)
   b.add_input(N_("Start"))
   .default_value({-1.0f, 0.0f, 0.0f})
   .subtype(PROP_TRANSLATION)
-  .description(N_("Position of the first control point"));
+  .description(N_("Position of the first control point"))
+  .make_available(enable_points);
   b.add_input(N_("Middle"))
   .default_value({0.0f, 2.0f, 0.0f})
   .subtype(PROP_TRANSLATION)
-  .description(N_("Position of the middle control point"));
+  .description(N_("Position of the middle control point"))
+  .make_available(enable_points);
   b.add_input(N_("End"))
   .default_value({1.0f, 0.0f, 0.0f})
   .subtype(PROP_TRANSLATION)
-  .description(N_("Position of the last control point"));
+  .description(N_("Position of the last control point"))
+  .make_available(enable_points);
   b.add_input(N_("Radius"))
   .default_value(1.0f)
   .min(0.0f)
   .subtype(PROP_DISTANCE)
-  .description(N_("Distance of the points from the origin"));
+  .description(N_("Distance of the points from the origin"))
+  .make_available(enable_radius);
   b.add_input(N_("Start Angle"))
   .default_value(0.0f)
   .subtype(PROP_ANGLE)
-

[Bf-blender-cvs] [1cb303242fa] master: UI: align labels of number fields and value sliders

2022-03-07 Thread Leon Schittek
Commit: 1cb303242fa67574449315c59a786a7ad52ea957
Author: Leon Schittek
Date:   Mon Mar 7 17:47:57 2022 +0100
Branches: master
https://developer.blender.org/rB1cb303242fa67574449315c59a786a7ad52ea957

UI: align labels of number fields and value sliders

Previously the labels and values in number fields and value sliders
used different padding for the text. This looks weird when they are
placed underneath each other in a column and, as noted by a comment
in the code of `widget_numslider`, they are actually meant to be
aligned.

This patch fixes that by using the same padding that is used for the
number field for the value slider, as well. This also has the benefit,
that the labels of the value sliders don't shift anymore when adjusting
the corner roundness.

Differential Revision: https://developer.blender.org/D14091

===

M   source/blender/editors/interface/interface_widgets.c

===

diff --git a/source/blender/editors/interface/interface_widgets.c 
b/source/blender/editors/interface/interface_widgets.c
index d1f3843c643..35cf952b5ce 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -3319,6 +3319,8 @@ static void ui_draw_separator(const rcti *rect, const 
uiWidgetColors *wcol)
 /** \name Button Draw Callbacks
  * \{ */
 
+#define NUM_BUT_PADDING_FACTOR 0.425f
+
 static void widget_numbut_draw(
 uiWidgetColors *wcol, rcti *rect, const float zoom, int state, int 
roundboxalign, bool emboss)
 {
@@ -3413,11 +3415,10 @@ static void widget_numbut_draw(
   }
 
   if (!(state & UI_STATE_TEXT_INPUT)) {
-const float textofs = 0.425f * BLI_rcti_size_y(rect);
+const float text_padding = NUM_BUT_PADDING_FACTOR * BLI_rcti_size_y(rect);
 
-/* text space */
-rect->xmin += textofs;
-rect->xmax -= textofs;
+rect->xmin += text_padding;
+rect->xmax -= text_padding;
   }
 }
 
@@ -3745,7 +3746,6 @@ static void widget_numslider(
 
   /* Backdrop first. */
   const float ofs = widget_radius_from_zoom(zoom, wcol);
-  const float toffs = ofs * 0.75f;
   round_box_edges(&wtb, roundboxalign, rect, ofs);
 
   wtb.draw_outline = false;
@@ -3838,8 +3838,9 @@ static void widget_numslider(
   /* Add space at either side of the button so text aligns with number-buttons
* (which have arrow icons). */
   if (!(state & UI_STATE_TEXT_INPUT)) {
-rect->xmax -= toffs;
-rect->xmin += toffs;
+const float text_padding = NUM_BUT_PADDING_FACTOR * BLI_rcti_size_y(rect);
+rect->xmax -= text_padding;
+rect->xmin += text_padding;
   }
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [6b8dde93b0c] master: Fix T95531: Draw y axis values in Driver Editor

2022-03-07 Thread Leon Schittek
Commit: 6b8dde93b0ca898da16ff367d110f785e35e8981
Author: Leon Schittek
Date:   Mon Mar 7 16:15:16 2022 +0100
Branches: master
https://developer.blender.org/rB6b8dde93b0ca898da16ff367d110f785e35e8981

Fix T95531: Draw y axis values in Driver Editor

When drawing the driver editor, only skip drawing the "scrubbing area"
and not the Y-axis values or the scroll bars.

The issue was introduced in rBb3431a88465db2433b46e1f6426c801125d0047d
to avoid drawing the playhead in the Driver Editor but also prevented
the text on the y axis from being drawn.

Reviewed by: Severin, sybren

Maniphest Tasks: T95531

Differential Revision: https://developer.blender.org/D14022

===

M   source/blender/editors/space_graph/space_graph.c

===

diff --git a/source/blender/editors/space_graph/space_graph.c 
b/source/blender/editors/space_graph/space_graph.c
index 22427675ff3..f041f2d1d3b 100644
--- a/source/blender/editors/space_graph/space_graph.c
+++ b/source/blender/editors/space_graph/space_graph.c
@@ -295,16 +295,14 @@ static void graph_main_region_draw_overlay(const bContext 
*C, ARegion *region)
   /* draw entirely, view changes should be handled here */
   const SpaceGraph *sipo = CTX_wm_space_graph(C);
 
-  /* Driver Editor's X axis is not time. */
-  if (sipo->mode == SIPO_MODE_DRIVERS) {
-return;
-  }
-
   const Scene *scene = CTX_data_scene(C);
   View2D *v2d = ®ion->v2d;
 
-  /* scrubbing region */
-  ED_time_scrub_draw_current_frame(region, scene, sipo->flag & SIPO_DRAWTIME);
+  /* Driver Editor's X axis is not time. */
+  if (sipo->mode != SIPO_MODE_DRIVERS) {
+/* scrubbing region */
+ED_time_scrub_draw_current_frame(region, scene, sipo->flag & 
SIPO_DRAWTIME);
+  }
 
   /* scrollers */
   /* FIXME: args for scrollers depend on the type of data being shown. */

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [ea3b2e87361] blender-v3.1-release: Fix T95531: Draw y axis values in Driver Editor

2022-03-07 Thread Leon Schittek
Commit: ea3b2e8736164e01d7fc5630eb7c7adbc01c8bc4
Author: Leon Schittek
Date:   Mon Mar 7 16:15:16 2022 +0100
Branches: blender-v3.1-release
https://developer.blender.org/rBea3b2e8736164e01d7fc5630eb7c7adbc01c8bc4

Fix T95531: Draw y axis values in Driver Editor

When drawing the driver editor, only skip drawing the "scrubbing area"
and not the Y-axis values or the scroll bars.

The issue was introduced in rBb3431a88465db2433b46e1f6426c801125d0047d
to avoid drawing the playhead in the Driver Editor but also prevented
the text on the y axis from being drawn.

Reviewed by: Severin, sybren

Maniphest Tasks: T95531

Differential Revision: https://developer.blender.org/D14022

===

M   source/blender/editors/space_graph/space_graph.c

===

diff --git a/source/blender/editors/space_graph/space_graph.c 
b/source/blender/editors/space_graph/space_graph.c
index 7d5e8836490..537f6db2d4d 100644
--- a/source/blender/editors/space_graph/space_graph.c
+++ b/source/blender/editors/space_graph/space_graph.c
@@ -311,16 +311,14 @@ static void graph_main_region_draw_overlay(const bContext 
*C, ARegion *region)
   /* draw entirely, view changes should be handled here */
   const SpaceGraph *sipo = CTX_wm_space_graph(C);
 
-  /* Driver Editor's X axis is not time. */
-  if (sipo->mode == SIPO_MODE_DRIVERS) {
-return;
-  }
-
   const Scene *scene = CTX_data_scene(C);
   View2D *v2d = ®ion->v2d;
 
-  /* scrubbing region */
-  ED_time_scrub_draw_current_frame(region, scene, sipo->flag & SIPO_DRAWTIME);
+  /* Driver Editor's X axis is not time. */
+  if (sipo->mode != SIPO_MODE_DRIVERS) {
+/* scrubbing region */
+ED_time_scrub_draw_current_frame(region, scene, sipo->flag & 
SIPO_DRAWTIME);
+  }
 
   /* scrollers */
   /* FIXME: args for scrollers depend on the type of data being shown. */

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [ae6400cfb4c] master: UI: Fix multi input socket outline and highlight

2022-02-28 Thread Leon Schittek
Commit: ae6400cfb4cae798667eab903d9c463fdec31298
Author: Leon Schittek
Date:   Mon Feb 28 18:05:12 2022 -0500
Branches: master
https://developer.blender.org/rBae6400cfb4cae798667eab903d9c463fdec31298

UI: Fix multi input socket outline and highlight

Small fixes to the drawing of multi input sockets:
 - Make the outline thickness consistent with normal node sockets,
   independent from the screen DPI.
 - Only highlight multi input sockets when they are actually selected.
 - Skip selected multi inputs when drawing normal selected sockets.

Differential Revision: https://developer.blender.org/D14192

===

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_intern.hh

===

diff --git a/source/blender/editors/space_node/node_draw.cc 
b/source/blender/editors/space_node/node_draw.cc
index 7b4578e6c05..1286f6a818c 100644
--- a/source/blender/editors/space_node/node_draw.cc
+++ b/source/blender/editors/space_node/node_draw.cc
@@ -718,7 +718,12 @@ static void node_socket_draw_multi_input(const float 
color[4],
  const int locx,
  const int locy)
 {
-  const float outline_width = 1.0f;
+  /* The other sockets are drawn with the keyframe shader. There, the outline 
has a base thickness
+   * that can be varied but always scales with the size the socket is drawn 
at. Using `U.dpi_fac`
+   * has the the same effect here. It scales the outline correctly across 
different screen DPIs
+   * and UI scales without being affected by the 'line-width'. */
+  const float outline_width = NODE_SOCK_OUTLINE_SCALE * U.dpi_fac;
+
   /* UI_draw_roundbox draws the outline on the outer side, so compensate for 
the outline width. */
   const rctf rect = {
   locx - width + outline_width * 0.5f,
@@ -1060,7 +1065,7 @@ void ED_node_socket_draw(bNodeSocket *sock, const rcti 
*rect, const float color[
 {
   using namespace blender::ed::space_node;
 
-  const float size = 2.25f * NODE_SOCKSIZE * scale;
+  const float size = NODE_SOCKSIZE_DRAW_MULIPLIER * NODE_SOCKSIZE * scale;
   rcti draw_rect = *rect;
   float outline_color[4] = {0};
 
@@ -1081,7 +1086,7 @@ void ED_node_socket_draw(bNodeSocket *sock, const rcti 
*rect, const float color[
   GPU_program_point_size(true);
 
   immBindBuiltinProgram(GPU_SHADER_KEYFRAME_SHAPE);
-  immUniform1f("outline_scale", 1.0f);
+  immUniform1f("outline_scale", NODE_SOCK_OUTLINE_SCALE);
   immUniform2f("ViewportSize", -1.0f, -1.0f);
 
   /* Single point. */
@@ -1232,13 +1237,14 @@ static void node_draw_sockets(const View2D &v2d,
   GPU_blend(GPU_BLEND_ALPHA);
   GPU_program_point_size(true);
   immBindBuiltinProgram(GPU_SHADER_KEYFRAME_SHAPE);
-  immUniform1f("outline_scale", 1.0f);
+  immUniform1f("outline_scale", NODE_SOCK_OUTLINE_SCALE);
   immUniform2f("ViewportSize", -1.0f, -1.0f);
 
   /* Set handle size. */
+  const float socket_draw_size = NODE_SOCKSIZE * NODE_SOCKSIZE_DRAW_MULIPLIER;
   float scale;
   UI_view2d_scale_get(&v2d, &scale, nullptr);
-  scale *= 2.25f * NODE_SOCKSIZE;
+  scale *= socket_draw_size;
 
   if (!select_all) {
 immBeginAtMost(GPU_PRIM_POINTS, total_input_len + total_output_len);
@@ -1251,7 +1257,10 @@ static void node_draw_sockets(const View2D &v2d,
   continue;
 }
 if (select_all || (sock->flag & SELECT)) {
-  selected_input_len++;
+  if (!(sock->flag & SOCK_MULTI_INPUT)) {
+/* Don't add multi-input sockets here since they are drawn in a 
different batch. */
+selected_input_len++;
+  }
   continue;
 }
 /* Don't draw multi-input sockets here since they are drawn in a different 
batch. */
@@ -1318,6 +1327,10 @@ static void node_draw_sockets(const View2D &v2d,
 if (nodeSocketIsHidden(sock)) {
   continue;
 }
+/* Don't draw multi-input sockets here since they are drawn in a 
different batch. */
+if (sock->flag & SOCK_MULTI_INPUT) {
+  continue;
+}
 if (select_all || (sock->flag & SELECT)) {
   node_socket_draw_nested(C,
   ntree,
@@ -1383,13 +1396,13 @@ static void node_draw_sockets(const View2D &v2d,
 }
 
 const bool is_node_hidden = (node.flag & NODE_HIDDEN);
-const float width = NODE_SOCKSIZE;
+const float width = 0.5f * socket_draw_size;
 float height = is_node_hidden ? width : 
node_socket_calculate_height(*socket) - width;
 
 float color[4];
 float outline_color[4];
 node_socket_color_get(C, ntree, node_ptr, *socket, color);
-node_socket_outline_color_get(selected, socket->type, outline_color);
+node_socket_outline_color_

[Bf-blender-cvs] [75bb99fa40d] master: Nodes: Improve readability of selected node links

2022-02-28 Thread Leon Schittek
Commit: 75bb99fa40dd09e4ae0e92cca9398b929f855a2c
Author: Leon Schittek
Date:   Mon Feb 28 15:52:00 2022 -0500
Branches: master
https://developer.blender.org/rB75bb99fa40dd09e4ae0e92cca9398b929f855a2c

Nodes: Improve readability of selected node links

This commit improves the drawing of selected node links:
 - Highlight the entire link to make it easier to spot where the link
   is going/coming from.
 - Always draw selected links on top, so they are always clearly
   visible.
 - Don't fade selected node links when the sockets they are connected
   to are out out view.
 - Dragged node links still get a partial highlight when they are only
   attached to one socket.

Differential Revision: https://developer.blender.org/D11930

===

M   source/blender/blenkernel/BKE_node.h
M   source/blender/blenkernel/intern/node.cc
M   source/blender/editors/space_node/drawnode.cc
M   source/blender/editors/space_node/node_draw.cc
M   source/blender/editors/space_node/node_intern.hh

===

diff --git a/source/blender/blenkernel/BKE_node.h 
b/source/blender/blenkernel/BKE_node.h
index 8a65279ae74..315e24485fa 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -681,6 +681,7 @@ void nodeRemLink(struct bNodeTree *ntree, struct bNodeLink 
*link);
 void nodeRemSocketLinks(struct bNodeTree *ntree, struct bNodeSocket *sock);
 void nodeMuteLinkToggle(struct bNodeTree *ntree, struct bNodeLink *link);
 bool nodeLinkIsHidden(const struct bNodeLink *link);
+bool nodeLinkIsSelected(const struct bNodeLink *link);
 void nodeInternalRelink(struct bNodeTree *ntree, struct bNode *node);
 
 void nodeToView(const struct bNode *node, float x, float y, float *rx, float 
*ry);
diff --git a/source/blender/blenkernel/intern/node.cc 
b/source/blender/blenkernel/intern/node.cc
index 9fd9f9a1492..876ccc5351c 100644
--- a/source/blender/blenkernel/intern/node.cc
+++ b/source/blender/blenkernel/intern/node.cc
@@ -2438,6 +2438,11 @@ bool nodeLinkIsHidden(const bNodeLink *link)
   return nodeSocketIsHidden(link->fromsock) || 
nodeSocketIsHidden(link->tosock);
 }
 
+bool nodeLinkIsSelected(const bNodeLink *link)
+{
+  return (link->fromnode->flag & NODE_SELECT) || (link->tonode->flag & 
NODE_SELECT);
+}
+
 /* Adjust the indices of links connected to the given multi input socket after 
deleting the link at
  * `deleted_index`. This function also works if the link has not yet been 
deleted. */
 static void adjust_multi_input_indices_after_removed_link(bNodeTree *ntree,
diff --git a/source/blender/editors/space_node/drawnode.cc 
b/source/blender/editors/space_node/drawnode.cc
index b2c361ecaba..afb205f9f9e 100644
--- a/source/blender/editors/space_node/drawnode.cc
+++ b/source/blender/editors/space_node/drawnode.cc
@@ -1967,9 +1967,10 @@ void node_draw_link_bezier(const bContext &C,
const bNodeLink &link,
const int th_col1,
const int th_col2,
-   const int th_col3)
+   const int th_col3,
+   const bool selected)
 {
-  const float dim_factor = node_link_dim_factor(v2d, link);
+  const float dim_factor = selected ? 1.0f : node_link_dim_factor(v2d, link);
   float thickness = 1.5f;
   float dash_factor = 1.0f;
 
@@ -2025,19 +2026,17 @@ void node_draw_link_bezier(const bContext &C,
 }
 
 /* Highlight links connected to selected nodes. */
-const bool is_fromnode_selected = link.fromnode && link.fromnode->flag & 
SELECT;
-const bool is_tonode_selected = link.tonode && link.tonode->flag & SELECT;
-if (is_fromnode_selected || is_tonode_selected) {
+if (selected) {
   float color_selected[4];
   UI_GetThemeColor4fv(TH_EDGE_SELECT, color_selected);
   const float alpha = color_selected[3];
 
   /* Interpolate color if highlight color is not fully transparent. */
   if (alpha != 0.0) {
-if (is_fromnode_selected) {
+if (link.fromsock) {
   interp_v3_v3v3(colors[1], colors[1], color_selected, alpha);
 }
-if (is_tonode_selected) {
+if (link.tosock) {
   interp_v3_v3v3(colors[2], colors[2], color_selected, alpha);
 }
   }
@@ -2102,7 +2101,8 @@ void node_draw_link_bezier(const bContext &C,
 void node_draw_link(const bContext &C,
 const View2D &v2d,
 const SpaceNode &snode,
-const bNodeLink &link)
+const bNodeLink &link,
+const bool selected)
 {
   int th_col1 = TH_WIRE_INNER, th_col2 = TH_WIRE_INNER, th_col3 = TH_WIRE;
 
@@ -2146,7 +2146,7 @@ void node_draw_link(const bContext &C,
 }
   }
 
-  node_draw_link_bezier(C

[Bf-blender-cvs] [ddc52f2e1d0] blender-v3.1-release: Fix: Curve to Mesh node creates caps when curve is cyclic

2022-02-18 Thread Leon Schittek
Commit: ddc52f2e1d0d15c2176c54691dbc24c549453c3b
Author: Leon Schittek
Date:   Fri Feb 18 11:25:25 2022 -0600
Branches: blender-v3.1-release
https://developer.blender.org/rBddc52f2e1d0d15c2176c54691dbc24c549453c3b

Fix: Curve to Mesh node creates caps when curve is cyclic

The "Fill Caps" option on the Curve to Mesh node introduced in
rBbc2f4dd8b408ee makes it possible to fill the open ends of the sweep
to create a manifold mesh.

This patch fixes an edge case, where caps were created even when the
rail curve (the curve used in the "Curve" input socket) was cyclic
making the resulting mesh non-manifold.

Differential Revision: https://developer.blender.org/D14124

===

M   source/blender/blenkernel/intern/curve_to_mesh_convert.cc

===

diff --git a/source/blender/blenkernel/intern/curve_to_mesh_convert.cc 
b/source/blender/blenkernel/intern/curve_to_mesh_convert.cc
index 833b2fe99ec..097414cced1 100644
--- a/source/blender/blenkernel/intern/curve_to_mesh_convert.cc
+++ b/source/blender/blenkernel/intern/curve_to_mesh_convert.cc
@@ -186,7 +186,8 @@ static void spline_extrude_to_mesh_data(const ResultInfo 
&info,
 }
   }
 
-  if (fill_caps && profile.is_cyclic()) {
+  const bool has_caps = fill_caps && profile.is_cyclic() && 
!spline.is_cyclic();
+  if (has_caps) {
 const int poly_size = info.spline_edge_len * info.profile_edge_len;
 const int cap_loop_offset = info.loop_offset + poly_size * 4;
 const int cap_poly_offset = info.poly_offset + poly_size;
@@ -270,7 +271,8 @@ static inline int spline_extrude_loop_size(const Spline 
&curve,
const bool fill_caps)
 {
   const int tube = curve.evaluated_edges_size() * 
profile.evaluated_edges_size() * 4;
-  const int caps = (fill_caps && profile.is_cyclic()) ? 
profile.evaluated_edges_size() * 2 : 0;
+  const bool has_caps = fill_caps && profile.is_cyclic() && !curve.is_cyclic();
+  const int caps = has_caps ? profile.evaluated_edges_size() * 2 : 0;
   return tube + caps;
 }
 
@@ -279,7 +281,8 @@ static inline int spline_extrude_poly_size(const Spline 
&curve,
const bool fill_caps)
 {
   const int tube = curve.evaluated_edges_size() * 
profile.evaluated_edges_size();
-  const int caps = (fill_caps && profile.is_cyclic()) ? 2 : 0;
+  const bool has_caps = fill_caps && profile.is_cyclic() && !curve.is_cyclic();
+  const int caps = has_caps ? 2 : 0;
   return tube + caps;
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [ed4b0321553] master: UI: Improve node drop shadow

2022-02-11 Thread Leon Schittek
Commit: ed4b03215533e601a7a47bc949aae7e49d53e5b7
Author: Leon Schittek
Date:   Fri Feb 11 11:52:56 2022 -0600
Branches: master
https://developer.blender.org/rBed4b03215533e601a7a47bc949aae7e49d53e5b7

UI: Improve node drop shadow

Improve the nodes' drop shadow by making it scale with the view
and replace the loop for the alpha calculation with something more
explicit.

The amount of drop shadow softness was scaled with the zoom level
and therefore had a fixed screen space size. DPI and UI scale
weren't taken into account either. This patch fixes both issues by
basing the shadow softness on the `widget_unit` that scales correctly
in zoomable views and takes UI scale etc. into account.

Differential Revision: https://developer.blender.org/D13356

===

M   source/blender/editors/interface/interface_draw.c

===

diff --git a/source/blender/editors/interface/interface_draw.c 
b/source/blender/editors/interface/interface_draw.c
index 23ae8915e93..9a51aa5cb9d 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -2293,54 +2293,29 @@ void UI_draw_box_shadow(const rctf *rect, uchar alpha)
 void ui_draw_dropshadow(
 const rctf *rct, float radius, float aspect, float alpha, int 
UNUSED(select))
 {
-  float rad;
+  const float max_radius = (BLI_rctf_size_y(rct) - 10.0f) * 0.5f;
+  const float rad = min_ff(radius, max_radius);
 
-  if (radius > (BLI_rctf_size_y(rct) - 10.0f) * 0.5f) {
-rad = (BLI_rctf_size_y(rct) - 10.0f) * 0.5f;
-  }
-  else {
-rad = radius;
-  }
+  /* This undoes the scale of the view for higher zoom factors to clamp the 
shadow size. */
+  const float clamped_aspect = smoothminf(aspect, 1.0f, 0.5f);
 
-  int a, i = 12;
-#if 0
-  if (select) {
-a = i * aspect; /* same as below */
-  }
-  else
-#endif
-  {
-a = i * aspect;
-  }
+  const float shadow_softness = 0.6f * U.widget_unit * clamped_aspect;
+  const float shadow_offset = 0.5f * U.widget_unit * clamped_aspect;
+  const float shadow_alpha = 0.5f * alpha;
 
   GPU_blend(GPU_BLEND_ALPHA);
-  const float dalpha = alpha * 2.0f / 255.0f;
-  float calpha = dalpha;
-  float visibility = 1.0f;
-  for (; i--;) {
-/* alpha ranges from 2 to 20 or so */
-#if 0 /* Old Method (pre 2.8) */
-float color[4] = {0.0f, 0.0f, 0.0f, calpha};
-UI_draw_roundbox_4fv(
-true, rct->xmin - a, rct->ymin - a, rct->xmax + a, rct->ymax - 10.0f + 
a, rad + a, color);
-#endif
-/* Compute final visibility to match old method result. */
-/* TODO: we could just find a better fit function inside the shader 
instead of this. */
-visibility = visibility * (1.0f - calpha);
-calpha += dalpha;
-  }
 
   uiWidgetBaseParameters widget_params = {
   .recti.xmin = rct->xmin,
   .recti.ymin = rct->ymin,
   .recti.xmax = rct->xmax,
-  .recti.ymax = rct->ymax - 10.0f,
-  .rect.xmin = rct->xmin - a,
-  .rect.ymin = rct->ymin - a,
-  .rect.xmax = rct->xmax + a,
-  .rect.ymax = rct->ymax - 10.0f + a,
+  .recti.ymax = rct->ymax - shadow_offset,
+  .rect.xmin = rct->xmin - shadow_softness,
+  .rect.ymin = rct->ymin - shadow_softness,
+  .rect.xmax = rct->xmax + shadow_softness,
+  .rect.ymax = rct->ymax - shadow_offset + shadow_softness,
   .radi = rad,
-  .rad = rad + a,
+  .rad = rad + shadow_softness,
   .round_corners[0] = (roundboxtype & UI_CNR_BOTTOM_LEFT) ? 1.0f : 0.0f,
   .round_corners[1] = (roundboxtype & UI_CNR_BOTTOM_RIGHT) ? 1.0f : 0.0f,
   .round_corners[2] = (roundboxtype & UI_CNR_TOP_RIGHT) ? 1.0f : 0.0f,
@@ -2351,7 +2326,7 @@ void ui_draw_dropshadow(
   GPUBatch *batch = ui_batch_roundbox_shadow_get();
   GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_SHADOW);
   GPU_batch_uniform_4fv_array(batch, "parameters", 4, (const float(*)[4]) & 
widget_params);
-  GPU_batch_uniform_1f(batch, "alpha", 1.0f - visibility);
+  GPU_batch_uniform_1f(batch, "alpha", shadow_alpha);
   GPU_batch_draw(batch);
 
   /* outline emphasis */

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [5edb924e573] blender-v3.1-release: UI Papercut: Fix gap in node outline

2022-01-31 Thread Leon Schittek
Commit: 5edb924e57348ce69de8a977258589b9a7a8de02
Author: Leon Schittek
Date:   Mon Jan 31 12:31:07 2022 -0500
Branches: blender-v3.1-release
https://developer.blender.org/rB5edb924e57348ce69de8a977258589b9a7a8de02

UI Papercut: Fix gap in node outline

Correct corner radius of the node outline to prevent a noticeable gap in
some cases.

---

Currently we make a small mistake in the creation of the node outline:
We offset the rectangle describing the outline by the outline thickness,
but we don't adjust the corner radius accordingly.
Therefore the rounded corner of the outline and the node body are not
concentric which can sometimes lead to a visible gap at the corner.
How noticeable it is depends on the theme, the screen's dpi and the
line thickness set in the preferences.

Simply adjusting the corner radius for the outline to also be increased
by the outline thickness fixes this small issue.

| display, line thickness | **patch** | **master** |
| --- | --- | --- |
| 1080p, default/thin  | {F12835304} | {F12835305} |
| retina, thin | {F12835306} | {F12835307} |

The issue was mentioned by @hitrpr

Reviewed By: Blendify

Differential Revision: https://developer.blender.org/D13955

===

M   source/blender/editors/space_node/node_draw.cc

===

diff --git a/source/blender/editors/space_node/node_draw.cc 
b/source/blender/editors/space_node/node_draw.cc
index 82da890fa9b..834bb3e5802 100644
--- a/source/blender/editors/space_node/node_draw.cc
+++ b/source/blender/editors/space_node/node_draw.cc
@@ -2028,7 +2028,7 @@ static void node_draw_basis(const bContext &C,
 }
 
 UI_draw_roundbox_corner_set(UI_CNR_ALL);
-UI_draw_roundbox_4fv(&rect, false, BASIS_RAD, color_outline);
+UI_draw_roundbox_4fv(&rect, false, BASIS_RAD + outline_width, 
color_outline);
   }
 
   float scale;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs