allow z top/bottom visual select in left menu. double select cancels
This commit is contained in:
parent
c889491aeb
commit
96577c4b7b
3 changed files with 42 additions and 9 deletions
|
|
@ -10,24 +10,32 @@ let ondone;
|
|||
let lastY;
|
||||
|
||||
export function zPlaneStart(which, onselect) {
|
||||
alert = api.show.alert("[esc] cancels z plane selection");
|
||||
plane = which;
|
||||
ondone = onselect;
|
||||
hoverStart(onHover, onHoverUp);
|
||||
alert = api.show.alert("[esc] cancels z plane selection", 1000);
|
||||
}
|
||||
|
||||
export function zPlaneDone() {
|
||||
api.hide.alert(alert);
|
||||
updateStock();
|
||||
alert = undefined;
|
||||
}
|
||||
|
||||
export function zPlaneSelecting() {
|
||||
return alert ? true : false;
|
||||
}
|
||||
|
||||
function onHover(data) {
|
||||
const { int, type, point } = data;
|
||||
const { int, point } = data;
|
||||
if (!int) return;
|
||||
if (plane === 'top') showZTop(lastY = point.y); else
|
||||
if (plane === 'bottom') showZBottom(lastY = point.y);
|
||||
}
|
||||
|
||||
function onHoverUp(int) {
|
||||
ondone(lastY);
|
||||
clearPops();
|
||||
if (int) {
|
||||
ondone(lastY);
|
||||
clearPops();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,30 @@ function zAnchorSave() {
|
|||
api.platform.update_top_z();
|
||||
}
|
||||
|
||||
const bottom = true;
|
||||
const top = true;
|
||||
|
||||
function selector(type, { input, event, opt }) {
|
||||
let which = opt?.top ? 'top' : opt?.bottom ? 'bottom' : 'unknown';
|
||||
let value = parseFloat(input.value);
|
||||
switch (type) {
|
||||
case 'click':
|
||||
api.event.emit('cam.zplane.select', { which, onselect(value) {
|
||||
input.focus();
|
||||
input.value = value;
|
||||
input.blur();
|
||||
} } );
|
||||
break;
|
||||
case 'enter':
|
||||
api.event.emit('cam.zplane.show', { which, value });
|
||||
break;
|
||||
case 'leave':
|
||||
api.event.emit('cam.zplane.hide', { which });
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export function menu() {
|
||||
let anim = ui.anim = {};
|
||||
|
||||
|
|
@ -121,8 +145,8 @@ export function menu() {
|
|||
_____: newGroup(LANG.cc_menu, $('cam-limits'), { modes:CAM, driven, separator }),
|
||||
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}),
|
||||
camZTop: newInput(LANG.ou_ztop_s, {title:LANG.ou_ztop_l, convert:toFloat, units, trigger}),
|
||||
camZBottom: newInput(LANG.ou_zbot_s, {title:LANG.ou_zbot_l, convert:toFloat, units, trigger}),
|
||||
camZTop: newInput(LANG.ou_ztop_s, {title:LANG.ou_ztop_l, convert:toFloat, units, trigger, selector, top }),
|
||||
camZBottom: newInput(LANG.ou_zbot_s, {title:LANG.ou_zbot_l, convert:toFloat, units, trigger, selector, bottom }),
|
||||
camZClearance: newInput(LANG.ou_zclr_s, {title:LANG.ou_zclr_l, convert:toFloat, bound:bound(0.01,100), units }),
|
||||
separator: newBlank({ class:"set-sep", driven }),
|
||||
camFastFeed: newInput(LANG.cc_rapd_s, {title:LANG.cc_rapd_l, convert:toFloat, units}),
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import { surfaceOn, surfaceDone } from './cl-surface.js';
|
|||
import { tabAdd, tabDone, tabClear, restoreTabs, rotateTabs, updateTabs, clearTabs, mirrorTabs } from './cl-tab.js';
|
||||
import { traceOn, traceDone, unselectTraces } from './cl-trace.js';
|
||||
import { Widget, newWidget } from '../../app/widget.js';
|
||||
import { zPlaneStart, zPlaneDone } from './cl-zplane.js';
|
||||
import { zPlaneStart, zPlaneDone, zPlaneSelecting } from './cl-zplane.js';
|
||||
|
||||
const { BufferGeometryUtils } = THREE;
|
||||
|
||||
|
|
@ -582,6 +582,9 @@ export function zPlaneHide({ which }) {
|
|||
}
|
||||
|
||||
export function zPlaneSelect({ which, onselect }) {
|
||||
if (zPlaneSelecting()) {
|
||||
return zPlaneDone();
|
||||
}
|
||||
clearPops();
|
||||
zPlaneStart(which, value => {
|
||||
onselect(parseFloat(value));
|
||||
|
|
@ -805,8 +808,6 @@ export function init() {
|
|||
};
|
||||
|
||||
$('op-add-list').onclick = (ev) => {
|
||||
let settings = api.conf.get();
|
||||
let { process, device } = settings;
|
||||
switch (ev.target.innerText.toLowerCase()) {
|
||||
case "index": return opAddIndex();
|
||||
case "laser on": return opAddLaserOn();
|
||||
|
|
|
|||
Loading…
Reference in a new issue