Skip to content

Commit

Permalink
#2079 Add ability to adjust position of context toolbar for links (#2080
Browse files Browse the repository at this point in the history
)

Signed-off-by: CTomlyn <[email protected]>
  • Loading branch information
tomlyn authored Jul 31, 2024
1 parent c994e2d commit dc5c074
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2828,9 +2828,9 @@ export default class SVGCanvasRenderer {
}
}

getContextToolbarPos(objType, d) {
getDefaultContextToolbarPos(objType, d) {
if (objType === "link") {
return d.pathInfo.centerPoint;
return { ...d.pathInfo.centerPoint };

} else if (objType === "node" && d.layout.contextToolbarPosition === "topCenter" && !d.is_expanded) {
return { x: d.x_pos + (d.width / 2), y: d.y_pos };
Expand All @@ -2839,11 +2839,13 @@ export default class SVGCanvasRenderer {
return { x: d.x_pos + d.width, y: d.y_pos };
}

addContextToolbar(d3Event, d, objType) {
addContextToolbar(d3Event, d, objType, xPos, yPos) {
if (!this.isSizing() && !this.isDragging() &&
!this.svgCanvasTextArea.isEditingText() && !CanvasUtils.isSuperBindingNode(d)) {
this.canvasController.setMouseInObject(d.id);
let pos = this.getContextToolbarPos(objType, d);
let pos = this.getDefaultContextToolbarPos(objType, d);
pos.x = xPos ? pos.x + xPos : pos.x;
pos.y = yPos ? pos.y + yPos : pos.y;
pos = this.zoomUtils.unTransformPos(pos);
this.openContextMenu(d3Event, objType, d, null, pos);
}
Expand Down Expand Up @@ -4249,7 +4251,10 @@ export default class SVGCanvasRenderer {
this.setLinkLineStyles(targetObj, link, "hover");

if (this.config.enableContextToolbar) {
this.addContextToolbar(d3Event, link, "link");
this.addContextToolbar(d3Event, link, "link",
this.canvasLayout.linkContextToolbarPosX,
this.canvasLayout.linkContextToolbarPosY
);
}
})
// This will be called when the mouse cursor enters the link or moves out of
Expand Down
10 changes: 10 additions & 0 deletions canvas_modules/common-canvas/src/object-model/layout-dimensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,11 @@ const portsHorizontalDefaultLayout = {
// get a default arrow head or to an SVG string for a custom arrow head.
dataLinkArrowHead: false,

// Offset amounts for the link's context toolbar from its default
// position.
linkContextToolbarPosX: 0,
linkContextToolbarPosY: 0,

// Link handle for input port can be "circle" or "image".
linkStartHandleObject: "circle",

Expand Down Expand Up @@ -751,6 +756,11 @@ const portsVerticalDefaultLayout = {
// get a default arrow head or to an SVG string for a custom arrow head.
dataLinkArrowHead: false,

// Offset amounts for the link's context toolbar from its default
// position.
linkContextToolbarPosX: 0,
linkContextToolbarPosY: 0,

// Link handle for input port can be "circle" or "image".
linkStartHandleObject: "circle",

Expand Down

0 comments on commit dc5c074

Please sign in to comment.