Skip to content

Commit

Permalink
feat(imgui): add IMGUI.clear(), update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Aug 16, 2019
1 parent bded179 commit d10732d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
9 changes: 8 additions & 1 deletion packages/imgui/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@thi.ng/imgui",
"version": "0.0.1",
"description": "Customizable immediate mode GUI",
"description": "Immediate mode GUI with flexible state handling & data only shape output",
"module": "./index.js",
"main": "./lib/index.js",
"umd:main": "./lib/index.umd.js",
Expand Down Expand Up @@ -36,13 +36,20 @@
"@thi.ng/api": "^6.3.2",
"@thi.ng/checks": "^2.2.2",
"@thi.ng/geom": "^1.7.2",
"@thi.ng/geom-api": "^0.3.2",
"@thi.ng/geom-isec": "^0.3.4",
"@thi.ng/geom-tessellate": "^0.2.4",
"@thi.ng/math": "^1.4.2",
"@thi.ng/transducers": "5.4.2",
"@thi.ng/vectors": "^3.1.0"
},
"keywords": [
"canvas",
"components",
"ES6",
"GUI",
"IMGUI",
"immediate mode",
"typescript"
],
"publishConfig": {
Expand Down
15 changes: 11 additions & 4 deletions packages/imgui/src/gui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ export class IMGUI implements IToHiccup {
return stack[stack.length - 1];
}

/**
* Clears all shape layers and resets theme / disabled stacks.
*/
clear() {
this.layers[0].length = 0;
this.layers[1].length = 0;
this.themeStack.length = 1;
this.disabledStack.length = 1;
}

/**
* Sets mouse position and current mouse button flags (i.e.
* `MouseEvent.buttons`).
Expand Down Expand Up @@ -282,11 +292,8 @@ export class IMGUI implements IToHiccup {
begin(draw = true) {
this.hotID = "";
this.cursor = "default";
this.layers[0].length = 0;
this.layers[1].length = 0;
this.themeStack.length = 1;
this.disabledStack.length = 1;
this.draw = draw;
this.clear();
this.time = (Date.now() - this.t0) * 1e-3;
}

Expand Down

0 comments on commit d10732d

Please sign in to comment.