refactor of device settings viewer / editor

This commit is contained in:
Stewart Allen 2024-06-01 16:49:26 -04:00
commit 18f9975390
7 changed files with 134 additions and 264 deletions

View file

@ -27,6 +27,7 @@ gapp.register("kiri.init", [], (root, exports) => {
CAM = [MODES.CAM], CAM = [MODES.CAM],
SLA = [MODES.SLA], SLA = [MODES.SLA],
FDM = [MODES.FDM], FDM = [MODES.FDM],
FDM_CAM = [MODES.FDM,MODES.CAM],
FDM_SLA = [MODES.FDM,MODES.SLA], FDM_SLA = [MODES.FDM,MODES.SLA],
FDM_LZR = [MODES.LASER,MODES.FDM], FDM_LZR = [MODES.LASER,MODES.FDM],
FDM_CAM_SLA = [MODES.CAM,MODES.FDM,MODES.SLA], FDM_CAM_SLA = [MODES.CAM,MODES.FDM,MODES.SLA],
@ -274,18 +275,18 @@ gapp.register("kiri.init", [], (root, exports) => {
return active && (active.nodeName === "INPUT" || active.nodeName === "TEXTAREA"); return active && (active.nodeName === "INPUT" || active.nodeName === "TEXTAREA");
} }
function inputTextOK() { // function inputTextOK() {
return DOC.activeElement === ui.deviceName; // return DOC.activeElement === ui.deviceName;
} // }
function textAreaHasFocus() { // function textAreaHasFocus() {
let active = DOC.activeElement; // let active = DOC.activeElement;
return active && active.nodeName === "TEXTAREA"; // return active && active.nodeName === "TEXTAREA";
} // }
function inputSize() { // function inputSize() {
return parseInt(DOC.activeElement.size); // return parseInt(DOC.activeElement.size);
} // }
function cca(c) { function cca(c) {
return c.charCodeAt(0); return c.charCodeAt(0);
@ -784,7 +785,7 @@ gapp.register("kiri.init", [], (root, exports) => {
dev.new = false; dev.new = false;
dev.deviceName = devicename; dev.deviceName = devicename;
ui.deviceName.value = devicename; // ui.deviceName.value = devicename;
ui.deviceBelt.checked = dev.bedBelt; ui.deviceBelt.checked = dev.bedBelt;
ui.deviceRound.checked = dev.bedRound; ui.deviceRound.checked = dev.bedRound;
ui.deviceOrigin.checked = dev.outputOriginCenter || dev.originCenter || dev.bedRound; ui.deviceOrigin.checked = dev.outputOriginCenter || dev.originCenter || dev.bedRound;
@ -802,7 +803,7 @@ gapp.register("kiri.init", [], (root, exports) => {
// disable editing for non-local devices // disable editing for non-local devices
[ [
ui.deviceName, // ui.deviceName,
ui.gcodePre, ui.gcodePre,
ui.gcodePost, ui.gcodePost,
ui.bedDepth, ui.bedDepth,
@ -847,14 +848,19 @@ gapp.register("kiri.init", [], (root, exports) => {
ui.deviceSave.disabled = !local; ui.deviceSave.disabled = !local;
ui.deviceDelete.disabled = !local; ui.deviceDelete.disabled = !local;
ui.deviceRename.disabled = !local;
ui.deviceExport.disabled = !local; ui.deviceExport.disabled = !local;
ui.deviceAdd.style.display = mode === 'SLA' ? 'none' : '';
if (local) { if (local) {
ui.deviceAdd.innerText = "copy"; ui.deviceAdd.innerText = "copy";
ui.deviceDelete.style.display = ''; ui.deviceDelete.style.display = '';
ui.deviceRename.style.display = '';
ui.deviceExport.style.display = ''; ui.deviceExport.style.display = '';
} else { } else {
ui.deviceAdd.innerText = "customize"; ui.deviceAdd.innerText = "customize";
ui.deviceDelete.style.display = 'none'; ui.deviceDelete.style.display = 'none';
ui.deviceRename.style.display = 'none';
ui.deviceExport.style.display = 'none'; ui.deviceExport.style.display = 'none';
} }
ui.deviceAdd.disabled = dev.noclone; ui.deviceAdd.disabled = dev.noclone;
@ -981,9 +987,8 @@ gapp.register("kiri.init", [], (root, exports) => {
space.world.add(deviceImage = mesh); space.world.add(deviceImage = mesh);
} }
function updateDeviceName() { function updateDeviceName(newname) {
let newname = ui.deviceName.value, let selected = api.device.get(),
selected = api.device.get(),
devs = settings().devices; devs = settings().devices;
if (newname !== selected) { if (newname !== selected) {
devs[newname] = devs[selected]; devs[newname] = devs[selected];
@ -1000,8 +1005,7 @@ gapp.register("kiri.init", [], (root, exports) => {
} }
function renderDevices(devices) { function renderDevices(devices) {
let selectedIndex = -1, let selected = api.device.get() || devices[0],
selected = api.device.get(),
features = api.feature, features = api.feature,
devs = settings().devices, devs = settings().devices,
dfilter = typeof(features.device_filter) === 'function' ? features.device_filter : undefined; dfilter = typeof(features.device_filter) === 'function' ? features.device_filter : undefined;
@ -1039,8 +1043,13 @@ gapp.register("kiri.init", [], (root, exports) => {
ui.deviceDelete.onclick = function() { ui.deviceDelete.onclick = function() {
api.function.clear(); api.function.clear();
removeLocalDevice(getSelectedDevice()); removeLocalDevice(getSelectedDevice());
selectDevice(getModeDevices()[0]);
showDevices(); showDevices();
}; };
ui.deviceRename.onclick = function() {
const newname = prompt(`Rename "${selected}`, selected);
if (newname) updateDeviceName(newname);
};
ui.deviceExport.onclick = function(event) { ui.deviceExport.onclick = function(event) {
const record = { const record = {
version: kiri.version, version: kiri.version,
@ -1054,12 +1063,9 @@ gapp.register("kiri.init", [], (root, exports) => {
api.device.export(exp, selected, { event, record }); api.device.export(exp, selected, { event, record });
}; };
ui.deviceList.innerHTML = '';
ui.deviceMy.innerHTML = '';
let incr = 0;
let found = null;
let first = devices[0];
let dedup = {}; let dedup = {};
let list_cdev = [];
let list_mdev = [];
devices.forEach(function(device, index) { devices.forEach(function(device, index) {
// prevent device from appearing twice // prevent device from appearing twice
// such as local name = standard device name // such as local name = standard device name
@ -1068,48 +1074,31 @@ gapp.register("kiri.init", [], (root, exports) => {
} }
dedup[device] = device; dedup[device] = device;
let loc = isLocalDevice(device); let loc = isLocalDevice(device);
// if filter set, use
if (!loc && deviceFilter && device.toLowerCase().indexOf(deviceFilter) < 0) {
return;
}
// allow for device filter feature
if (dfilter && dfilter(device) === false) { if (dfilter && dfilter(device) === false) {
return; return;
} }
if (incr === 0) {
first = device;
}
let opt = DOC.createElement('button');
opt.appendChild(DOC.createTextNode(device.replace(/\./g,' ')));
opt.onclick = function() {
selectDevice(device);
opt.classList.add("selected");
if (found && found !== opt) {
found.classList.remove("selected");
}
found = opt;
api.platform.layout();
};
if (loc) { if (loc) {
ui.deviceMy.appendChild(opt); list_mdev.push(h.option(device));
} else { } else {
ui.deviceList.appendChild(opt); list_cdev.push(h.option(device));
} }
if (device === selected) {
// scroll to highlighted selection
setTimeout(() => ui.deviceList.scrollTop = opt.offsetTop, 0);
opt.classList.add("selected");
selectedIndex = incr;
found = opt;
}
incr++;
}); });
if (selectedIndex >= 0) { let dev_list = $('dev-list');
selectDevice(selected); h.bind(dev_list, [
} else { h.option({ _: '-- My Devices --', disabled: true }),
selectDevice(first); ...list_mdev,
h.option({ _: '-- Stock Devices --', disabled: true }),
...list_cdev
]);
let dev_opts = [...dev_list.options].map(o => o.label);
dev_list.selectedIndex = dev_opts.indexOf(selected);
dev_list.onchange = ev => {
const seldev = dev_list.options[dev_list.selectedIndex];
selectDevice(seldev.label);
api.platform.layout();
} }
selectDevice(selected);
} }
function renderTools() { function renderTools() {
@ -1362,8 +1351,12 @@ gapp.register("kiri.init", [], (root, exports) => {
// not the best way to do this, but main decl of api.show is broken // not the best way to do this, but main decl of api.show is broken
api.show.tools = showTools; api.show.tools = showTools;
function getModeDevices() {
return Object.keys(devices[api.mode.get_lower()]).sort();
}
function updateDeviceList() { function updateDeviceList() {
renderDevices(Object.keys(devices[api.mode.get_lower()]).sort()); renderDevices(getModeDevices());
} }
async function sync_get() { async function sync_get() {
@ -1379,10 +1372,8 @@ gapp.register("kiri.init", [], (root, exports) => {
} }
function _showDevices() { function _showDevices() {
// disable device filter and show devices updateDeviceList();
ui.dev.header.onclick(true);
api.modal.show('setup'); api.modal.show('setup');
ui.deviceList.focus();
} }
function dragOverHandler(evt) { function dragOverHandler(evt) {
@ -1516,7 +1507,7 @@ gapp.register("kiri.init", [], (root, exports) => {
let { event, conf, view, show } = api; let { event, conf, view, show } = api;
let { bound, toInt, toFloat } = uc; let { bound, toInt, toFloat } = uc;
let { newBlank, newButton, newBoolean, newGroup, newInput } = uc; let { newBlank, newButton, newBoolean, newGroup, newInput } = uc;
let { newInput2, newSelect, newText, newRow, newGCode } = uc; let { newSelect, newText, newRow, newGCode } = uc;
event.emit('init.one'); event.emit('init.one');
@ -1624,13 +1615,6 @@ gapp.register("kiri.init", [], (root, exports) => {
speedbar: $('speedbar'), speedbar: $('speedbar'),
context: $('context-menu'), context: $('context-menu'),
// options: {
// // area: $('lt-options'),
// // trash: $('lt-trash'),
// // enable: $('lt-w-enable'),
// // disable: $('lt-w-disable'),
// },
back: $('lt-back'), back: $('lt-back'),
ltsetup: $('lt-setup'), ltsetup: $('lt-setup'),
ltfile: $('lt-file'), ltfile: $('lt-file'),
@ -1638,7 +1622,6 @@ gapp.register("kiri.init", [], (root, exports) => {
ltact: $('lt-start'), ltact: $('lt-start'),
edit: $('lt-tools'), edit: $('lt-tools'),
nozzle: $('menu-nozzle'), nozzle: $('menu-nozzle'),
// render: $('menu-render'),
modal: $('modal'), modal: $('modal'),
modalBox: $('modal-box'), modalBox: $('modal-box'),
@ -1656,10 +1639,9 @@ gapp.register("kiri.init", [], (root, exports) => {
catalogList: $('catalogList'), catalogList: $('catalogList'),
devices: $('devices'), devices: $('devices'),
deviceList: $('device-list'),
deviceMy: $('device-my'),
deviceAdd: $('device-add'), deviceAdd: $('device-add'),
deviceDelete: $('device-del'), deviceDelete: $('device-del'),
deviceRename: $('device-ren'),
deviceExport: $('device-exp'), deviceExport: $('device-exp'),
deviceSave: $('device-save'), deviceSave: $('device-save'),
@ -1715,37 +1697,34 @@ gapp.register("kiri.init", [], (root, exports) => {
/** Device Browser / Editor */ /** Device Browser / Editor */
device: newGroup(LANG.dv_gr_dev, $('device1'), {group:"ddev", inline:true, class:"noshow"}), _____: uc.newDiv({ class: "f-col t-body t-inset", addto: $('dev-config'), set:true }),
deviceName: newInput(LANG.dv_name_s, {title:LANG.dv_name_l, size:"70%", text:true, action:updateDeviceName}), device: newGroup(LANG.dv_gr_dev, null, {group:"ddev", inline:true, class:"noshow"}),
devbed: newRow([ _____: newGroup("workspace", null, {group:"dext", inline:true}),
uc.newLabel(LANG.volume, { class: "grow" }), bedWidth: newInput('X (width)', {title:LANG.dv_bedw_l, convert:toFloat, size:6, units:true, round:2, action:updateDeviceSize}),
uc.newLabel('X', { class: "dim" }), bedDepth: newInput('Y (depth)', {title:LANG.dv_bedw_l, convert:toFloat, size:6, units:true, round:2, action:updateDeviceSize}),
ui.bedWidth = newInput2({title:LANG.dv_bedw_l, convert:toFloat, size:5, units:true, round:2, action:updateDeviceSize}), maxHeight: newInput('Z (height)', {title:LANG.dv_bedw_l, convert:toFloat, size:6, units:true, round:2, action:updateDeviceSize}),
uc.newLabel('Y', { class: "dim" }), resolutionX: newInput(LANG.dv_rezx_s, {title:LANG.dv_rezx_l, convert:toInt, size:6, modes:SLA}),
ui.bedDepth = newInput2({title:LANG.dv_bedd_l, convert:toFloat, size:5, units:true, round:2, action:updateDeviceSize}), resolutionY: newInput(LANG.dv_rezy_s, {title:LANG.dv_rezy_l, convert:toInt, size:6, modes:SLA}),
uc.newLabel('Z', { class: "dim" }), _____: uc.newDiv({ class: "f-col t-body t-inset", addto: $('dev-config'), set:true, modes:GCODE }),
ui.maxHeight = newInput2({title:LANG.dv_bedh_l, convert:toFloat, size:5, modes:FDM_SLA, action:updateDeviceSize}), _____: newGroup("firmware", null, {group:"dext", inline:true}),
], { class: "var-row" }), fwRetract: newBoolean(LANG.dv_retr_s, onBooleanClick, {title:LANG.dv_retr_l, modes:FDM}),
deviceOrigin: newBoolean(LANG.dv_orgc_s, onBooleanClick, {title:LANG.dv_orgc_l, modes:FDM_LZR, show:() => !ui.deviceRound.checked}),
resolutionX: newInput(LANG.dv_rezx_s, {title:LANG.dv_rezx_l, convert:toInt, size:5, modes:SLA}), deviceRound: newBoolean(LANG.dv_bedc_s, onBooleanClick, {title:LANG.dv_bedc_l, modes:FDM, trigger:true, show:isNotBelt}),
resolutionY: newInput(LANG.dv_rezy_s, {title:LANG.dv_rezy_l, convert:toInt, size:5, modes:SLA}), deviceBelt: newBoolean(LANG.dv_belt_s, onBooleanClick, {title:LANG.dv_belt_l, modes:FDM, trigger:true, show:() => !ui.deviceRound.checked}),
separator: newBlank({class:"pop-sep", modes:FDM, driven:true}),
spindleMax: newInput(LANG.dv_spmx_s, {title:LANG.dv_spmx_l, convert:toInt, size:5, modes:CAM, trigger:1}), spindleMax: newInput(LANG.dv_spmx_s, {title:LANG.dv_spmx_l, convert:toInt, size:5, modes:CAM, trigger:1}),
deviceZMax: newInput(LANG.dv_zmax_s, {title:LANG.dv_zmax_l, convert:toInt, size:5, modes:FDM}), deviceZMax: newInput(LANG.dv_zmax_s, {title:LANG.dv_zmax_l, convert:toInt, size:5, modes:FDM}),
gcodeTime: newInput(LANG.dv_time_s, {title:LANG.dv_time_l, convert:toFloat, size:5, modes:FDM}), gcodeTime: newInput(LANG.dv_time_s, {title:LANG.dv_time_l, convert:toFloat, size:5, modes:FDM}),
separator: newBlank({class:"pop-sep", modes:FDM, driven:true}), filamentSource: newSelect(LANG.dv_fsrc_s, {title: LANG.dv_fsrc_l, action: filamentSourceSave, modes:FDM, show:() => false}, "filasrc"),
filamentSource: newSelect(LANG.dv_fsrc_s, {title: LANG.dv_fsrc_l, action: filamentSourceSave, modes:FDM}, "filasrc"), _____: uc.newDiv({ class: "f-col t-body t-inset", addto: $('dev-config'), set:true, modes:FDM }),
fwRetract: newBoolean(LANG.dv_retr_s, onBooleanClick, {title:LANG.dv_retr_l, modes:FDM}), extruder: newGroup(LANG.dv_gr_ext, null, {group:"dext", inline:true}),
deviceOrigin: newBoolean(LANG.dv_orgc_s, onBooleanClick, {title:LANG.dv_orgc_l, modes:FDM_LZR, show:() => !ui.deviceRound.checked}),
deviceRound: newBoolean(LANG.dv_bedc_s, onBooleanClick, {title:LANG.dv_bedc_l, trigger:true, show:isNotBelt}),
deviceBelt: newBoolean(LANG.dv_belt_s, onBooleanClick, {title:LANG.dv_belt_l, trigger:true, show:() => !ui.deviceRound.checked}),
extruder: newGroup(LANG.dv_gr_ext, $('device2'), {group:"dext", inline:true, modes:FDM}),
extFilament: newInput(LANG.dv_fila_s, {title:LANG.dv_fila_l, convert:toFloat, modes:FDM}), extFilament: newInput(LANG.dv_fila_s, {title:LANG.dv_fila_l, convert:toFloat, modes:FDM}),
extNozzle: newInput(LANG.dv_nozl_s, {title:LANG.dv_nozl_l, convert:toFloat, modes:FDM}), extNozzle: newInput(LANG.dv_nozl_s, {title:LANG.dv_nozl_l, convert:toFloat, modes:FDM}),
extOffsetX: newInput(LANG.dv_exox_s, {title:LANG.dv_exox_l, convert:toFloat, modes:FDM}), extOffsetX: newInput(LANG.dv_exox_s, {title:LANG.dv_exox_l, convert:toFloat, modes:FDM}),
extOffsetY: newInput(LANG.dv_exoy_s, {title:LANG.dv_exoy_l, convert:toFloat, modes:FDM}), extOffsetY: newInput(LANG.dv_exoy_s, {title:LANG.dv_exoy_l, convert:toFloat, modes:FDM}),
separator: newBlank({class:"set-sep", modes:FDM, driven:true}), _____: uc.newDiv({ class: "f-col t-body t-inset", addto: $('dev-config'), set:true, modes:GCODE }),
_____: newGroup(LANG.dv_gr_too, $('device2'), {group:"dext", inline:true, modes:CAM_LZR}), _____: newGroup(LANG.dv_gr_too, null, {group:"dext", inline:true}),
extSelect: newText(LANG.dv_exts_s, {title:LANG.dv_exts_l, size:14, height:3, area:gcode, modes:GCODE}), extSelect: newText(LANG.dv_exts_s, {title:LANG.dv_exts_l, size:14, height:3, area:gcode, modes:GCODE}),
extDeselect: newText(LANG.dv_dext_s, {title:LANG.dv_dext_l, size:14, height:3, area:gcode, modes:GCODE}), extDeselect: newText(LANG.dv_dext_s, {title:LANG.dv_dext_l, size:14, height:3, area:gcode, modes:GCODE}),
extPad: newBlank({class:"grow", modes:FDM}), extPad: newBlank({class:"grow", modes:FDM}),
@ -1755,7 +1734,8 @@ gapp.register("kiri.init", [], (root, exports) => {
ui.extDel = newButton(undefined, undefined, {icon:'<i class="fas fa-minus"></i>'}), ui.extDel = newButton(undefined, undefined, {icon:'<i class="fas fa-minus"></i>'}),
ui.extNext = newButton(undefined, undefined, {icon:'<i class="fas fa-greater-than"></i>'}) ui.extNext = newButton(undefined, undefined, {icon:'<i class="fas fa-greater-than"></i>'})
], {class:"dev-buttons ext-buttons", modes:FDM}), ], {class:"dev-buttons ext-buttons", modes:FDM}),
palette: newGroup(LANG.dv_gr_pal, $('palette3'), {group:"dext2", inline:true, modes:FDM}), _____: uc.newDiv({ class: "f-col t-body t-inset", addto: $('dev-config'), set:true, modes:FDM, show: () => false && ui.filamentSource.selectedOptions[0].value === 'palette3' }),
palette: newGroup(LANG.dv_gr_pal, null, {group:"dext2", inline:true, modes:FDM}),
paletteId: newInput(LANG.dv_paid_s, {title:LANG.dv_paid_l, modes:FDM, size:15, text:true}), paletteId: newInput(LANG.dv_paid_s, {title:LANG.dv_paid_l, modes:FDM, size:15, text:true}),
palettePing: newInput(LANG.dv_paps_s, {title:LANG.dv_paps_l, modes:FDM, convert:toInt}), palettePing: newInput(LANG.dv_paps_s, {title:LANG.dv_paps_l, modes:FDM, convert:toInt}),
paletteFeed: newInput(LANG.dv_pafe_s, {title:LANG.dv_pafe_l, modes:FDM, convert:toInt}), paletteFeed: newInput(LANG.dv_pafe_s, {title:LANG.dv_pafe_l, modes:FDM, convert:toInt}),
@ -1765,7 +1745,8 @@ gapp.register("kiri.init", [], (root, exports) => {
paletteHeat: newInput(LANG.dv_pahe_s, {title:LANG.dv_pahe_l, modes:FDM, convert:toInt}), paletteHeat: newInput(LANG.dv_pahe_s, {title:LANG.dv_pahe_l, modes:FDM, convert:toInt}),
paletteCool: newInput(LANG.dv_paco_s, {title:LANG.dv_paco_l, modes:FDM, convert:toInt}), paletteCool: newInput(LANG.dv_paco_s, {title:LANG.dv_paco_l, modes:FDM, convert:toInt}),
palettePress: newInput(LANG.dv_pacm_s, {title:LANG.dv_pacm_l, modes:FDM, convert:toInt}), palettePress: newInput(LANG.dv_pacm_s, {title:LANG.dv_pacm_l, modes:FDM, convert:toInt}),
_____: newGroup(LANG.dv_gr_out, $('device2'), {group:"dgco", inline:true, modes:CAM_LZR}), _____: uc.newDiv({ class: "f-col t-body t-inset", addto: $('dev-config'), set:true, modes:CAM_LZR }),
_____: newGroup(LANG.dv_gr_out, null, {group:"dgco", inline:true}),
gcodeStrip: newBoolean(LANG.dv_strc_s, onBooleanClick, {title:LANG.dv_strc_l, modes:CAM}), gcodeStrip: newBoolean(LANG.dv_strc_s, onBooleanClick, {title:LANG.dv_strc_l, modes:CAM}),
gcodeSpace: newBoolean(LANG.dv_tksp_s, onBooleanClick, {title:LANG.dv_tksp_l, modes:CAM_LZR}), gcodeSpace: newBoolean(LANG.dv_tksp_s, onBooleanClick, {title:LANG.dv_tksp_l, modes:CAM_LZR}),
useLaser: newBoolean(LANG.dv_lazr_s, onBooleanClick, {title:LANG.dv_lazr_l, modes:CAM}), useLaser: newBoolean(LANG.dv_lazr_s, onBooleanClick, {title:LANG.dv_lazr_l, modes:CAM}),
@ -1801,7 +1782,7 @@ gapp.register("kiri.init", [], (root, exports) => {
shiny: newBoolean(LANG.op_shny_s, booleanSave, {title:LANG.op_shny_l, modes:FDM}), shiny: newBoolean(LANG.op_shny_s, booleanSave, {title:LANG.op_shny_l, modes:FDM}),
lineType: newSelect(LANG.op_line_s, {title: LANG.op_line_l, action: lineTypeSave, modes:FDM}, "linetype"), lineType: newSelect(LANG.op_line_s, {title: LANG.op_line_l, action: lineTypeSave, modes:FDM}, "linetype"),
animesh: newSelect(LANG.op_anim_s, {title: LANG.op_anim_l, action: aniMeshSave, modes:CAM}, "animesh"), animesh: newSelect(LANG.op_anim_s, {title: LANG.op_anim_l, action: aniMeshSave, modes:CAM}, "animesh"),
units: newSelect(LANG.op_unit_s, {title: LANG.op_unit_l, action: unitsSave, modes:CAM, trace:false}, "units"), units: newSelect(LANG.op_unit_s, {title: LANG.op_unit_l, action: unitsSave, modes:CAM}, "units"),
_____: newGroup(LANG.lo_menu, $('prefs-lay'), {inline: true}), _____: newGroup(LANG.lo_menu, $('prefs-lay'), {inline: true}),
autoSave: newBoolean(LANG.op_save_s, booleanSave, {title:LANG.op_save_l}), autoSave: newBoolean(LANG.op_save_s, booleanSave, {title:LANG.op_save_l}),
autoLayout: newBoolean(LANG.op_auto_s, booleanSave, {title:LANG.op_auto_l}), autoLayout: newBoolean(LANG.op_auto_s, booleanSave, {title:LANG.op_auto_l}),
@ -1962,7 +1943,7 @@ gapp.register("kiri.init", [], (root, exports) => {
camStockIndexed: newBoolean(LANG.cs_indx_s, onBooleanClick, {title:LANG.cs_indx_l}), camStockIndexed: newBoolean(LANG.cs_indx_s, onBooleanClick, {title:LANG.cs_indx_l}),
camStockIndexGrid: newBoolean(LANG.cs_ishg_s, onBooleanClick, {title:LANG.cs_ishg_l, show:() => ui.camStockIndexed.checked}), camStockIndexGrid: newBoolean(LANG.cs_ishg_s, onBooleanClick, {title:LANG.cs_ishg_l, show:() => ui.camStockIndexed.checked}),
camLimits: newGroup(LANG.cc_menu, $('cam-limits'), { modes:CAM, driven, separator }), camLimits: newGroup(LANG.cc_menu, $('cam-limits'), { modes:CAM, driven, separator }),
camZAnchor: newSelect(LANG.ou_zanc_s, {title: LANG.ou_zanc_l, action:zAnchorSave, trace:false, show:() => !ui.camStockIndexed.checked}, "zanchor"), camZAnchor: newSelect(LANG.ou_zanc_s, {title: LANG.ou_zanc_l, action:zAnchorSave, show:() => !ui.camStockIndexed.checked}, "zanchor"),
camZOffset: newInput(LANG.ou_ztof_s, {title:LANG.ou_ztof_l, convert:toFloat, units:true}), camZOffset: newInput(LANG.ou_ztof_s, {title:LANG.ou_ztof_l, convert:toFloat, units:true}),
camZBottom: newInput(LANG.ou_zbot_s, {title:LANG.ou_zbot_l, convert:toFloat, units:true, trigger: true}), camZBottom: newInput(LANG.ou_zbot_s, {title:LANG.ou_zbot_l, convert:toFloat, units:true, trigger: true}),
camZThru: newInput(LANG.ou_ztru_s, {title:LANG.ou_ztru_l, convert:toFloat, bound:bound(0.0,100), units:true, show:() => { return ui.camZBottom.value == 0 }}), camZThru: newInput(LANG.ou_ztru_s, {title:LANG.ou_ztru_l, convert:toFloat, bound:bound(0.0,100), units:true, show:() => { return ui.camZBottom.value == 0 }}),
@ -2192,30 +2173,6 @@ gapp.register("kiri.init", [], (root, exports) => {
if (!ev.buttons) api.event.emit('slider.unlabel'); if (!ev.buttons) api.event.emit('slider.unlabel');
}; };
ui.dev.header.onclick = (hide) => {
let style = ui.dev.filter.style;
if (style.display === 'flex' || hide === true) {
style.display = '';
deviceFilter = null;
updateDeviceList();
} else {
style.display = 'flex';
ui.dev.filter.focus();
deviceFilter = ui.dev.filter.value.toLowerCase();
updateDeviceList();
}
};
ui.dev.filter.onkeyup = (ev) => {
deviceFilter = ui.dev.filter.value.toLowerCase();
updateDeviceList();
};
ui.dev.filter.onclick = (ev) => {
ev.preventDefault();
ev.stopPropagation();
};
api.event.on('slider.unlabel', (values) => { api.event.on('slider.unlabel', (values) => {
}); });
@ -2686,9 +2643,6 @@ gapp.register("kiri.init", [], (root, exports) => {
// fill device list // fill device list
updateDeviceList(); updateDeviceList();
// ensure settings has gcode
selectDevice(DEVNAME || api.device.get());
// update ui fields from settings // update ui fields from settings
api.conf.update_fields(); api.conf.update_fields();

View file

@ -566,7 +566,6 @@ function platformChanged() {
h.bind($('ws-widgets'), api.widgets.all().map(w => { h.bind($('ws-widgets'), api.widgets.all().map(w => {
let color; let color;
return [ return [
h.div([ h.div([
h.button({ h.button({
@ -585,12 +584,10 @@ function platformChanged() {
color = w.getColor(); color = w.getColor();
} }
}), }),
h.button( h.button(
{ onclick() { platformDelete(w) } }, { onclick() { platformDelete(w) } },
[ h.i({ class:"fas fa-trash" }), ] [ h.i({ class:"fas fa-trash" }), ]
) )
]) ])
] ]
})); }));

View file

@ -56,11 +56,11 @@ gapp.register("kiri.ui", [], (root, exports) => {
newBoolean, newBoolean,
newButton, newButton,
newBlank, newBlank,
newDiv,
newGCode, newGCode,
newGroup, newGroup,
newLabel, newLabel,
newInput, newInput,
newInput2,
newRange, newRange,
newRow, newRow,
newSelect, newSelect,
@ -333,19 +333,23 @@ gapp.register("kiri.ui", [], (root, exports) => {
try { try {
return fn(); return fn();
} catch (e) { } catch (e) {
return true; // console.log({ safecall_error: e });
return false;
} }
} }
function addModeControls(el, opt = {}) { function addModeControls(el, opt = {}) {
el.__opt = opt; el.__opt = opt;
el.showMe = function() { el.showMe = function() {
if (opt.trace) console.log({ showMe: el });
el.classList.remove('hide'); el.classList.remove('hide');
}; };
el.hideMe = function() { el.hideMe = function() {
if (opt.trace) console.log({ hideMe: el });
el.classList.add('hide'); el.classList.add('hide');
}; };
el.setVisible = function(show) { el.setVisible = function(show) {
if (opt.trace) console.log({ setVisible: show });
if (show) el.showMe(); if (show) el.showMe();
else el.hideMe(); else el.hideMe();
}; };
@ -353,8 +357,10 @@ gapp.register("kiri.ui", [], (root, exports) => {
let xprt = opt.expert === undefined || (opt.expert === lastExpert); let xprt = opt.expert === undefined || (opt.expert === lastExpert);
let show = opt.show ? safecall(opt.show) : true; let show = opt.show ? safecall(opt.show) : true;
let disp = opt.visible ? opt.visible() : true; let disp = opt.visible ? opt.visible() : true;
let hmod = el.hasMode(mode);
if (opt.trace) console.log({ setMode: mode, xprt, show, disp, hmod, modes:el.modes });
if (opt.manual) return; if (opt.manual) return;
el.setVisible(el.hasMode(mode) && show && xprt && disp); el.setVisible(hmod && show && xprt && disp);
} }
el.hasMode = function(mode) { el.hasMode = function(mode) {
return el.modes.length === 0 || el.modes.contains(mode); return el.modes.length === 0 || el.modes.contains(mode);
@ -366,8 +372,10 @@ gapp.register("kiri.ui", [], (root, exports) => {
function newDiv(opt = {}) { function newDiv(opt = {}) {
let div = DOC.createElement('div'); let div = DOC.createElement('div');
addModeControls(div, opt); addModeControls(div, opt);
addTo.appendChild(div); (opt.addto || addTo).appendChild(div);
lastGroup.push(div); if (opt.addto) lastDiv = addTo = div;
if (opt.addto && opt.class) div.setAttribute('class', opt.class);
lastGroup?.push(div);
div._group = groupName; div._group = groupName;
return div; return div;
} }
@ -608,74 +616,6 @@ gapp.register("kiri.ui", [], (root, exports) => {
return ip; return ip;
} }
function newInput2(opt = {}) {
let hide = opt.hide,
size = opt.size || 5,
height = opt.height || 0,
ip = height > 1 ? DOC.createElement('textarea') : DOC.createElement('input'),
action = opt.action || bindTo || inputAction;
ip.setAttribute("class", "var-input");
if (Number.isInteger(size)) {
ip.setAttribute("size", size);
} else {
ip.setAttribute("style", `width:${size}`);
}
ip.setAttribute("type", "text");
ip.setAttribute("spellcheck", "false");
if (opt.disabled) ip.setAttribute("disabled", "true");
if (opt.title) ip.setAttribute("title", opt.title);
if (opt.convert) ip.convert = opt.convert.bind(ip);
if (opt.bound) ip.bound = opt.bound;
if (opt.action) action = opt.action;
ip.addEventListener('focus', function(event) {
hidePop();
setSticky(true);
});
if (action) {
ip.addEventListener('keydown', function(event) {
let key = event.key;
if (
opt.text ||
(key >= '0' && key <= '9') ||
key === '.' ||
key === '-' ||
key === 'Backspace' ||
key === 'Delete' ||
key === 'ArrowLeft' ||
key === 'ArrowRight' ||
key === 'Tab' ||
event.metaKey ||
event.ctrlKey ||
(key === ',' && opt.comma)
) {
return;
}
event.preventDefault();
event.stopPropagation();
});
ip.addEventListener('keyup', function(event) {
if (event.keyCode === 13) {
ip.blur();
}
});
ip.addEventListener('blur', function(event) {
setSticky(false);
lastChange = ip;
action(event);
if (opt.trigger) {
refresh();
}
});
if (opt.units) {
addUnits(ip, opt.round || 3);
}
}
if (!ip.convert) ip.convert = raw.bind(ip);
return ip;
}
function addUnits(input, round) { function addUnits(input, round) {
setters.push(input); setters.push(input);
input.setv = function(value) { input.setv = function(value) {

View file

@ -133,7 +133,10 @@ gapp.overlay(root, {
}); });
// add common element types // add common element types
["a", "i", "hr", "div", "span", "label", "input", "button", "svg", "textarea"].forEach(type => { [
"a", "i", "hr", "div", "span", "label", "input",
"button", "svg", "textarea", "select", "option"
].forEach(type => {
h[type] = (attr, innr) => { h[type] = (attr, innr) => {
return h.el(type, attr, innr); return h.el(type, attr, innr);
} }

View file

@ -123,7 +123,7 @@ input:focus {
input[disabled] { input[disabled] {
background-color: #ddd; background-color: #ddd;
color: #000; color: #000;
border-width: 1px; /* border-width: 1px; */
} }
input[type="range"] { input[type="range"] {
width: 85px; width: 85px;
@ -1263,6 +1263,9 @@ th, tr, td, label {
max-width: 70%; max-width: 70%;
padding-bottom: 5px; padding-bottom: 5px;
} }
#mod-setup textarea {
border-radius: 3px;
}
#mod-setup .header { #mod-setup .header {
text-align: center; text-align: center;
border-bottom: 1px solid rgba(126,153,183,1); border-bottom: 1px solid rgba(126,153,183,1);
@ -1273,33 +1276,12 @@ th, tr, td, label {
#mod-setup .header.sub { #mod-setup .header.sub {
padding-top: 10px; padding-top: 10px;
} }
#dev-search {
position: absolute;
font-size: 10px;
right: 3px;
}
#dev-search:hover {
color: #00f;
}
#dev-filter {
transform: translateY(-7px);
text-align: center;
position: absolute;
display: none;
padding: 1px;
right: 150%;
}
#mod-setup .left { #mod-setup .left {
width: 180px; width: 180px;
padding-right: 10px; padding-right: 10px;
margin-right: 10px; margin-right: 10px;
border-right: 1px solid #ddd; 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 { .devlist {
background-color: #fdfdfd; background-color: #fdfdfd;
} }
@ -1684,7 +1666,7 @@ th, tr, td, label {
width: 100%; width: 100%;
background-color: #f8f8f8; background-color: #f8f8f8;
} }
#device-action, #tool-action { #tool-action {
margin-top: 5px; margin-top: 5px;
} }
#device-action button, #tool-action button { #device-action button, #tool-action button {
@ -1946,6 +1928,16 @@ th, tr, td, label {
.settings .set-header a { .settings .set-header a {
font-size: smaller; font-size: smaller;
} }
#dev-sel {
margin-bottom: 0;
}
#dev-list {
align-self: stretch;
padding: 0 5px 0 5px;
}
#dev-list:hover {
background-color: var(--blue-4);
}
.set2-group { .set2-group {
border-radius: 3px; border-radius: 3px;
border: 1px solid #ddd !important; border: 1px solid #ddd !important;
@ -1965,7 +1957,7 @@ th, tr, td, label {
border-right: 3px solid var(--blue-1); border-right: 3px solid var(--blue-1);
background-color: var(--blue-4) !important; background-color: var(--blue-4) !important;
} }
.set2-group .var-row label { .set2-group .var-row label, #mod-setup .var-row label {
margin-right: 25px; margin-right: 25px;
} }
.set2-sep { .set2-sep {

View file

@ -367,50 +367,33 @@
</div> </div>
<!-- device selector / editor --> <!-- device selector / editor -->
<div id="mod-setup" class="mdialog f-row"> <div id="mod-setup" class="mdialog f-col gap3">
<div class="f-col left a-stretch"> <div class="f-row gap4 a-center">
<div id="dev-header" class="header sub f-col j-center"> <label id="dev-sel" class="set-header">select device</label>
<label lk="dm_stdd">standard devices</label> <select id="dev-list"></select>
<div id="dev-search"> <div class="f-row grow j-end">
<i class="fas fa-search"></i>
<input id="dev-filter">
</div>
</div>
<div class="f-col mh0 j-center a-stretch">
<div id="device-list" class="devlist f-col overy"></div>
</div>
<label class="header sub" lk="dm_mydd">my devices</label>
<div class="f-col">
<div id="device-my" class="devlist f-col grow overy"></div>
</div>
<div class="f-row footer">
<div class="grow"></div>
<button id="device-add" lk="copy">copy</button> <button id="device-add" lk="copy">copy</button>
<button id="device-ren" lk="rename">rename</button>
<button id="device-del" lk="delete">delete</button> <button id="device-del" lk="delete">delete</button>
<button id="device-exp" lk="export">export</button> <button id="device-exp" lk="export">export</button>
<div class="grow"></div>
</div> </div>
</div> </div>
<div class="f-col grow a-stretch"> <div class="set-sep"></div>
<label class="header" lk="dm_seld">selected device</label> <div class="f-row grow gap4">
<div class="f-row"> <div id="dev-config" class="f-col gap4 overy shrink0"></div>
<div id="device1" class="f-col t-body t-inset overy grow"></div> <div class="f-col grow">
<div class="t-pad"></div> <div id="gcode-edit" class="f-col grow gap4">
<div id="device2" class="f-col t-body t-inset overy grow"></div> <div id="dg" class="f-col t-body t-inset"></div>
<div id="palette3" class="f-col t-body t-inset overy grow"></div> <div id="dev-gcode" class="grow"></div>
</div> </div>
<div class="t-pad"></div>
<div id="gcode-edit" class="f-col grow">
<div id="dg" class="f-col t-body t-inset"></div>
<div class="t-pad"></div>
<div id="dev-gcode" class="grow"></div>
</div>
<div id="device-action" class="f-row footer">
<div class="grow"></div>
<button id="device-save" lk="save">save</button>
<div class="grow"></div>
</div> </div>
</div> </div>
<div class="set-sep"></div>
<div id="device-action" class="f-row">
<div class="grow"></div>
<button id="device-save" lk="save">save</button>
<div class="grow"></div>
</div>
</div> </div>
<!-- recent file menu --> <!-- recent file menu -->

View file

@ -37,6 +37,7 @@ self.kiri.lang['en-us'] = {
prefs: "preferences", // right menu "preferences" prefs: "preferences", // right menu "preferences"
preview: "preview", preview: "preview",
recent: "recent", recent: "recent",
rename: "rename",
render: "render", // left render pop menu render: "render", // left render pop menu
reset: "reset", reset: "reset",
right: "right", right: "right",
@ -95,7 +96,7 @@ self.kiri.lang['en-us'] = {
// DEVICE dialog groups // DEVICE dialog groups
dv_gr_dev: "device", dv_gr_dev: "device",
dv_gr_ext: "extruder", dv_gr_ext: "extruder",
dv_gr_too: "tool", dv_gr_too: "tool macros",
dv_gr_pal: "palette", dv_gr_pal: "palette",
dv_gr_out: "output", dv_gr_out: "output",
dv_gr_gco: "gcode macros", dv_gr_gco: "gcode macros",