container: refactor strip using panel as base

This commit is contained in:
jean-emmanuel 2017-06-05 18:43:49 +02:00
parent 1f858cc205
commit 67eae0ef84
11 changed files with 1965 additions and 668 deletions

View file

@ -6,6 +6,7 @@
- add property inheritance between widgets through `@{parent.propertyName}` statements;
- containers: added `variables` options (arbitrary varibles to pass to children)
- modal: changed style to fit popups' appearance; added `popupWidth` and `popupHeight` options
- strip: refactored widget using `panel` as base; added `stretch` option
- custom module
- add access to the app's `settings` object

File diff suppressed because it is too large Load diff

View file

@ -46,7 +46,8 @@
"preArgs": [],
"target": [],
"linkId": "",
"spring": false
"spring": false,
"touchAddress": ""
},
{
"type": "toggle",
@ -90,7 +91,8 @@
"origin": "auto",
"value": "",
"linkId": "",
"spring": false
"spring": false,
"touchAddress": ""
},
{
"type": "knob",
@ -117,7 +119,8 @@
"origin": "auto",
"value": "",
"linkId": "",
"spring": false
"spring": false,
"touchAddress": ""
},
{
"type": "knob",
@ -144,7 +147,8 @@
"origin": "auto",
"value": "",
"linkId": "",
"spring": false
"spring": false,
"touchAddress": ""
},
{
"type": "fader",
@ -180,10 +184,16 @@
"target": [],
"linkId": "",
"width": "auto",
"spring": false
"spring": false,
"touchAddress": "",
"meterAddress": ""
}
],
"width": "auto"
"width": "auto",
"left": "auto",
"top": "auto",
"stretch": false,
"variables": {}
},
{
"type": "strip",
@ -219,7 +229,8 @@
"preArgs": [],
"target": [],
"linkId": "",
"spring": false
"spring": false,
"touchAddress": ""
},
{
"type": "toggle",
@ -263,7 +274,8 @@
"origin": "auto",
"value": "",
"linkId": "",
"spring": false
"spring": false,
"touchAddress": ""
},
{
"type": "knob",
@ -290,7 +302,8 @@
"origin": "auto",
"value": "",
"linkId": "",
"spring": false
"spring": false,
"touchAddress": ""
},
{
"type": "knob",
@ -317,7 +330,8 @@
"origin": "auto",
"value": "",
"linkId": "",
"spring": false
"spring": false,
"touchAddress": ""
},
{
"type": "fader",
@ -353,10 +367,16 @@
"preArgs": [],
"target": [],
"linkId": "",
"spring": false
"spring": false,
"touchAddress": "",
"meterAddress": ""
}
],
"width": "auto"
"width": "auto",
"left": "auto",
"top": "auto",
"stretch": false,
"variables": {}
},
{
"type": "strip",
@ -392,7 +412,8 @@
"preArgs": [],
"target": [],
"linkId": "",
"spring": false
"spring": false,
"touchAddress": ""
},
{
"type": "toggle",
@ -436,7 +457,8 @@
"origin": "auto",
"value": "",
"linkId": "",
"spring": false
"spring": false,
"touchAddress": ""
},
{
"type": "knob",
@ -463,7 +485,8 @@
"origin": "auto",
"value": "",
"linkId": "",
"spring": false
"spring": false,
"touchAddress": ""
},
{
"type": "knob",
@ -490,7 +513,8 @@
"origin": "auto",
"value": "",
"linkId": "",
"spring": false
"spring": false,
"touchAddress": ""
},
{
"type": "fader",
@ -526,10 +550,16 @@
"preArgs": [],
"target": [],
"linkId": "",
"spring": false
"spring": false,
"touchAddress": "",
"meterAddress": ""
}
],
"width": "auto"
"width": "auto",
"left": "auto",
"top": "auto",
"stretch": false,
"variables": {}
},
{
"type": "strip",
@ -565,7 +595,8 @@
"preArgs": [],
"target": [],
"linkId": "",
"spring": false
"spring": false,
"touchAddress": ""
},
{
"type": "toggle",
@ -609,7 +640,8 @@
"origin": "auto",
"value": "",
"linkId": "",
"spring": false
"spring": false,
"touchAddress": ""
},
{
"type": "knob",
@ -636,7 +668,8 @@
"origin": "auto",
"value": "",
"linkId": "",
"spring": false
"spring": false,
"touchAddress": ""
},
{
"type": "knob",
@ -663,7 +696,8 @@
"origin": "auto",
"value": "",
"linkId": "",
"spring": false
"spring": false,
"touchAddress": ""
},
{
"type": "fader",
@ -699,10 +733,16 @@
"preArgs": [],
"target": [],
"linkId": "",
"spring": false
"spring": false,
"touchAddress": "",
"meterAddress": ""
}
],
"width": "auto"
"width": "auto",
"left": "auto",
"top": "auto",
"stretch": false,
"variables": {}
},
{
"type": "strip",
@ -738,7 +778,8 @@
"preArgs": [],
"target": [],
"linkId": "",
"spring": false
"spring": false,
"touchAddress": ""
},
{
"type": "toggle",
@ -782,7 +823,8 @@
"origin": "auto",
"value": "",
"linkId": "",
"spring": false
"spring": false,
"touchAddress": ""
},
{
"type": "knob",
@ -809,7 +851,8 @@
"origin": "auto",
"value": "",
"linkId": "",
"spring": false
"spring": false,
"touchAddress": ""
},
{
"type": "knob",
@ -836,7 +879,8 @@
"origin": "auto",
"value": "",
"linkId": "",
"spring": false
"spring": false,
"touchAddress": ""
},
{
"type": "fader",
@ -872,10 +916,16 @@
"preArgs": [],
"target": [],
"linkId": "",
"spring": false
"spring": false,
"touchAddress": "",
"meterAddress": ""
}
],
"width": "auto"
"width": "auto",
"left": "auto",
"top": "auto",
"stretch": false,
"variables": {}
},
{
"type": "strip",
@ -911,7 +961,8 @@
"preArgs": [],
"target": [],
"linkId": "",
"spring": false
"spring": false,
"touchAddress": ""
},
{
"type": "toggle",
@ -955,7 +1006,8 @@
"origin": "auto",
"value": "",
"linkId": "",
"spring": false
"spring": false,
"touchAddress": ""
},
{
"type": "knob",
@ -982,7 +1034,8 @@
"origin": "auto",
"value": "",
"linkId": "",
"spring": false
"spring": false,
"touchAddress": ""
},
{
"type": "knob",
@ -1009,7 +1062,8 @@
"origin": "auto",
"value": "",
"linkId": "",
"spring": false
"spring": false,
"touchAddress": ""
},
{
"type": "fader",
@ -1045,10 +1099,16 @@
"preArgs": [],
"target": [],
"linkId": "",
"spring": false
"spring": false,
"touchAddress": "",
"meterAddress": ""
}
],
"width": "auto"
"width": "auto",
"left": "auto",
"top": "auto",
"stretch": false,
"variables": {}
},
{
"type": "strip",
@ -1083,7 +1143,8 @@
"preArgs": [],
"target": [],
"linkId": "",
"spring": false
"spring": false,
"touchAddress": ""
},
{
"type": "toggle",
@ -1127,7 +1188,8 @@
"origin": "auto",
"value": "",
"linkId": "",
"spring": false
"spring": false,
"touchAddress": ""
},
{
"type": "knob",
@ -1154,7 +1216,8 @@
"origin": "auto",
"value": "",
"linkId": "",
"spring": false
"spring": false,
"touchAddress": ""
},
{
"type": "knob",
@ -1181,7 +1244,8 @@
"origin": "auto",
"value": "",
"linkId": "",
"spring": false
"spring": false,
"touchAddress": ""
},
{
"type": "fader",
@ -1217,11 +1281,17 @@
"target": [],
"linkId": "",
"spring": false,
"width": "auto"
"width": "auto",
"touchAddress": "",
"meterAddress": ""
}
],
"height": "auto",
"width": "auto"
"width": "auto",
"left": "auto",
"top": "auto",
"stretch": false,
"variables": {}
},
{
"type": "strip",
@ -1257,7 +1327,8 @@
"preArgs": [],
"target": [],
"linkId": "",
"spring": false
"spring": false,
"touchAddress": ""
},
{
"type": "toggle",
@ -1301,7 +1372,8 @@
"origin": "auto",
"value": "",
"linkId": "",
"spring": false
"spring": false,
"touchAddress": ""
},
{
"type": "knob",
@ -1328,7 +1400,8 @@
"origin": "auto",
"value": "",
"linkId": "",
"spring": false
"spring": false,
"touchAddress": ""
},
{
"type": "knob",
@ -1355,7 +1428,8 @@
"origin": "auto",
"value": "",
"linkId": "",
"spring": false
"spring": false,
"touchAddress": ""
},
{
"type": "fader",
@ -1391,10 +1465,16 @@
"preArgs": [],
"target": [],
"linkId": "",
"spring": false
"spring": false,
"touchAddress": "",
"meterAddress": ""
}
],
"width": "auto"
"width": "auto",
"left": "auto",
"top": "auto",
"stretch": false,
"variables": {}
},
{
"type": "strip",
@ -1430,7 +1510,8 @@
"preArgs": [],
"target": [],
"linkId": "",
"spring": false
"spring": false,
"touchAddress": ""
},
{
"type": "toggle",
@ -1474,7 +1555,8 @@
"origin": "auto",
"value": "",
"linkId": "",
"spring": false
"spring": false,
"touchAddress": ""
},
{
"type": "knob",
@ -1501,7 +1583,8 @@
"origin": "auto",
"value": "",
"linkId": "",
"spring": false
"spring": false,
"touchAddress": ""
},
{
"type": "knob",
@ -1528,7 +1611,8 @@
"origin": "auto",
"value": "",
"linkId": "",
"spring": false
"spring": false,
"touchAddress": ""
},
{
"type": "fader",
@ -1564,10 +1648,16 @@
"linkId": "",
"spring": false,
"value": "",
"origin": "auto"
"origin": "auto",
"touchAddress": "",
"meterAddress": ""
}
],
"width": "auto"
"width": "auto",
"left": "auto",
"top": "auto",
"stretch": false,
"variables": {}
},
{
"type": "strip",
@ -1603,7 +1693,8 @@
"preArgs": [],
"target": [],
"linkId": "",
"spring": false
"spring": false,
"touchAddress": ""
},
{
"type": "toggle",
@ -1647,7 +1738,8 @@
"origin": "auto",
"value": "",
"linkId": "",
"spring": false
"spring": false,
"touchAddress": ""
},
{
"type": "knob",
@ -1674,7 +1766,8 @@
"origin": "auto",
"value": "",
"linkId": "",
"spring": false
"spring": false,
"touchAddress": ""
},
{
"type": "knob",
@ -1701,7 +1794,8 @@
"origin": "auto",
"value": "",
"linkId": "",
"spring": false
"spring": false,
"touchAddress": ""
},
{
"type": "fader",
@ -1737,14 +1831,22 @@
"preArgs": [],
"target": [],
"linkId": "",
"spring": false
"spring": false,
"touchAddress": "",
"meterAddress": ""
}
],
"width": "auto"
"width": "auto",
"left": "auto",
"top": "auto",
"stretch": false,
"variables": {}
}
],
"height": "auto",
"top": 0
"top": 0,
"stretch": false,
"variables": {}
},
{
"type": "strip",
@ -1788,7 +1890,8 @@
"preArgs": [],
"split": false,
"target": [],
"spring": true
"spring": true,
"touchAddress": ""
},
{
"type": "keyboard",
@ -1805,9 +1908,9 @@
"preArgs": [],
"split": false,
"target": [],
"height": "auto",
"width": "auto",
"css": ""
"width": "100%",
"css": "",
"height": "auto"
},
{
"type": "strip",
@ -1834,9 +1937,7 @@
"on": 1,
"off": 0,
"norelease": true,
"id": "octave_up",
"separator1": "style",
"separator2": "osc"
"id": "octave_up"
},
{
"type": "push",
@ -1853,15 +1954,20 @@
"off": 0,
"linkId": "",
"norelease": true,
"id": "octave_down",
"separator1": "style",
"separator2": "osc"
"id": "octave_down"
}
]
],
"left": "auto",
"top": "auto",
"stretch": false,
"variables": {}
}
],
"id": "strip_12"
"id": "strip_12",
"stretch": false,
"variables": {}
}
]
],
"id": ""
}
]

