canvas: add onResize script property
This commit is contained in:
parent
c2bc99b2b3
commit
c84067c456
4 changed files with 44 additions and 2 deletions
|
|
@ -33,6 +33,7 @@ class CanvasWidget extends Canvas {
|
|||
onValue: {type: 'script', value: '', editor: 'javascript', help: ['Script executed whenever the widget\'s value updates. See <a href="https://openstagecontrol.ammd.net/docs/widgets/scripting/">documentation</a>.']},
|
||||
onTouch: {type: 'script', value: '', editor:'javascript', help: ['Script executed when the widget is touched and released, and when the pointer moves when the widget is touched. See <a href="https://openstagecontrol.ammd.net/docs/widgets/canvas/">documentation</a>.',]},
|
||||
onDraw: {type: 'script', value: '', editor:'javascript', help: ['Script executed when the widget is redrawn. See <a href="https://openstagecontrol.ammd.net/docs/widgets/canvas/">documentation</a>.']},
|
||||
onResize: {type: 'script', value: '', editor:'javascript', help: ['Script executed when the widget is resized. See <a href="https://openstagecontrol.ammd.net/docs/widgets/canvas/">documentation</a>.']},
|
||||
}
|
||||
return defaults
|
||||
|
||||
|
|
@ -49,6 +50,20 @@ class CanvasWidget extends Canvas {
|
|||
this.valueLength = Math.max(1, parseInt(this.getProp('valueLength')) || 1)
|
||||
this.value = this.valueLength > 1 ? Array(this.valueLength).fill(0) : 0
|
||||
|
||||
if (this.getProp('onResize')) {
|
||||
this.scripts.onResize = new Script({
|
||||
widget: this,
|
||||
property: 'onResize',
|
||||
code: this.getProp('onResize'),
|
||||
context: {
|
||||
value: 0,
|
||||
width: 100,
|
||||
height: 100,
|
||||
cssVars: {}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (this.getProp('onDraw')) {
|
||||
this.scripts.onDraw = new Script({
|
||||
widget: this,
|
||||
|
|
@ -161,6 +176,19 @@ class CanvasWidget extends Canvas {
|
|||
|
||||
}
|
||||
|
||||
extraResizeHandle(event) {
|
||||
|
||||
if (!this.getProp('onResize')) return
|
||||
|
||||
this.scripts.onDraw.run({
|
||||
value: this.value,
|
||||
width: this.width,
|
||||
height: this.height,
|
||||
cssVars: this.cssVars
|
||||
}, {sync: false, send: false})
|
||||
|
||||
}
|
||||
|
||||
onRemove() {
|
||||
|
||||
clearInterval(this.drawInterval)
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ module.exports = class Knob extends Slider {
|
|||
|
||||
}
|
||||
|
||||
extraResizeHandle() {
|
||||
extraResizeHandle(event) {
|
||||
|
||||
super.extraResizeHandle(event)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue