rename settings ops

This commit is contained in:
Stewart Allen 2025-12-25 13:05:51 -05:00
commit 40f992f12b
3 changed files with 36 additions and 45 deletions

View file

@ -4,11 +4,7 @@ import { $ } from '../../../moto/webui.js';
import { api } from '../api.js'; import { api } from '../api.js';
import { settings as set_ctrl } from './manager.js'; import { settings as set_ctrl } from './manager.js';
function settings() { function export_device(exp, name) {
return api.conf.get();
}
function deviceExport(exp, name) {
name = (name || "device") name = (name || "device")
.toLowerCase() .toLowerCase()
.replace(/ /g,'_') .replace(/ /g,'_')
@ -20,7 +16,7 @@ function deviceExport(exp, name) {
}); });
} }
function objectsExport(format = "stl") { function export_objects(format = "stl") {
// return selection.export(); // return selection.export();
api.uc.confirm("Export Filename", {ok:true, cancel: false}, `selected.${format}`).then(name => { api.uc.confirm("Export Filename", {ok:true, cancel: false}, `selected.${format}`).then(name => {
if (!name) return; if (!name) return;
@ -31,18 +27,7 @@ function objectsExport(format = "stl") {
}); });
} }
function workspaceNew() { function export_profile() {
api.uc.confirm("Clear Workspace?", {ok:true, cancel: false}).then(value => {
if (value === true) {
let proc = set_ctrl.proc();
proc.ops && (proc.ops.length = 0);
proc.op2 && (proc.op2.length = 0);
api.platform.clear();
}
});
}
function profileExport() {
const opt = {pre: [ const opt = {pre: [
"<div class='f-col a-center gap5 mlr10'>", "<div class='f-col a-center gap5 mlr10'>",
" <h3>Workspace Export</h3>", " <h3>Workspace Export</h3>",
@ -73,7 +58,18 @@ function profileExport() {
}); });
} }
function settingsSave(ev, name) { function new_workspace() {
api.uc.confirm("Clear Workspace?", {ok:true, cancel: false}).then(value => {
if (value === true) {
let proc = set_ctrl.proc();
proc.ops && (proc.ops.length = 0);
proc.op2 && (proc.op2.length = 0);
api.platform.clear();
}
});
}
function settings_save(ev, name) {
if (ev) { if (ev) {
ev.stopPropagation(); ev.stopPropagation();
ev.preventDefault(); ev.preventDefault();
@ -81,7 +77,7 @@ function settingsSave(ev, name) {
api.dialog.hide(); api.dialog.hide();
let mode = api.mode.get(), let mode = api.mode.get(),
s = settings(), s = api.conf.get(),
def = "default", def = "default",
cp = s.process, cp = s.process,
pl = s.sproc[mode], pl = s.sproc[mode],
@ -112,27 +108,22 @@ function settingsSave(ev, name) {
} }
} }
function settingsLoad() { function settings_load() {
api.conf.show(); api.conf.show();
} }
function updateDeviceSize() { function update_platform_size() {
api.conf.update(); api.conf.update();
api.platform.update_size(); api.platform.update_size();
api.platform.update_origin(); api.platform.update_origin();
} }
async function sync_put() {
await set_ctrl.sync.put();
}
export const settingsOps = { export const settingsOps = {
deviceExport, export_device,
objectsExport, export_objects,
workspaceNew, export_profile,
profileExport, new_workspace,
settingsSave, settings_save,
settingsLoad, settings_load,
updateDeviceSize, update_device: update_platform_size,
sync_put
}; };

View file

@ -203,7 +203,7 @@ export function init_input() {
preferences.updateDrawer(); preferences.updateDrawer();
// api augmentation with local functions // api augmentation with local functions
api.device.export = settingsOps.deviceExport; api.device.export = settingsOps.export_device;
Object.assign(ui, { Object.assign(ui, {
tracker: tracker, tracker: tracker,
@ -218,9 +218,9 @@ export function init_input() {
device: newGroup(LANG.dv_gr_dev, null, {group:"ddev", inline, class:"noshow"}), device: newGroup(LANG.dv_gr_dev, null, {group:"ddev", inline, class:"noshow"}),
_____: newGroup("workspace", null, {group:"dext", inline}), _____: newGroup("workspace", null, {group:"dext", inline}),
bedWidth: newInput('X (width)', {title:LANG.dv_bedw_l, convert:toFloat, size:6, units, round:2, action:settingsOps.updateDeviceSize}), bedWidth: newInput('X (width)', {title:LANG.dv_bedw_l, convert:toFloat, size:6, units, round:2, action:settingsOps.update_device}),
bedDepth: newInput('Y (depth)', {title:LANG.dv_bedw_l, convert:toFloat, size:6, units, round:2, action:settingsOps.updateDeviceSize}), bedDepth: newInput('Y (depth)', {title:LANG.dv_bedw_l, convert:toFloat, size:6, units, round:2, action:settingsOps.update_device}),
maxHeight: newInput('Z (height)', {title:LANG.dv_bedw_l, convert:toFloat, size:6, units, round:2, action:settingsOps.updateDeviceSize}), maxHeight: newInput('Z (height)', {title:LANG.dv_bedw_l, convert:toFloat, size:6, units, round:2, action:settingsOps.update_device}),
resolutionX: newInput(LANG.dv_rezx_s, {title:LANG.dv_rezx_l, convert:toInt, size:6, modes:SLA}), resolutionX: newInput(LANG.dv_rezx_s, {title:LANG.dv_rezx_l, convert:toInt, size:6, modes:SLA}),
resolutionY: newInput(LANG.dv_rezy_s, {title:LANG.dv_rezy_l, convert:toInt, size:6, modes:SLA}), resolutionY: newInput(LANG.dv_rezy_s, {title:LANG.dv_rezy_l, convert:toInt, size:6, modes:SLA}),
_____: newDiv({ class: "f-col t-body t-inset", addto: $('dev-config'), set:true, modes:NO_WEDM }), _____: newDiv({ class: "f-col t-body t-inset", addto: $('dev-config'), set:true, modes:NO_WEDM }),
@ -342,7 +342,7 @@ export function init_input() {
// override old style settings two-button menu // override old style settings two-button menu
ui.settingsSave.onclick = () => { ui.settingsSave.onclick = () => {
settingsOps.settingsSave(undefined, ui.settingsName.value); settingsOps.settings_save(undefined, ui.settingsName.value);
}; };
// initialize and expose modal to API // initialize and expose modal to API
@ -391,7 +391,7 @@ export function init_input() {
DOC, DOC,
WIN, WIN,
rotateInputSelection: input_rotate, rotateInputSelection: input_rotate,
settingsLoad: settingsOps.settingsLoad settingsLoad: settingsOps.settings_load
}); });
// add mobile class to body if needed // add mobile class to body if needed

View file

@ -200,7 +200,7 @@ function setup_keybd_nav() {
ui.acct.help.onclick = (ev) => { ev.stopPropagation(); api.help.show() }; ui.acct.help.onclick = (ev) => { ev.stopPropagation(); api.help.show() };
ui.acct.don8.onclick = (ev) => { ev.stopPropagation(); api.modal.show('don8') }; ui.acct.don8.onclick = (ev) => { ev.stopPropagation(); api.modal.show('don8') };
ui.acct.mesh.onclick = (ev) => { ev.stopPropagation(); WIN.location = "/mesh" }; ui.acct.mesh.onclick = (ev) => { ev.stopPropagation(); WIN.location = "/mesh" };
ui.acct.export.onclick = (ev) => { ev.stopPropagation(); settingsOps.profileExport() }; ui.acct.export.onclick = (ev) => { ev.stopPropagation(); settingsOps.export_profile() };
ui.acct.export.title = LANG.acct_xpo; ui.acct.export.title = LANG.acct_xpo;
ui.func.slice.onclick = (ev) => { ev.stopPropagation(); api.function.slice() }; ui.func.slice.onclick = (ev) => { ev.stopPropagation(); api.function.slice() };
ui.func.preview.onclick = (ev) => { ev.stopPropagation(); api.function.print() }; ui.func.preview.onclick = (ev) => { ev.stopPropagation(); api.function.print() };
@ -211,7 +211,7 @@ function setup_keybd_nav() {
$('export-support-a').onclick = (ev) => { ev.stopPropagation(); api.modal.show('don8') }; $('export-support-a').onclick = (ev) => { ev.stopPropagation(); api.modal.show('don8') };
$('mode-device').onclick = api.show.devices; $('mode-device').onclick = api.show.devices;
$('mode-profile').onclick = settingsOps.settingsLoad; $('mode-profile').onclick = settingsOps.settings_load;
$('mode-fdm').onclick = () => api.mode.set('FDM'); $('mode-fdm').onclick = () => api.mode.set('FDM');
$('mode-cam').onclick = () => api.mode.set('CAM'); $('mode-cam').onclick = () => api.mode.set('CAM');
$('mode-sla').onclick = () => api.mode.set('SLA'); $('mode-sla').onclick = () => api.mode.set('SLA');
@ -223,7 +223,7 @@ function setup_keybd_nav() {
$('set-profs').onclick = (ev) => { ev.stopPropagation(); api.conf.show() }; $('set-profs').onclick = (ev) => { ev.stopPropagation(); api.conf.show() };
$('set-tools').onclick = (ev) => { ev.stopPropagation(); api.show.tools() }; $('set-tools').onclick = (ev) => { ev.stopPropagation(); api.show.tools() };
$('set-prefs').onclick = (ev) => { ev.stopPropagation(); api.modal.show('prefs') }; $('set-prefs').onclick = (ev) => { ev.stopPropagation(); api.modal.show('prefs') };
$('file-new').onclick = (ev) => { ev.stopPropagation(); settingsOps.workspaceNew() }; $('file-new').onclick = (ev) => { ev.stopPropagation(); settingsOps.new_workspace() };
$('file-recent').onclick = () => { api.modal.show('files') }; $('file-recent').onclick = () => { api.modal.show('files') };
$('file-import').onclick = (ev) => { api.event.import(ev); }; $('file-import').onclick = (ev) => { api.event.import(ev); };
$('view-arrange').onclick = api.platform.layout; $('view-arrange').onclick = api.platform.layout;
@ -259,8 +259,8 @@ function setup_keybd_nav() {
$('render-ghost').onclick = () => { api.view.wireframe(false, 0, api.view.is_arrange() ? 0.4 : 0.25); }; $('render-ghost').onclick = () => { api.view.wireframe(false, 0, api.view.is_arrange() ? 0.4 : 0.25); };
$('render-wire').onclick = () => { api.view.wireframe(true, 0, api.space.is_dark() ? 0.25 : 0.5); }; $('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); }; $('render-solid').onclick = () => { api.view.wireframe(false, 0, 1); };
$('mesh-export-stl').onclick = () => { settingsOps.objectsExport('stl') }; $('mesh-export-stl').onclick = () => { settingsOps.export_objects('stl') };
$('mesh-export-obj').onclick = () => { settingsOps.objectsExport('obj') }; $('mesh-export-obj').onclick = () => { settingsOps.export_objects('obj') };
$('mesh-merge').onclick = selection.merge; $('mesh-merge').onclick = selection.merge;
$('mesh-split').onclick = selection.isolateBodies; $('mesh-split').onclick = selection.isolateBodies;
$('context-duplicate').onclick = selection.duplicate; $('context-duplicate').onclick = selection.duplicate;