tree: add support for filtering widgets by type (by typing type:fader for example) (wip)
This commit is contained in:
parent
a402cd4aa0
commit
5f83b062a6
2 changed files with 10 additions and 4 deletions
|
|
@ -43,7 +43,9 @@ Selected widget's properties are displayed and can be modified in the inspector.
|
|||
|
||||
## Project tree
|
||||
|
||||
The project tree displays the whole widget structure of the session. Widgets can be reordered within a container with drag-and-drop.
|
||||
The project tree displays the whole widget structure of the session. Widgets can be reordered or moved to another container with drag-and-drop.
|
||||
|
||||
The "Filter" input allows filtering displayed widgets by their `id`. It's also possible to only display a single type of widget by typing `type:fader` for example.
|
||||
|
||||
## Widget resizing / dragging
|
||||
|
||||
|
|
|
|||
|
|
@ -248,7 +248,7 @@ class UiTree extends UiWidget {
|
|||
var selected = selectedWidgets.includes(widget),
|
||||
id = widget.getProp('id'),
|
||||
node = html`<li class="${selected ? 'editing' : ''} ${!widget.getProp('visible') ? 'invisible' : ''}"
|
||||
data-widget="${widget.hash}">
|
||||
data-widget="${widget.hash}" data-type="${widget.getProp('type')}">
|
||||
${raw(icon(widgetIcons[widget.getProp('type')] || 'root'))}${id}</li>`
|
||||
|
||||
if (widget instanceof Panel && !(widget instanceof Matrix || widget instanceof Keyboard)) {
|
||||
|
|
@ -277,9 +277,12 @@ class UiTree extends UiWidget {
|
|||
|
||||
applyFilter() {
|
||||
|
||||
var filter = this.filter.value
|
||||
var filter = this.filter.value.replace(/type\:[^\s]+/, ''),
|
||||
type = this.filter.value.match(/type\:([^\s]+)/)
|
||||
|
||||
if (!filter) {
|
||||
if (type !== null) type = type[1]
|
||||
|
||||
if (!filter && !type) {
|
||||
this.list.classList.remove('filter-active')
|
||||
} else {
|
||||
this.list.classList.add('filter-active')
|
||||
|
|
@ -287,6 +290,7 @@ class UiTree extends UiWidget {
|
|||
var show = []
|
||||
DOM.each(this.list, 'li', (element)=>{
|
||||
var match = element.innerText.includes(filter)
|
||||
if (type && element.dataset.type !== type) match = false
|
||||
element.classList.toggle('filter-hide', !match)
|
||||
if (match) show.push(element)
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue