[Bf-blender-cvs] [4d605ef2f41] master: Fix T92427: Adding new nodes does no edge-panning

Philipp Oeser noreply at git.blender.org
Wed Oct 27 10:25:34 CEST 2021


Commit: 4d605ef2f413e8ab484743218f0d0517138513d5
Author: Philipp Oeser
Date:   Tue Oct 26 13:42:19 2021 +0200
Branches: master
https://developer.blender.org/rB4d605ef2f413e8ab484743218f0d0517138513d5

Fix T92427: Adding new nodes does no edge-panning

Unlike translating existing nodes [which disables cursor wrapping and
enables edge-panning instead since rBSa1cc7042a74], adding new nodes
would still show the old behavior of cursor wrapping.

This has been disabled for the case when the node whould be added
outside (due to menus overlapping other editors).

Now enable edge-panning for adding new nodes as well and make sure
this only starts once the mouse has returned into the inside rect once.

Maniphest Tasks: T92427

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

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

M	source/blender/editors/include/UI_view2d.h
M	source/blender/editors/interface/view2d_edge_pan.c
M	source/blender/editors/space_node/node_ops.c

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

diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h
index e959f9ae7ce..122e5a7d839 100644
--- a/source/blender/editors/include/UI_view2d.h
+++ b/source/blender/editors/include/UI_view2d.h
@@ -315,6 +315,9 @@ typedef struct View2DEdgePanData {
   /** View2d we're operating in. */
   struct View2D *v2d;
 
+  /** Panning should only start once being in the inside rect once (e.g. adding nodes can happen
+   * outside). */
+  bool enabled;
   /** Inside distance in UI units from the edge of the region within which to start panning. */
   float inside_pad;
   /** Outside distance in UI units from the edge of the region at which to stop panning. */
diff --git a/source/blender/editors/interface/view2d_edge_pan.c b/source/blender/editors/interface/view2d_edge_pan.c
index a49666ebbd3..8d8b9a4fe48 100644
--- a/source/blender/editors/interface/view2d_edge_pan.c
+++ b/source/blender/editors/interface/view2d_edge_pan.c
@@ -92,6 +92,8 @@ void UI_view2d_edge_pan_init(bContext *C,
   vpd->delay = delay;
   vpd->zoom_influence = zoom_influence;
 
+  vpd->enabled = false;
+
   /* Calculate translation factor, based on size of view. */
   const float winx = (float)(BLI_rcti_size_x(&vpd->region->winrct) + 1);
   const float winy = (float)(BLI_rcti_size_y(&vpd->region->winrct) + 1);
@@ -227,9 +229,16 @@ void UI_view2d_edge_pan_apply(bContext *C, View2DEdgePanData *vpd, const int xy[
   BLI_rcti_pad(&inside_rect, -vpd->inside_pad * U.widget_unit, -vpd->inside_pad * U.widget_unit);
   BLI_rcti_pad(&outside_rect, vpd->outside_pad * U.widget_unit, vpd->outside_pad * U.widget_unit);
 
+  /* Check if we can actually start the edge pan (e.g. adding nodes outside the view will start
+   * disabled). */
+  if (BLI_rcti_isect_pt_v(&inside_rect, xy)) {
+    /* We are inside once, can start. */
+    vpd->enabled = true;
+  }
+
   int pan_dir_x = 0;
   int pan_dir_y = 0;
-  if ((vpd->outside_pad == 0) || BLI_rcti_isect_pt_v(&outside_rect, xy)) {
+  if (vpd->enabled && ((vpd->outside_pad == 0) || BLI_rcti_isect_pt_v(&outside_rect, xy))) {
     /* Find whether the mouse is beyond X and Y edges. */
     if (xy[0] > inside_rect.xmax) {
       pan_dir_x = 1;
diff --git a/source/blender/editors/space_node/node_ops.c b/source/blender/editors/space_node/node_ops.c
index df4f63af20b..0c54da65e9c 100644
--- a/source/blender/editors/space_node/node_ops.c
+++ b/source/blender/editors/space_node/node_ops.c
@@ -156,6 +156,7 @@ void ED_operatormacros_node(void)
                                     OPTYPE_UNDO | OPTYPE_REGISTER);
   mot = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
   RNA_boolean_set(mot->ptr, "remove_on_cancel", true);
+  RNA_boolean_set(mot->ptr, "view2d_edge_pan", true);
   WM_operatortype_macro_define(ot, "NODE_OT_attach");
   WM_operatortype_macro_define(ot, "NODE_OT_insert_offset");



More information about the Bf-blender-cvs mailing list