ui cleanup. stub in animate button when stock set in cam mode

This commit is contained in:
Stewart Allen 2020-11-23 21:55:46 -05:00
commit de2ad2a02d
6 changed files with 86 additions and 76 deletions

View file

@ -1,6 +1,6 @@
{ {
"name": "grid-apps", "name": "grid-apps",
"version": "2.4.2.D", "version": "2.4.3.D",
"description": "grid.space 3d slice & modeling tools", "description": "grid.space 3d slice & modeling tools",
"author": "Stewart Allen <sa@grid.space>", "author": "Stewart Allen <sa@grid.space>",
"license": "MIT", "license": "MIT",

View file

@ -6,7 +6,7 @@
if (!self.kiri) { if (!self.kiri) {
self.kiri = { self.kiri = {
beta: 2402, beta: 2403,
driver: {}, // driver modules driver: {}, // driver modules
loader: [] // module loading: array of functions loader: [] // module loading: array of functions
}; };

View file

@ -40,7 +40,6 @@
// clear labels // clear labels
UC.setGroup(labels); UC.setGroup(labels);
labels.innerHTML = ''; labels.innerHTML = '';
} }
function getStack(name) { function getStack(name) {
@ -65,6 +64,9 @@
}, },
clear: function() { clear: function() {
view.remove(stack.view); view.remove(stack.view);
},
button: function(label, action) {
UC.newRow([ UC.newButton(label, action) ]);
} }
}; };
return stack; return stack;

View file

@ -8,10 +8,11 @@
let SELF = self, let SELF = self,
KIRI = self.kiri, KIRI = self.kiri,
DOC = SELF.document,
inputAction = null,
lastGroup = null, lastGroup = null,
lastDiv = null, lastDiv = null,
addTo = null, addTo = null,
inputAction = null,
groups = {}, groups = {},
groupShow = {}, groupShow = {},
groupSticky = false, groupSticky = false,
@ -23,49 +24,52 @@
letMode = null, letMode = null,
letExpert = false, letExpert = false,
letHoverPop = true, letHoverPop = true,
DOC = SELF.document,
state = {},
prefix = "tab",
NOMODE = "nomode",
exitimer = undefined, exitimer = undefined,
units = 1; NOMODE = "nomode",
prefix = "tab",
state = {},
units = 1,
lastBtn = null,
lastTxt = null,
lastPop = null,
savePop = null;
SELF.$ = (SELF.$ || function (id) { return DOC.getElementById(id) } ); SELF.$ = (SELF.$ || function (id) { return DOC.getElementById(id) } );
KIRI.ui = { KIRI.ui = {
prefix: function(pre) { prefix = pre; return kiri.ui }, prefix: function(pre) { prefix = pre; return kiri.ui },
inputAction: function(fn) { inputAction = fn; return kiri.ui }, inputAction: function(fn) { inputAction = fn; return kiri.ui },
refresh: refresh,
setMode: setMode,
setExpert: setExpert,
setHoverPop: setHoverPop,
bound: bound,
toInt: toInt,
toFloat: toFloat,
hidePop: hidePop,
isPopped: isPopped,
newText: newTextArea,
newGCode: newGCode,
newLabel: newLabel,
newRange: newRange,
newInput: newInputField,
newButton: newButton,
newBoolean: newBooleanField,
newSelect: newSelect,
newTable: newTables,
newTableRow: newTableRow,
newRow: newRow,
newBlank: newBlank,
newGroup: newGroup,
setGroup: setGroup,
setUnits: setUnits,
addUnits: addUnits,
hidePoppers: hidePoppers,
confirm: confirm,
prompt: prompt,
alert: alert,
checkpoint, checkpoint,
restore restore,
refresh,
setMode,
setExpert,
setHoverPop,
hidePoppers,
bound,
toInt,
toFloat,
hidePop,
isPopped,
newBoolean,
newButton,
newBlank,
newGCode,
newGroup,
newInput,
newLabel,
newRange,
newRow,
newSelect,
newTable,
newTableRow,
newText,
setGroup,
addUnits,
setUnits,
confirm,
prompt,
alert
}; };
function alert(message) { function alert(message) {
@ -282,6 +286,13 @@
return row; return row;
} }
function addCollapsableElement(parent) {
let row = newDiv();
if (parent) parent.appendChild(row);
if (lastGroup) lastGroup.push(row);
return row;
}
function hidePoppers() { function hidePoppers() {
showGroup(undefined); showGroup(undefined);
} }
@ -408,11 +419,6 @@
return div; return div;
} }
let lastBtn = null;
let lastTxt = null;
let lastPop = null;
let savePop = null;
function hidePop() { function hidePop() {
if (lastPop) { if (lastPop) {
lastPop.style.display = "none"; lastPop.style.display = "none";
@ -490,7 +496,7 @@
return txt; return txt;
} }
function newTextArea(label, options) { function newText(label, options) {
let opt = options || {}, let opt = options || {},
inline = opt.row, inline = opt.row,
row = inline ? lastDiv : newDiv(options), row = inline ? lastDiv : newDiv(options),
@ -564,7 +570,7 @@
return txt; return txt;
} }
function newInputField(label, options) { function newInput(label, options) {
let opt = options || {}, let opt = options || {},
row = newDiv(opt), row = newDiv(opt),
hide = opt && opt.hide, hide = opt && opt.hide,
@ -714,7 +720,7 @@
return ip; return ip;
} }
function newBooleanField(label, action, options) { function newBoolean(label, action, options) {
let row = newDiv(options), let row = newDiv(options),
ip = DOC.createElement('input'), ip = DOC.createElement('input'),
hide = options && options.hide; hide = options && options.hide;
@ -757,6 +763,7 @@
return row; return row;
} }
// unlike other elements, does not auto-add to a row
function newButton(label, action, options) { function newButton(label, action, options) {
let opt = options || {}, let opt = options || {},
b = DOC.createElement('button'); b = DOC.createElement('button');
@ -786,27 +793,6 @@
return b; return b;
} }
function newTableRow(arrayOfArrays, options) {
return newRow(newTables(arrayOfArrays), options);
}
function newTables(arrayOfArrays) {
let array = [];
for (let i=0; i<arrayOfArrays.length; i++) {
array.push(newRowTable(arrayOfArrays[i]));
}
return array;
}
function newRowTable(array) {
let div = newDiv();
div.setAttribute("class", "table-row");
array.forEach(function(c) {
div.appendChild(c);
});
return div;
}
function newRow(children, options) { function newRow(children, options) {
let row = addCollapsableElement((options && options.noadd) ? null : addTo); let row = addCollapsableElement((options && options.noadd) ? null : addTo);
if (children) children.forEach(function (c) { row.appendChild(c) }); if (children) children.forEach(function (c) { row.appendChild(c) });
@ -819,11 +805,25 @@
return row; return row;
} }
function addCollapsableElement(parent) { function newRowTable(array) {
let row = newDiv(); let div = newDiv();
if (parent) parent.appendChild(row); div.setAttribute("class", "table-row");
if (lastGroup) lastGroup.push(row); array.forEach(function(c) {
return row; div.appendChild(c);
});
return div;
}
function newTableRow(arrayOfArrays, options) {
return newRow(newTable(arrayOfArrays), options);
}
function newTable(arrayOfArrays) {
let array = [];
for (let i=0; i<arrayOfArrays.length; i++) {
array.push(newRowTable(arrayOfArrays[i]));
}
return array;
} }
})(); })();

