@itwin/core-markup
Version:
iTwin.js markup package
127 lines • 5.61 kB
TypeScript
/** @packageDocumentation
* @module MarkupTools
*/
import { BeEvent } from "@itwin/core-bentley";
import { Point2d, Transform, XAndY } from "@itwin/core-geometry";
import { BeButtonEvent, BeModifierKeys, BeTouchEvent, EventHandled } from "@itwin/core-frontend";
import { G, Element as MarkupElement } from "@svgdotjs/svg.js";
import { MarkupTool } from "./MarkupTool";
import { UndoManager } from "./Undo";
/** Classes added to HTMLElements so they can be customized in CSS by applications.
* A "modify handle" is a visible position on the screen that provides UI to modify a MarkupElement.
* @public
*/
export declare abstract class ModifyHandle {
handles: Handles;
vbToStartTrn: Transform;
constructor(handles: Handles);
/** perform the modification given a current mouse position. */
abstract modify(ev: BeButtonEvent): void;
onClick(_ev: BeButtonEvent): Promise<void>;
/** set the position for this handle on the screen given the current state of the element */
abstract setPosition(): void;
/** the mouse just went down on this handle, begin modification. */
startDrag(_ev: BeButtonEvent, makeCopy?: boolean): void;
startModify(makeCopy: boolean): void;
setMouseHandler(target: MarkupElement): void;
addTouchPadding(visible: MarkupElement, handles: Handles): MarkupElement;
}
/** The set of ModifyHandles active. Only applies if there is a single element selected.
* @public
*/
export declare class Handles {
ss: MarkupSelected;
el: MarkupElement;
readonly handles: ModifyHandle[];
active?: ModifyHandle;
dragging: boolean;
group: G;
npcToVbTrn: Transform;
vbToBoxTrn: Transform;
constructor(ss: MarkupSelected, el: MarkupElement);
npcToBox(p: XAndY): Point2d;
npcToVb(p: XAndY, result?: Point2d): Point2d;
vbToBox(p: XAndY, result?: Point2d): Point2d;
npcToVbArray(pts: Point2d[]): Point2d[];
draw(): void;
remove(): void;
startDrag(ev: BeButtonEvent): EventHandled;
drag(ev: BeButtonEvent): void;
/** complete the modification for the active handle. */
endDrag(undo: UndoManager): EventHandled;
/** called when the reset button is pressed. */
cancelDrag(): void;
}
/** The set of currently selected SVG elements. When elements are added to the set, they are hilited.
* @public
*/
export declare class MarkupSelected {
svg: G;
readonly elements: Set<MarkupElement>;
handles?: Handles;
/** Called whenever elements are added or removed from this SelectionSet */
readonly onChanged: BeEvent<(selected: MarkupSelected) => void>;
get size(): number;
get isEmpty(): boolean;
has(el: MarkupElement): boolean;
emptyAll(): void;
restart(el?: MarkupElement): void;
constructor(svg: G);
clearEditors(): void;
sizeChanged(): void;
/** Add a new element to the SS */
add(el: MarkupElement): void;
/** Remove an element from the selection set and unhilite it.
* @returns true if the element was in the SS and was removed.
*/
drop(el: MarkupElement): boolean;
/** Replace an entry in the selection set with a different element. */
replace(oldEl: MarkupElement, newEl: MarkupElement): void;
deleteAll(undo: UndoManager): void;
groupAll(undo: UndoManager): void;
ungroupAll(undo: UndoManager): void;
/** Move all of the entries to a new position in the DOM via a callback. */
reposition(cmdName: string, undo: UndoManager, fn: (el: MarkupElement) => void): void;
}
/** Provides UI for selection, delete, move, copy, bring-to-front, send-to-back, etc. for Markup SVG elements
* @public
*/
export declare class SelectTool extends MarkupTool {
static toolId: string;
static iconSpec: string;
private _flashedElement?;
private readonly _dragging;
private _anchorPt;
private _isBoxSelect;
get flashedElement(): MarkupElement | undefined;
set flashedElement(el: MarkupElement | undefined);
protected unflashSelected(): void;
private initSelect;
private clearSelect;
onCleanup(): Promise<void>;
onPostInstall(): Promise<void>;
onRestartTool(): Promise<void>;
protected showPrompt(): void;
/** When we start a drag operation, we add a new set of elements to the DOM and start modifying them.
* If we cancel the operation, we need remove them from the DOM.
*/
private cancelDrag;
onResetButtonUp(_ev: BeButtonEvent): Promise<EventHandled>;
/** Called when there is a mouse "click" (down+up without any motion) */
onDataButtonUp(ev: BeButtonEvent): Promise<EventHandled>;
onTouchTap(ev: BeTouchEvent): Promise<EventHandled>;
protected boxSelectInit(): void;
protected boxSelectStart(ev: BeButtonEvent): boolean;
protected boxSelect(ev: BeButtonEvent, isDynamics: boolean): boolean;
/** called when the mouse moves while the data button is down. */
onMouseStartDrag(ev: BeButtonEvent): Promise<EventHandled>;
/** Called whenever the mouse moves while this tool is active. */
onMouseMotion(ev: BeButtonEvent): Promise<void>;
/** Called when the mouse goes up after dragging. */
onMouseEndDrag(ev: BeButtonEvent): Promise<EventHandled>;
/** called when a modifier key is pressed or released. Updates stretch handles, if present */
onModifierKeyTransition(_wentDown: boolean, modifier: BeModifierKeys, _event: KeyboardEvent): Promise<EventHandled>;
/** called whenever a key is pressed while this tool is active. */
onKeyTransition(wentDown: boolean, key: KeyboardEvent): Promise<EventHandled>;
}
//# sourceMappingURL=SelectTool.d.ts.map