A single-side view without toolbars.
Methods
addOutOfBoundsChangeListener(listener)
Registers a of bounds change listener with this single-side view.
Parameters:
Name | Type | Description |
---|---|---|
listener |
SideView~outOfBoundsChangeListener | listener to register |
addSelectionChangeListener(listener)
Registers a selection change listener with this single-side view.
Parameters:
Name | Type | Description |
---|---|---|
listener |
SideView~selectionChangeListener | listener to register |
focus()
Convenience method. Sets input focus to the view's canvas element.
Equivalent to
getCanvasElement().focus()
.
getCanvasElement() → {Element}
Gets the canvas DOM element which this view uses to perform its drawing.
Returns:
the canvas element
- Type
- Element
getData() → {SideViewData}
Returns the complete state of this side view.
Returns:
the current view state
- Type
- SideViewData
getFont() → {module:TagEditor.Font}
Returns the font set by the last successful call to SideView#setFont. When a
SideView
is
created, the font is set to ENGRAVE
by default.
Returns:
the current font
- Type
- module:TagEditor.Font
getLines() → {Array.<string>}
Returns the text lines set by the last successful call to SideView#setLines. When a
SideView
is created, it has no text lines set, and this method returns an empty array.
Returns:
current text lines
- Type
- Array.<string>
getTag() → (nullable) {TagOptions}
Returns the tag options from the last successful call to SideView#setTag. If
setTag
was not
previously called, or no call succeeded, returns null
.
Returns:
tag options used previously by
setTag
- Type
- TagOptions
hasSelection() → {boolean}
Checks if the side has any selected lines.
Returns:
Whether there are any selected lines on this side
- Type
- boolean
isPreviewEnabled()
Checks if preview is enabled for this side view. When preview is enabled, a translucent version of the tag
image or (for side 1, if set) the blank tag image is displayed under the rendered tag outline and text.
Returns:
whether preview is enabled
repaint()
Repaints the single-side view.
resetSelection()
Unselects all lines on this side. Does not fire a selection change event.
resetVisibleUnits()
Resets corners that display the measurement unit switcher to defaults.
setData(data) → {Promise.<void>}
Sets the complete state of this side view. Any layout customizations are reset to default.
Parameters:
Name | Type | Description |
---|---|---|
data |
SideViewData | the new view state |
Returns:
promise that is resolved when the operation completes
- Type
- Promise.<void>
setFont(font) → {Promise.<void>}
Sets the font for the single-side view.
Parameters:
Name | Type | Description |
---|---|---|
font |
module:TagEditor.Font | font identifier |
Returns:
promise that is resolved when the operation completes
- Type
- Promise.<void>
setLines(textLines) → {Promise.<void>}
Sets the text lines for the single-side view. Any custom layout changes are reset, and the text is relaid
out according to the default layout rules.
Parameters:
Name | Type | Description |
---|---|---|
textLines |
Array.<string> | text lines to set |
Returns:
promise that is resolved when the operation completes
- Type
- Promise.<void>
setOnWheel(handler)
Replaces the default mouse wheel handler with
handler
. The handler listens to the browser
wheel
event on the canvas element. Inside the handler, this
refers to the
side view.
Parameters:
Name | Type | Description |
---|---|---|
handler |
jQueryEventHandler | the new wheel event handler |
setPreviewEnabled(previewEnabled)
Sets the preview flag for this side view. Repaints the view if necessary.
Parameters:
Name | Type | Description |
---|---|---|
previewEnabled |
true to enable preview, false to disable |
setSelectionEnabled(selectionEnabled)
Enables or disables line selection by user. If selection is disabled, current selection is cleared.
Parameters:
Name | Type | Description |
---|---|---|
selectionEnabled |
boolean | true to enable selection, false to disable |
setTag(options) → {Promise.<void>}
Sets the tag for the single-side view.
If the side has text on it, and the default layout was not customized, the text is relaid out according to
the default layout of the new tag. A custom layout is untouched, so the text will likely not fit the new tag.
If desired, a custom layout can be manually reset afterwards using SideView#resetLayout.
Parameters:
Name | Type | Description |
---|---|---|
options |
TagOptions | tag options |
Returns:
promise that is resolved when the operation completes
- Type
- Promise.<void>
setVisibleRulers(visibleRulers)
Specifies which rulers are visible and which are hidden.
Parameters:
Name | Type | Description |
---|---|---|
visibleRulers |
RulerSides | flags specifying which rulers are visible |
setVisibleUnits(visibleUnits)
Specifies which corners will display the measurement unit switcher.
Parameters:
Name | Type | Description |
---|---|---|
visibleUnits |
UnitCorners | flags specifying which corners show the unit switcher |
showImperialUnits(imperial)
Forces the side view to use metric units (cm) or imperial units (inches) for rulers, replacing the current
user selection.
Parameters:
Name | Type | Description |
---|---|---|
imperial |
boolean | true to use inches, false to use centimeters |
Type Definitions
outOfBoundsChangeListener(outOfBoundsLines)
Listener for out of bounds change events.
Parameters:
Name | Type | Description |
---|---|---|
outOfBoundsLines |
Array.<number> | Indexes of lines that cross the tag bounds (zero-based), empty if none |
selectionChangeListener(selectedLines)
Listener for selection change events.
Parameters:
Name | Type | Description |
---|---|---|
selectedLines |
Array.<number> | Indexes of selected lines (zero-based), empty if no selection |