View file

@ -3,7 +3,7 @@
let terms = { let terms = {
COPYRIGHT: "Copyright (C) Stewart Allen <sa@grid.space> - All Rights Reserved", COPYRIGHT: "Copyright (C) Stewart Allen <sa@grid.space> - All Rights Reserved",
LICENSE: "See the license.md file included with the source distribution", LICENSE: "See the license.md file included with the source distribution",
VERSION: "2.4.D2" VERSION: "2.4.D3"
}; };
if (typeof(module) === 'object') { if (typeof(module) === 'object') {

View file

@ -13,10 +13,11 @@
isArrange, isArrange,
isCamMode, isCamMode,
camStock, camStock,
API, SPACE, MODES, VIEWS, UI, UC; API, SPACE, STACKS, MODES, VIEWS, UI, UC;
CAM.init = function(kiri, api) { CAM.init = function(kiri, api) {
// console.log({kiri,api}) // console.log({kiri,api})
STACKS = api.const.STACKS;
SPACE = api.const.SPACE; SPACE = api.const.SPACE;
MODES = api.const.MODES; MODES = api.const.MODES;
VIEWS = api.const.VIEWS; VIEWS = api.const.VIEWS;
@ -64,12 +65,19 @@
"selection.scale", "selection.scale",
"selection.rotate" "selection.rotate"
], updateStock); ], updateStock);
api.event.on("preview.end", () => {
if (camStock) STACKS.getStack("bounds").button("animate", animate);
});
}; };
function updateStock(args, event) { function animate() {
const SPACE = API.const.SPACE; API.view.set(VIEWS.ARRANGE);
const STACKS = API.const.STACKS; API.widgets.opacity(0.75);
// console.log("animate", API.conf.get().stock);
}
function updateStock(args, event) {
STACKS.remove('bounds'); STACKS.remove('bounds');
if (isCamMode && isArrange) { if (isCamMode && isArrange) {
STACKS.clear(); STACKS.clear();