diff --git a/src/kiri/init.js b/src/kiri/init.js index fd3506f9..f62f042e 100644 --- a/src/kiri/init.js +++ b/src/kiri/init.js @@ -663,17 +663,15 @@ return settings().devices[devicename] ? true : false; } - function isFavoriteDevice(devicename) { - return settings().favorites[devicename] ? true : false; - } - function getSelectedDevice() { - return UI.deviceList.options[UI.deviceList.selectedIndex].text; + return API.device.get(); } function selectDevice(devicename, lock) { deviceLock = lock; - if (lock) UI.setupDevices.style.display = 'none'; + if (lock) { + UI.setupDevices.style.display = 'none'; + } if (isLocalDevice(devicename)) { setDeviceCode(settings().devices[devicename], devicename); } else { @@ -684,7 +682,7 @@ // only for local filters function cloneDevice() { - let name = `${getSelectedDevice()}.copy`; + let name = `${getSelectedDevice().replace(/\./g,' ')} Copy`; let code = API.clone(settings().device); code.mode = API.mode.get(); putLocalDevice(name, code); @@ -775,8 +773,17 @@ UI.extrudeAbs.style.display = mode === 'CAM' ? 'none' : 'flex'; UI.deviceSave.disabled = !local; UI.deviceDelete.disabled = !local; - UI.deviceAdd.disabled = dev.noclone; UI.deviceExport.disabled = !local; + if (local) { + UI.deviceAdd.innerText = "copy"; + UI.deviceDelete.style.display = ''; + UI.deviceExport.style.display = ''; + } else { + UI.deviceAdd.innerText = "customize"; + UI.deviceDelete.style.display = 'none'; + UI.deviceExport.style.display = 'none'; + } + UI.deviceAdd.disabled = dev.noclone; API.view.update_fields(); platform.update_size(); @@ -933,66 +940,49 @@ deviceExport(exp, selected); }; - UI.deviceAll.onclick = function() { - API.show.favorites(false); - showDevices(); - }; - UI.deviceFavorites.onclick = function() { - API.show.favorites(true); - showDevices(); - }; - UI.deviceList.innerHTML = ''; + UI.deviceMy.innerHTML = ''; let incr = 0; - let faves = API.show.favorites(); - let found = false; + let found = null; let first = devices[0]; - // run through the list up to twice forcing faves off - // the second time if incr === 0 (no devices shown) - // if incr > 0, second loop is avoided - for (let rep=0; rep<2; rep++) - if (incr === 0) + let dedup = {}; devices.forEach(function(device, index) { - // force faves off for second try - if (rep === 1) faves = false; - let fav = isFavoriteDevice(device), - loc = isLocalDevice(device); - if (faves && !(fav || loc)) { + // prevent device from appearing twice + // such as local name = standard device name + if (dedup[device]) { return; } + dedup[device] = device; + let loc = isLocalDevice(device); if (incr === 0) { first = device; } - let opt = DOC.createElement('option'); + let opt = DOC.createElement('button'); opt.appendChild(DOC.createTextNode(device.replace(/\./g,' '))); opt.onclick = function() { selectDevice(device); - }; - opt.ondblclick = function() { - if (settings().favorites[device]) { - delete settings().favorites[device]; - API.show.alert(`removed "${device}" from favorites`, 3); - } else { - settings().favorites[device] = true; - API.show.alert(`added "${device}" to favorites`, 3); + opt.classList.add("selected"); + if (found) { + found.classList.remove("selected"); } - showDevices(); + found = opt; }; - if (loc) opt.setAttribute("local", 1); - if (loc || fav) opt.setAttribute("favorite", 1); - UI.deviceList.appendChild(opt); + if (loc) { + UI.deviceMy.appendChild(opt); + } else { + UI.deviceList.appendChild(opt); + } if (device === selected) { + opt.classList.add("selected"); selectedIndex = incr; - found = true; + found = opt; } incr++; }); if (selectedIndex >= 0) { - UI.deviceList.selectedIndex = selectedIndex; selectDevice(selected); } else { - UI.deviceList.selectedIndex = 0; selectDevice(first); } } @@ -1444,12 +1434,11 @@ devices: $('devices'), deviceList: $('device-list'), + deviceMy: $('device-my'), deviceAdd: $('device-add'), deviceDelete: $('device-del'), deviceExport: $('device-exp'), deviceSave: $('device-save'), - deviceFavorites: $('device-favorites'), - deviceAll: $('device-all'), toolsSave: $('tools-save'), toolsClose: $('tools-close'), @@ -1500,7 +1489,7 @@ stockDepth: $('stock-width'), stockHeight: $('stock-width'), - device: UC.newGroup(LANG.dv_gr_dev, $('device'), {group:"ddev", inline:true}), + device: UC.newGroup(LANG.dv_gr_dev, $('device1'), {group:"ddev", inline:true}), deviceName: UC.newInput(LANG.dv_name_s, {title:LANG.dv_name_l, size:"60%", text:true, action:updateDeviceName}), bedWidth: UC.newInput(LANG.dv_bedw_s, {title:LANG.dv_bedw_l, convert:UC.toFloat, size:6, units:true}), bedDepth: UC.newInput(LANG.dv_bedd_s, {title:LANG.dv_bedd_l, convert:UC.toFloat, size:6, units:true}), @@ -1510,7 +1499,7 @@ deviceRound: UC.newBoolean(LANG.dv_bedc_s, onBooleanClick, {title:LANG.dv_bedc_l, modes:FDM}), deviceBelt: UC.newBoolean(LANG.dv_belt_s, onBooleanClick, {title:LANG.dv_belt_l, modes:FDM}), - extruder: UC.newGroup(LANG.dv_gr_ext, $('device'), {group:"dext", inline:true, modes:FDM}), + extruder: UC.newGroup(LANG.dv_gr_ext, $('device2'), {group:"dext", inline:true, modes:FDM}), extFilament: UC.newInput(LANG.dv_fila_s, {title:LANG.dv_fila_l, convert:UC.toFloat, modes:FDM}), extNozzle: UC.newInput(LANG.dv_nozl_s, {title:LANG.dv_nozl_l, convert:UC.toFloat, modes:FDM}), extOffsetX: UC.newInput(LANG.dv_exox_s, {title:LANG.dv_exox_l, convert:UC.toFloat, modes:FDM, expert:true}), @@ -1522,37 +1511,27 @@ UI.extAdd = UC.newButton(undefined, undefined, {icon:''}), UI.extDel = UC.newButton(undefined, undefined, {icon:''}), UI.extNext = UC.newButton(undefined, undefined, {icon:''}) - ], {modes:FDM, expert:true, class:"ext-buttons"}), + ], {modes:FDM, expert:true, class:"dev-buttons ext-buttons"}), - gcode: UC.newGroup(LANG.dv_gr_out, $('device'), {group:"dgco", inline:true, modes:CAM_LASER}), + gcode: UC.newGroup(LANG.dv_gr_out, $('device2'), {group:"dgco", inline:true, modes:CAM_LASER}), gcodeSpace: UC.newBoolean(LANG.dv_tksp_s, onBooleanClick, {title:LANG.dv_tksp_l, modes:CAM_LASER}), gcodeStrip: UC.newBoolean(LANG.dv_strc_s, onBooleanClick, {title:LANG.dv_strc_l, modes:CAM}), gcodeFExt: UC.newInput(LANG.dv_fext_s, {title:LANG.dv_fext_l, modes:CAM_LASER, size:7, text:true}), gcodeEd: UC.newGroup(LANG.dv_gr_gco, $('dg'), {group:"dgcp", inline:true, modes:GCODE}), gcodeFanTrack: UC.newRow([ + (UI.gcodePre = UC.newGCode(LANG.dv_head_s, {title:LANG.dv_head_l, modes:GCODE, area:gcode})).button, + (UI.gcodePost = UC.newGCode(LANG.dv_foot_s, {title:LANG.dv_foot_l, modes:GCODE, area:gcode})).button, (UI.gcodeFan = UC.newGCode(LANG.dv_fanp_s, {title:LANG.dv_fanp_l, modes:FDM, area:gcode})).button, - (UI.gcodeTrack = UC.newGCode(LANG.dv_prog_s, {title:LANG.dv_prog_l, modes:FDM, area:gcode})).button - ], {modes:FDM, class:"ext-buttons f-row"}), - gcodeLayerPause: UC.newRow([ + (UI.gcodeTrack = UC.newGCode(LANG.dv_prog_s, {title:LANG.dv_prog_l, modes:FDM, area:gcode})).button, (UI.gcodeLayer = UC.newGCode(LANG.dv_layr_s, {title:LANG.dv_layr_l, modes:FDM, area:gcode})).button, - (UI.gcodePause = UC.newGCode(LANG.dv_paus_s, {title:LANG.dv_paus_l, modes:FDM, area:gcode})).button - ], {modes:FDM, class:"ext-buttons f-row"}), - gcodeLaserOnOff: UC.newRow([ + (UI.gcodePause = UC.newGCode(LANG.dv_paus_s, {title:LANG.dv_paus_l, modes:FDM, area:gcode})).button, (UI.gcodeLaserOn = UC.newGCode(LANG.dv_lzon_s, {title:LANG.dv_lzon_l, modes:LASER, area:gcode})).button, (UI.gcodeLaserOff = UC.newGCode(LANG.dv_lzof_s, {title:LANG.dv_lzof_l, modes:LASER, area:gcode})).button, - ], {modes:LASER, class:"ext-buttons f-row"}), - gcodeCam1: UC.newRow([ - (UI.gcodeChange = UC.newGCode(LANG.dv_tool_s, {title:LANG.dv_tool_l, modes:CAM, area:gcode})).button - ], {modes:CAM, class:"ext-buttons f-row"}), - gcodeCam2: UC.newRow([ + (UI.gcodeChange = UC.newGCode(LANG.dv_tool_s, {title:LANG.dv_tool_l, modes:CAM, area:gcode})).button, (UI.gcodeDwell = UC.newGCode(LANG.dv_dwll_s, {title:LANG.dv_dwll_l, modes:CAM, area:gcode})).button, (UI.gcodeSpindle = UC.newGCode(LANG.dv_sspd_s, {title:LANG.dv_sspd_l, modes:CAM, area:gcode})).button - ], {modes:CAM, class:"ext-buttons f-row"}), - gcodeHeadFoot: UC.newRow([ - (UI.gcodePre = UC.newGCode(LANG.dv_head_s, {title:LANG.dv_head_l, modes:GCODE, area:gcode})).button, - (UI.gcodePost = UC.newGCode(LANG.dv_foot_s, {title:LANG.dv_foot_l, modes:GCODE, area:gcode})).button - ], {modes:GCODE, class:"ext-buttons f-row"}), + ], {class:"ext-buttons f-row"}), lprefs: UC.newGroup(LANG.op_menu, $('prefs-gen1'), {inline: true}), // hoverPop: UC.newBoolean(LANG.op_hopo_s, booleanSave, {title:LANG.op_hopo_l}), @@ -2052,6 +2031,8 @@ UI.toolMetric.onclick = updateTool; UI.toolType.onchange = updateTool; + // default show gcode pre + UI.gcodePre.button.click(); function mksvg(src) { let svg = DOC.createElement('svg'); diff --git a/src/kiri/ui.js b/src/kiri/ui.js index e3c6739a..f3c11e5f 100644 --- a/src/kiri/ui.js +++ b/src/kiri/ui.js @@ -470,7 +470,7 @@ cols = Math.max(cols, row.length); }); txt.setAttribute("cols", Math.max(30, cols + 1)); - txt.setAttribute("rows", Math.max(10, rows.length + 1)); + // txt.setAttribute("rows", Math.max(10, rows.length + 1)); let showing = btn === lastBtn; hidePop(); diff --git a/web/kiri/index.css b/web/kiri/index.css index 7d15fe96..3ff612e6 100644 --- a/web/kiri/index.css +++ b/web/kiri/index.css @@ -100,12 +100,6 @@ select { background-color: rgba(255,255,255,0.5); border-radius: 3px; } -select option[local="1"] { - color: #55d; -} -select option[favorite="1"] { - font-weight: bold; -} th, tr, td, span, div, label, button { user-select: none; } @@ -161,6 +155,9 @@ th, tr, td, label { .j-end { justify-content: flex-end; } +.space-around { + justify-content: space-around; +} .space-between { justify-content: space-between; } @@ -182,6 +179,9 @@ th, tr, td, label { .mh0 { min-height: 0; } +.mh35 { + max-height: 35%; +} .mh85 { max-height: 85%; } @@ -469,6 +469,13 @@ th, tr, td, label { } } +.dev-buttons { + margin: 5px 15px 0 15px; +} +.dev-buttons button { + margin-left: 2px; + margin-right: 2px; +} .ext-buttons button { justify-content: center; align-items: center; @@ -587,6 +594,46 @@ th, tr, td, label { } #mod-setup { height: 500px; + width: 700px; + padding-bottom: 5px; +} +#mod-setup .header { + text-align: center; + border-bottom: 1px solid rgba(150,130,200,0.5); + padding-bottom: 5px; + margin-bottom: 5px; +} +#mod-setup .header.sub { + padding-top: 10px; +} +#mod-setup .left { + width: 180px; + padding-right: 10px; + margin-right: 10px; + border-right: 1px solid #ddd; +} +#mod-setup .footer { + padding-top: 5px; + margin-top: 5px; + border-top: 1px solid rgba(150,130,200,0.5); +} +.devlist button { + margin: 1px; + padding: 2px; + border: 1px solid rgba(0,0,0,0); + border-radius: 0; + font-size: 11px; + font-family: sans-serif; + background-color: rgba(255,255,255,0.9); + text-align: left; + min-height: 1.5em; +} +.devlist button:hover { + background-color: rgba(200,200,200,0.9); +} +.devlist button.selected { + background-color: rgba(200,220,220,0.9); + border: 1px splid rgba(200,220,200,1); } #mod-print { background-color: rgba(255,255,255,0.85); @@ -809,9 +856,12 @@ th, tr, td, label { align-items: center; background-color: rgba(255,255,255,0.75); border-radius: 5px; - width: 100px; margin: 5px; } +.dev-type svg { + width: 60px; + height: 30px; +} .dev-sel { color: #033; background-color: #bbb; @@ -845,29 +895,24 @@ th, tr, td, label { } .t-pad { width: 5px; + height: 5px; } .t-pad2 { width: 10px; } #devices { - width: 200px; + width: 225px; } -#device { - width: 200px; -} -#gcode-edit { - width: 200px; +#device1, #device2 { + width: 225px; } #dev-gcode textarea { font-family: monospace; + overflow: auto; + padding: 5px; width: 100%; } -#device-exp { - position: absolute; - left: 0; - z-index: 10; -} #device-action, #tool-action { margin-top: 5px; } diff --git a/web/kiri/index.html b/web/kiri/index.html index a04a6445..56777a31 100644 --- a/web/kiri/index.html +++ b/web/kiri/index.html @@ -247,35 +247,52 @@ Sienci Labs Teaching Tech -
-
- - - - -
-
-
-
-
-
-
-
-
-
+
+
+ +
+ + + + + + +
+
+ +
+
+
+ +
+
+
-
- -
- - -
- - -
- -
+
+ +
+
+
+
+
+
+
+
+
+
+
+
diff --git a/web/kiri/lang/en.js b/web/kiri/lang/en.js index 7e7de6a5..f0a08717 100644 --- a/web/kiri/lang/en.js +++ b/web/kiri/lang/en.js @@ -11,7 +11,7 @@ kiri.lang['en-us'] = { dv_gr_dev: "device", dv_gr_ext: "extruder", dv_gr_out: "output", - dv_gr_gco: "gcode", + dv_gr_gco: "gcode macros", // DEVICE dialog (_s = label, _l = hover help) dv_name_s: "name",