Skip to content

Commit d3830fc

Browse files
authored
Zoom Pipeline editor in/out/reset (#2006)
* mouse wheel zooms in and out * bind scale to NodeUI * override PointerMove related functions * resize widget with zoom * update temp-link with scale * scroll added * exposed reloadUserStudy * zoom in and out working * Use fixed zoom values * split zoom function * zoom toolbar added * always visible Service catalog * ZoomAll working
1 parent c2062a7 commit d3830fc

File tree

7 files changed

+391
-103
lines changed

7 files changed

+391
-103
lines changed

services/web/client/source/class/osparc/component/workbench/NodeUI.js

Lines changed: 56 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,19 @@ qx.Class.define("osparc.component.workbench.NodeUI", {
7474
check: "osparc.data.model.Node",
7575
nullable: false
7676
},
77+
78+
scale: {
79+
check: "Number",
80+
event: "changeScale",
81+
nullable: false
82+
},
83+
7784
thumbnail: {
7885
check: "String",
7986
nullable: true,
8087
apply: "_applyThumbnail"
8188
},
89+
8290
appearance: {
8391
init: "window-small-cap",
8492
refine: true
@@ -90,7 +98,8 @@ qx.Class.define("osparc.component.workbench.NodeUI", {
9098
"edgeDragOver": "qx.event.type.Data",
9199
"edgeDrop": "qx.event.type.Data",
92100
"edgeDragEnd": "qx.event.type.Data",
93-
"nodeMoving": "qx.event.type.Event"
101+
"nodeMoving": "qx.event.type.Event",
102+
"nodeStoppedMoving": "qx.event.type.Event"
94103
},
95104

96105
statics: {
@@ -292,14 +301,54 @@ qx.Class.define("osparc.component.workbench.NodeUI", {
292301
return bounds;
293302
},
294303

295-
// override qx.ui.window.Window "move" event listener
304+
__scaleCoordinates: function(x, y) {
305+
return {
306+
x: parseInt(x / this.getScale()),
307+
y: parseInt(y / this.getScale())
308+
};
309+
},
310+
311+
// override qx.ui.core.MMovable
296312
_onMovePointerMove: function(e) {
297-
this.base(arguments, e);
298-
if (e.getPropagationStopped() === true) {
299-
const cBounds = this.getCurrentBounds();
300-
this.getNode().setPosition(cBounds.left, cBounds.top);
301-
this.fireEvent("nodeMoving");
313+
// Only react when dragging is active
314+
if (!this.hasState("move")) {
315+
return;
316+
}
317+
const sideBarWidth = this.__dragRange.left;
318+
const navigationBarHeight = this.__dragRange.top;
319+
const native = e.getNativeEvent();
320+
const x = native.clientX + this.__dragLeft - sideBarWidth;
321+
const y = native.clientY + this.__dragTop - navigationBarHeight;
322+
const coords = this.__scaleCoordinates(x, y);
323+
const insets = this.getLayoutParent().getInsets();
324+
this.setDomPosition(coords.x - (insets.left || 0), coords.y - (insets.top || 0));
325+
e.stopPropagation();
326+
327+
this.getNode().setPosition(coords);
328+
this.fireEvent("nodeMoving");
329+
},
330+
331+
// override qx.ui.core.MMovable
332+
_onMovePointerUp : function(e) {
333+
if (this.hasListener("roll")) {
334+
this.removeListener("roll", this._onMoveRoll, this);
335+
}
336+
337+
// Only react when dragging is active
338+
if (!this.hasState("move")) {
339+
return;
302340
}
341+
342+
this._onMovePointerMove(e);
343+
344+
this.fireEvent("nodeStoppedMoving");
345+
346+
// Remove drag state
347+
this.removeState("move");
348+
349+
this.releaseCapture();
350+
351+
e.stopPropagation();
303352
},
304353

305354
_applyThumbnail: function(thumbnail, oldThumbnail) {

services/web/client/source/class/osparc/component/workbench/ServiceCatalog.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ qx.Class.define("osparc.component.workbench.ServiceCatalog", {
4444
caption: this.tr("Service catalog"),
4545
showMinimize: false,
4646
minWidth: 400,
47+
width: this.self().Width,
4748
minHeight: 400,
49+
height: this.self().Height,
4850
modal: true,
4951
contentPadding: 0,
5052
clickAwayClose: true
@@ -76,7 +78,9 @@ qx.Class.define("osparc.component.workbench.ServiceCatalog", {
7678
},
7779

7880
statics: {
79-
LATEST: "latest"
81+
LATEST: "latest",
82+
Width: 580,
83+
Height: 400
8084
},
8185

8286
members: {

0 commit comments

Comments
 (0)