Skip to content

@fabwcie/free-drawing / components/toolbar/widgets/Frame

components/toolbar/widgets/Frame ​

Classes ​

FrameWidget ​

Defined in: packages/free-drawing/src/components/toolbar/widgets/Frame/Frame.ts:11

Frame: area with a title (name of frame, "Frame 1"...), its shapes are moved with it and cut at its edges. Shapes entirely in a new frame are put in it, shapes drawn or moved later in it too (see Drawer.placeInFrames).

Extends

Constructors ​

Constructor ​

new FrameWidget(drawer): FrameWidget

Defined in: packages/free-drawing/src/components/toolbar/widgets/Frame/Frame.ts:19

Create the frame tool, shortcut F

Parameters
drawer ​

Drawer

Drawer of this widget

Returns

FrameWidget

Overrides

ShapeWidget.constructor

Properties ​

$button ​

$button: HTMLButtonElement

Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:29

Button activating the widget, pressed while it is active, named by the title of the tool

Inherited from

ShapeWidget.$button

$container ​

protected readonly $container: HTMLElement

Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:21

Container of the button in toolbar (or menu of its group), with a class from widget id

Inherited from

ShapeWidget.$container

actionOnly ​

readonly actionOnly: boolean = false

Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:27

Button runs an action (setActive(true)), the widget never becomes the active tool (e.g. image tool)

Inherited from

ShapeWidget.actionOnly

cursor ​

protected cursor: string = crosshairCursor

Defined in: packages/free-drawing/src/components/toolbar/widgets/ShapeWidget.ts:62

Stage cursor while widget is active

Inherited from

ShapeWidget.cursor

drawer ​

protected drawer: Drawer

Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:61

Drawer of this widget

Inherited from

ShapeWidget.drawer

hasArrowOptions ​

protected hasArrowOptions: boolean = false

Defined in: packages/free-drawing/src/components/toolbar/widgets/ShapeWidget.ts:70

Path and heads of arrows (arrowType, arrowheads options)

Inherited from

ShapeWidget.hasArrowOptions

hasEdges ​

protected hasEdges: boolean = false

Defined in: packages/free-drawing/src/components/toolbar/widgets/ShapeWidget.ts:68

Corners sharp or round (edges option)

Inherited from

ShapeWidget.hasEdges

hasFill ​

protected hasFill: boolean = false

Defined in: packages/free-drawing/src/components/toolbar/widgets/ShapeWidget.ts:66

Shapes of tool have a background color (rectangle, ellipse)

Inherited from

ShapeWidget.hasFill

id ​

id: AvailableTools

Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:31

Id of the tool, key of the widget in toolbar (drawer.getWidget(id)) and namespace of its stage events

Inherited from

ShapeWidget.id

inAction ​

inAction: boolean = false

Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:39

Pointer action in progress (drawing, erasing, selecting...), see startAction / endAction

Inherited from

ShapeWidget.inAction

options ​

readonly options: WidgetOptions

Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:37

Widget options given with drawer widgets option

Inherited from

ShapeWidget.options

overlay ​

overlay: ShapeOverlay

Defined in: packages/free-drawing/src/components/toolbar/widgets/ShapeWidget.ts:61

Options of the tool (color, width...), shown while widget is active (see showOverlayOnActive)

Inherited from

ShapeWidget.overlay

pointerEvent ​

protected pointerEvent: MouseEvent | TouchEvent | null = null

Defined in: packages/free-drawing/src/components/toolbar/widgets/ShapeWidget.ts:72

Last pointer event of drawing (modifier keys)

Inherited from

ShapeWidget.pointerEvent

shortcut ​

shortcut: string | undefined

Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:33

Key activating the tool, lower case (shortcut widget option, else default of the widget), none if undefined

Inherited from

ShapeWidget.shortcut

showOverlayOnActive ​

protected showOverlayOnActive: boolean = false

Defined in: packages/free-drawing/src/components/toolbar/widgets/Frame/Frame.ts:13

Show overlay while widget is active (false when overlay depends on something else, e.g. selection)

Overrides

ShapeWidget.showOverlayOnActive

Accessors ​

isDisabled ​
Get Signature

get isDisabled(): boolean

Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:138

Widget can not be activated (see setDisabled)

Returns

boolean

Inherited from

ShapeWidget.isDisabled

isPaint ​
Get Signature

