diff --git a/CHANGELOG.md b/CHANGELOG.md
index 83580d50..59148957 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,8 @@
## 0.48.9
+- widgets:
+ - **new** `menu` widget, circular alternative to the dropdown & switch widgets
- editor:
- convert invalid quote characters automatically to avoid errors
diff --git a/src/client/app/widgets/buttons/menu.js b/src/client/app/widgets/buttons/menu.js
new file mode 100644
index 00000000..e6654f10
--- /dev/null
+++ b/src/client/app/widgets/buttons/menu.js
@@ -0,0 +1,184 @@
+var Widget = require('../common/widget'),
+ {iconify} = require('../../ui/utils'),
+ html = require('nanohtml'),
+ raw = require('nanohtml/raw')
+
+class Menu extends Widget {
+
+ static defaults() {
+
+ return super.defaults({
+
+ _menu:'menu',
+
+ size: {type: 'number', value: 200},
+ values: {type: 'array|object', value: {'Value 1':1,'Value 2':2}, help: [
+ '`Array` of possible values to switch between : `[1,2,3]`',
+ '`Object` of label:value pairs. Numeric labels must be prepended or appended with a white space (or any other non-numeric character) otherwise the order of the values won\'t be kept',
+ ]},
+ weights: {type: 'array', value: '', help: [
+ '`Array` of `number` defining the weights of each value in `values`'
+ ]}
+
+ })
+
+ }
+
+ constructor(options) {
+
+ super({...options, html: html`
`})
+
+ this.menu = this.widget.appendChild(html``)
+
+ this.opened = false
+ this.values = []
+ this.selected = -1
+ this.value = undefined
+
+ this.parseValues()
+
+
+ this.parentScroll = [0,0]
+ this.opened = false
+
+ this.on('draginit',(e)=>{
+ if (this.opened) return
+ this.open(e)
+ }, {element: this.widget})
+
+ this.on('drag',(e)=>{
+ if (e.target === this.menu) {
+ DOM.each(this.menu, '.active', (el)=>{el.classList.remove('active')})
+ this.selected = -1
+ } else if (!e.target.classList.contains('active')) {
+ DOM.each(this.menu, '.active', (el)=>{el.classList.remove('active')})
+ e.target.classList.add('active')
+ this.selected = DOM.index(e.target)
+ }
+ }, {element: this.widget})
+
+ this.on('dragend',()=>{
+ if (!this.opened) return
+ this.close()
+ if (this.selected > -1) {
+ this.setValue(this.values[this.selected], {send: true, sync: true})
+ }
+
+ }, {element: this.widget})
+
+ this.container.style.setProperty('--size', parseInt(this.getProp('size')) + 'rem')
+
+
+
+ }
+
+ open(e) {
+
+ this.opened = true
+ var off = this.scrollOffset()
+ this.menu.style.setProperty('--x', (e.offsetX - off[0]) / PXSCALE + 'rem')
+ this.menu.style.setProperty('--y', (e.offsetY - off[1]) / PXSCALE + 'rem')
+ this.menu.classList.add('show')
+
+ }
+
+ close() {
+
+ this.opened = false
+ this.menu.classList.remove('show')
+ DOM.each(this.menu, '.active', (el)=>{el.classList.remove('active')})
+
+ }
+
+ parseValues() {
+
+ var nval = 0,
+ i = 0,
+ values = this.getProp('values'),
+ weights = this.getProp('weights'),
+ totalWeight
+
+ if (!Array.isArray(values) && !(typeof values === 'object' && values !== null)) {
+ values = values !== '' ? [values] : []
+ }
+
+ this.values = []
+ this.menu.innerHTML = ''
+
+
+ nval = Array.isArray(values) ? values.length : Object.keys(values).length
+ weights = Array.isArray(weights) ? weights.slice(0, nval) : Array(nval).fill(1)
+ if (weights.length < nval) weights = weights.concat(Array(nval - weights.length).fill(1))
+ totalWeight = weights.reduce((a, b) => a + b, 0)
+
+ var ac = 0
+ for (let k in values) {
+ let angle = Math.min(360 * weights[i] / totalWeight, 120),
+ skew = 90 - angle
+ this.values.push(values[k])
+ this.menu.appendChild(html`
+
+
${raw(iconify(parseFloat(k) != k ? k : values[k]))}
+
+ `)
+ i++
+ ac+=angle
+
+ }
+
+ }
+
+ scrollOffset() {
+
+ var parent = this.parent,
+ scrollOffset = [0,0]
+
+ while (parent && parent.props && parent.getProp('type') !== 'tab') {
+ scrollOffset[0] += parent.widget.scrollLeft
+ scrollOffset[1] += parent.widget.scrollTop
+ parent = parent.parent
+ }
+
+ return scrollOffset
+
+ }
+
+ setValue(v,options={}) {
+
+ var i = this.values.indexOf(v)
+
+ if (i > -1) this.value = this.values[i]
+
+ DOM.each(this.menu, '.on', (el)=>{el.classList.remove('on')})
+ if (i > -1) DOM.get(this.menu, '.item')[i].classList.add('on')
+
+ if (options.send) this.sendValue()
+ if (options.sync) this.changed(options)
+
+ }
+
+ onPropChanged(propName, options, oldPropValue) {
+
+ var ret = super.onPropChanged(...arguments)
+
+ switch (propName) {
+
+ case 'values':
+ this.parseValues()
+ this.setValue(this.value)
+ return
+
+ }
+
+ return ret
+
+ }
+
+}
+
+Menu.dynamicProps = Menu.prototype.constructor.dynamicProps.concat(
+ 'values'
+)
+
+
+module.exports = Menu
diff --git a/src/client/app/widgets/index.js b/src/client/app/widgets/index.js
index 4bb00a72..7e2c1298 100644
--- a/src/client/app/widgets/index.js
+++ b/src/client/app/widgets/index.js
@@ -14,6 +14,7 @@ module.exports.widgets = {
push: require('./buttons/push'),
switch: require('./buttons/switch'),
dropdown: require('./buttons/dropdown'),
+ menu: require('./buttons/menu'),
// pads
xy: require('./pads/xy'),
@@ -61,7 +62,7 @@ module.exports.widgets = {
module.exports.categories = {
'Sliders':['fader','knob', 'encoder', 'range'],
- 'Buttons':['toggle','push','switch', 'dropdown'],
+ 'Buttons':['toggle','push','switch', 'dropdown', 'menu'],
'Pads':['xy','rgb','multixy'],
'Matrices':['matrix', 'keyboard', 'patchbay'],
'Plots':['plot','eq','visualizer','led', 'rgbled','meter','text', 'image', 'svg', 'html', 'frame'],
diff --git a/src/scss/widgets.scss b/src/scss/widgets.scss
index b4483e76..d3c00933 100644
--- a/src/scss/widgets.scss
+++ b/src/scss/widgets.scss
@@ -98,6 +98,7 @@
@import 'widgets/toggle';
@import 'widgets/push';
@import 'widgets/switch';
+@import 'widgets/menu';
@import 'widgets/panel';
diff --git a/src/scss/widgets/menu.scss b/src/scss/widgets/menu.scss
new file mode 100644
index 00000000..c3cf3ad8
--- /dev/null
+++ b/src/scss/widgets/menu.scss
@@ -0,0 +1,123 @@
+@keyframes menu-widget-fade {
+ 0%{opacity: 0; transform: scale(0.9);}
+ 100%{opacity: 1; transform: scale(1);}
+}
+.menu-container {
+ @extend .modal-container;
+
+
+ border-radius: 0!important; // border radius breaks it somehow
+ z-index: initial!important;
+
+ --size:300rem;
+
+ .menu {
+ display:none;
+ &.show {
+ display:block;
+ animation: menu-widget-fade .1s forwards;
+ }
+
+ width:var(--size);
+ height:var(--size);
+ position: fixed;
+ z-index: 999999999;
+ margin-left: calc(var(--x) - var(--size) / 2);
+ margin-top: calc(var(--y) - var(--size) / 2);
+
+ background: var(--color-fg);
+
+ border-radius: 100%;
+ overflow: hidden;
+ box-shadow: 0 0 0 1rem var(--color-light) inset, 0 0 5rem 0 var(--color-bg) ;
+
+ &:after {
+ content:"";
+ position: absolute;
+ width: calc(var(--size) / 3);
+ height: calc(var(--size) / 3);
+ top:50%;
+ left: 50%;
+ margin-left: calc(-1 * var(--size) / 6);
+ margin-top: calc(-1 * var(--size) / 6);
+ background: var(--color-raised);
+ box-shadow: 0 0 2rem 0 var(--color-bg), 0 0 0 2rem var(--color-light) inset;
+ border-radius: 100%;
+ z-index: 10;
+ }
+
+
+ .item {
+
+ position: absolute;
+ z-index: 1;
+ top: calc(-1 * var(--size) / 2);
+ left: calc(-1 * var(--size) / 2);
+ width: 100%;
+ height: 100%;
+ transform-origin: 100% 100%;
+ overflow: hidden;
+ box-shadow: 0 0 0 2.5rem var(--color-light) inset, 0 0 0 1.5rem var(--color-bg) inset;
+
+ &.on div:before {
+ content:"";
+ position: absolute;
+ width: calc(var(--size) / 3);
+ height: calc(var(--size) / 3);
+ left: calc(-1 * var(--size) / 6);
+ top: calc(-1 * var(--size) / 6);
+ border-radius: 100%;
+ pointer-events: none;
+ box-shadow: 0 0 0 4rem var(--color-custom);
+ }
+
+ &.on:before {
+ content:"";
+ position: absolute;
+ top:0;
+ left:0;
+ right:0;
+ bottom:0;
+ pointer-events: none;
+ background: var(--color-custom);
+ opacity: 0.3;
+ }
+
+ &.active:after {
+ content:"";
+ position: absolute;
+ top:0;
+ left:0;
+ right:0;
+ bottom:0;
+ pointer-events: none;
+ background: var(--color-light);
+ }
+
+ div {
+ position: absolute;
+ bottom: 0;
+ right: 0;
+ text-align: center;
+ pointer-events: none;
+ }
+
+ span {
+ position: absolute;
+ top: calc(-1 * var(--size) / 3);
+ width: calc(var(--size) / 2);
+ margin-left: calc(-1 * var(--size) / 4);
+ }
+
+ }
+
+ }
+}
+
+.widget.menu-container > .label:after {
+ content:"\f51f";
+ transform: none;
+ font-size: 12rem;
+ top:4rem;
+ right:6rem;
+}
diff --git a/src/scss/widgets/panel.scss b/src/scss/widgets/panel.scss
index 3dd06c5f..48037479 100644
--- a/src/scss/widgets/panel.scss
+++ b/src/scss/widgets/panel.scss
@@ -182,7 +182,7 @@
@extend .toggle-container;
> .label:after {
- content:"\f0da"!important;
+ content:"\f0da";
font-family: FontAwesome;
transform: rotateZ(-45deg);
font-size: 20rem;