ui progress
This commit is contained in:
parent
76c7e7b8a6
commit
c67c2b4c50
37 changed files with 773 additions and 788 deletions
|
|
@ -25,9 +25,7 @@ class Menu extends Widget {
|
|||
layout: {type: 'string', value: 'circular', choices: ['circular', 'horizontal', 'vertical', 'grid'], help: [
|
||||
'Defines whether the menu\'s layout should be rendered in a circle or in a box'
|
||||
]},
|
||||
columns: {type: 'number', value: '', help: [
|
||||
'If `layout` is `grid`, defines the number of columns'
|
||||
]},
|
||||
gridTemplate: {type: 'string|number', value: '', help:'If `layout` is `grid`, can be either a number of columns of a value css grid-template definition.'},
|
||||
toggle: {type: 'boolean', value: false, help: 'Set to `true` to make the menu stay opened after mouse/touch release'},
|
||||
doubleTap: {type: 'boolean', value: false, help: 'Set to `true` to make the menu require a double tap to be opened instead of a single tap'},
|
||||
values: {type: 'array|object', value: [1, 2, 3], help: [
|
||||
|
|
@ -241,7 +239,11 @@ class Menu extends Widget {
|
|||
this.container.classList.toggle('circular', layout === 'circular')
|
||||
this.container.classList.toggle('grid', layout === 'grid')
|
||||
this.container.classList.toggle('vertical', layout === 'vertical')
|
||||
this.container.style.setProperty('--grid-columns', this.getProp('columns') === '' ? parseInt(this.values.length / 2) : parseInt(this.getProp('columns')))
|
||||
|
||||
if (layout === 'grid') {
|
||||
var template = this.getProp('gridTemplate') || Math.round(this.values.length / 2)
|
||||
this.menu.style.gridTemplate = template === parseInt(template) ? `none / repeat(${template}, 1fr)` : template
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,14 @@
|
|||
var _matrix_base = require('./_matrix_base'),
|
||||
var Panel = require('./panel'),
|
||||
Widget = require('../common/widget'),
|
||||
StaticProperties = require('../mixins/static_properties'),
|
||||
parser = require('../../parser'),
|
||||
{deepCopy} = require('../../utils')
|
||||
{deepCopy} = require('../../utils'),
|
||||
html = require('nanohtml'),
|
||||
{enableTraversingGestures, disableTraversingGestures} = require('../../events/drag')
|
||||
|
||||
|
||||
|
||||
class Matrix extends _matrix_base {
|
||||
class Matrix extends StaticProperties(Panel, {scroll: false}) {
|
||||
|
||||
static description() {
|
||||
|
||||
|
|
@ -14,16 +18,16 @@ class Matrix extends _matrix_base {
|
|||
|
||||
static defaults() {
|
||||
|
||||
return super.defaults({
|
||||
return Widget.defaults({
|
||||
|
||||
_matrix: 'matrix',
|
||||
|
||||
widgetType: {type: 'string', value: 'toggle', help: 'Defines the type of the widgets in the matrix'},
|
||||
matrix: {type: 'array', value: [2,2], help: 'Defines the number of columns and and rows in the matrix'},
|
||||
layout: {type: 'string', value: 'horizontal', choices: ['horizontal', 'vertical', 'grid'], help:''},
|
||||
gridTemplate: {type: 'string|number', value: '', help:'If `layout` is `grid`, can be either a number of columns of a value css grid-template definition.'},
|
||||
quantity: {type: 'number', value: 4, help: 'Defines the number of widgets in the matrix'},
|
||||
start: {type: 'integer', value: 0, help: 'First widget\'s index'},
|
||||
spacing: {type: 'integer', value: 0, help: 'Adds space between widgets'},
|
||||
traversing: {type: 'boolean', value: true, help: 'Set to `false` to disable traversing gestures'},
|
||||
border: {type: 'boolean', value: true, help: 'Set to `false` to disables the widgets\' borders'},
|
||||
props: {type: 'object', value: {}, help: [
|
||||
'Defines a set of property to override the widgets\' defaults.',
|
||||
'Formulas in this field are resolved with an extra variable representing each widget\'s index: `$`',
|
||||
|
|
@ -36,7 +40,9 @@ class Matrix extends _matrix_base {
|
|||
|
||||
constructor(options) {
|
||||
|
||||
super(options)
|
||||
super({...options, html: html`<div class="panel"></div>`})
|
||||
|
||||
this.value = []
|
||||
|
||||
this.on('change',(e)=>{
|
||||
|
||||
|
|
@ -61,17 +67,13 @@ class Matrix extends _matrix_base {
|
|||
|
||||
})
|
||||
|
||||
this.widget.style.setProperty('--columns', this.getProp('matrix')[0])
|
||||
this.widget.style.setProperty('--rows', this.getProp('matrix')[1])
|
||||
this.widget.style.setProperty('--spacing', this.getProp('spacing') + 'rem')
|
||||
|
||||
if (this.getProp('borders') === false) this.widget.classList.add('noborders')
|
||||
|
||||
this.start = parseInt(this.getProp('start'))
|
||||
|
||||
if (parser.widgets[this.getProp('widgetType')]) {
|
||||
|
||||
for (let i = 0; i < this.getProp('matrix')[0] * this.getProp('matrix')[1]; i++) {
|
||||
for (let i = 0; i < this.getProp('quantity'); i++) {
|
||||
|
||||
var props = this.resolveProp('props', undefined, false, false, false, {'$':i + this.start})
|
||||
var data = this.defaultProps(i + this.start)
|
||||
|
|
@ -99,6 +101,8 @@ class Matrix extends _matrix_base {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
defaultProps(i) {
|
||||
|
|
@ -26,7 +26,8 @@ class Modal extends Panel {
|
|||
popupHeight: {type: 'number|percentage', value: '80%', help: 'Modal popup\'s size'},
|
||||
popupLeft: {type: 'number|percentage', value: 'auto', help: 'Modal popup\'s position'},
|
||||
popupTop: {type: 'number|percentage', value: 'auto', help: 'Modal popup\'s position'},
|
||||
layout: {type: 'string', value: 'default', choices: ['default', 'vertical', 'horizontal'], help:''},
|
||||
layout: {type: 'string', value: 'default', choices: ['default', 'vertical', 'horizontal', 'grid'], help:''},
|
||||
gridTemplate: {type: 'string|number', value: '', help:'If `layout` is `grid`, can be either a number of columns of a value css grid-template definition.'},
|
||||
scroll: {type: 'boolean', value: true, help: 'Set to `false` to disable scrollbars'},
|
||||
variables: {type: '*', value: '@{parent.variables}', help: 'Defines one or more arbitrary variables that can be inherited by children widgets'},
|
||||
|
||||
|
|
|
|||
|
|
@ -20,8 +20,9 @@ class Panel extends Container() {
|
|||
|
||||
_panel:'panel',
|
||||
|
||||
layout: {type: 'string', value: 'default', choices: ['default', 'vertical', 'horizontal', 'grid'], help:''},
|
||||
gridTemplate: {type: 'string|number', value: '', help:'If `layout` is `grid`, can be either a number of columns of a value css grid-template definition.'},
|
||||
scroll: {type: 'boolean', value: true, help: 'Set to `false` to disable scrollbars'},
|
||||
layout: {type: 'string', value: 'default', choices: ['default', 'vertical', 'horizontal'], help:''},
|
||||
traversing: {type: 'boolean', value: false, help: 'Set to `true` to enable traversing gestures in this widget. Set to `smart` or `auto` to limit affected widgets by the type of the first touched widget'},
|
||||
variables: {type: '*', value: '@{parent.variables}', help: 'Defines one or more arbitrary variables that can be inherited by children widgets'},
|
||||
|
||||
|
|
@ -45,9 +46,13 @@ class Panel extends Container() {
|
|||
|
||||
super({...options, html: html`<div class="panel"></div>`})
|
||||
|
||||
if (this.getProp('scroll') === false) this.container.classList.add('noscroll')
|
||||
this.container.classList.toggle('noscroll', this.getProp('scroll') === false)
|
||||
this.container.classList.add('layout-' + this.getProp('layout'))
|
||||
|
||||
if (this.getProp('layout') === 'grid') {
|
||||
var template = this.getProp('gridTemplate') || 2
|
||||
this.widget.style.gridTemplate = template === parseInt(template) ? `none / repeat(${template}, 1fr)` : template
|
||||
}
|
||||
|
||||
if (this.getProp('tabs') && this.getProp('tabs').length) {
|
||||
|
||||
|
|
@ -62,11 +67,12 @@ class Panel extends Container() {
|
|||
|
||||
|
||||
|
||||
this.value = -1
|
||||
this.tabs = []
|
||||
|
||||
if (this.getProp('tabs') && this.getProp('tabs').length) {
|
||||
|
||||
this.value = -1
|
||||
|
||||
this.navigation = this.widget.appendChild(html`<div class="navigation"></div>`)
|
||||
|
||||
this.children = options.children || new Array(this.getProp('tabs').length)
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
var Panel = require('./panel'),
|
||||
Widget = require('../common/widget'),
|
||||
StaticProperties = require('../mixins/static_properties'),
|
||||
resize = require('../../events/resize')
|
||||
|
||||
module.exports = class Tab extends StaticProperties(Panel, {scroll: true}) {
|
||||
module.exports = class Tab extends Panel {
|
||||
|
||||
static description() {
|
||||
|
||||
|
|
@ -18,7 +17,9 @@ module.exports = class Tab extends StaticProperties(Panel, {scroll: true}) {
|
|||
_tab:'tab',
|
||||
|
||||
// detached: {type: 'boolean', value: true, help: 'Set to `false` if the tab contains `frame` widgets that should not be reloaded when the tab opens'},
|
||||
layout: {type: 'string', value: 'default', choices: ['default', 'vertical', 'horizontal'], help:''},
|
||||
layout: {type: 'string', value: 'default', choices: ['default', 'vertical', 'horizontal', 'grid'], help:''},
|
||||
gridTemplate: {type: 'string|number', value: '', help:'If `layout` is `grid`, can be either a number of columns of a value css grid-template definition.'},
|
||||
scroll: {type: 'boolean', value: true, help: 'Set to `false` to disable scrollbars'},
|
||||
traversing: {type: 'boolean', value: false, help: 'Set to `true` to enable traversing gestures in this widget. Set to `smart` or `auto` to limit affected widgets by the type of the first touched widget'},
|
||||
variables: {type: '*', value: '@{parent.variables}', help: 'Defines one or more arbitrary variables that can be inherited by children widgets'},
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ module.exports.widgets = {
|
|||
canvas: require('./pads/canvas'), // implement...
|
||||
|
||||
// matrices
|
||||
matrix: require('./matrices/matrix'),
|
||||
keyboard: require('./matrices/keyboard'),
|
||||
patchbay: require('./matrices/patchbay').PatchBay,
|
||||
patchbaynode: require('./matrices/patchbay').PatchBayNode,
|
||||
|
|
@ -46,6 +45,7 @@ module.exports.widgets = {
|
|||
panel: require('./containers/panel'),
|
||||
modal: require('./containers/modal'),
|
||||
clone: require('./containers/clone'),
|
||||
matrix: require('./containers/matrix'),
|
||||
|
||||
// state switchers
|
||||
switcher: require('./switchers/switcher'),
|
||||
|
|
@ -63,12 +63,12 @@ module.exports.widgets = {
|
|||
|
||||
module.exports.categories = {
|
||||
'Buttons':['toggle', 'switch', 'dropdown', 'menu'],
|
||||
'Containers':['panel', 'modal', 'clone'],
|
||||
'Containers':['panel', 'modal', 'clone', 'matrix'],
|
||||
'Frames':['frame', 'svg', 'html', 'image'],
|
||||
'Graphs':['plot','eq','visualizer'],
|
||||
'Indicators':['led', 'text'],
|
||||
'Inputs':['input', 'keys', 'script', 'gyroscope', 'file'],
|
||||
'Matrices':['matrix', 'keyboard', 'patchbay'],
|
||||
'Matrices':['keyboard', 'patchbay'],
|
||||
'Pads':['xy','rgb','multixy', 'canvas'],
|
||||
'Sliders':['fader','knob', 'encoder', 'range'],
|
||||
'Switchers':['state', 'switcher','crossfader'],
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
var Widget = require('../common/widget'),
|
||||
html = require('nanohtml'),
|
||||
raw = require('nanohtml/raw'),
|
||||
{remoteBrowse, icon} = require('../../ui/utils')
|
||||
uiFilebrowser = require('../../ui/ui-filebrowser'),
|
||||
{icon} = require('../../ui/utils')
|
||||
|
||||
module.exports = class File extends Widget {
|
||||
|
||||
|
|
@ -37,7 +38,7 @@ module.exports = class File extends Widget {
|
|||
|
||||
if (e.capturedByEditor === true) return
|
||||
|
||||
remoteBrowse({
|
||||
uiFilebrowser({
|
||||
extension: this.getProp('extension').replace(/^\.?(.*)$/, '$1'),
|
||||
directory: this.getProp('directory') === 'auto' ? undefined : this.getProp('directory'),
|
||||
loadDir: this.getProp('allowDir')
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
var _matrix_base = require('./_matrix_base'),
|
||||
Panel = require('../containers/panel'),
|
||||
Widget = require('../common/widget'),
|
||||
parser = require('../../parser')
|
||||
|
||||
|
||||
module.exports = class Keyboard extends _matrix_base {
|
||||
module.exports = class Keyboard extends Panel {
|
||||
|
||||
static description() {
|
||||
|
||||
|
|
@ -12,7 +14,7 @@ module.exports = class Keyboard extends _matrix_base {
|
|||
|
||||
static defaults() {
|
||||
|
||||
return super.defaults({
|
||||
return Widget.defaults({
|
||||
|
||||
_matrix: 'matrix',
|
||||
|
||||
|
|
@ -32,7 +34,7 @@ module.exports = class Keyboard extends _matrix_base {
|
|||
]},
|
||||
toggles: {type: 'boolean', value: false, help: 'Set to `true` to make keys bahave like toggle buttons'}
|
||||
|
||||
}, ['_value', 'default', 'value'], {
|
||||
}, ['_value', 'default', 'value', 'linkId'], {
|
||||
|
||||
css: {type: 'string', value: '', help: [
|
||||
'Available CSS variables:',
|
||||
|
|
@ -48,6 +50,8 @@ module.exports = class Keyboard extends _matrix_base {
|
|||
|
||||
super(options)
|
||||
|
||||
this.value = []
|
||||
|
||||
this.on('change',(e)=>{
|
||||
|
||||
if (e.widget === this) return
|
||||
|
|
@ -68,12 +72,15 @@ module.exports = class Keyboard extends _matrix_base {
|
|||
if (pattern[i % 12] == 'w') whiteKeys++
|
||||
}
|
||||
|
||||
this.container.style.setProperty('--nkeys', whiteKeys)
|
||||
|
||||
for (i = start; i < keys + start && i < 109; i++) {
|
||||
|
||||
var data = JSON.parse(strData)
|
||||
|
||||
data.top = data.left = data.height = data.width = 'auto'
|
||||
data.type = this.getProp('toggles') ? 'toggle' : 'push'
|
||||
data.type = 'toggle'
|
||||
data.mode = this.getProp('toggles') ? 'toggle' : 'push'
|
||||
data.id = this.getProp('id') + '/' + i
|
||||
data.label = false
|
||||
data.css = ''
|
||||
|
|
@ -82,11 +89,11 @@ module.exports = class Keyboard extends _matrix_base {
|
|||
data.precision = '@{parent.precision}'
|
||||
|
||||
data.address = '@{parent.address}'
|
||||
data.preArgs = `#{
|
||||
a = @{parent.preArgs};
|
||||
b = typeof(a) == 'string' and a == '' ? [] : typeof(a) == 'Array' ? a : [a];
|
||||
concat(b, [${i}])
|
||||
}`
|
||||
data.preArgs = `JS{{
|
||||
var a = @{parent.preArgs};
|
||||
var b = typeof a === 'string' and a === '' ? [] : Array.isArray(a) ? a : [a];
|
||||
return b.concat([${i}])
|
||||
}}`
|
||||
|
||||
var key = parser.parse({
|
||||
data: data,
|
||||
|
|
@ -96,15 +103,14 @@ module.exports = class Keyboard extends _matrix_base {
|
|||
|
||||
key._index = i - start
|
||||
key.container.classList.add('not-editable')
|
||||
key.container.classList.add('key')
|
||||
|
||||
if (pattern[i % 12] == 'w') {
|
||||
key.container.classList.add('white')
|
||||
key.container.style.width = `${100/whiteKeys}%`
|
||||
whiteKeys2++
|
||||
} else {
|
||||
key.container.classList.add('black')
|
||||
key.container.style.width = `${60 / whiteKeys}%`
|
||||
key.container.style.left = `${100 / whiteKeys * (whiteKeys2 - 3/10)}%`
|
||||
key.container.style.setProperty('--rank', whiteKeys2)
|
||||
}
|
||||
|
||||
this.value[i - start] = this.getProp('off')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue