diff --git a/src/kiri/init.js b/src/kiri/init.js index ac28a691..abf68d72 100644 --- a/src/kiri/init.js +++ b/src/kiri/init.js @@ -2682,10 +2682,10 @@ gapp.register("kiri.init", [], (root, exports) => { $('render-wire').onclick = () => { api.view.wireframe(true, 0, api.space.is_dark() ? 0.25 : 0.5); }; $('render-solid').onclick = () => { api.view.wireframe(false, 0, 1); }; // mesh buttons - $('mesh-swap').onclick = () => { api.widgets.replace() }; - $('mesh-enable').onclick = () => { api.selection.enable() }; - $('mesh-disable').onclick = () => { api.selection.disable() }; - $('mesh-rename').onclick = () => { api.widgets.rename() }; + // $('mesh-swap').onclick = () => { api.widgets.replace() }; + // $('mesh-enable').onclick = () => { api.selection.enable() }; + // $('mesh-disable').onclick = () => { api.selection.disable() }; + // $('mesh-rename').onclick = () => { api.widgets.rename() }; $('mesh-export-stl').onclick = () => { objectsExport('stl') }; $('mesh-export-obj').onclick = () => { objectsExport('obj') }; $('context-duplicate').onclick = duplicateSelection; diff --git a/src/kiri/platform.js b/src/kiri/platform.js index 16bd8fe4..ad2ee6ac 100644 --- a/src/kiri/platform.js +++ b/src/kiri/platform.js @@ -235,44 +235,6 @@ function platformUpdateSelected() { const { extruders } = device; const { selection, ui } = api; - const selwid = selection.widgets(true); - const selreal = selection.widgets(false).length; - const selcount = selwid.length; - - $('mesh-enable').disabled = selreal != 1; - $('mesh-disable').disabled = selreal != 1; - $('mesh-rename').disabled = selcount != 1; - $('mesh-swap').disabled = selcount != 1; - - if (selcount) { - let enaC = selwid.filter(w => w.meta.disabled !== true).length; - let disC = selwid.filter(w => w.meta.disabled === true).length; - if (api.feature.meta && selcount) { - let name = selwid[0].meta.file || selwid[0].meta.url; - if (name) { - name = name - .toLowerCase() - .replace(/_/g, ' ') - .replace(/.png/, '') - .replace(/.stl/, ''); - let sp = name.indexOf('/'); - if (sp >= 0) { - name = name.substring(sp + 1); - } - } - let vert = selwid.map(w => w.meta.vertices).reduce((a,b) => a+b); - ui.mesh.points.innerText = util.comma(vert); - ui.mesh.faces.innerText = util.comma(vert / 3); - } else { - ui.mesh.points.innerText = '-'; - ui.mesh.faces.innerText = '-'; - } - } else { - ui.mesh.points.innerText = '-'; - ui.mesh.faces.innerText = '-'; - } - ui.mesh.name.innerText = selection.widgets(false).length; - if (extruders) { for (let i = 0; i < extruders.length; i++) { let b = $(`sel-ext-${i}`); @@ -568,29 +530,77 @@ function platformDeletePost() { function platformChanged() { h.bind($('ws-widgets'), api.widgets.all().map(w => { let color; + let file = w.meta.file || 'no name'; + let fsho = file.length > 25 ? file.slice(0,20) + '..' + file.slice(-2) : file; return [ - h.div([ - + h.div({ + onmouseenter() { + color = w.getColor(); + w.setColor(0x0088ff, null, false); + }, + onmouseleave() { + w.setColor(color, null, false); + }, + },[ + h.div({ class: "widpop" }, [ + h.div({ class: "widopt" }, [ + h.button( + { + title: "rename", + onclick() { api.widgets.rename(w) + }}, + [ h.i({ class:"fas fa-pen-to-square" }) ] + ), + h.button( + { + title: "replace", + onclick() { api.widgets.replace(null,w) } + }, + [ h.i({ class:"fas fa-rotate" }) ] + ), + h.button( + { + id: `w-en-${w.id}`, + title: "toggle disabled", + class: w.meta.disabled ? "disabled" : "", + onclick() { + let dis = w.meta.disabled = !w.meta.disabled; + let sel = api.selection.contains(w); + api.uc.setClass($(`w-en-${w.id}`), "disabled", dis); + w.setColor(sel ? COLOR.selected : COLOR.deselected, null, false); + } + }, + [ h.i({ class:"fas fa-ban" }) ] + ), + h.button( + { + title: "delete", + onclick() { platformDelete(w) } + }, + [ h.i({ class:"fas fa-trash" }), ] + ) + ]), + h.button([ + h.i({ class: "fa-solid fa-caret-left" }) + ]) + ]), h.button({ - _: w.meta.file || 'no name', + _: fsho, id: `ws-${w.id}`, - class: "grow", - onmouseenter() { - color = w.getColor(); - w.setColor(0x0088ff); - }, - onmouseleave() { - w.setColor(color); - }, + class: "grow name", + title: file, + // onmouseenter() { + // color = w.getColor(); + // w.setColor(0x0088ff, null, false); + // }, + // onmouseleave() { + // w.setColor(color, null, false); + // }, onclick() { platformSelect(w, true, false); color = w.getColor(); } - }), - h.button( - { onclick() { platformDelete(w) } }, - [ h.i({ class:"fas fa-trash" }), ] - ) + }) ]) ] })); diff --git a/src/kiri/widgets.js b/src/kiri/widgets.js index 6288917f..2dcff847 100644 --- a/src/kiri/widgets.js +++ b/src/kiri/widgets.js @@ -29,8 +29,9 @@ function annotate(id) { return (w.anno = w.anno || {}); } -function rename() { - let widgets = api.selection.widgets(true); +/** TODO really should be on widget, not widgets */ +function rename(sel) { + let widgets = sel ? [ sel ] : api.selection.widgets(true); if (widgets.length !== 1) { return; } @@ -43,8 +44,8 @@ function rename() { } } -function replace(vertices) { - let widgets = api.selection.widgets(true); +function replace(vertices, sel) { + let widgets = sel ? [sel] : api.selection.widgets(true); if (!widgets.length) { return; } diff --git a/web/kiri/index.css b/web/kiri/index.css index 6bd3efec..094736e6 100644 --- a/web/kiri/index.css +++ b/web/kiri/index.css @@ -912,16 +912,28 @@ th, tr, td, label { #ws-widgets button { text-transform: none; text-align: left; + white-space: nowrap; align-items: center; + overflow: hidden; + max-width: 150px; } #ws-widgets button.selected { background-color: var(--blue-3); color: #000; } -/* .slim-hide { - width: 0; - overflow: hidden; -} */ +.widpop:not(:hover) .widopt { + display: none; +} +.widopt { + background-color: white; + position: absolute; + top: 0; + right: 0; + bottom: 0; +} +.widopt button.disabled { + background-color: var(--blue-3); +} #top-sep { display: none; } @@ -1126,8 +1138,7 @@ th, tr, td, label { #ft-mesh-btn { display: grid; grid-auto-flow: row; - grid-template-rows: 1fr 1fr; - grid-template-columns: 1fr 1fr; + grid-template-rows: 1fr; } #ft-mesh-btn button { justify-content: center; diff --git a/web/kiri/index.html b/web/kiri/index.html index d034ce61..9065a8e7 100644 --- a/web/kiri/index.html +++ b/web/kiri/index.html @@ -214,7 +214,7 @@