get isPaint(): boolean

Defined in: packages/free-drawing/src/components/toolbar/widgets/ShapeWidget.ts:99

Shape being drawn (pointer action in progress)

Deprecated

use inAction

Returns

boolean

Inherited from

ShapeWidget.isPaint

shapeStyle ​
Get Signature

get protected shapeStyle(): object

Defined in: packages/free-drawing/src/components/toolbar/widgets/ShapeWidget.ts:140

Style of new shapes, from drawer options

Returns
dash ​

dash: number[] | undefined

Dash of strokeStyle option for this stroke width, undefined for solid

fill ​

fill: ColorLike | undefined

Background color (fillColor option) of shapes having one (hasFill), none if transparent

hitStrokeWidth ​

hitStrokeWidth: number

Width of the hit region, 20 at least: easier to select / erase than the stroke only

lineCap ​

lineCap: "round"

Round ends of lines, dashes and dots

opacity ​

opacity: number

Opacity (opacity option)

stroke ​

stroke: ColorLike = strokeColor

Stroke color (strokeColor option)

strokeWidth ​

strokeWidth: number

Stroke width (strokeWidth option)

Inherited from

ShapeWidget.shapeStyle

Methods ​

_nextNumber() ​

private _nextNumber(): number

Defined in: packages/free-drawing/src/components/toolbar/widgets/Frame/Frame.ts:42

Number of the next frame, after the number of frames and the numbers of their names ("Frame 3" in the language of the drawer): a deleted frame does not give its number to two frames

Returns

number

Number of the frame drawn

addTo() ​

addTo(parent): void

Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:96

Internal

Adds the button of this widget (icon, shortcut letter) in its container, at the end of parent

Parameters
parent ​

HTMLElement

Element receiving the button container: toolbar root or menu of a group

Returns

void

Inherited from

ShapeWidget.addTo

afterDraw() ​

protected afterDraw(): void

Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:320

Shape drawn with this tool: selection tool activated, nothing selected, unless tool is kept (keepTool preference)

Returns

void

Inherited from

ShapeWidget.afterDraw

cancelAction() ​

cancelAction(): void

Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:241

Pointer action cancelled (two finger gesture of the drawer: zoom and move of the view): its result is discarded (onCancel: shape being drawn removed...), then it ends without change

Returns

void

Inherited from

ShapeWidget.cancelAction

clearSelection() ​

clearSelection(): void

Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:313

Unselect shapes, with selection widget (implemented by it)

Returns

void

Inherited from

ShapeWidget.clearSelection

createShape() ​

protected createShape(start): Frame

Defined in: packages/free-drawing/src/components/toolbar/widgets/Frame/Frame.ts:28

Frame of size 0 at drag start, titled with the next frame number

Parameters
start ​

Vector2d

Drag start, in drawing coordinates

Returns

Frame

Frame named "Frame n" in the language of the drawer

Overrides

ShapeWidget.createShape

drawShape() ​

drawShape(start, end): Frame

Defined in: packages/free-drawing/src/components/toolbar/widgets/ShapeWidget.ts:126

Shape of the tool from a start to an end, as drawn by a drag (shapes recognized in brush strokes): links of arrows to the shapes at their ends, not added to the drawing

Parameters
start ​

Vector2d

Start of the drag, in drawing coordinates

end ​

Vector2d

End of the drag, in drawing coordinates

Returns

Frame

Shape of the tool, to add with drawer.addShape

Inherited from

ShapeWidget.drawShape

endAction() ​

protected endAction(): void

Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:254

Pointer action ends (pointer up)

Returns

void

Inherited from

ShapeWidget.endAction

initEvents() ​

protected initEvents(): void

Defined in: packages/free-drawing/src/components/toolbar/widgets/ShapeWidget.ts:201

Draw by drag: shape created on pointer down, updated on move (shared live), finished on pointer up (removed after a simple click)

Returns

void

Inherited from

ShapeWidget.initEvents

onActive() ​

protected onActive(): void

Defined in: packages/free-drawing/src/components/toolbar/widgets/ShapeWidget.ts:178

Overlay shared by shape tools: background color and edges only for shapes having them

Returns

void

Inherited from

ShapeWidget.onActive

onCancel() ​

protected onCancel(): void

Defined in: packages/free-drawing/src/components/toolbar/widgets/ShapeWidget.ts:187

Shape being drawn removed (two finger gesture), also for collaborators who got its preview

Returns

void

Inherited from

ShapeWidget.onCancel

onConstrainChange() ​

protected onConstrainChange(constrain): void

Defined in: packages/free-drawing/src/components/toolbar/widgets/ShapeWidget.ts:171

Shift pressed or released while drawing: shape updated to the pointer with or without constraint

Parameters
constrain ​

boolean

Shift pressed

Returns

void

Inherited from

ShapeWidget.onConstrainChange

onDesactive() ​

protected onDesactive(): void

Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:204

Called on deactivation, after events removal and overlay hidden

Returns

void

Inherited from

ShapeWidget.onDesactive

onDrawEnd() ​

protected onDrawEnd(frame): void

Defined in: packages/free-drawing/src/components/toolbar/widgets/Frame/Frame.ts:75

Frame drawn: moved under other shapes, takes the shapes entirely in it

Parameters
frame ​

Frame | null

Frame drawn, null after a simple click

Returns

void

Overrides

ShapeWidget.onDrawEnd

onStage() ​

protected onStage(events, handler): void

Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:150

Listen stage events while widget is active. Events are namespaced with widget id, so they are removed on deactivation without removing other listeners. One pointer at a time: during a pointer action, another press (second finger, other button) is ignored, and a touch action ends when its finger is lifted, where it is lifted. Touches of a two finger gesture are ignored.

Parameters
events ​

string

Space separated event names

handler ​

KonvaEventListener<Stage, any>

Konva listener called with the stage event

Returns

void

Inherited from

ShapeWidget.onStage

removeEvents() ​

protected removeEvents(): void

Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:192

Remove widget events, called on deactivation

Returns

void

Inherited from

ShapeWidget.removeEvents

setActive() ​

setActive(active): void

Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:353

Activate widget (nothing if disabled): previous widget deactivated, button pressed, then initEvents, updateCursor, overlay shown (if showOverlayOnActive), onActive and drawer focused. Deactivate it: pointer action ended, removeEvents, overlay hidden, onDesactive, button released.

Parameters
active ​

boolean

Activate (true) or deactivate (false) widget

Returns

void

Inherited from

ShapeWidget.setActive

setDisabled() ​

setDisabled(disabled): void

Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:123

Disable or enable widget: a disabled widget can not be activated and its button is disabled (also its group when all its widgets are). Drawing tools are disabled in read only.

Parameters
disabled ​

boolean

Disable widget

Returns

void

Inherited from

ShapeWidget.setDisabled

shareLive() ​

protected shareLive(...shapes): void

Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:306

Shapes being drawn shown to collaborators while drawing (final state is sent on change)

Parameters
shapes ​

...DrawingShape[]

Shapes in their current state, sent as a live change of the collaboration session

Returns

void

Inherited from

ShapeWidget.shareLive

showToolOverlay() ​

showToolOverlay(): void

Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:210

Overlay shown again (selection cleared), only for a tool showing it while active (not the frame tool, sharing the overlay of shape tools: it would stay shown once the tool is changed)

Returns

void

Inherited from

ShapeWidget.showToolOverlay

startAction() ​

protected startAction(): void

Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:231

Pointer action starts (pointer down): shortcuts are disabled and UI (toolbar, overlays...) ignores pointer, pointer followed out of the canvas until it is released

Returns

void

Inherited from

ShapeWidget.startAction

toggleDisable() ​

toggleDisable(): void

Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:114

Disable / enable widget, a disabled widget can not be activated

Returns

void

Inherited from

ShapeWidget.toggleDisable

updateCursor() ​

updateCursor(): void

Defined in: packages/free-drawing/src/components/toolbar/widgets/BaseWidget.ts:223

Set stage cursor to the cursor of widget: on activation, and to restore it after a temporary one (pan grabbing)

Returns

void

Inherited from

ShapeWidget.updateCursor

updateShape() ​

protected updateShape(frame, start, end, constrain): void

Defined in: packages/free-drawing/src/components/toolbar/widgets/Frame/Frame.ts:64

Frame of the dragged box

Parameters
frame ​

Frame

Frame being drawn

start ​

Vector2d

Drag start, in drawing coordinates

end ​

Vector2d

Pointer, in drawing coordinates

constrain ​

boolean

Shift pressed: square frame

Returns

void

Overrides

ShapeWidget.updateShape