UNPKG

@eclipse-glsp/client

Version:

A sprotty-based client for GLSP

66 lines 3.48 kB
/******************************************************************************** * Copyright (c) 2020-2024 EclipseSource and others. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0. * * This Source Code may also be made available under the following Secondary * Licenses when the conditions for such availability set forth in the Eclipse * Public License v. 2.0 are satisfied: GNU General Public License, version 2 * with the GNU Classpath Exception which is available at * https://www.gnu.org/software/classpath/license.html. * * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 ********************************************************************************/ import { GModelElement, ISnapper, Point, Writable } from '@eclipse-glsp/sprotty'; import { IHelperLineManager } from '../helper-lines/helper-line-manager'; import { Direction } from '../helper-lines/model'; import { PositionSnapper } from './position-snapper'; /** * This class can be used to calculate the current position, when an element is * moved. This includes node movements, node resizing (resize handle movement) * or edge routing-point movements. * * You can initialize a this class with a optional {@link ISnapper}. If a * snapper is present, the positions will be snapped to the defined grid. * * @deprecated The use of this class is discouraged. Use the {@link ChangeBoundsManager.createTracker} * instead which centralized a few aspects of the tracking. */ export declare class PointPositionUpdater { protected positionSnapper: PositionSnapper; protected lastDragPosition?: Point; protected positionDelta: Writable<Point>; constructor(snapper?: PositionSnapper); constructor(snapper?: ISnapper, helperLineManager?: IHelperLineManager); /** * Init the position with the {@link Point} of your mouse cursor. * This method is normally called in the `mouseDown` event. * @param mousePosition current mouse position e.g `{x: event.pageX, y: event.pageY }` */ updateLastDragPosition(mousePosition: Point): void; updateLastDragPosition(mouseEvent: MouseEvent): void; /** * Check if the mouse is currently not in a drag mode. * @returns true if the last drag position is undefined */ isLastDragPositionUndefined(): boolean; /** * Reset the updater for new movements. * This method is normally called in the `mouseUp` event. */ resetPosition(): void; /** * Calculate the current position of your movement. * This method is normally called in the `mouseMove` event. * @param target node which is moved around * @param mousePosition current mouse position e.g `{x: event.pageX, y: event.pageY }` * @param useSnap if a snapper is defined you can disable it, e.g when a specific key is pressed `!event.shiftKey` * @param direction the direction in which the position is updated, will be calculated if not provided * @returns delta to previous position or undefined if no delta should be applied */ updatePosition(target: GModelElement, mousePosition: Point, useSnap: boolean, direction?: Direction[]): Point | undefined; updatePosition(target: GModelElement, mouseEvent: MouseEvent, direction?: Direction[]): Point | undefined; } //# sourceMappingURL=point-position-updater.d.ts.map