View file

@ -1,6 +1,6 @@
## Widgets generics
A widget object is a javascript object. All widgets share a set of generic properties described below. Each widget type comes with an additional set of specific properties which are documented in these pages:
All widgets share a set of generic properties described below. Each widget type comes with an additional set of specific properties which are documented in these pages:
- [Sliders](widgets-specifics/sliders.md)
- [Buttons](widgets-specifics/buttons.md)

View file

@ -1,29 +1,12 @@
# Containers
Containers can contain any widgets
Containers can contain any widgets. Children can inherit from the container's properties by using the following syntax : `@{parent.propertyName}`. It can be used to:
----
- concatenate strings: `/@{parent.id}/some_suffix`
- define object value: `["@{parent.id}"]`
## Strip
If the retreived property is an object (`[] / {}`), it can be used as is or one can retreive a specfic item from it: `@{parent.variables.0}` will try to return the first item of the parent's `variables` property.
Strips can contain any number of widgets, which can't be absolutely positioned and whose size can't overflow their parent's.
```js
{
type:'strip',
// etc
}
```
#### `horizontal`
- type: `boolean`
- default: `false`
- usage: set to `true` to display widgets horizontally
#### `widgets`
- type: `array`
- default: `[]`
- usage: each element of the `array` must be a widget `object`
----
@ -65,11 +48,51 @@ Panels can contains tabs or widgets. These can be absolutely positioned and can
- default: `0`
- usage: spacing size used in `layout` expression, can be set as a `[vertical,horizontal]` array.
#### `variables`
- type: `*`
- default: `{}`
- usage: defines one or more arbitrary variables that can be inherited by children widgets.
- examples:
- `1` (`@{parent.variables}` will return `1`)
- `{a: [1, 2], b: 2}` (`@{parent.variables.a}` will return `[1, 2]`)
- `[1, 2]` (`@{parent.variables.0}` will return `1`)
- `@{parent.variables}` useful when nesting containers
----
## Strip
Unidirectionnal panel with stretching capability.
```js
{
type:'strip',
// etc
}
```
#### `horizontal`
- type: `boolean`
- default: `false`
- usage: set to `true` to display widgets horizontally
#### `stretch`
- type: `boolean`
- default: `false`
- usage: set to `true` to stretch widgets evenly
#### `widgets`
- type: `array`
- default: `[]`
- usage: each element of the `array` must be a widget `object`
----
## Modal
Modals are buttons that turn into a fullscreen panels when enabled. They can be enabled via osc (1 to enable, 0 to disable).
Modals are buttons that turn into a centered popup panels when enabled. They can be enabled via osc (1 to enable, 0 to disable).
```js
{
@ -78,5 +101,11 @@ Modals are buttons that turn into a fullscreen panels when enabled. They can be
}
```
#### `popupWidth` / `popupHeight`
- type: `number|percentage`
- default: `100%`
- usage: sets the modal's size once opened.
#### `options`
- see panel's [`options`](#panel)

