editor: display the id of selected widget in the inspector's header

This commit is contained in:
jean-emmanuel 2023-03-10 10:59:05 +01:00
parent b337432651
commit 8546ce6dee
3 changed files with 16 additions and 6 deletions

View file

@ -9,7 +9,7 @@
- editor
- when focusing the label property with `F2`, select all text in the text area
- preserve scroll position in code editor when validating
- display the id of selected widget in the inspector's header
- scripting
- expose file browser (from the file widget) as a scripting function

View file

@ -31,7 +31,7 @@ class UiInspector extends UiWidget {
<div class="btn toolbar-btn" data-action="zoom-out">${raw(icon('magnifying-glass-minus'))}</div>
<div class="btn toolbar-btn" data-action="zoom-reset">${raw(icon('magnifying-glass'))}</div>
<div class="btn toolbar-btn" data-action="zoom-in">${raw(icon('magnifying-glass-plus'))}</div>
<div class="spacer"></div>
<div class="btn toolbar-btn" data-action="selected-id"><span></span></div>
<div class="btn toolbar-btn" data-action="reset-selection">${raw(icon('border-none'))}</div>
<div class="btn toolbar-btn" data-action="toggle-grid">${raw(icon('table-cells'))}</div>
</div>
@ -39,8 +39,10 @@ class UiInspector extends UiWidget {
this.toolbarBtns = {}
DOM.each(this.toolbar, '.btn', (item)=>{
var action = item.getAttribute('data-action')
item.setAttribute('title', locales('inspector_' + action.replace('-', '_')))
this.toolbarBtns[action] = item
if (action) {
if (action !== 'selected-id') item.setAttribute('title', locales('inspector_' + action.replace('-', '_')))
this.toolbarBtns[action] = item
}
})
zoom.on('local-zoom-changed',()=>{
this.toolbarBtns['zoom-out'].classList.toggle('active', zoom.localZoom < 1)
@ -163,6 +165,7 @@ class UiInspector extends UiWidget {
this.clearTimeout = setTimeout(()=>{
this.widget = null
this.content.innerHTML = ''
this.toolbarBtns['selected-id'].firstChild.innerHTML = ''
this.mounted = false
this.clearTimeout = null
this.colorPicker.close()
@ -259,6 +262,8 @@ class UiInspector extends UiWidget {
morph(this.content, content)
this.toolbarBtns['selected-id'].firstChild.innerHTML = widgets.map(x=>x.getProp('id')).join(', ')
if (codeEditorFields.length) {
let fields = DOM.get(this.container, '.has-editor')
for (var i in codeEditorFields) {

View file

@ -46,6 +46,10 @@ osc-panel-container.right.editor-breakout {
align-items: center;
justify-content: center;
display: flex;
span{
overflow: hidden;
text-overflow: ellipsis;
}
i {
pointer-events: none;
}
@ -64,8 +68,9 @@ osc-panel-container.right.editor-breakout {
transform: rotate(45deg);
}
}
.spacer {
flex: 1
[data-action="selected-id"] {
flex: 1;
cursor: default;
}
}