UNPKG

@eclipse-glsp/client

Version:

A sprotty-based client for GLSP

83 lines 5.34 kB
/******************************************************************************** * Copyright (c) 2023-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 { Action, Bounds, CommandExecutionContext, CommandReturn, GModelElement, GModelRoot, ILogger, Point, Viewport } from '@eclipse-glsp/sprotty'; import '../../../css/helper-lines.css'; import { FeedbackCommand } from '../../base/feedback/feedback-command'; import { BoundsAwareModelElement } from '../../utils/gmodel-util'; import { HelperLine, HelperLineType } from './model'; export type ViewportLineType = typeof HelperLineType.Center | typeof HelperLineType.Middle | string; export type AlignmentElementFilter = (element: BoundsAwareModelElement, referenceElementIds: string[]) => boolean; export declare const isTopLevelBoundsAwareElement: AlignmentElementFilter; export interface DrawHelperLinesFeedbackAction extends Action { kind: typeof DrawHelperLinesFeedbackAction.KIND; elementIds: string[]; elementLines?: HelperLineType[]; viewportLines?: ViewportLineType[]; alignmentEpsilon?: number; alignmentElementFilter?: AlignmentElementFilter; debug?: boolean; } export declare const ALL_ELEMENT_LINE_TYPES: ("top" | "right" | "bottom" | "left" | "center" | "middle" | "left-right" | "right-left" | "bottom-top" | "top-bottom")[]; export declare const ALL_VIEWPORT_LINE_TYPES: ("center" | "middle")[]; export declare const DEFAULT_ELEMENT_LINES: ("top" | "right" | "bottom" | "left" | "center" | "middle" | "left-right" | "right-left" | "bottom-top" | "top-bottom")[]; export declare const DEFAULT_VIEWPORT_LINES: ("center" | "middle")[]; export declare const DEFAULT_EPSILON = 1; export declare const DEFAULT_ALIGNABLE_ELEMENT_FILTER: (element: BoundsAwareModelElement) => boolean; export declare const DEFAULT_DEBUG = false; export declare namespace DrawHelperLinesFeedbackAction { const KIND = "drawHelperLines"; function create(options: Omit<DrawHelperLinesFeedbackAction, 'kind'>): DrawHelperLinesFeedbackAction; } export declare class DrawHelperLinesFeedbackCommand extends FeedbackCommand { protected logger: ILogger; static readonly KIND = "drawHelperLines"; protected elementIds: string[]; protected elementLines: HelperLineType[]; protected viewportLines: ViewportLineType[]; protected alignmentEpsilon: number; protected alignableElementFilter: AlignmentElementFilter; protected isAlignableElementPredicate: (element: GModelElement) => element is BoundsAwareModelElement; protected debug: boolean; constructor(action: DrawHelperLinesFeedbackAction, logger: ILogger); execute(context: CommandExecutionContext): CommandReturn; protected isAlignableElement(element: GModelElement): element is BoundsAwareModelElement; protected calcReferenceBounds(referenceElements: BoundsAwareModelElement[]): Bounds; protected calcBounds(element: BoundsAwareModelElement): Bounds; protected calcHelperLines(elements: BoundsAwareModelElement[], bounds: Bounds, context: CommandExecutionContext): HelperLine[]; protected calcHelperLinesForViewport(root: Viewport & GModelRoot, bounds: Bounds, lineTypes: HelperLineType[]): HelperLine[]; protected calcHelperLinesForElement(element: BoundsAwareModelElement, bounds: Bounds, lineTypes: HelperLineType[]): HelperLine[]; protected calcHelperLinesForBounds(elementBounds: Bounds, bounds: Bounds, lineTypes: HelperLineType[]): HelperLine[]; protected isAligned(coordinate: (elem: Bounds) => number, leftBounds: Bounds, rightBounds: Bounds, epsilon: number): boolean; protected isMatch(leftCoordinate: number, rightCoordinate: number, epsilon: number): boolean; protected log(message: string, ...params: any[]): void; } export interface RemoveHelperLinesFeedbackAction extends Action { kind: typeof RemoveHelperLinesFeedbackAction.KIND; } export declare namespace RemoveHelperLinesFeedbackAction { const KIND = "removeHelperLines"; function create(options?: Omit<RemoveHelperLinesFeedbackAction, 'kind'>): RemoveHelperLinesFeedbackAction; } export declare class RemoveHelperLinesFeedbackCommand extends FeedbackCommand { action: RemoveHelperLinesFeedbackAction; static readonly KIND = "removeHelperLines"; constructor(action: RemoveHelperLinesFeedbackAction); execute(context: CommandExecutionContext): CommandReturn; } export declare function removeHelperLines(root: GModelRoot): void; export declare function removeSelectionBounds(root: GModelRoot): void; export declare function boundsInViewport(element: GModelElement, bounds: Bounds | Point): Bounds | Point; //# sourceMappingURL=helper-line-feedback.d.ts.map