be4 copy paste any widget

This commit is contained in:
bordun 2020-03-06 15:42:23 +01:00
parent 9744fe422b
commit 8edcb8d044
32 changed files with 412 additions and 356 deletions

View file

@ -82,7 +82,7 @@ module.exports = {
return parent ? Array.prototype.indexOf.call(parent.children, element) : -1
},
offset: function(element) {
offset: function(element, container) {
var offsetLeft = 0,
offsetTop = 0
@ -95,7 +95,7 @@ module.exports = {
if (!isNaN(element.offsetTop)) {
offsetTop += element.offsetTop - element.scrollTop
}
} while ((element = element.offsetParent))
} while ((element = element.offsetParent) && element !== container)
}
return {

View file

@ -52,23 +52,6 @@ var handleClick = function(event) {
parent = editor.selectedWidgets[0].parent,
actions = []
// case root: only "add tab" option
// if (parent === widgetManager) {
// actions.push({
// label: icon('plus') + ' ' + locales('editor_addtab'),
// action: ()=>{
// data[0].tabs.push({})
//
// var indexes = {addedIndexes: [data[0].tabs.length -1]}
// updateWidget(editor.selectedWidgets[0], indexes)
// editor.pushHistory(indexes)
// }
// })
// contextMenu.open(eventData, actions)
//
// return
// }
// case !root
var clickX = Math.round((eventData.offsetX + eventData.target.scrollLeft) / (GRIDWIDTH * PXSCALE)) * GRIDWIDTH,
@ -76,6 +59,13 @@ var handleClick = function(event) {
if (type === 'widget' && parent !== widgetManager) {
if (event.target.tagName !== 'LI') actions.push({
label: icon('project-diagram') + ' ' + locales('editor_show_in_tree'),
action: ()=>{
editor.widgetTree.showWidget(editor.selectedWidgets[0])
}
})
actions.push({
label: icon('copy') + ' ' + locales('editor_copy'),
action: editor.copyWidget.bind(editor)
@ -86,46 +76,6 @@ var handleClick = function(event) {
action: editor.cutWidget.bind(editor)
})
// var wrapActions = []
// for (let c of categories.Containers) {
// if (c === 'clone') continue
// wrapActions.push({
// label: c,
// action: ()=>{
// var wrap = {type: c, widgets:[], label: c === 'modal' ? 'auto' : false}
//
// wrap.widgets = data
//
// var minTop = Math.min(...data.map(x=>isNaN(x.top) ? x.top == 'auto' ? 0 : Infinity : x.top))
// var minLeft = Math.min(...data.map(x=>isNaN(x.left) ? x.left == 'auto' ? 0 : Infinity : x.left))
//
// wrap.top = minTop === Infinity ? data[0].top : minTop
// wrap.left= minLeft === Infinity ? data[0].left : minLeft
//
// for (var w of wrap.widgets) {
// if (!isNaN(w.top)) w.top = Math.max(w.top - minTop, 0)
// if (!isNaN(w.left)) w.left = Math.max(w.left - minLeft, 0)
// }
//
// var i
// for (i of index) {
// parent.props.widgets.splice(i,1)
// }
//
// parent.props.widgets = parent.props.widgets.slice(0, i).concat(wrap, parent.props.widgets.slice(i, parent.props.widgets.length))
//
// editor.select(updateWidget(parent, {preventSelect: true, removedIndexes: index, addedIndexes: [i]}))
// editor.pushHistory({removedIndexes: index, addedIndexes: [i]})
//
// }
// })
// }
//
// actions.push({
// label: icon('layer-group') + ' ' + locales('editor_wrap'),
// action: wrapActions
// })
}

View file

@ -9,6 +9,7 @@ var {updateWidget, incrementWidget} = require('./data-workers'),
UiInspector = require('../ui/ui-inspector'),
UiTree = require('../ui/ui-tree'),
UiDragResize = require('../ui/ui-dragresize'),
Panel = require('../widgets/containers/panel'),
sidepanel = require('../ui/ui-sidepanel'),
html = require('nanohtml'),
sessionManager
@ -500,6 +501,7 @@ var Editor = class Editor {
pasteWidget(x, y, increment) {
if (!this.selectedWidgets.length || this.clipboard === null) return
if (!(this.selectedWidgets[0] instanceof Panel)) return
var data = this.selectedWidgets.map((w)=>w.props)
@ -618,7 +620,7 @@ var Editor = class Editor {
nH = w.container.offsetHeight + deltaH
}
if (w.props.width !== undefined) {
if (w.props.width !== undefined && w.parent.getProp('layout') !== 'vertical') {
var newWidth = Math.max(nW, GRIDWIDTH) / PXSCALE
if (typeof w.props.width === 'string' && w.props.width.indexOf('%') > -1) {
w.props.width = (100 * PXSCALE * newWidth / w.container.parentNode.offsetWidth).toFixed(2) + '%'
@ -627,7 +629,7 @@ var Editor = class Editor {
}
}
if (w.props.height !== undefined) {
if (w.props.height !== undefined && w.parent.getProp('layout') !== 'horizontal') {
var newHeight = Math.max(nH, GRIDWIDTH) / PXSCALE
if (typeof w.props.height === 'string' && w.props.height.indexOf('%') > -1) {
w.props.height = (100 * PXSCALE * newHeight / w.container.parentNode.offsetHeight).toFixed(2) + '%'

View file

@ -8,6 +8,7 @@ module.exports = {
editor_inspector: 'Inspector',
// editor context-menu
editor_show_in_tree: 'Show in tree',
editor_copy: 'Copy',
editor_cut: 'Cut',
editor_wrap: 'Wrap in',

View file

@ -2,7 +2,8 @@ var {updateWidget} = require('./editor/data-workers'),
editor = require('./editor'),
widgetManager = require('./managers/widgets'),
stateManager = require('./managers/state'),
deepExtend = require('deep-extend')
deepExtend = require('deep-extend'),
notifications = require('./ui/notifications')
var callbacks = {
'/EDIT': function(args) {
@ -213,26 +214,18 @@ var callbacks = {
stateManager.quickLoad()
},
'/TABS': function(args) {
'/NOTIFY': function(args) {
if (!Array.isArray(args)) args = [args]
console.log(args)
notifications.add({
message: args.join('\n')
})
for (let id of args) {
let ws = widgetManager.getWidgetById(id)
for (let w of ws) {
if (w.getProp('type') === 'tab') {
var index = w.parent.children.indexOf(w)
w.parent.setValue(index, {sync: true, send: false})
}
}
}
},
}
}
// backward-compatibility
callbacks['/EDIT_SOFT'] = callbacks['/EDIT/MERGE']
module.exports = {
exec: function(name, args){
if (callbacks[name]) {

View file

@ -20,11 +20,12 @@ class Toast {
var toast = html`
<div class="toast ${data.class || ''}">
<i class="fa fa-fw fa-${data.icon || (data.class === 'error' ? 'exclamation' : 'bell')}"></i>
<div class="content">
${data.message}
</div>
<div class="content"></div>
</div>
`
DOM.get(toast, '.content')[0].textContent = data.message
if (this.html) {
this.html = morph(this.html, toast)
} else {

View file

@ -118,6 +118,22 @@ class UiTree extends UiWidget {
}
showWidget(widget) {
var node = DOM.get(this.list, `[data-widget="${widget.hash}"]`)
if (node) {
var parent = node[0].parentNode
while (parent !== this.list) {
if (parent.classList.contains('container')) {
parent.classList.add('expanded')
}
parent = parent.parentNode
}
node[0].scrollIntoView({block: 'center'})
}
}
select() {
// hint selection in folded containers

View file

@ -17,7 +17,8 @@ class Switch extends Widget {
_switch:'switch',
horizontal: {type: 'boolean', value: false, help: 'Set to `true` to display values horizontally'},
layout: {type: 'string', value: 'vertical', choices: ['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.'},
showValues: {type: 'boolean', value: false, help: 'If values is an object, set to `true` to display both values and labels instead of labels only'},
values: {type: 'array|object', value: {'Value 1':1,'Value 2':2}, help: [
'`Array` of possible values to switch between : `[1,2,3]`',
@ -39,7 +40,13 @@ class Switch extends Widget {
super({...options, html: html`<inner></inner>`})
if (this.getProp('horizontal')) this.container.classList.add('horizontal')
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
}
this.values = []
this.stringValues = []

View file

@ -68,6 +68,7 @@ class Widget extends EventEmitter {
]},
width: {type: 'number|percentage', value: 'auto', help: ''},
height: {type: 'number|percentage', value: 'auto', help: ''},
expand: {type: 'boolean|number', value: 'false', help: 'If parent\'s layout is `vertical` or `horizontal`, set this to `true` to stretch the widget to use available space automatically.'},
_style:'style',
@ -756,6 +757,7 @@ class Widget extends EventEmitter {
case 'height':
case 'width':
case 'expand':
this.setContainerStyles(['geometry'])
var container = this.parent !== widgetManager && this.parent.getProp('layout') !== 'default' ? this.parent.container : this.container
resize.check(container)
@ -851,6 +853,7 @@ class Widget extends EventEmitter {
}
}
this.container.classList.toggle('absolute-position', absolutePos)
this.container.classList.toggle('flex-expand', this.getProp('expand'))
}
@ -859,13 +862,13 @@ class Widget extends EventEmitter {
// label
if (this.getProp('label') === false) {
this.container.classList.add('nolabel')
this.container.classList.add('no-label')
this.label.innerHTML = ''
} else {
this.container.classList.remove('nolabel')
this.container.classList.remove('no-label')
var label = this.getProp('label') == 'auto'?
this.getProp('id'):
iconify(this.getProp('label'))
iconify(this.getProp('label').replace(/</g, '&lt;'))
this.label.innerHTML = label
this.container.appendChild(this.label)
@ -1037,6 +1040,7 @@ Widget.dynamicProps = [
'left',
'height',
'width',
'expand',
'colorText',

View file

@ -6,7 +6,7 @@ var Container = require('../common/container'),
{diff, diffToWidget} = require('../../editor/diff'),
html = require('nanohtml')
var excludedCloneClasses = ['widget', 'absolute-position', 'not-editable', 'editing']
var excludedCloneClasses = ['widget', 'absolute-position', 'not-editable', 'editing', 'flex-expand']
class Clone extends Container() {

View file

@ -22,7 +22,9 @@ class Panel extends Container() {
colorPanel: {type: 'string', value: 'auto', help:''},
layout: {type: 'string', value: 'default', choices: ['default', 'vertical', 'horizontal', 'grid'], help:''},
justify: {type: 'string', value: 'start', choices: ['start', 'end', 'center', 'space-around', 'space-between'], help:'If `layout` is `vertical` or `horizontal`, defines how widgets should be justified.'},
gridTemplate: {type: 'string|number', value: '', help:'If `layout` is `grid`, can be either a number of columns of a value css grid-template definition.'},
verticalTabs: {type: 'boolean', value: false, help: 'Set to `true` to display for vertical tab layout'},
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'},
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'},
@ -50,14 +52,24 @@ class Panel extends Container() {
this.container.classList.toggle('no-scroll', !this.getProp('scroll'))
this.container.classList.add('layout-' + this.getProp('layout'))
if (this.getProp('layout') === 'grid') {
var layout = this.getProp('layout')
if (layout === 'grid') {
var template = this.getProp('gridTemplate') || 2
this.widget.style.gridTemplate = template === parseInt(template) ? `none / repeat(${template}, 1fr)` : template
} else if (layout === 'vertical' || layout === 'horizontal'){
var justify = this.getProp('justify')
if (justify === 'start' || justify === 'end') justify = 'flex-' + justify
this.widget.style.justifyContent = justify
}
if (this.getProp('tabs') && this.getProp('tabs').length) {
this.container.classList.add('contains-tabs')
this.container.classList.toggle('vertical-tabs', this.getProp('verticalTabs'))
} else {
@ -74,7 +86,7 @@ class Panel extends Container() {
this.value = -1
this.navigation = this.widget.appendChild(html`<div class="navigation"></div>`)
this.navigation = this.widget.appendChild(html`<div class="navigation ${this.getProp('verticalTabs') ? 'vertical' : ''}"></div>`)
this.children = options.children || new Array(this.getProp('tabs').length)
for (let i = 0; i < this.children.length; i++) {
@ -156,11 +168,12 @@ class Panel extends Container() {
if (!widget.getProp('visible')) style += 'display:none;'
this.tabs.push(widget)
this.navigation.appendChild(html`
var label = html`
<div class="tablink" data-widget="${widget.hash}" style="${style}">
${raw(widget.label.innerHTML)}
</div>
`)
`
label.innerHTML = widget.label.innerHTML
this.navigation.appendChild(label)
})

View file

@ -22,7 +22,9 @@ class Root extends StaticProperties(Panel, {scroll: false, label: false, id: 'ro
colorPanel: {type: 'string', value: 'auto', help:''},
layout: {type: 'string', value: 'default', choices: ['default', 'vertical', 'horizontal', 'grid'], help:''},
justify: {type: 'string', value: 'start', choices: ['start', 'end', 'center', 'space-around', 'space-between'], help:'If `layout` is `vertical` or `horizontal`, defines how widgets should be justified.'},
gridTemplate: {type: 'string|number', value: '', help:'If `layout` is `grid`, can be either a number of columns of a value css grid-template definition.'},
verticalTabs: {type: 'boolean', value: false, help: 'Set to `true` to display for vertical tab layout'},
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: '', help: 'Defines one or more arbitrary variables that can be inherited by children widgets'},

View file

@ -18,7 +18,9 @@ module.exports = class Tab extends Panel {
// 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', 'grid'], help:''},
justify: {type: 'string', value: 'start', choices: ['start', 'end', 'center', 'space-around', 'space-between'], help:'If `layout` is `vertical` or `horizontal`, defines how widgets should be justified.'},
gridTemplate: {type: 'string|number', value: '', help:'If `layout` is `grid`, can be either a number of columns of a value css grid-template definition.'},
verticalTabs: {type: 'boolean', value: false, help: 'Set to `true` to display for vertical tab layout'},
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'},
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'},

View file

@ -17,9 +17,8 @@ module.exports = class Fader extends Slider {
_fader:'fader',
mode: {type: 'string', value: 'compact', choices: ['compact', 'classic', 'round'], help: 'Design style'},
design: {type: 'string', value: 'compact', choices: ['compact', 'classic', 'round'], help: 'Design style'},
horizontal: {type: 'boolean', value: false, help: 'Set to `true` to display the fader horizontally'},
alignRight: {type: 'boolean', value: false, help: 'Set to `true` to invert the pip\'s and fader\'s position'},
pips: {type: 'boolean', value: false, help: 'Set to `true` to show range breakpoints'},
dashed: {type: 'boolean', value: false, help: 'Set to `true` to display a dashed gauge'},
gradient: {type: 'array|object', value: [], help: [
@ -65,8 +64,6 @@ module.exports = class Fader extends Slider {
this.gaugeGradient = null
this.container.classList.add('design-' + this.getProp('mode'))
}
draginitHandle(e) {
@ -180,7 +177,7 @@ module.exports = class Fader extends Slider {
o = Math.round(this.percentToCoord(this.valueToPercent(this.originValue))),
m = this.getProp('horizontal') ? this.height / 2 : this.width / 2,
dashed = this.getProp('dashed'),
compact = this.getProp('mode') === 'compact'
compact = this.getProp('design') === 'compact'
this.clear()
@ -256,7 +253,7 @@ module.exports = class Fader extends Slider {
this.clearRect = [0, 0, width, height]
} else if (this.getProp('mode') === 'classic') {
} else if (this.getProp('design') === 'classic') {
if (this.cssVars.alphaStroke) {
@ -342,7 +339,7 @@ module.exports = class Fader extends Slider {
var width = this.getProp('horizontal') ? this.height : this.width,
height = !this.getProp('horizontal') ? this.height : this.width,
m = this.getProp('horizontal') ? this.height / 2 : this.width / 2,
compact = this.getProp('mode') === 'compact'
compact = this.getProp('design') === 'compact'
if (width % 2 && parseInt(m) !== m) m -= 0.5

View file

@ -15,6 +15,7 @@ module.exports = class Knob extends Slider {
_knob:'knob',
design: {type: 'string', value: 'default', choices: ['default', 'classic'], help: 'Design style'},
mode: {type: 'string', value: 'vertical', choices: ['vertical', 'circular', 'snap'], help: [
'- `circular`: relative move in circular motion',
'- `snap`: snap to touch position and move in vertical motion',
@ -181,58 +182,118 @@ module.exports = class Knob extends Slider {
this.clear()
// fill
this.ctx.strokeStyle = this.cssVars.colorFill
this.ctx.lineWidth = gaugeWidth - this.gaugePadding * 2
if (this.getProp('design') === 'default') {
// fill
this.ctx.strokeStyle = this.cssVars.colorFill
this.ctx.lineWidth = gaugeWidth - this.gaugePadding * 2
if (this.cssVars.alphaFillOff) {
this.ctx.globalAlpha = this.cssVars.alphaFillOff
this.ctx.beginPath()
this.ctx.arc(this.width / 2, this.height / 2, gaugeRadius, min, max)
this.ctx.stroke()
}
if (dashed) this.ctx.setLineDash([1.5 * PXSCALE, 1.5 * PXSCALE])
if (this.cssVars.alphaFillOn) {
this.ctx.globalAlpha = this.cssVars.alphaFillOn
this.ctx.beginPath()
this.ctx.arc(this.width / 2, this.height / 2, gaugeRadius, o, d, o > d)
this.ctx.stroke()
}
if (dashed) this.ctx.setLineDash([])
// stroke
this.ctx.globalAlpha = this.cssVars.alphaStroke
this.ctx.strokeStyle = this.cssVars.colorStroke
this.ctx.lineWidth = PXSCALE
if (this.cssVars.alphaFillOff) {
this.ctx.globalAlpha = this.cssVars.alphaFillOff
this.ctx.beginPath()
this.ctx.arc(this.width / 2, this.height / 2, gaugeRadius, min, max)
this.ctx.arc(this.width / 2, this.height / 2, minRadius, 0, 2 * Math.PI)
this.ctx.stroke()
this.ctx.beginPath()
this.ctx.arc(this.width / 2, this.height / 2, maxRadius, 0, 2 * Math.PI)
this.ctx.stroke()
// knob
this.ctx.globalAlpha = 1
this.ctx.strokeStyle = this.cssVars.colorFill
this.ctx.lineWidth = 1.5 * PXSCALE
let r1 = minRadius + this.gaugePadding,
r2 = maxRadius - this.gaugePadding,
a = 2 * Math.PI - d
this.ctx.beginPath()
this.ctx.moveTo(r1 * Math.cos(a) + this.width / 2, this.height / 2 - r1 * Math.sin(a))
this.ctx.lineTo(r2 * Math.cos(a) + this.width / 2, this.height / 2 - r2 * Math.sin(a))
this.ctx.stroke()
} else {
// fill
this.ctx.strokeStyle = this.cssVars.colorFill
this.ctx.lineWidth = 2 * PXSCALE
if (this.cssVars.alphaFillOff) {
this.ctx.globalAlpha = this.cssVars.alphaFillOff
this.ctx.beginPath()
this.ctx.arc(this.width / 2, this.height / 2, maxRadius, min, max)
this.ctx.stroke()
}
if (dashed) this.ctx.setLineDash([1.5 * PXSCALE, 1.5 * PXSCALE])
if (this.cssVars.alphaFillOn) {
this.ctx.globalAlpha = this.cssVars.alphaFillOn
this.ctx.beginPath()
this.ctx.arc(this.width / 2, this.height / 2, maxRadius, o, d, o > d)
this.ctx.stroke()
}
if (dashed) this.ctx.setLineDash([])
// center
this.ctx.fillStyle = this.cssVars.colorPanel
this.ctx.strokeStyle = this.cssVars.colorStroke
this.ctx.lineWidth = 1 * PXSCALE
this.ctx.beginPath()
this.ctx.arc(this.width / 2, this.height / 2, maxRadius - (2 + this.cssVars.padding) * PXSCALE, 0, 2 * Math.PI)
this.ctx.globalAlpha = this.cssVars.alphaStroke
this.ctx.stroke()
this.ctx.globalAlpha = 1
// this.ctx.fill()
// knob
this.ctx.globalAlpha = 1
this.ctx.fillStyle = this.cssVars.colorFill
this.ctx.lineWidth = 1.5 * PXSCALE
let r1 = maxRadius - (8 + this.cssVars.padding) * PXSCALE,
r2 = maxRadius / 3 ,
a = 2 * Math.PI - d
this.ctx.beginPath()
this.ctx.arc(r1 * Math.cos(a) + this.width / 2, this.height / 2 - r1 * Math.sin(a), 1.5 * PXSCALE, 0, 2*Math.PI)
this.ctx.fill()
}
if (dashed) this.ctx.setLineDash([1.5 * PXSCALE, 1.5 * PXSCALE])
if (this.cssVars.alphaFillOn) {
this.ctx.globalAlpha = this.cssVars.alphaFillOn
this.ctx.beginPath()
this.ctx.arc(this.width / 2, this.height / 2, gaugeRadius, o, d, o > d)
this.ctx.stroke()
}
if (dashed) this.ctx.setLineDash([])
// stroke
this.ctx.globalAlpha = this.cssVars.alphaStroke
this.ctx.strokeStyle = this.cssVars.colorStroke
this.ctx.lineWidth = PXSCALE
this.ctx.beginPath()
this.ctx.arc(this.width / 2, this.height / 2, minRadius, 0, 2 * Math.PI)
this.ctx.stroke()
this.ctx.beginPath()
this.ctx.arc(this.width / 2, this.height / 2, maxRadius, 0, 2 * Math.PI)
this.ctx.stroke()
// knob
this.ctx.globalAlpha = 1
this.ctx.strokeStyle = this.cssVars.colorFill
this.ctx.lineWidth = 1.5 * PXSCALE
let r1 = minRadius + this.gaugePadding,
r2 = maxRadius - this.gaugePadding,
a = 2 * Math.PI - d
this.ctx.beginPath()
this.ctx.moveTo(r1 * Math.cos(a) + this.width / 2, this.height / 2 - r1 * Math.sin(a))
this.ctx.lineTo(r2 * Math.cos(a) + this.width / 2, this.height / 2 - r2 * Math.sin(a))
this.ctx.stroke()
// pips

View file

@ -3,12 +3,11 @@ var {clip} = require('../utils'),
Fader = require('./fader'),
Input = require('../inputs/input'),
touchstate = require('../mixins/touch_state'),
html = require('nanohtml'),
StaticProperties = require('../mixins/static_properties')
html = require('nanohtml')
var faderDefaults = Fader.defaults()._props()
class Range extends StaticProperties(Fader, {mode: 'compact'}) {
class Range extends Fader {
static description() {
@ -16,15 +15,6 @@ class Range extends StaticProperties(Fader, {mode: 'compact'}) {
}
static defaults() {
var defaults = super.defaults()
delete defaults.mode
return defaults
}
constructor(options) {
options.multitouch = true
@ -209,19 +199,36 @@ class Range extends StaticProperties(Fader, {mode: 'compact'}) {
var d = Math.round(fader.percentToCoord(fader.valueToPercent(this.faders[this.getProp('horizontal')?0:1].value))),
d2 = Math.round(fader.percentToCoord(fader.valueToPercent(this.faders[this.getProp('horizontal')?1:0].value))),
m = Math.round(this.getProp('horizontal') ? this.height / 2 : this.width / 2)
// sharp border trick
if (width % 2 && parseInt(m) === m) m -= 0.5
var dashed = this.getProp('dashed')
m = this.getProp('horizontal') ? this.height / 2 : this.width / 2,
dashed = this.getProp('dashed'),
compact = this.getProp('design') === 'compact'
this.clear()
if (this.getProp('pips') && !compact) m -= 10 * PXSCALE
// sharp border trick
if (compact) {
if (width % 2 && parseInt(m) === m) m -= 0.5
} else {
if (width % 2 && parseInt(m) !== m) m -= 0.5
}
this.ctx.strokeStyle = this.gaugeGradient || this.cssVars.colorFill
this.ctx.lineWidth = Math.round(width - this.gaugePadding * 2)
if (compact) {
this.ctx.lineWidth = Math.round(width - this.gaugePadding * 2)
} else {
this.ctx.lineWidth = 2 * PXSCALE
}
if (dashed) this.ctx.setLineDash([PXSCALE, PXSCALE])
if (this.cssVars.alphaFillOff) {
// gaugo off
this.ctx.globalAlpha = this.cssVars.alphaFillOff
this.ctx.beginPath()
this.ctx.moveTo(m, height - this.gaugePadding)
@ -229,12 +236,9 @@ class Range extends StaticProperties(Fader, {mode: 'compact'}) {
this.ctx.stroke()
}
if (dashed) {
this.ctx.lineDashOffset = d % 2 ? PXSCALE : 0 // avoid flickering
this.ctx.setLineDash([PXSCALE, PXSCALE])
}
if (this.cssVars.alphaFillOn) {
// gaugo on
this.ctx.globalAlpha = this.cssVars.alphaFillOn
this.ctx.beginPath()
this.ctx.moveTo(m, d)
@ -244,31 +248,114 @@ class Range extends StaticProperties(Fader, {mode: 'compact'}) {
if (dashed) this.ctx.setLineDash([])
this.ctx.globalAlpha = this.cssVars.alphaStroke
this.ctx.strokeStyle = this.cssVars.colorStroke
if (compact) {
this.ctx.beginPath()
this.ctx.moveTo(0, 0)
this.ctx.lineTo(width, 0)
this.ctx.lineTo(width, height)
this.ctx.lineTo(0, height)
this.ctx.closePath()
this.ctx.lineWidth = 2 * PXSCALE
this.ctx.stroke()
// stroke
this.ctx.globalAlpha = this.cssVars.alphaStroke
this.ctx.strokeStyle = this.cssVars.colorStroke
this.ctx.beginPath()
this.ctx.moveTo(0, 0)
this.ctx.lineTo(width, 0)
this.ctx.lineTo(width, height)
this.ctx.lineTo(0, height)
this.ctx.closePath()
this.ctx.lineWidth = 2 * PXSCALE
this.ctx.stroke()
this.ctx.globalAlpha = 1
this.ctx.fillStyle = this.cssVars.colorFill
// flat knob
this.ctx.beginPath()
this.ctx.rect(this.gaugePadding, Math.min(d, height - 3 * PXSCALE), width - this.gaugePadding * 2, PXSCALE)
this.ctx.fill()
this.ctx.globalAlpha = 1
this.ctx.fillStyle = this.cssVars.colorFill
this.ctx.beginPath()
this.ctx.rect(this.gaugePadding, Math.min(d2, height - 3 * PXSCALE), width - this.gaugePadding * 2, PXSCALE)
this.ctx.fill()
this.ctx.beginPath()
this.ctx.rect(this.gaugePadding, Math.min(d, height - this.gaugePadding - PXSCALE), width - this.gaugePadding * 2, PXSCALE)
this.ctx.fill()
// extra knob
this.ctx.beginPath()
this.ctx.rect(this.gaugePadding, Math.min(d2, height - this.gaugePadding - PXSCALE), width - this.gaugePadding * 2, PXSCALE)
this.ctx.fill()
this.clearRect = [0, 0, width, height]
} else if (this.getProp('design') === 'classic') {
for (let _d of [d, d2]) {
if (this.cssVars.alphaStroke) {
this.ctx.globalAlpha = 1
this.ctx.fillStyle = this.cssVars.colorPanel
this.ctx.beginPath()
this.ctx.rect(m - 6 * PXSCALE, _d - 10 * PXSCALE, 12 * PXSCALE, 20 * PXSCALE)
this.ctx.fill()
this.ctx.globalAlpha = this.cssVars.alphaStroke
this.ctx.strokeStyle = this.cssVars.colorStroke
this.ctx.lineWidth = PXSCALE
this.ctx.beginPath()
this.ctx.rect(m - 5.5 * PXSCALE, _d - 9.5 * PXSCALE, 11 * PXSCALE, 19 * PXSCALE)
this.ctx.stroke()
}
this.ctx.globalAlpha = 1
this.ctx.fillStyle = this.cssVars.colorWidget
this.ctx.beginPath()
this.ctx.rect(m - 3 * PXSCALE, _d, 6 * PXSCALE, PXSCALE)
this.ctx.fill()
}
this.clearRect = [m - 10 * PXSCALE, this.gaugePadding - 10 * PXSCALE, 20 * PXSCALE, height - 2 * this.gaugePadding + 20 * PXSCALE]
} else {
this.ctx.globalAlpha = 1
this.ctx.fillStyle = this.cssVars.colorFill
this.ctx.beginPath()
this.ctx.arc(m, d, 3 * PXSCALE, 0, 2 * Math.PI)
this.ctx.fill()
// extra knob
this.ctx.beginPath()
this.ctx.arc(m, d2, 3 * PXSCALE, 0, 2 * Math.PI)
this.ctx.fill()
if (this.cssVars.alphaStroke) {
this.ctx.globalAlpha = this.cssVars.alphaStroke
this.ctx.fillStyle = this.cssVars.colorFill
this.ctx.beginPath()
this.ctx.arc(m, d, 10 * PXSCALE, 0, 2 * Math.PI)
this.ctx.fill()
// extra knob
this.ctx.beginPath()
this.ctx.arc(m, d2, 10 * PXSCALE, 0, 2 * Math.PI)
this.ctx.fill()
}
this.clearRect = [m - 11 * PXSCALE, this.gaugePadding - 11 * PXSCALE, 22 * PXSCALE, height - 2 * this.gaugePadding + 22 * PXSCALE]
}
if (this.getProp('pips')) {
this.ctx.globalAlpha = 1
this.ctx.drawImage(this.pips, 0, 0);
if (!compact) this.clearRect = [this.clearRect, [m + 10 * PXSCALE, 0, 10 * PXSCALE + this.pipsTextSize, height]]
}
this.clearRect = [0, 0, width, height]
}

View file

@ -12,6 +12,8 @@ class Slider extends Canvas {
<canvas></canvas>
`})
this.container.classList.add('design-' + this.getProp('design'))
this.value = undefined
this.percent = 0

View file

@ -5,7 +5,6 @@
@import 'ui';
@import 'editor';
@import 'sidepanel';
@import 'widgets';
input,

View file

@ -1,148 +0,0 @@
//
// #sidepanel {
// position:absolute;
// z-index: 999999;
// width:var(--sidepanel-size);
// max-width: calc(100% - 45rem);
// min-width: 300rem;
// border-top: 2rem solid var(--color-bg);
// border-bottom: 2rem solid var(--color-bg);
// border-right: 2rem solid var(--color-bg);
// top:0;
// right:0;
// bottom:0;
// margin-right:calc(-1 * var(--sidepanel-size));
// background:var(--color-bg);
// transition:transform .25s, opacity .25s;
// transform: translate3d(0,0,0);
// opacity: 0;
// box-shadow: 0 0 15rem 0 rgba(black, 0.3);
// display: flex;
// flex-direction: column;
//
// #sidepanel-wrapper {
// overflow-y: auto;
// overflow-x: visible;
// display: flex;
// flex-direction: column;
// flex:1;
// }
//
// &.sidepanel-open {
// transform: translate3d(calc(-1 * var(--sidepanel-size)),0,0);
// opacity: 1;
// }
//
// &.hide {
// z-index: -1;
// pointer-events: none;
// margin-right: 0;
// }
//
// .navigation {
// margin-bottom:2rem;
// margin-left: 0;
// li {
// cursor:default;
// }
// a {
// text-transform: none;
// color: var(--color-accent);
// justify-content: center;
// }
// }
// #options {
// box-shadow: 0 0 0 1rem var(--color-light) inset;
// background: var(--color-fg);
// padding: 8rem;
// flex: 1 1 auto;
// flex-shrink:0;
//
// li {
// display: block;
// margin-bottom: 8rem;
// &:last-child {
// margin-bottom:0;
// }
// }
// }
// }
// .actions {
// padding:0.5rem;
// background:var(--color-bg);
// display: flex;
// align-items: stretch;
// flex-wrap:wrap;
// .title {
// flex: 1 1 100%;
// background: var(--color-fg);
// box-shadow: 0 0 0 1rem var(--color-light) inset;
// padding: 13rem 10rem;
// position: relative;
// margin: 0.5rem;
// &.disabled {
// color:var(--color-text-fade);
// }
// &:before {
// content:"";
// position: absolute;
// top:0;
// left:0;
// right:0;
// bottom:0;
// box-shadow: 0 0 0 1rem;
// color:var(--color-bg);
// }
//
// }
// a {
// // flex: 4 1 32%;
// flex:1;
// min-width: 32%;
// padding:13rem 10rem;
// display: block;
// text-align: center;
// position: relative;
// color:var(--color-text);
// overflow: visible;
// margin: 0.5rem;
// &.narrow {
// width: auto;
// min-width: 40rem;
// flex:0;
// }
//
//
// &.on {
// z-index: 0;
// color: var(--color-custom);
// &:not(.toggle) {
// pointer-events: none;
// }
// &:after {
// content: "";
// position: absolute;
// top:0;
// left: 0;
// right: 0;
// bottom: 0;
// opacity: 0.4;
// background: radial-gradient( ellipse at center, transparent, var(--color-bg));
// }
// &:before {
// content:"";
// position: absolute;
// top:0;
// left: 0;
// right: 0;
// bottom: 0;
// opacity: 0.3;
// box-shadow: 0 0 0 1rem var(--color-custom) inset;
// border-radius: inherit;
// }
// }
//
// }
// }

View file

@ -42,7 +42,8 @@ $line-height: 30rem;
width: 10rem;
text-align: center;
line-height: $line-height - 2;
font-size: 90%;
font-size: 9rem;
pointer-events: none;
}
&.focus {
> .context-menu {
@ -95,6 +96,7 @@ $line-height: 30rem;
flex: 1;
text-transform: capitalize;
opacity: 0.5;
pointer-events: none;
}
}
.separator{

View file

@ -38,7 +38,7 @@
}
.content {
padding: 10rem;
white-space: normal;
white-space: pre-line;
text-transform: none;
line-height: normal;
}

View file

@ -12,6 +12,11 @@ osc-workspace {
flex-direction: row;
overflow: hidden;
background-image: url(../assets/logo.png);
background-size: 80rem;
background-position: center;
background-repeat: no-repeat;
}
osc-panel-container {

View file

@ -28,7 +28,7 @@
z-index: 10;
}
&.nolabel {
&.no-label {
> .label {
display:none;
}
@ -41,7 +41,7 @@
border-bottom-left-radius:inherit;
min-height: 0;
}
&.nolabel > .label ~ div {
&.no-label > .label ~ div {
border-radius: inherit;
}

View file

@ -210,7 +210,7 @@
width: 100rem;
height:60rem;
padding:1rem;
&.nolabel {
&.no-label {
--color-border:var(--color-bg);
padding: 0;
.file {

View file

@ -8,7 +8,7 @@
}
height:200rem;
width:200rem;
&.nolabel .matrix {
&.no-label .matrix {
top:0;
}

View file

@ -81,7 +81,7 @@
}
}
&.nolabel {
&.no-label {
> .panel {
top:-1rem;
}

View file

@ -234,7 +234,7 @@
}
}
}
.editor-enabled .frame-container.nolabel iframe {
.editor-enabled .frame-container.no-label iframe {
pointer-events: none;
}

View file

@ -4,7 +4,7 @@
height:100rem;
padding:1rem;
&.nolabel {
&.no-label {
--color-border:var(--color-bg);
padding: 0;
.switch, .switcher {
@ -147,7 +147,7 @@
width:100rem;
height: 60rem;
padding:1rem;
&.nolabel {
&.no-label {
--color-border:var(--color-bg);
padding: 0;
.select {

View file

@ -45,7 +45,7 @@
z-index: 10;
}
&.nolabel {
&.no-label {
> label {
display:none;
}

View file

@ -66,12 +66,19 @@
}
&.horizontal inner {
&.layout-horizontal inner {
flex-direction: row;
}
&.layout-grid inner {
display:grid;
}
value {
position: relative;

View file

@ -40,6 +40,9 @@
max-height: 100%;
max-width: 100%;
}
> .flex-expand {
flex: 1
}
}
&.layout-vertical > inner {
display: flex;
@ -55,7 +58,9 @@
max-height: 100%;
max-width: 100%;
}
> .flex-expand {
flex: 1
}
}
&.layout-grid > inner {
display: grid;
@ -92,6 +97,14 @@
padding: 0;
}
}
&.vertical-tabs {
> inner {
flex-direction: row;
}
}
}
}
@ -139,12 +152,15 @@
}
}
&.contains-widgets.nolabel > inner {
&.contains-widgets.no-label > inner {
border-top: 1rem solid var(--color-background);
}
&.contains-tabs > inner > .navigation {
margin: 0 1rem;
&.vertical {
margin: 1rem 0;
}
}
@ -154,7 +170,6 @@
@extend .widget-panel-base;
--widget-padding: 1rem;
--alpha-fill-on: 0.75;
width: 100%;
@ -209,6 +224,8 @@
text-overflow: ellipsis;
padding: 0 8rem;
overflow: hidden!important;
white-space: pre-wrap;
text-align: center;
i {
pointer-events: none;
@ -228,13 +245,6 @@
background: var(--color-fill);
z-index: 101;
}
&:last-child {
margin-right:0;
margin-left: auto;
i {
font-size: 14rem;
}
}
&:first-child:before {
margin-left: 1rem;
}
@ -244,6 +254,43 @@
}
}
&.vertical {
flex-direction: column;
height: 100%;
padding-bottom: 0;
padding-right: 1rem;
div {
height: 100%;
padding: 0 12rem;
line-height: normal;
// justify-content: flex-start;
// text-align: left;
&.on:before {
content: "";
position: absolute;
left: auto;
top: 0rem;
right: 0rem;
bottom: 0rem;
opacity: var(--alpha-fill-on);
width: 4rem;
height: auto;
background: var(--color-fill);
z-index: 101;
}
&:first-child:before {
margin-top: 1rem;
margin-left: 0;
}
&:last-child:before {
margin-bottom: 1rem;
margin-right: 0;
}
}
}
}

View file

@ -52,4 +52,10 @@
--widget-padding: 1rem;
--alpha-stroke: 0.75;
&.design-classic {
--alpha-stroke: 0.5;
--alpha-fill-off: 0.25;
--alpha-fill-on: 1;
}
}