ui cleanup. stub in animate button when stock set in cam mode
This commit is contained in:
parent
bc7541a8dc
commit
de2ad2a02d
6 changed files with 86 additions and 76 deletions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "grid-apps",
|
||||
"version": "2.4.2.D",
|
||||
"version": "2.4.3.D",
|
||||
"description": "grid.space 3d slice & modeling tools",
|
||||
"author": "Stewart Allen <sa@grid.space>",
|
||||
"license": "MIT",
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
if (!self.kiri) {
|
||||
self.kiri = {
|
||||
beta: 2402,
|
||||
beta: 2403,
|
||||
driver: {}, // driver modules
|
||||
loader: [] // module loading: array of functions
|
||||
};
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@
|
|||
// clear labels
|
||||
UC.setGroup(labels);
|
||||
labels.innerHTML = '';
|
||||
|
||||
}
|
||||
|
||||
function getStack(name) {
|
||||
|
|
@ -65,6 +64,9 @@
|
|||
},
|
||||
clear: function() {
|
||||
view.remove(stack.view);
|
||||
},
|
||||
button: function(label, action) {
|
||||
UC.newRow([ UC.newButton(label, action) ]);
|
||||
}
|
||||
};
|
||||
return stack;
|
||||
|
|
|
|||
140
src/kiri/ui.js
140
src/kiri/ui.js
|
|
@ -8,10 +8,11 @@
|
|||
|
||||
let SELF = self,
|
||||
KIRI = self.kiri,
|
||||
DOC = SELF.document,
|
||||
inputAction = null,
|
||||
lastGroup = null,
|
||||
lastDiv = null,
|
||||
addTo = null,
|
||||
inputAction = null,
|
||||
groups = {},
|
||||
groupShow = {},
|
||||
groupSticky = false,
|
||||
|
|
@ -23,49 +24,52 @@
|
|||
letMode = null,
|
||||
letExpert = false,
|
||||
letHoverPop = true,
|
||||
DOC = SELF.document,
|
||||
state = {},
|
||||
prefix = "tab",
|
||||
NOMODE = "nomode",
|
||||
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) } );
|
||||
|
||||
KIRI.ui = {
|
||||
prefix: function(pre) { prefix = pre; 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,
|
||||
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) {
|
||||
|
|
@ -282,6 +286,13 @@
|
|||
return row;
|
||||
}
|
||||
|
||||
function addCollapsableElement(parent) {
|
||||
let row = newDiv();
|
||||
if (parent) parent.appendChild(row);
|
||||
if (lastGroup) lastGroup.push(row);
|
||||
return row;
|
||||
}
|
||||
|
||||
function hidePoppers() {
|
||||
showGroup(undefined);
|
||||
}
|
||||
|
|
@ -408,11 +419,6 @@
|
|||
return div;
|
||||
}
|
||||
|
||||
let lastBtn = null;
|
||||
let lastTxt = null;
|
||||
let lastPop = null;
|
||||
let savePop = null;
|
||||
|
||||
function hidePop() {
|
||||
if (lastPop) {
|
||||
lastPop.style.display = "none";
|
||||
|
|
@ -490,7 +496,7 @@
|
|||
return txt;
|
||||
}
|
||||
|
||||
function newTextArea(label, options) {
|
||||
function newText(label, options) {
|
||||
let opt = options || {},
|
||||
inline = opt.row,
|
||||
row = inline ? lastDiv : newDiv(options),
|
||||
|
|
@ -564,7 +570,7 @@
|
|||
return txt;
|
||||
}
|
||||
|
||||
function newInputField(label, options) {
|
||||
function newInput(label, options) {
|
||||
let opt = options || {},
|
||||
row = newDiv(opt),
|
||||
hide = opt && opt.hide,
|
||||
|
|
@ -714,7 +720,7 @@
|
|||
return ip;
|
||||
}
|
||||
|
||||
function newBooleanField(label, action, options) {
|
||||
function newBoolean(label, action, options) {
|
||||
let row = newDiv(options),
|
||||
ip = DOC.createElement('input'),
|
||||
hide = options && options.hide;
|
||||
|
|
@ -757,6 +763,7 @@
|
|||
return row;
|
||||
}
|
||||
|
||||
// unlike other elements, does not auto-add to a row
|
||||
function newButton(label, action, options) {
|
||||
let opt = options || {},
|
||||
b = DOC.createElement('button');
|
||||
|
|
@ -786,27 +793,6 @@
|
|||
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) {
|
||||
let row = addCollapsableElement((options && options.noadd) ? null : addTo);
|
||||
if (children) children.forEach(function (c) { row.appendChild(c) });
|
||||
|
|
@ -819,11 +805,25 @@
|
|||
return row;
|
||||
}
|
||||
|
||||
function addCollapsableElement(parent) {
|
||||
let row = newDiv();
|
||||
if (parent) parent.appendChild(row);
|
||||
if (lastGroup) lastGroup.push(row);
|
||||
return row;
|
||||
function newRowTable(array) {
|
||||
let div = newDiv();
|
||||
div.setAttribute("class", "table-row");
|
||||
array.forEach(function(c) {
|
||||
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;
|
||||
}
|
||||
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
let terms = {
|
||||
COPYRIGHT: "Copyright (C) Stewart Allen <sa@grid.space> - All Rights Reserved",
|
||||
LICENSE: "See the license.md file included with the source distribution",
|
||||
VERSION: "2.4.D2"
|
||||
VERSION: "2.4.D3"
|
||||
};
|
||||
|
||||
if (typeof(module) === 'object') {
|
||||
|
|
|
|||
|
|
@ -13,10 +13,11 @@
|
|||
isArrange,
|
||||
isCamMode,
|
||||
camStock,
|
||||
API, SPACE, MODES, VIEWS, UI, UC;
|
||||
API, SPACE, STACKS, MODES, VIEWS, UI, UC;
|
||||
|
||||
CAM.init = function(kiri, api) {
|
||||
// console.log({kiri,api})
|
||||
STACKS = api.const.STACKS;
|
||||
SPACE = api.const.SPACE;
|
||||
MODES = api.const.MODES;
|
||||
VIEWS = api.const.VIEWS;
|
||||
|
|
@ -64,12 +65,19 @@
|
|||
"selection.scale",
|
||||
"selection.rotate"
|
||||
], updateStock);
|
||||
|
||||
api.event.on("preview.end", () => {
|
||||
if (camStock) STACKS.getStack("bounds").button("animate", animate);
|
||||
});
|
||||
};
|
||||
|
||||
function updateStock(args, event) {
|
||||
const SPACE = API.const.SPACE;
|
||||
const STACKS = API.const.STACKS;
|
||||
function animate() {
|
||||
API.view.set(VIEWS.ARRANGE);
|
||||
API.widgets.opacity(0.75);
|
||||
// console.log("animate", API.conf.get().stock);
|
||||
}
|
||||
|
||||
function updateStock(args, event) {
|
||||
STACKS.remove('bounds');
|
||||
if (isCamMode && isArrange) {
|
||||
STACKS.clear();
|
||||
|
|
|
|||
Loading…
Reference in a new issue