UNPKG

sprotty

Version:

A next-gen framework for graphical views

68 lines 3.26 kB
/******************************************************************************** * Copyright (c) 2017-2018 TypeFox 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 { VNode } from 'snabbdom'; import { Action } from 'sprotty-protocol/lib/actions'; import { Bounds, Point } from 'sprotty-protocol/lib/utils/geometry'; import { ILogger } from '../../utils/logging'; import { IActionDispatcher } from '../../base/actions/action-dispatcher'; import { SModelElementImpl, SModelRootImpl } from '../../base/model/smodel'; import { IVNodePostprocessor } from '../../base/views/vnode-postprocessor'; import { Layouter } from './layout'; import { InternalBoundsAware } from './model'; export declare class BoundsData { vnode?: VNode; bounds?: Bounds; alignment?: Point; boundsChanged: boolean; alignmentChanged: boolean; } /** * Grabs the bounds from hidden SVG DOM elements, applies layouts and fires * ComputedBoundsActions. * * The actual bounds of an element can usually not be determined from the SModel * as they depend on the view implementation and CSS stylings. So the best way is * to grab them from a live (but hidden) SVG using getBBox(). * * If an element is Alignable, and the top-left corner of its bounding box is not * the origin, we also issue a realign with the ComputedBoundsAction. */ export declare class HiddenBoundsUpdater implements IVNodePostprocessor { protected logger: ILogger; protected actionDispatcher: IActionDispatcher; protected layouter: Layouter; private readonly element2boundsData; root: SModelRootImpl | undefined; decorate(vnode: VNode, element: SModelElementImpl): VNode; postUpdate(cause?: Action): void; protected getBoundsFromDOM(): void; /** * Compute the bounds of the given DOM element. Override this method to customize how * the bounding box of a rendered view is determined. * * In case your Sprotty model element contains children that are rendered outside of * their parent, you can add the `ATTR_BBOX_ELEMENT` attribute to the SVG element * that shall be used to compute the bounding box. */ protected getBounds(elm: Node, element: SModelElementImpl & InternalBoundsAware): Bounds; } /** * Attribute name identifying the SVG element that determines the bounding box of a rendered view. * This can be used when a view creates a group of which only a part should contribute to the * bounding box computed by `HiddenBoundsUpdater`. */ export declare const ATTR_BBOX_ELEMENT = "bboxElement"; //# sourceMappingURL=hidden-bounds-updater.d.ts.map