13
0
livetrax/share/web_surfaces/builtin/mixer/js/widget.js

106 lines
2.1 KiB
JavaScript
Raw Normal View History

2020-06-21 17:29:27 -04:00
/*
* Copyright © 2020 Luciano Iam <oss@lucianoiam.com>
2020-06-21 17:29:27 -04:00
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
export class BaseWidget {
constructor (element) {
if (element) {
this.element = element;
}
2020-06-21 17:29:27 -04:00
}
appendTo (container) {
container.appendChild(this);
}
get id () {
return this.element.id;
}
set id (id) {
this.element.id = id;
}
get classList () {
return this.element.classList;
}
}
export class BaseContainer extends BaseWidget {
constructor () {
super();
2020-06-21 17:29:27 -04:00
this.children = [];
}
appendChild (child) {
this.children.push(child);
}
}
export class BaseDialog extends BaseContainer {
constructor () {
super();
this.children = [];
}
set closeButton (button) {
// empty
}
show () {
// empty
}
close () {
// empty
}
onClose () {
// empty
}
}
2020-06-21 17:29:27 -04:00
export class BaseControl extends BaseWidget {
get value () {
// empty
}
set value (val) {
// empty
}
callback (val) {
// empty
}
bindTo (component, property) {
// ardour → ui
this.value = component[property];
component.on(property, (value) => this.value = value);
// ui → ardour
this.callback = (value) => component[property] = value;
}
}