- new widget container : panel

- width parameter in px (no more x100 factor)
This commit is contained in:
jean-emmanuel 2015-09-25 11:46:41 +02:00
parent 91896169b9
commit f9cc812f6b
6 changed files with 103 additions and 5 deletions

View file

@ -99,7 +99,7 @@ It can also be a self invoking function that returns an array of objects :
{
id:"my_widget_id", // [string] optional, default to unique 'widget_n'
label:"My widget", // [string] default to id
width:false, // [integer] widget's width (1 = 100px)
width:false, // [integer] widget's width in px
target:false, // [array/string] List of target hosts ("ip:port" pairs), separated by spaces
path:false // [string] osc path, default to '/widget_id'
}
@ -108,12 +108,24 @@ It can also be a self invoking function that returns an array of objects :
### Widget specifics
- **strip**
*Strips are simple widget containers*
```
type:'strip',
horizontal:false, // [bool] set to true to display widgets horizontally
widgets: [] // [array] of widget objects
```
- **panel**
*Panel are widget containers with absolute position and arbitrary size*
```
type:'panel',
top:'auto', // [integer] absolute position in px
left:'auto', // [integer] absolute position in px
height:'auto', // [integer] absolute position in px
width:'auto', // [integer] width in px
widgets: [] // [array] of widget objects
```
- **fader**
```
type:'fader',

File diff suppressed because one or more lines are too long

View file

@ -64,8 +64,8 @@ parsewidgets = function(widgets,parent) {
var id = widgetData.id,
label = widgetData.label || id,
path = widgetData.path || '/' + id,
width = clip(parseInt(widgetData.width),[1,20]),
style= widgetData.width?`width:${width*100}rem;min-width:${width*100}rem`:''
width = clip(parseInt(widgetData.width),[100,2000]),
style= widgetData.width?`width:${width}rem;min-width:${width}rem`:''
widgetData.path = path
widgetData.target = widgetData.target?(Array.isArray(widgetData.target)?widgetData.target:[widgetData.target]):false

View file

@ -16,6 +16,33 @@ createWidget.strip = function(widgetData,container) {
}
createWidget.panel = function(widgetData,container) {
var widget = $(`
<div class="panel">
</div>
`),
left = parseInt(widgetData.left) || 'auto',
top = parseInt(widgetData.top) || 'auto',
width = parseInt(widgetData.width) || 'auto',
height = parseInt(widgetData.height) || 'auto'
container.css({
left:parseInt(widgetData.left)+'rem',
top:parseInt(widgetData.top)+'rem',
width:parseInt(widgetData.width)+'rem',
height:parseInt(widgetData.height)+'rem',
'min-width':''
})
parsewidgets(widgetData.widgets,widget)
widget.getValue = function(){return}
widget.setValue = function(){return}
return widget
}
createWidget.led = function(widgetData) {
var widget = $(`
<div class="led">

View file

@ -545,6 +545,7 @@ form {
.tab {
display:none;
overflow: auto;
position: relative;
&.on {
display: block;
height:100%;
@ -565,12 +566,13 @@ form {
font-size:13rem;
padding:35rem 0 0;
vertical-align:top;
border: 6rem solid $color-fg;
border: 6rem solid transparent;
border-width:6rem 0;
margin:0 3rem;
box-shadow: 0 0 0 1px $color-bg inset;
background:$bg-3d;
background-clip:padding-box;
&:first-child {
margin-left:6rem;
@ -703,6 +705,22 @@ form {
.panel-container {
position: absolute;
margin:0!important;
border-top:0;
z-index: 2;
.panel {
height:100%;
padding:6rem 0;
> .widget {
border:0;
}
}
}
/* BUTTONS */

41
sessions/demo-panel.js Normal file
View file

@ -0,0 +1,41 @@
[
{
widgets:[
{
type:'panel',
label:false,
top:40,
left:200,
height:400,
widgets:[
// these are fader (all options to defaults)
{
},
{
},
{
},
{
}
]
},
{
type:'panel',
top:450,
left:200,
height:400,
widgets:[
// these are fader (all options to defaults)
{
},
{
},
{
},
{
}
]
}
]
}
]