add timeline op for editing indexed timelines

This commit is contained in:
Stewart Allen 2022-10-30 17:04:16 -04:00
commit 0a5e578c43
3 changed files with 40 additions and 18 deletions

View file

@ -65,6 +65,9 @@ CAM.init = function(kiri, api) {
} }
function setAnimationStyle(settings) { function setAnimationStyle(settings) {
if (!isCamMode) {
return;
}
isIndexed = settings.process.camStockIndexed; isIndexed = settings.process.camStockIndexed;
animVer = isIndexed ? 1 : 0; animVer = isIndexed ? 1 : 0;
updateStock(); updateStock();
@ -74,6 +77,17 @@ CAM.init = function(kiri, api) {
} }
api.platform.update_top_z(); api.platform.update_top_z();
$('cam-index').style.display = isIndexed ? '' : 'none'; $('cam-index').style.display = isIndexed ? '' : 'none';
// add or remove clock op depending on indexing
const cp = current.process;
if (!cp.ops) {
return;
}
const clockOp = cp.ops.filter(op => op.type === '|')[0];
if (isIndexed && !clockOp) {
func.opAdd(popOp['|'].new());
} else if (!isIndexed && clockOp) {
func.opDel(clockOp);
}
} }
// wire up animate button in ui // wire up animate button in ui
@ -356,7 +370,9 @@ CAM.init = function(kiri, api) {
api.event.on("cam.op.render", func.opRender = () => { api.event.on("cam.op.render", func.opRender = () => {
// $('camops').style.display = isCamMode && isArrange ? 'flex' : ''; // $('camops').style.display = isCamMode && isArrange ? 'flex' : '';
let oplist = current.process.ops; let oplist = current.process.ops;
if (!(isCamMode && oplist)) return; if (!(isCamMode && oplist)) {
return;
}
oplist = oplist.filter(rec => !Array.isArray(rec)); oplist = oplist.filter(rec => !Array.isArray(rec));
let mark = Date.now(); let mark = Date.now();
let html = []; let html = [];
@ -364,9 +380,12 @@ CAM.init = function(kiri, api) {
let bind = {}; let bind = {};
let scale = API.view.unit_scale(); let scale = API.view.unit_scale();
oplist.forEach((rec,i) => { oplist.forEach((rec,i) => {
let clock = rec.clock = rec.type === '|';
let label = clock ? '<i class="fa-regular fa-clock"></i>' : rec.type;
html.appendAll([ html.appendAll([
`<div id="${mark+i}" class="draggable">`, `<div id="${mark+i}" class="draggable">`,
`<label class="label">${rec.type}</label>`, `<label class="label">${label}</label>`,
clock ? '' :
`<label id="${mark+i}-x" class="del"><i class="fa-regular fa-circle-xmark"></i></label>`, `<label id="${mark+i}-x" class="del"><i class="fa-regular fa-circle-xmark"></i></label>`,
`</div>` `</div>`
]); ]);
@ -378,6 +397,7 @@ CAM.init = function(kiri, api) {
let unpop = null; let unpop = null;
// drag and drop re-ordering // drag and drop re-ordering
for (let [id, rec] of Object.entries(bind)) { for (let [id, rec] of Object.entries(bind)) {
if (!rec.clock)
$(`${id}-x`).onmousedown = (ev) => { $(`${id}-x`).onmousedown = (ev) => {
ev.stopPropagation(); ev.stopPropagation();
ev.preventDefault(); ev.preventDefault();
@ -416,8 +436,10 @@ CAM.init = function(kiri, api) {
popped = true; popped = true;
poprec.use(rec); poprec.use(rec);
hoveredOp = el; hoveredOp = el;
el.appendChild(poprec.div); if (!rec.clock) {
poprec.addNote(); el.appendChild(poprec.div);
poprec.addNote();
}
// option click event appears latent // option click event appears latent
// and overides the sticky settings // and overides the sticky settings
setTimeout(() => { setTimeout(() => {
@ -1372,6 +1394,8 @@ CAM.init = function(kiri, api) {
}).inputs = { }).inputs = {
disable: UC.newRow([ UC.newButton(LANG.disable, editDisable) ], {class:"ext-buttons f-row"}), disable: UC.newRow([ UC.newButton(LANG.disable, editDisable) ], {class:"ext-buttons f-row"}),
}; };
createPopOp('|', {}).inputs = {};
}; };
function createPopOp(type, map) { function createPopOp(type, map) {

View file

@ -148,6 +148,9 @@ CAM.slice = function(settings, widget, onupdate, ondone) {
sliceAll.appendAll(slices); sliceAll.appendAll(slices);
if (axisIndex !== undefined) { if (axisIndex !== undefined) {
console.log({post_axis_index: slices}); console.log({post_axis_index: slices});
for (let slice of slices) {
slice.axisIndex = axisIndex;
}
} }
} }

View file

@ -256,20 +256,15 @@ gapp.register("kiri.init", [], (root, exports) => {
return el; return el;
} }
// function onLayerToggle() { function onBooleanClick(el) {
// api.conf.update(); uc.refresh();
// api.show.slices();
// }
function onBooleanClick() {
// prevent hiding elements in device editor on clicks
// if (!api.modal.visible()) {
uc.refresh();
// }
api.conf.update(); api.conf.update();
DOC.activeElement.blur(); DOC.activeElement.blur();
api.event.emit("boolean.click"); api.event.emit("boolean.click");
updateLaserState(); updateLaserState();
if (el === ui.camStockIndexed) {
api.space.set_focus();
}
} }
function onButtonClick(ev) { function onButtonClick(ev) {
@ -2780,10 +2775,10 @@ gapp.register("kiri.init", [], (root, exports) => {
$('view-top').onclick = space.view.top; $('view-top').onclick = space.view.top;
$('view-home').onclick = space.view.home; $('view-home').onclick = space.view.home;
$('view-clear').onclick = api.platform.clear; $('view-clear').onclick = api.platform.clear;
$('mode-fdm').onclick = () => { api.mode.set('FDM') }; $('mode-fdm').onclick = () => { api.mode.set('FDM'); api.space.set_focus() };
$('mode-sla').onclick = () => { api.mode.set('SLA') }; $('mode-sla').onclick = () => { api.mode.set('SLA'); api.space.set_focus() };
$('mode-cam').onclick = () => { api.mode.set('CAM') }; $('mode-cam').onclick = () => { api.mode.set('CAM'); api.space.set_focus() };
$('mode-laser').onclick = () => { api.mode.set('LASER') }; $('mode-laser').onclick = () => { api.mode.set('LASER'); api.space.set_focus() };
$('unrotate').onclick = () => { $('unrotate').onclick = () => {
api.widgets.for(w => w.unrotate()); api.widgets.for(w => w.unrotate());
api.selection.update_info(); api.selection.update_info();