View file

@ -37,6 +37,8 @@ module.exports = class Modal extends _widgets_base {
_chidlren:'children',
variables:{},
widgets:[],
tabs:[]
}

View file

@ -1,6 +1,6 @@
var _widgets_base = require('../common/_widgets_base')
var Panel = require('./panel')
module.exports = class Strip extends _widgets_base {
module.exports = class Strip extends Panel {
static defaults() {
@ -15,12 +15,18 @@ module.exports = class Strip extends _widgets_base {
top:'auto',
width:'auto',
height:'auto',
horizontal:false,
color:'auto',
css:'',
_strip: 'strip',
horizontal:false,
stretch:false,
_children:'children',
variables:{},
widgets:[]
}
@ -28,18 +34,13 @@ module.exports = class Strip extends _widgets_base {
constructor(options) {
super({...options, html: '<div class="strip"></div>'})
options.props = {...Panel.defaults(), ...options.props}
super(options)
var parsewidgets = require('../../parser').widgets
this.container.addClass(this.getProp('horizontal') ? 'horizontal' : 'vertical')
this.container.addClass(this.getProp('stretch') ? 'stretch' : '')
if (this.getProp('horizontal')) {
this.container.addClass('horizontal')
} else {
this.container.addClass('vertical')
}
parsewidgets(this.props.widgets, this.widget, this)
}

View file

@ -92,6 +92,7 @@
overflow: hidden;
.white {
--color-light-fg: var(--color-white);
height:100%;
.light.active:before {
opacity: .5;
background:var(--color-fg);

View file

@ -70,6 +70,73 @@
}
.strip-container {
@extend .panel-container-base;
width: 100rem;
height: 100%;
&.horizontal {
width: 100%;
height: 130rem;
}
&.vertical {
> .panel {
display: flex;
flex-direction: column;
> .widget {
// flex:1;
max-width: 100%;
width: 100%;
min-height: 0!important;
}
}
}
&.horizontal {
> .panel {
display: flex;
flex-direction: row;
> .widget {
// flex:1;
height: 100%;
max-height: 100%;
min-width: 0!important;
}
left:29rem;
top:-1rem;
}
&.nolabel > .panel {
left:-1rem;
}
> .label {
width:30rem;
line-height: 20rem;
flex-shrink: 0;
height:100%;
border-bottom:0;
border-right:1rem solid var(--color-bg);
max-height: initial;
span {
transform: rotate(180deg);
display: block;
position: relative;
overflow: hidden;
text-overflow: ellipsis;
-webkit-writing-mode:vertical-lr;
writing-mode:vertical-lr;
text-align: center;
}
}
}
&.stretch > .panel > .widget {
flex:1
}
background: var(--color-fg);
}
.modal-container {
@extend .panel-container-base;
@extend .toggle-container;

View file

@ -1,96 +0,0 @@
.strip-container {
width:100rem;
height:100%;
overflow: visible;
> .strip {
height: 100%;
width:100%;
display: flex;
flex-direction: column;
> .widget {
width:auto;
.label {
background-image: none;
}
}
}
&.vertical {
> .strip {
align-items: center;
}
> .strip > .widget {
width: 100%;
min-width: 100%;
margin-left:0;
border-left:0;
margin-left:0rem;
}
&::before {
border-right: 1rem solid var(--color-bg);
}
&.nolabel > .strip > .widget {
&:first-child{
border-top:0;
}
}
}
&.horizontal {
width:100%;
height:200rem;
display: flex;
flex-direction: row;
&::before {
border-bottom: 1rem solid var(--color-bg);
}
> .strip {
flex-direction: row;
flex:1;
> .widget {
flex-shrink: initial;
width: 100%;
min-height: 100%;
margin-top:0;
border-top:0;
margin-left:0rem;
height:100%;
&:last-child {
border-right:0;
}
}
}
> .label {
width:30rem;
line-height: 20rem;
flex-shrink: 0;
height:100%;
border-bottom:0;
max-height: initial;
span {
transform: rotate(180deg);
display: block;
position: relative;
overflow: hidden;
text-overflow: ellipsis;
-webkit-writing-mode:vertical-lr;
writing-mode:vertical-lr;
text-align: center;
}
}
&.nolabel > .strip > .widget {
&:first-child{
border-left:0;
}
}
}
}

View file

@ -1,6 +1,6 @@
.toggle-container {
width:100rem;
min-height: 60rem;
height: 60rem;
flex-shrink: 0;
padding:0!important;
background: var(--color-light-fg);