Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stabilize disable move element out of window #431

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 5 additions & 27 deletions packages/editor/src/lanes/change-lane-bounds-tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,16 @@ import {
BoundsAware,
Dimension,
ChangeBoundsOperation,
CompoundOperation,
CursorCSS,
cursorFeedbackAction,
deleteCssClasses,
DragAwareMouseListener,
ElementAndBounds,
findParentByFeature,
forEachElement,
ISnapper,
isSelected,
isViewport,
MouseListener,
Operation,
Point,
toElementAndBounds,
SModelElement,
Expand All @@ -33,7 +30,7 @@ import { isValidSize } from '@eclipse-glsp/client/lib/utils/layout-utils';
import { inject, injectable, optional } from 'inversify';

import { HideChangeLaneBoundsToolFeedbackAction, ShowChangeLaneBoundsToolFeedbackAction } from './change-lane-bounds-tool-feedback';
import { isLaneResizable, isSelectedLane, LaneResizable, LaneResizeHandleLocation, SLaneResizeHandle } from './model';
import { isLaneResizable, LaneResizable, LaneResizeHandleLocation, SLaneResizeHandle } from './model';
import { addNegativeArea, removeNegativeArea } from '../tools/negative-area/model';
import { QuickActionUI } from '../ui-tools/quick-action/quick-action-ui';

Expand Down Expand Up @@ -131,6 +128,10 @@ export class ChangeLaneBoundsListener extends DragAwareMouseListener implements
return [];
}

mouseLeave(target: SModelElement, event: MouseEvent) {
return this.draggingMouseUp(this.activeResizeElement ?? target, event);
}

draggingMouseUp(target: SModelElement, event: MouseEvent): Action[] {
if (this.lastDragPosition === undefined) {
this.resetPosition();
Expand All @@ -141,35 +142,12 @@ export class ChangeLaneBoundsListener extends DragAwareMouseListener implements
if (this.activeResizeHandle) {
// Resize
actions.push(...this.handleResize(this.activeResizeHandle));
} else {
// Move
actions.push(...this.handleMoveOnServer(target));
}
this.resetPosition();
removeNegativeArea(target);
return actions;
}

protected handleMoveOnServer(target: SModelElement): Action[] {
const operations = this.handleMoveElementsOnServer(target);
if (operations.length > 0) {
return [CompoundOperation.create(operations)];
}
return operations;
}

protected handleMoveElementsOnServer(target: SModelElement): Operation[] {
const result: Operation[] = [];
const newBounds: ElementAndBounds[] = [];
forEachElement(target.index, isSelectedLane, element => {
this.createElementAndBounds(element).forEach(bounds => newBounds.push(bounds));
});
if (newBounds.length > 0) {
result.push(ChangeBoundsOperation.create(newBounds));
}
return result;
}

protected handleResize(activeResizeHandle: SLaneResizeHandle): Action[] {
const actions: Action[] = [];
actions.push(cursorFeedbackAction(CursorCSS.DEFAULT));
Expand Down
11 changes: 7 additions & 4 deletions packages/editor/src/tools/change-bounds-tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
MouseListener,
ChangeBoundsListener,
SModelElement,
Operation,
Action,
SetUIExtensionVisibilityAction,
FeedbackMoveMouseListener,
Expand All @@ -30,11 +29,11 @@ export class IvyChangeBoundsTool extends ChangeBoundsTool {
}

export class IvyChangeBoundsListener extends ChangeBoundsListener {
protected handleMoveRoutingPointsOnServer(target: SModelElement): Operation[] {
protected handleMoveRoutingPointsOnServer(target: SModelElement) {
return [];
}

mouseMove(target: SModelElement, event: MouseEvent): Action[] {
mouseMove(target: SModelElement, event: MouseEvent) {
const actions = super.mouseMove(target, event);
if (this.isMouseDrag && this.activeResizeHandle) {
actions.push(
Expand All @@ -48,7 +47,11 @@ export class IvyChangeBoundsListener extends ChangeBoundsListener {
return actions;
}

draggingMouseUp(target: SModelElement, event: MouseEvent): Action[] {
mouseLeave(target: SModelElement, event: MouseEvent) {
return this.draggingMouseUp(this.activeResizeElement ?? target, event);
}

draggingMouseUp(target: SModelElement, event: MouseEvent) {
const actions = super.draggingMouseUp(target, event);
removeNegativeArea(target);
return actions;
Expand Down