input/text: add align & wrap props (feature request #176)

This commit is contained in:
jean-emmanuel 2018-03-03 10:16:52 +01:00
parent a0bf06f8e9
commit 8292aa788d
7 changed files with 49 additions and 5 deletions

View file

@ -12,6 +12,8 @@
- knob: big knobs design tweaks
- **new** `default` property that sets a widgets initial/doubleTap/spring value. The `value` property does no longer serve this purpose.
- property inheritance: `@{widget_id.value}`, `@{widget_id}` and `@{widget_id._value}` now all refer to the widget's current value (the latter being kept for backward compatibility)
- text: added `align` and `wrap` properties
- input: added `align` property
- editor
- allow selecting multiple widgets (`ctrl + click`) if they share the same parent. Context-menu and sidepanel editing actions apply to all selected widgets

View file

@ -20,6 +20,11 @@
- default: `false`
- usage: set to `true` to display the input horizontally
### `align`
- type: `string`
- default: `''`
- usage: set to `left` or `right` to change text alignment (otherwise `center`)
### `unit`
- type: `string`
- default: `empty`

View file

@ -196,6 +196,16 @@ Text displays incoming values (via osc) as text. Sending a message with no argum
- default: `false`
- usage: set to `true` display vertically
### `wrap`
- type: `boolean`
- default: `false`
- usage: set to `true` to wrap long lines automatically
### `align`
- type: `string`
- default: `''`
- usage: set to `left` or `right` to change text alignment (otherwise `center`)
## Meter
Meter displays incoming numerical values (via osc) as a gauge level

View file

@ -28,6 +28,7 @@ module.exports = class Input extends Canvas {
_input:'input',
vertical:false,
align: '',
unit: '',
editable:true,
@ -59,9 +60,10 @@ module.exports = class Input extends Canvas {
this.stringValue = ''
this.focused = false
if (this.getProp('vertical')) {
this.widget.classList.add('vertical')
}
if (this.getProp('vertical')) this.widget.classList.add('vertical')
if (this.getProp('align') === 'left') this.widget.classList.add('left')
if (this.getProp('align') === 'right') this.widget.classList.add('right')
if (this.getProp('editable')) {
this.canvas.setAttribute('tabindex', 0)

View file

@ -27,6 +27,8 @@ module.exports = class Text extends Widget {
_text: 'text',
vertical:false,
wrap:false,
align:'',
_value: 'value',
default: '',
@ -50,6 +52,9 @@ module.exports = class Text extends Widget {
super({...options, html: '<div class="text"></div>'})
if (this.getProp('vertical')) this.widget.classList.add('vertical')
if (this.getProp('align') === 'left') this.widget.classList.add('left')
if (this.getProp('align') === 'right') this.widget.classList.add('right')
if (this.getProp('wrap')) this.widget.classList.add('wrap')
this.defaultValue = this.getProp('value') || ( this.getProp('label')===false ?
this.getProp('id'):

View file

@ -30,6 +30,12 @@
padding:1rem;
border: 1rem solid var(--color-bg);
background: var(--color-track);
&.right {
text-align: right;
}
&.left {
text-align: left;
}
input {
display: block;
flex:1;

View file

@ -70,9 +70,19 @@
display: flex;
align-items: center;
white-space: pre;
word-break: break-all;
background: var(--color-track);
color:var(--color-custom);
border: 1rem solid var(--color-bg);
&.right {
justify-content: flex-end;
}
&.left {
justify-content: flex-start;
}
&.wrap {
white-space: pre-wrap;
}
&.vertical {
transform: rotate(180deg);
text-overflow: ellipsis;
@ -155,11 +165,15 @@
--color-border:transparent;
padding: 0rem;
.plot, .text, .led, .image, .svg {
padding: 0rem;
margin: 1rem;
background-clip: content-box;
box-shadow: 0 0 0 1rem var(--color-fg);
outline:1rem solid var(--color-light);
border: 1rem solid var(--color-bg);
}
}
.panel:not(.tab) > .image-container {
.image {
background-clip: content-box;
}
}