separate init bindings
This commit is contained in:
parent
0e0710e85b
commit
b79c8da8e2
9 changed files with 288 additions and 241 deletions
|
|
@ -213,24 +213,24 @@ function setDeviceCode(code, devicename) {
|
|||
e.disabled = !local;
|
||||
});
|
||||
|
||||
ui.deviceSave.disabled = !local;
|
||||
ui.deviceDelete.disabled = !local;
|
||||
ui.deviceRename.disabled = !local;
|
||||
ui.deviceExport.disabled = !local;
|
||||
ui.deviceAdd.style.display = mode === 'SLA' ? 'none' : '';
|
||||
ui.devices.save.disabled = !local;
|
||||
ui.devices.delete.disabled = !local;
|
||||
ui.devices.rename.disabled = !local;
|
||||
ui.devices.export.disabled = !local;
|
||||
ui.devices.add.style.display = mode === 'SLA' ? 'none' : '';
|
||||
|
||||
if (local) {
|
||||
ui.deviceAdd.innerText = "copy";
|
||||
ui.deviceDelete.style.display = '';
|
||||
ui.deviceRename.style.display = '';
|
||||
ui.deviceExport.style.display = '';
|
||||
ui.devices.add.innerText = "copy";
|
||||
ui.devices.delete.style.display = '';
|
||||
ui.devices.rename.style.display = '';
|
||||
ui.devices.export.style.display = '';
|
||||
} else {
|
||||
ui.deviceAdd.innerText = "customize";
|
||||
ui.deviceDelete.style.display = 'none';
|
||||
ui.deviceRename.style.display = 'none';
|
||||
ui.deviceExport.style.display = 'none';
|
||||
ui.devices.add.innerText = "customize";
|
||||
ui.devices.delete.style.display = 'none';
|
||||
ui.devices.rename.style.display = 'none';
|
||||
ui.devices.export.style.display = 'none';
|
||||
}
|
||||
ui.deviceAdd.disabled = dev.noclone;
|
||||
ui.devices.add.disabled = dev.noclone;
|
||||
|
||||
setconf.update_fields();
|
||||
space.platform.setBelt(isBelt());
|
||||
|
|
@ -301,7 +301,7 @@ function renderDevices(devices) {
|
|||
|
||||
event.emit('devices.render', devices);
|
||||
|
||||
ui.deviceSave.onclick = function() {
|
||||
ui.devices.save.onclick = function() {
|
||||
event.emit('device.save');
|
||||
api.function.clear();
|
||||
setconf.save();
|
||||
|
|
@ -309,18 +309,18 @@ function renderDevices(devices) {
|
|||
showDevices();
|
||||
api.modal.hide();
|
||||
};
|
||||
ui.deviceAdd.onclick = function() {
|
||||
ui.devices.add.onclick = function() {
|
||||
api.function.clear();
|
||||
cloneDevice();
|
||||
showDevices();
|
||||
};
|
||||
ui.deviceDelete.onclick = function() {
|
||||
ui.devices.delete.onclick = function() {
|
||||
api.function.clear();
|
||||
removeLocalDevice(getSelectedDevice());
|
||||
selectDevice(getModeDevices()[0]);
|
||||
showDevices();
|
||||
};
|
||||
ui.deviceRename.onclick = function() {
|
||||
ui.devices.rename.onclick = function() {
|
||||
api.uc.prompt(`Rename "${selected}`, selected).then(newname => {
|
||||
if (newname) {
|
||||
updateDeviceName(newname);
|
||||
|
|
@ -332,7 +332,7 @@ function renderDevices(devices) {
|
|||
}
|
||||
});
|
||||
};
|
||||
ui.deviceExport.onclick = function(event) {
|
||||
ui.devices.export.onclick = function(event) {
|
||||
const record = {
|
||||
version: api.version,
|
||||
device: selected,
|
||||
|
|
|
|||
133
src/kiri/app/init/bind.js
Normal file
133
src/kiri/app/init/bind.js
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
|
||||
|
||||
import { $ } from '../../../moto/webui.js';
|
||||
import { api } from '../api.js';
|
||||
|
||||
export function bind() {
|
||||
return {
|
||||
alert: {
|
||||
dialog: $('alert-area'),
|
||||
text: $('alert-text')
|
||||
},
|
||||
func: {
|
||||
slice: $('act-slice'),
|
||||
preview: $('act-preview'),
|
||||
animate: $('act-animate'),
|
||||
export: $('act-export')
|
||||
},
|
||||
label: {
|
||||
slice: $('label-slice'),
|
||||
preview: $('label-preview'),
|
||||
animate: $('label-animate'),
|
||||
export: $('label-export'),
|
||||
},
|
||||
acct: {
|
||||
help: $('app-help'),
|
||||
don8: $('app-don8'),
|
||||
mesh: $('app-mesh'),
|
||||
export: $('app-export')
|
||||
},
|
||||
dev: {
|
||||
header: $('dev-header'),
|
||||
search: $('dev-search'),
|
||||
filter: $('dev-filter')
|
||||
},
|
||||
mesh: {
|
||||
name: $('mesh-name'),
|
||||
points: $('mesh-points'),
|
||||
faces: $('mesh-faces'),
|
||||
},
|
||||
|
||||
stats: {
|
||||
fps: $('fps'),
|
||||
rms: $('rms'),
|
||||
div: $('stats'),
|
||||
rnfo: $('rnfo'),
|
||||
},
|
||||
|
||||
load: $('load-file'),
|
||||
speeds: $('speeds'),
|
||||
speedbar: $('speedbar'),
|
||||
|
||||
context: $('context-menu'),
|
||||
|
||||
// ltsetup: $('lt-setup'),
|
||||
// ltfile: $('lt-file'),
|
||||
// ltview: $('lt-view'),
|
||||
// ltact: $('lt-start'),
|
||||
// edit: $('lt-tools'),
|
||||
nozzle: $('menu-nozzle'),
|
||||
|
||||
modal: $('modal'),
|
||||
modalBox: $('modal-box'),
|
||||
modals: {
|
||||
help: $('mod-help'),
|
||||
setup: $('mod-setup'),
|
||||
prefs: $('mod-prefs'),
|
||||
files: $('mod-files'),
|
||||
saves: $('mod-saves'),
|
||||
tools: $('mod-tools'),
|
||||
xany: $('mod-x-any'),
|
||||
xsla: $('mod-x-sla'),
|
||||
xlaser: $('mod-x-laser'),
|
||||
don8: $('mod-don8'),
|
||||
any: $('mod-any'),
|
||||
},
|
||||
|
||||
catalog: {
|
||||
body: $('catalogBody'),
|
||||
list: $('catalogList'),
|
||||
},
|
||||
|
||||
devices: {
|
||||
div: $('devices'),
|
||||
add: $('device-add'),
|
||||
delete: $('device-del'),
|
||||
export: $('device-exp'),
|
||||
rename: $('device-ren'),
|
||||
save: $('device-save'),
|
||||
},
|
||||
|
||||
setMenu: $('set-menu'),
|
||||
settings: $('settings'),
|
||||
settingsBody: $('settingsBody'),
|
||||
settingsList: $('settingsList'),
|
||||
|
||||
slider: {
|
||||
div: $('slider'),
|
||||
hi: $('slider-hi'),
|
||||
hold: $('slider-hold'),
|
||||
lo: $('slider-lo'),
|
||||
max: $('slider-max'),
|
||||
mid: $('slider-mid'),
|
||||
min: $('slider-zero'),
|
||||
range: $('slider-center'),
|
||||
},
|
||||
|
||||
loading: $('progress').style,
|
||||
progress: $('progbar').style,
|
||||
prostatus: $('progtxt'),
|
||||
selection: $('selection'),
|
||||
|
||||
size: {
|
||||
X: $('size_x'),
|
||||
Y: $('size_y'),
|
||||
Z: $('size_z'),
|
||||
},
|
||||
scale: {
|
||||
X: $('scale_x'),
|
||||
Y: $('scale_y'),
|
||||
Z: $('scale_z'),
|
||||
},
|
||||
lock: {
|
||||
X: $('lock_x'),
|
||||
Y: $('lock_y'),
|
||||
Z: $('lock_z'),
|
||||
},
|
||||
|
||||
stock: $('stock'),
|
||||
stockWidth: $('stock-width'),
|
||||
stockDepth: $('stock-width'),
|
||||
stockHeight: $('stock-width'),
|
||||
};
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
import { $ } from '../../../moto/webui.js';
|
||||
import { api } from '../api.js';
|
||||
import { bind } from './bind.js';
|
||||
import { version } from '../../../moto/license.js';
|
||||
import { fileOps } from '../file-ops.js';
|
||||
import { init as initCAM } from '../../mode/cam/init-ui.js';
|
||||
|
|
@ -207,118 +208,8 @@ function init_one() {
|
|||
tracker: tracker,
|
||||
container: container,
|
||||
|
||||
alert: {
|
||||
dialog: $('alert-area'),
|
||||
text: $('alert-text')
|
||||
},
|
||||
func: {
|
||||
slice: $('act-slice'),
|
||||
preview: $('act-preview'),
|
||||
animate: $('act-animate'),
|
||||
export: $('act-export')
|
||||
},
|
||||
label: {
|
||||
slice: $('label-slice'),
|
||||
preview: $('label-preview'),
|
||||
animate: $('label-animate'),
|
||||
export: $('label-export'),
|
||||
},
|
||||
acct: {
|
||||
help: $('app-help'),
|
||||
don8: $('app-don8'),
|
||||
mesh: $('app-mesh'),
|
||||
export: $('app-export')
|
||||
},
|
||||
dev: {
|
||||
header: $('dev-header'),
|
||||
search: $('dev-search'),
|
||||
filter: $('dev-filter')
|
||||
},
|
||||
mesh: {
|
||||
name: $('mesh-name'),
|
||||
points: $('mesh-points'),
|
||||
faces: $('mesh-faces'),
|
||||
},
|
||||
|
||||
stats: {
|
||||
fps: $('fps'),
|
||||
rms: $('rms'),
|
||||
div: $('stats'),
|
||||
rnfo: $('rnfo'),
|
||||
},
|
||||
|
||||
load: $('load-file'),
|
||||
speeds: $('speeds'),
|
||||
speedbar: $('speedbar'),
|
||||
context: $('context-menu'),
|
||||
|
||||
ltsetup: $('lt-setup'),
|
||||
ltfile: $('lt-file'),
|
||||
ltview: $('lt-view'),
|
||||
ltact: $('lt-start'),
|
||||
edit: $('lt-tools'),
|
||||
nozzle: $('menu-nozzle'),
|
||||
|
||||
modal: $('modal'),
|
||||
modalBox: $('modal-box'),
|
||||
modals: {
|
||||
help: $('mod-help'),
|
||||
setup: $('mod-setup'),
|
||||
prefs: $('mod-prefs'),
|
||||
files: $('mod-files'),
|
||||
saves: $('mod-saves'),
|
||||
tools: $('mod-tools'),
|
||||
xany: $('mod-x-any'),
|
||||
xsla: $('mod-x-sla'),
|
||||
xlaser: $('mod-x-laser'),
|
||||
don8: $('mod-don8'),
|
||||
any: $('mod-any'),
|
||||
},
|
||||
|
||||
catalog: {
|
||||
body: $('catalogBody'),
|
||||
list: $('catalogList'),
|
||||
},
|
||||
|
||||
devices: $('devices'),
|
||||
deviceAdd: $('device-add'),
|
||||
deviceDelete: $('device-del'),
|
||||
deviceRename: $('device-ren'),
|
||||
deviceExport: $('device-exp'),
|
||||
deviceSave: $('device-save'),
|
||||
|
||||
setMenu: $('set-menu'),
|
||||
settings: $('settings'),
|
||||
settingsBody: $('settingsBody'),
|
||||
settingsList: $('settingsList'),
|
||||
|
||||
slider: $('slider'),
|
||||
sliderMax: $('slider-max'),
|
||||
sliderMin: $('slider-zero'),
|
||||
sliderLo: $('slider-lo'),
|
||||
sliderMid: $('slider-mid'),
|
||||
sliderHi: $('slider-hi'),
|
||||
sliderHold: $('slider-hold'),
|
||||
sliderRange: $('slider-center'),
|
||||
|
||||
loading: $('progress').style,
|
||||
progress: $('progbar').style,
|
||||
prostatus: $('progtxt'),
|
||||
|
||||
selection: $('selection'),
|
||||
sizeX: $('size_x'),
|
||||
sizeY: $('size_y'),
|
||||
sizeZ: $('size_z'),
|
||||
scaleX: $('scale_x'),
|
||||
scaleY: $('scale_y'),
|
||||
scaleZ: $('scale_z'),
|
||||
lockX: $('lock_x'),
|
||||
lockY: $('lock_y'),
|
||||
lockZ: $('lock_z'),
|
||||
stock: $('stock'),
|
||||
stockWidth: $('stock-width'),
|
||||
stockDepth: $('stock-width'),
|
||||
stockHeight: $('stock-width'),
|
||||
// static html --> ui bindings
|
||||
...bind(),
|
||||
|
||||
/** Device Browser / Editor */
|
||||
|
||||
|
|
@ -592,19 +483,19 @@ function init_one() {
|
|||
input_binding(ui);
|
||||
|
||||
$('lab-axis').onclick = () => {
|
||||
ui.lockX.checked =
|
||||
ui.lockY.checked =
|
||||
ui.lockZ.checked = !(
|
||||
ui.lockX.checked ||
|
||||
ui.lockY.checked ||
|
||||
ui.lockZ.checked
|
||||
ui.lock.X.checked =
|
||||
ui.lock.Y.checked =
|
||||
ui.lock.Z.checked = !(
|
||||
ui.lock.X.checked ||
|
||||
ui.lock.Y.checked ||
|
||||
ui.lock.Z.checked
|
||||
);
|
||||
};
|
||||
|
||||
$('scale-reset').onclick = $('lab-scale').onclick = () => {
|
||||
selection.scale(1 / ui.scaleX.was, 1 / ui.scaleY.was, 1 / ui.scaleZ.was);
|
||||
ui.scaleX.value = ui.scaleY.value = ui.scaleZ.value =
|
||||
ui.scaleX.was = ui.scaleY.was = ui.scaleZ.was = 1;
|
||||
selection.scale(1 / ui.scale.X.was, 1 / ui.scale.Y.was, 1 / ui.scale.Z.was);
|
||||
ui.scale.X.value = ui.scale.Y.value = ui.scale.Z.value =
|
||||
ui.scale.X.was = ui.scale.Y.was = ui.scale.Z.was = 1;
|
||||
};
|
||||
|
||||
$('app-xpnd').onclick = () => {
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import { settings as set_ctrl } from '../conf/manager.js';
|
|||
import { settingsOps } from '../conf/settings.js';
|
||||
import { space } from '../../../moto/space.js';
|
||||
import { VIEWS } from '../../core/consts.js';
|
||||
import * as view_tools from '../tools.js';
|
||||
|
||||
const DOC = self.document;
|
||||
const WIN = self.window;
|
||||
|
|
@ -201,6 +202,18 @@ function setup_keybd_nav(ui, WIN, LANG) {
|
|||
const { selection } = api;
|
||||
|
||||
// bind interface action elements
|
||||
ui.acct.help.onclick = (ev) => { ev.stopPropagation(); api.help.show() };
|
||||
ui.acct.don8.onclick = (ev) => { ev.stopPropagation(); api.modal.show('don8') };
|
||||
ui.acct.mesh.onclick = (ev) => { ev.stopPropagation(); WIN.location = "/mesh" };
|
||||
ui.acct.export.onclick = (ev) => { ev.stopPropagation(); settingsOps.profileExport() };
|
||||
ui.acct.export.title = LANG.acct_xpo;
|
||||
ui.func.slice.onclick = (ev) => { ev.stopPropagation(); api.function.slice() };
|
||||
ui.func.preview.onclick = (ev) => { ev.stopPropagation(); api.function.print() };
|
||||
ui.func.animate.onclick = (ev) => { ev.stopPropagation(); api.function.animate() };
|
||||
ui.func.export.onclick = (ev) => { ev.stopPropagation(); api.function.export() };
|
||||
// prevent modal input from propagating to parents
|
||||
ui.modalBox.onclick = (ev) => { ev.stopPropagation() };
|
||||
|
||||
$('export-support-a').onclick = (ev) => { ev.stopPropagation(); api.modal.show('don8') };
|
||||
$('mode-device').onclick = api.show.devices;
|
||||
$('mode-profile').onclick = settingsOps.settingsLoad;
|
||||
|
|
@ -215,18 +228,9 @@ function setup_keybd_nav(ui, WIN, LANG) {
|
|||
$('set-profs').onclick = (ev) => { ev.stopPropagation(); api.conf.show() };
|
||||
$('set-tools').onclick = (ev) => { ev.stopPropagation(); api.show.tools() };
|
||||
$('set-prefs').onclick = (ev) => { ev.stopPropagation(); api.modal.show('prefs') };
|
||||
ui.acct.help.onclick = (ev) => { ev.stopPropagation(); api.help.show() };
|
||||
ui.acct.don8.onclick = (ev) => { ev.stopPropagation(); api.modal.show('don8') };
|
||||
ui.acct.mesh.onclick = (ev) => { ev.stopPropagation(); WIN.location = "/mesh" };
|
||||
ui.acct.export.onclick = (ev) => { ev.stopPropagation(); settingsOps.profileExport() };
|
||||
ui.acct.export.title = LANG.acct_xpo;
|
||||
$('file-new').onclick = (ev) => { ev.stopPropagation(); settingsOps.workspaceNew() };
|
||||
$('file-recent').onclick = () => { api.modal.show('files') };
|
||||
$('file-import').onclick = (ev) => { api.event.import(ev); };
|
||||
ui.func.slice.onclick = (ev) => { ev.stopPropagation(); api.function.slice() };
|
||||
ui.func.preview.onclick = (ev) => { ev.stopPropagation(); api.function.print() };
|
||||
ui.func.animate.onclick = (ev) => { ev.stopPropagation(); api.function.animate() };
|
||||
ui.func.export.onclick = (ev) => { ev.stopPropagation(); api.function.export() };
|
||||
$('view-arrange').onclick = api.platform.layout;
|
||||
$('view-top').onclick = space.view.top;
|
||||
$('view-home').onclick = space.view.home;
|
||||
|
|
@ -238,12 +242,14 @@ function setup_keybd_nav(ui, WIN, LANG) {
|
|||
api.widgets.for(w => w.unrotate());
|
||||
selection.update_info();
|
||||
};
|
||||
|
||||
// attach button handlers to support targets
|
||||
for (let btn of ["don8pt","don8gh","don8pp"]) {
|
||||
$(btn).onclick = (ev) => {
|
||||
window.open(ev.target.children[0].href);
|
||||
}
|
||||
}
|
||||
|
||||
// rotation buttons
|
||||
let d = (Math.PI / 180);
|
||||
$('rot_x_lt').onclick = () => { selection.rotate(-d * $('rot_x').value,0,0) };
|
||||
|
|
@ -252,6 +258,7 @@ function setup_keybd_nav(ui, WIN, LANG) {
|
|||
$('rot_y_gt').onclick = () => { selection.rotate(0, d * $('rot_y').value,0) };
|
||||
$('rot_z_lt').onclick = () => { selection.rotate(0,0, d * $('rot_z').value) };
|
||||
$('rot_z_gt').onclick = () => { selection.rotate(0,0,-d * $('rot_z').value) };
|
||||
|
||||
// rendering options
|
||||
$('render-edges').onclick = () => { api.view.edges({ toggle: true }); api.conf.save() };
|
||||
$('render-ghost').onclick = () => { api.view.wireframe(false, 0, api.view.is_arrange() ? 0.4 : 0.25); };
|
||||
|
|
@ -263,21 +270,15 @@ function setup_keybd_nav(ui, WIN, LANG) {
|
|||
$('mesh-split').onclick = selection.isolateBodies;
|
||||
$('context-duplicate').onclick = selection.duplicate;
|
||||
$('context-mirror').onclick = selection.mirror;
|
||||
$('context-layflat').onclick = () => { api.event.emit("tool.mesh.lay-flat") };
|
||||
$('context-lefty').onclick = () => { api.event.emit("tool.mesh.lefty") };
|
||||
$('context-layflat').onclick = view_tools.startLayFlat;
|
||||
$('context-lefty').onclick = view_tools.startLeftAlign;
|
||||
$('context-setfocus').onclick = () => {
|
||||
api.event.emit(
|
||||
"tool.camera.focus",
|
||||
ev => api.space.set_focus(undefined, ev.object.point)
|
||||
);
|
||||
view_tools.startFocus(ev => api.space.set_focus(undefined, ev.object.point));
|
||||
};
|
||||
$('context-contents').onclick = () => { api.SPACE.view.fit() };
|
||||
$('view-fit').onclick = () => { api.SPACE.view.fit() };
|
||||
$('context-contents').onclick = api.const.SPACE.view.fit;
|
||||
$('view-fit').onclick = api.const.SPACE.view.fit;
|
||||
$('wassup').onmouseover = () => { $('suppopp').classList.remove('hide') };
|
||||
|
||||
// prevent modal input from propagating to parents
|
||||
ui.modalBox.onclick = (ev) => { ev.stopPropagation() };
|
||||
|
||||
// enable modal hiding
|
||||
$('mod-x').onclick = api.modal.hide;
|
||||
|
||||
|
|
@ -78,12 +78,12 @@ function update_info() {
|
|||
});
|
||||
if (bounds.min.x === Infinity) {
|
||||
if (selectedMeshes.length === 0) {
|
||||
ui.sizeX.value = 0;
|
||||
ui.sizeY.value = 0;
|
||||
ui.sizeZ.value = 0;
|
||||
ui.scaleX.value = 1;
|
||||
ui.scaleY.value = 1;
|
||||
ui.scaleZ.value = 1;
|
||||
ui.size.X.value = 0;
|
||||
ui.size.Y.value = 0;
|
||||
ui.size.Z.value = 0;
|
||||
ui.scale.X.value = 1;
|
||||
ui.scale.Y.value = 1;
|
||||
ui.scale.Z.value = 1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
@ -91,12 +91,12 @@ function update_info() {
|
|||
dy = bounds.max.y - bounds.min.y,
|
||||
dz = bounds.max.z - bounds.min.z,
|
||||
scale = api.view.unit_scale();
|
||||
ui.sizeX.value = ui.sizeX.was = (dx / scale).round(2)
|
||||
ui.sizeY.value = ui.sizeY.was = (dy / scale).round(2)
|
||||
ui.sizeZ.value = ui.sizeZ.was = (dz / scale).round(2)
|
||||
ui.scaleX.value = ui.scaleX.was = track.scale.x.round(2);
|
||||
ui.scaleY.value = ui.scaleY.was = track.scale.y.round(2);
|
||||
ui.scaleZ.value = ui.scaleZ.was = track.scale.z.round(2);
|
||||
ui.size.X.value = ui.size.X.was = (dx / scale).round(2)
|
||||
ui.size.Y.value = ui.size.Y.was = (dy / scale).round(2)
|
||||
ui.size.Z.value = ui.size.Z.was = (dz / scale).round(2)
|
||||
ui.scale.X.value = ui.scale.X.was = track.scale.x.round(2);
|
||||
ui.scale.Y.value = ui.scale.Y.was = track.scale.y.round(2);
|
||||
ui.scale.Z.value = ui.scale.Z.was = track.scale.z.round(2);
|
||||
update_bounds();
|
||||
}
|
||||
|
||||
|
|
@ -365,13 +365,13 @@ function input_resize(e, ui) {
|
|||
let dv = parseFloat(e.target.value || 1),
|
||||
pv = parseFloat(e.target.was || 1),
|
||||
ra = dv / pv,
|
||||
xv = parseFloat(ui.sizeX.was ?? ui.scaleX.value) || 1,
|
||||
yv = parseFloat(ui.sizeY.was ?? ui.scaleY.value) || 1,
|
||||
zv = parseFloat(ui.sizeZ.was ?? ui.scaleZ.value) || 1,
|
||||
xv = parseFloat(ui.size.X.was ?? ui.scale.X.value) || 1,
|
||||
yv = parseFloat(ui.size.Y.was ?? ui.scale.Y.value) || 1,
|
||||
zv = parseFloat(ui.size.Z.was ?? ui.scale.Z.value) || 1,
|
||||
ta = e.target,
|
||||
xc = ui.lockX.checked,
|
||||
yc = ui.lockY.checked,
|
||||
zc = ui.lockZ.checked,
|
||||
xc = ui.lock.X.checked,
|
||||
yc = ui.lock.Y.checked,
|
||||
zc = ui.lock.Z.checked,
|
||||
xt = ta === ui.sizeX,
|
||||
yt = ta === ui.sizeY,
|
||||
zt = ta === ui.sizeZ,
|
||||
|
|
@ -385,25 +385,25 @@ function input_resize(e, ui) {
|
|||
return;
|
||||
}
|
||||
selection.scale(xr,yr,zr);
|
||||
ui.sizeX.was = ui.sizeX.value = xv * xr;
|
||||
ui.sizeY.was = ui.sizeY.value = yv * yr;
|
||||
ui.sizeZ.was = ui.sizeZ.value = zv * zr;
|
||||
ui.size.X.was = ui.size.X.value = xv * xr;
|
||||
ui.size.Y.was = ui.size.Y.value = yv * yr;
|
||||
ui.size.Z.was = ui.size.Z.value = zv * zr;
|
||||
}
|
||||
|
||||
function input_scale(e, ui) {
|
||||
let dv = parseFloat(e.target.value || 1),
|
||||
pv = parseFloat(e.target.was || 1),
|
||||
ra = dv / pv,
|
||||
xv = parseFloat(ui.scaleX.was ?? ui.scaleX.value) || 1,
|
||||
yv = parseFloat(ui.scaleY.was ?? ui.scaleY.value) || 1,
|
||||
zv = parseFloat(ui.scaleZ.was ?? ui.scaleY.value) || 1,
|
||||
xv = parseFloat(ui.scale.X.was ?? ui.scale.X.value) || 1,
|
||||
yv = parseFloat(ui.scale.Y.was ?? ui.scale.Y.value) || 1,
|
||||
zv = parseFloat(ui.scale.Z.was ?? ui.scale.Y.value) || 1,
|
||||
ta = e.target,
|
||||
xc = ui.lockX.checked,
|
||||
yc = ui.lockY.checked,
|
||||
zc = ui.lockZ.checked,
|
||||
xt = ta === ui.scaleX,
|
||||
yt = ta === ui.scaleY,
|
||||
zt = ta === ui.scaleZ,
|
||||
xc = ui.lock.X.checked,
|
||||
yc = ui.lock.Y.checked,
|
||||
zc = ui.lock.Z.checked,
|
||||
xt = ta === ui.scale.X,
|
||||
yt = ta === ui.scale.Y,
|
||||
zt = ta === ui.scale.Z,
|
||||
tl = (xt && xc) || (yt && yc) || (zt && zc),
|
||||
xr = ((tl && xc) || (!tl && xt) ? ra : 1),
|
||||
yr = ((tl && yc) || (!tl && yt) ? ra : 1),
|
||||
|
|
@ -414,9 +414,9 @@ function input_scale(e, ui) {
|
|||
return;
|
||||
}
|
||||
selection.scale(xr,yr,zr);
|
||||
ui.scaleX.was = ui.scaleX.value = xv * xr;
|
||||
ui.scaleY.was = ui.scaleY.value = yv * yr;
|
||||
ui.scaleZ.was = ui.scaleZ.value = zv * zr;
|
||||
ui.scale.X.was = ui.scale.X.value = xv * xr;
|
||||
ui.scale.Y.was = ui.scale.Y.value = yv * yr;
|
||||
ui.scale.Z.was = ui.scale.Z.value = zv * zr;
|
||||
}
|
||||
|
||||
function parse_as_float(e) {
|
||||
|
|
@ -426,12 +426,12 @@ function parse_as_float(e) {
|
|||
function input_binding(ui) {
|
||||
// on enter but not on blur
|
||||
space.event.onEnterKey([
|
||||
ui.scaleX, (e) => input_scale(e, ui),
|
||||
ui.scaleY, (e) => input_scale(e, ui),
|
||||
ui.scaleZ, (e) => input_scale(e, ui),
|
||||
ui.sizeX, (e) => input_resize(e, ui),
|
||||
ui.sizeY, (e) => input_resize(e, ui),
|
||||
ui.sizeZ, (e) => input_resize(e, ui),
|
||||
ui.scale.X, (e) => input_scale(e, ui),
|
||||
ui.scale.Y, (e) => input_scale(e, ui),
|
||||
ui.scale.Z, (e) => input_scale(e, ui),
|
||||
ui.size.X, (e) => input_resize(e, ui),
|
||||
ui.size.Y, (e) => input_resize(e, ui),
|
||||
ui.size.Z, (e) => input_resize(e, ui),
|
||||
]);
|
||||
// on enter and blur
|
||||
space.event.onEnterKey([
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ class SliderControl {
|
|||
#layerHi = 0;
|
||||
#layerMax = 0;
|
||||
#ui;
|
||||
#slider;
|
||||
#tracker;
|
||||
#mobile;
|
||||
#sliderBar;
|
||||
|
|
@ -39,6 +40,7 @@ class SliderControl {
|
|||
}
|
||||
|
||||
this.#ui = ui;
|
||||
this.#slider = ui.slider;
|
||||
this.#tracker = tracker;
|
||||
this.#mobile = mobile;
|
||||
this.#sliderBar = mobile ? 80 : 30;
|
||||
|
|
@ -86,7 +88,7 @@ class SliderControl {
|
|||
*/
|
||||
setMax(max) {
|
||||
this.#layerMax = max;
|
||||
this.#ui.sliderMax.innerText = max;
|
||||
this.#slider.max.innerText = max;
|
||||
if (max < this.#layerHi) {
|
||||
this.#layerHi = max;
|
||||
this.showLabels();
|
||||
|
|
@ -100,7 +102,7 @@ class SliderControl {
|
|||
* @param {number} endPercent - End position (0-1)
|
||||
*/
|
||||
updatePosition(startPercent, endPercent) {
|
||||
const width = this.#ui.sliderRange.clientWidth;
|
||||
const width = this.#slider.range.clientWidth;
|
||||
const maxval = width - this.#sliderBar2;
|
||||
const start = Math.max(0, Math.min(1, startPercent));
|
||||
const end = Math.max(start, Math.min(1, endPercent));
|
||||
|
|
@ -109,9 +111,9 @@ class SliderControl {
|
|||
const midval = ((end - start) * maxval) + this.#sliderBar;
|
||||
const hival = maxval - end * maxval;
|
||||
|
||||
this.#ui.sliderHold.style.marginLeft = `${lowval}px`;
|
||||
this.#ui.sliderMid.style.width = `${midval}px`;
|
||||
this.#ui.sliderHold.style.marginRight = `${hival}px`;
|
||||
this.#slider.hold.style.marginLeft = `${lowval}px`;
|
||||
this.#slider.mid.style.width = `${midval}px`;
|
||||
this.#slider.hold.style.marginRight = `${hival}px`;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -119,10 +121,10 @@ class SliderControl {
|
|||
*/
|
||||
showLabels() {
|
||||
const digits = this.#layerMax.toString().length;
|
||||
this.#ui.sliderZero.style.width = `${digits}em`;
|
||||
this.#ui.sliderMax.style.width = `${digits}em`;
|
||||
this.#ui.sliderZero.innerText = this.#layerLo;
|
||||
this.#ui.sliderMax.innerText = this.#layerHi;
|
||||
this.#slider.min.style.width = `${digits}em`;
|
||||
this.#slider.max.style.width = `${digits}em`;
|
||||
this.#slider.min.innerText = this.#layerLo;
|
||||
this.#slider.max.innerText = this.#layerHi;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -130,7 +132,7 @@ class SliderControl {
|
|||
*/
|
||||
show() {
|
||||
this.#ui.layers.style.display = 'flex';
|
||||
this.#ui.slider.style.display = 'flex';
|
||||
this.#slider.div.style.display = 'flex';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -138,20 +140,20 @@ class SliderControl {
|
|||
*/
|
||||
hide() {
|
||||
this.#ui.layers.style.display = 'none';
|
||||
this.#ui.slider.style.display = 'none';
|
||||
this.#slider.div.style.display = 'none';
|
||||
}
|
||||
|
||||
#setupUI() {
|
||||
if (this.#mobile) {
|
||||
this.#ui.slider.classList.add('slider-mobile');
|
||||
this.#ui.sliderLo.classList.add('slider-mobile');
|
||||
this.#ui.sliderHi.classList.add('slider-mobile');
|
||||
this.#slider.div.classList.add('slider-mobile');
|
||||
this.#slider.lo.classList.add('slider-mobile');
|
||||
this.#slider.hi.classList.add('slider-mobile');
|
||||
}
|
||||
}
|
||||
|
||||
#bindEvents() {
|
||||
// Min/Max buttons
|
||||
this.#ui.sliderMin.onclick = () => {
|
||||
this.#slider.min.onclick = () => {
|
||||
this.#layerLo = 0;
|
||||
this.#layerHi = 0;
|
||||
this.showLabels();
|
||||
|
|
@ -159,7 +161,7 @@ class SliderControl {
|
|||
this.#notifyChange();
|
||||
};
|
||||
|
||||
this.#ui.sliderMax.onclick = () => {
|
||||
this.#slider.max.onclick = () => {
|
||||
this.#layerLo = this.#layerMax;
|
||||
this.#layerHi = this.#layerMax;
|
||||
this.showLabels();
|
||||
|
|
@ -168,24 +170,24 @@ class SliderControl {
|
|||
};
|
||||
|
||||
// Mouse hover for labels
|
||||
this.#ui.slider.onmouseover = () => {
|
||||
this.#slider.div.onmouseover = () => {
|
||||
this.showLabels();
|
||||
};
|
||||
|
||||
this.#ui.slider.onmouseleave = (ev) => {
|
||||
this.#slider.div.onmouseleave = (ev) => {
|
||||
if (!ev.buttons) {
|
||||
this.hideLabels();
|
||||
}
|
||||
};
|
||||
|
||||
// Drag handlers for the three slider sections
|
||||
this.#bindDrag(this.#ui.sliderLo, this.#handleLoDrag.bind(this));
|
||||
this.#bindDrag(this.#ui.sliderMid, this.#handleMidDrag.bind(this));
|
||||
this.#bindDrag(this.#ui.sliderHi, this.#handleHiDrag.bind(this));
|
||||
this.#bindDrag(this.#slider.lo, this.#handleLoDrag.bind(this));
|
||||
this.#bindDrag(this.#slider.mid, this.#handleMidDrag.bind(this));
|
||||
this.#bindDrag(this.#slider.hi, this.#handleHiDrag.bind(this));
|
||||
}
|
||||
|
||||
#bindDrag(el, deltaHandler) {
|
||||
const slider = this.#ui.sliderRange;
|
||||
const slider = this.#slider.range;
|
||||
|
||||
el.ontouchstart = el.onmousedown = (ev) => {
|
||||
this.#tracker.style.display = 'block';
|
||||
|
|
@ -195,9 +197,9 @@ class SliderControl {
|
|||
this.#drag.width = slider.clientWidth;
|
||||
this.#drag.maxval = this.#drag.width - this.#sliderBar2;
|
||||
this.#drag.start = obj.screenX;
|
||||
this.#drag.loat = this.#drag.low = this.#pxToInt(this.#ui.sliderHold.style.marginLeft);
|
||||
this.#drag.mdat = this.#drag.mid = this.#ui.sliderMid.clientWidth;
|
||||
this.#drag.hiat = this.#pxToInt(this.#ui.sliderHold.style.marginRight);
|
||||
this.#drag.loat = this.#drag.low = this.#pxToInt(this.#slider.hold.style.marginLeft);
|
||||
this.#drag.mdat = this.#drag.mid = this.#slider.mid.clientWidth;
|
||||
this.#drag.hiat = this.#pxToInt(this.#slider.hold.style.marginRight);
|
||||
this.#drag.mdmax = this.#drag.width - this.#sliderBar - this.#drag.loat;
|
||||
this.#drag.himax = this.#drag.width - this.#sliderBar - this.#drag.mdat;
|
||||
|
||||
|
|
@ -233,8 +235,8 @@ class SliderControl {
|
|||
return;
|
||||
}
|
||||
|
||||
this.#ui.sliderHold.style.marginLeft = `${lowval}px`;
|
||||
this.#ui.sliderMid.style.width = `${midval}px`;
|
||||
this.#slider.hold.style.marginLeft = `${lowval}px`;
|
||||
this.#slider.mid.style.width = `${midval}px`;
|
||||
this.#drag.low = lowval;
|
||||
this.#drag.mid = midval;
|
||||
this.#updateFromDrag();
|
||||
|
|
@ -248,8 +250,8 @@ class SliderControl {
|
|||
return;
|
||||
}
|
||||
|
||||
this.#ui.sliderHold.style.marginLeft = `${loval}px`;
|
||||
this.#ui.sliderHold.style.marginRight = `${hival}px`;
|
||||
this.#slider.hold.style.marginLeft = `${loval}px`;
|
||||
this.#slider.hold.style.marginRight = `${hival}px`;
|
||||
this.#drag.low = loval;
|
||||
this.#updateFromDrag();
|
||||
}
|
||||
|
|
@ -262,8 +264,8 @@ class SliderControl {
|
|||
return;
|
||||
}
|
||||
|
||||
this.#ui.sliderMid.style.width = `${midval}px`;
|
||||
this.#ui.sliderHold.style.marginRight = `${hival}px`;
|
||||
this.#slider.mid.style.width = `${midval}px`;
|
||||
this.#slider.hold.style.marginRight = `${hival}px`;
|
||||
this.#drag.mid = midval;
|
||||
this.#updateFromDrag();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,29 +105,37 @@ function cleanup() {
|
|||
|
||||
api.event.on('key.esc', endIt);
|
||||
|
||||
api.event.on('tool.camera.focus', (fn) => {
|
||||
function startFocus(fn) {
|
||||
opName = 'camera focus';
|
||||
onDone = fn;
|
||||
startIt();
|
||||
});
|
||||
}
|
||||
|
||||
api.event.on('tool.mesh.face-up', () => {
|
||||
function startFaceUp() {
|
||||
opName = 'face select';
|
||||
onDone = onFaceUpSelect;
|
||||
startIt();
|
||||
});
|
||||
}
|
||||
|
||||
api.event.on('tool.mesh.lay-flat', () => {
|
||||
function startLayFlat() {
|
||||
opName = 'lay flat';
|
||||
onDone = onLayFlatSelect;
|
||||
startIt();
|
||||
});
|
||||
}
|
||||
|
||||
api.event.on('tool.mesh.lefty', () => {
|
||||
function startLeftAlign() {
|
||||
opName = 'align y axis';
|
||||
onDone = onLeftySelect;
|
||||
startIt();
|
||||
});
|
||||
}
|
||||
|
||||
api.event.on('tool.camera.focus', startFocus);
|
||||
|
||||
api.event.on('tool.mesh.face-up', startFaceUp);
|
||||
|
||||
api.event.on('tool.mesh.lay-flat', startLayFlat);
|
||||
|
||||
api.event.on('tool.mesh.lefty', startLeftAlign);
|
||||
|
||||
function scale() {
|
||||
let cam = space.internals().camera;
|
||||
|
|
@ -187,4 +195,16 @@ api.event.on('mouse.hover.up', (ev) => {
|
|||
});
|
||||
|
||||
|
||||
export { onLayFlatSelect, onFaceUpSelect, startIt, endIt, cleanup, scale, onDone };
|
||||
export {
|
||||
cleanup,
|
||||
endIt,
|
||||
onDone,
|
||||
onFaceUpSelect,
|
||||
onLayFlatSelect,
|
||||
scale,
|
||||
startFaceUp,
|
||||
startFocus,
|
||||
startIt,
|
||||
startLeftAlign,
|
||||
startLayFlat,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import '../kiri/core/lang-en.js';
|
|||
import { api } from '../kiri/app/api.js';
|
||||
import { init_lang } from '../kiri/app/init/lang.js';
|
||||
import { init_input } from '../kiri/app/init/input.js';
|
||||
import { init_sync } from '../kiri/app/init/syn.js';
|
||||
import { init_sync } from '../kiri/app/init/sync.js';
|
||||
|
||||
let traceload = location.search.indexOf('traceload') > 0;
|
||||
let load = [];
|
||||
|
|
|
|||
|
|
@ -1335,7 +1335,7 @@ let Space = {
|
|||
}
|
||||
viewControl.update();
|
||||
|
||||
if (then) then();
|
||||
if (typeof(then) === 'function') then();
|
||||
},
|
||||
setCtrl: (name) => {
|
||||
if (name === 'onshape') {
|
||||
|
|
|
|||
Loading…
Reference in a new issue