This is an automated email from the ASF dual-hosted git repository.

hansva pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hop.git


The following commit(s) were added to refs/heads/main by this push:
     new 33fe12a7f1 Add canvas expand to hop GUI, fixes #6094 (#6505)
33fe12a7f1 is described below

commit 33fe12a7f19df5a665e93aaf25d3c395b3ddf9c0
Author: Hans Van Akelyen <[email protected]>
AuthorDate: Fri Feb 6 13:16:57 2026 +0100

    Add canvas expand to hop GUI, fixes #6094 (#6505)
---
 .../hopgui/file/pipeline/HopGuiPipelineGraph.java  |  2 +
 .../hopgui/file/workflow/HopGuiWorkflowGraph.java  |  2 +
 .../perspective/execution/DragViewZoomBase.java    | 53 ++++++++++++++++++++++
 3 files changed, 57 insertions(+)

diff --git 
a/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/HopGuiPipelineGraph.java
 
b/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/HopGuiPipelineGraph.java
index a52780b48e..d1b7e7a255 100644
--- 
a/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/HopGuiPipelineGraph.java
+++ 
b/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/HopGuiPipelineGraph.java
@@ -1672,6 +1672,7 @@ public class HopGuiPipelineGraph extends 
HopGuiAbstractGraph
       }
 
       moveSelected(dx, dy);
+      applyEdgeScrollWhileDragging(event.x, event.y);
 
       doRedraw = true;
     } else if ((startHopTransform != null && endHopTransform == null)
@@ -1750,6 +1751,7 @@ public class HopGuiPipelineGraph extends 
HopGuiAbstractGraph
       int dy = note.y - selectedNote.getLocation().y;
 
       moveSelected(dx, dy);
+      applyEdgeScrollWhileDragging(event.x, event.y);
 
       doRedraw = true;
     }
diff --git 
a/ui/src/main/java/org/apache/hop/ui/hopgui/file/workflow/HopGuiWorkflowGraph.java
 
b/ui/src/main/java/org/apache/hop/ui/hopgui/file/workflow/HopGuiWorkflowGraph.java
index ac7923e1da..a3016922dc 100644
--- 
a/ui/src/main/java/org/apache/hop/ui/hopgui/file/workflow/HopGuiWorkflowGraph.java
+++ 
b/ui/src/main/java/org/apache/hop/ui/hopgui/file/workflow/HopGuiWorkflowGraph.java
@@ -1392,6 +1392,7 @@ public class HopGuiWorkflowGraph extends 
HopGuiAbstractGraph
       }
 
       moveSelected(dx, dy);
+      applyEdgeScrollWhileDragging(event.x, event.y);
 
       doRedraw = true;
     } else if ((startHopAction != null && endHopAction == null)
@@ -1461,6 +1462,7 @@ public class HopGuiWorkflowGraph extends 
HopGuiAbstractGraph
       int dy = note.y - selectedNote.getLocation().y;
 
       moveSelected(dx, dy);
+      applyEdgeScrollWhileDragging(event.x, event.y);
 
       doRedraw = true;
     }
diff --git 
a/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/execution/DragViewZoomBase.java
 
b/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/execution/DragViewZoomBase.java
index 4eb072afe5..d69d6eee4a 100644
--- 
a/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/execution/DragViewZoomBase.java
+++ 
b/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/execution/DragViewZoomBase.java
@@ -394,6 +394,59 @@ public abstract class DragViewZoomBase extends Composite {
     return new Point(rect.width, rect.height);
   }
 
+  /** Pixel distance from canvas edge within which edge-scrolling starts. */
+  private static final int EDGE_SCROLL_MARGIN = 72;
+
+  /**
+   * Maximum scroll speed in graph coordinates per mouse move. Kept low so the 
view stays easy to
+   * follow when approaching the edge.
+   */
+  private static final double EDGE_SCROLL_MAX_SPEED = 6.0;
+
+  /**
+   * When dragging a transform or action near the canvas border, scroll the 
view so the user can
+   * keep dragging. Speed increases naturally as the pointer approaches the 
edge but is capped so
+   * the flow remains easy to follow.
+   *
+   * @param screenX mouse x in canvas coordinates
+   * @param screenY mouse y in canvas coordinates
+   */
+  protected void applyEdgeScrollWhileDragging(int screenX, int screenY) {
+    if (canvas == null || canvas.isDisposed() || maximum == null) {
+      return;
+    }
+    Point area = getArea();
+    if (area.x <= 0 || area.y <= 0) {
+      return;
+    }
+    int margin = EDGE_SCROLL_MARGIN;
+    if (area.x < 2 * margin || area.y < 2 * margin) {
+      return;
+    }
+    double dx = 0;
+    double dy = 0;
+    if (screenX < margin) {
+      double t = (margin - screenX) / (double) margin;
+      dx = t * EDGE_SCROLL_MAX_SPEED;
+    } else if (screenX > area.x - margin) {
+      double t = (screenX - (area.x - margin)) / (double) margin;
+      dx = -t * EDGE_SCROLL_MAX_SPEED;
+    }
+    if (screenY < margin) {
+      double t = (margin - screenY) / (double) margin;
+      dy = t * EDGE_SCROLL_MAX_SPEED;
+    } else if (screenY > area.y - margin) {
+      double t = (screenY - (area.y - margin)) / (double) margin;
+      dy = -t * EDGE_SCROLL_MAX_SPEED;
+    }
+    if (dx != 0 || dy != 0) {
+      offset.x += dx;
+      offset.y += dy;
+      validateOffset();
+      redraw();
+    }
+  }
+
   /**
    * Calculate the differences for the scrollbars. We take the system zoom 
factor and current
    * magnification into account

Reply via email to