@thi.ng/imgui 2.2.59 → 2.2.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -1
- package/README.md +2 -4
- package/behaviors/button.d.ts +1 -1
- package/behaviors/slider.d.ts +1 -1
- package/behaviors/text.js +8 -8
- package/components/button.d.ts +1 -1
- package/components/button.js +5 -5
- package/components/dropdown.js +6 -6
- package/components/radial-menu.js +7 -6
- package/components/ring.js +7 -7
- package/package.json +14 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2024-
|
|
3
|
+
- **Last updated**: 2024-06-21T19:34:38Z
|
|
4
4
|
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file.
|
|
@@ -9,6 +9,13 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
|
|
|
9
9
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
10
|
and/or version bumps of transitive dependencies.
|
|
11
11
|
|
|
12
|
+
### [2.2.60](https://github.com/thi-ng/umbrella/tree/@thi.ng/imgui@2.2.60) (2024-06-21)
|
|
13
|
+
|
|
14
|
+
#### ♻️ Refactoring
|
|
15
|
+
|
|
16
|
+
- update geom deps, update imports ([afd0b8b](https://github.com/thi-ng/umbrella/commit/afd0b8b))
|
|
17
|
+
- enforce uniform naming convention of internal functions ([56992b2](https://github.com/thi-ng/umbrella/commit/56992b2))
|
|
18
|
+
|
|
12
19
|
### [2.2.55](https://github.com/thi-ng/umbrella/tree/@thi.ng/imgui@2.2.55) (2024-04-20)
|
|
13
20
|
|
|
14
21
|
#### ♻️ Refactoring
|
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://mastodon.thi.ng/@toxi)
|
|
8
8
|
|
|
9
9
|
> [!NOTE]
|
|
10
|
-
> This is one of
|
|
10
|
+
> This is one of 193 standalone projects, maintained as part
|
|
11
11
|
> of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
|
|
12
12
|
> and anti-framework.
|
|
13
13
|
>
|
|
@@ -261,16 +261,14 @@ Browser ESM import:
|
|
|
261
261
|
|
|
262
262
|
[JSDelivr documentation](https://www.jsdelivr.com/)
|
|
263
263
|
|
|
264
|
-
Package sizes (brotli'd, pre-treeshake): ESM: 6.
|
|
264
|
+
Package sizes (brotli'd, pre-treeshake): ESM: 6.67 KB
|
|
265
265
|
|
|
266
266
|
## Dependencies
|
|
267
267
|
|
|
268
268
|
- [@thi.ng/api](https://github.com/thi-ng/umbrella/tree/develop/packages/api)
|
|
269
269
|
- [@thi.ng/checks](https://github.com/thi-ng/umbrella/tree/develop/packages/checks)
|
|
270
270
|
- [@thi.ng/geom](https://github.com/thi-ng/umbrella/tree/develop/packages/geom)
|
|
271
|
-
- [@thi.ng/geom-api](https://github.com/thi-ng/umbrella/tree/develop/packages/geom-api)
|
|
272
271
|
- [@thi.ng/geom-isec](https://github.com/thi-ng/umbrella/tree/develop/packages/geom-isec)
|
|
273
|
-
- [@thi.ng/geom-tessellate](https://github.com/thi-ng/umbrella/tree/develop/packages/geom-tessellate)
|
|
274
272
|
- [@thi.ng/layout](https://github.com/thi-ng/umbrella/tree/develop/packages/layout)
|
|
275
273
|
- [@thi.ng/math](https://github.com/thi-ng/umbrella/tree/develop/packages/math)
|
|
276
274
|
- [@thi.ng/transducers](https://github.com/thi-ng/umbrella/tree/develop/packages/transducers)
|
package/behaviors/button.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IShape } from "@thi.ng/geom
|
|
1
|
+
import type { IShape } from "@thi.ng/geom";
|
|
2
2
|
import type { IMGUI } from "../gui.js";
|
|
3
3
|
export declare const hoverButton: (gui: IMGUI, id: string, shape: IShape, info?: string) => boolean;
|
|
4
4
|
export declare const handleButtonKeys: (gui: IMGUI) => true | undefined;
|
package/behaviors/slider.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FnN4 } from "@thi.ng/api";
|
|
2
|
-
import type { IShape } from "@thi.ng/geom
|
|
2
|
+
import type { IShape } from "@thi.ng/geom";
|
|
3
3
|
import type { Vec } from "@thi.ng/vectors";
|
|
4
4
|
import type { IMGUI } from "../gui.js";
|
|
5
5
|
export declare const isHoverSlider: (gui: IMGUI, id: string, shape: IShape, cursor?: string) => boolean;
|
package/behaviors/text.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { clamp0 } from "@thi.ng/math/interval";
|
|
2
2
|
import { Key } from "../api.js";
|
|
3
3
|
const WS = /\s/;
|
|
4
|
-
const
|
|
4
|
+
const __nextNonAlpha = (src, i) => {
|
|
5
5
|
const n = src.length;
|
|
6
6
|
while (i < n && WS.test(src[i])) i++;
|
|
7
7
|
for (; i < n && !WS.test(src[i]); i++) {
|
|
8
8
|
}
|
|
9
9
|
return i;
|
|
10
10
|
};
|
|
11
|
-
const
|
|
11
|
+
const __prevNonAlpha = (src, i) => {
|
|
12
12
|
while (i > 0 && WS.test(src[i])) i--;
|
|
13
13
|
for (; i > 0 && !WS.test(src[i]); i--) {
|
|
14
14
|
}
|
|
15
15
|
return i;
|
|
16
16
|
};
|
|
17
|
-
const
|
|
17
|
+
const __getNext = (gui, txt, cursor, dir) => {
|
|
18
18
|
cursor += dir;
|
|
19
|
-
return gui.isAltDown() ? (dir < 0 ?
|
|
19
|
+
return gui.isAltDown() ? (dir < 0 ? __prevNonAlpha : __nextNonAlpha)(txt, cursor) : cursor;
|
|
20
20
|
};
|
|
21
21
|
const handleTextfieldKeys = (gui, state, filter, txt, cursor, drawCursor, maxLen) => {
|
|
22
22
|
const txtLen = txt.length;
|
|
@@ -42,26 +42,26 @@ const handleTextfieldKeys = (gui, state, filter, txt, cursor, drawCursor, maxLen
|
|
|
42
42
|
return txt;
|
|
43
43
|
case Key.BACKSPACE:
|
|
44
44
|
if (cursor > 0) {
|
|
45
|
-
const next =
|
|
45
|
+
const next = __getNext(gui, txt, cursor, -1);
|
|
46
46
|
move(next, next - cursor);
|
|
47
47
|
return txt.substring(0, next) + txt.substring(cursor);
|
|
48
48
|
}
|
|
49
49
|
break;
|
|
50
50
|
case Key.DELETE:
|
|
51
51
|
if (cursor < txtLen) {
|
|
52
|
-
const next =
|
|
52
|
+
const next = __getNext(gui, txt, cursor, 1);
|
|
53
53
|
return txt.substring(0, cursor) + txt.substring(next + 1);
|
|
54
54
|
}
|
|
55
55
|
break;
|
|
56
56
|
case Key.LEFT:
|
|
57
57
|
if (cursor > 0) {
|
|
58
|
-
const next =
|
|
58
|
+
const next = __getNext(gui, txt, cursor, -1);
|
|
59
59
|
move(next, next - cursor);
|
|
60
60
|
}
|
|
61
61
|
break;
|
|
62
62
|
case Key.RIGHT:
|
|
63
63
|
if (cursor < txtLen) {
|
|
64
|
-
const next =
|
|
64
|
+
const next = __getNext(gui, txt, cursor, 1);
|
|
65
65
|
move(next, next - cursor);
|
|
66
66
|
}
|
|
67
67
|
break;
|
package/components/button.d.ts
CHANGED
package/components/button.js
CHANGED
|
@@ -5,7 +5,7 @@ import { handleButtonKeys, hoverButton } from "../behaviors/button.js";
|
|
|
5
5
|
import { labelHash } from "../hash.js";
|
|
6
6
|
import { layoutBox } from "../layout.js";
|
|
7
7
|
import { textLabelRaw, textTransformH, textTransformV } from "./textlabel.js";
|
|
8
|
-
const
|
|
8
|
+
const __mkLabel = (gui, tx, id, key, x, y, w, h, hover, label) => gui.resource(
|
|
9
9
|
id,
|
|
10
10
|
labelHash(key, label, gui.disabled),
|
|
11
11
|
() => textLabelRaw(
|
|
@@ -25,10 +25,10 @@ const buttonH = (gui, layout, id, label, labelHover = label, info) => {
|
|
|
25
25
|
id,
|
|
26
26
|
gui.resource(id, key, () => rect([x, y], [w, h])),
|
|
27
27
|
key,
|
|
28
|
-
label ?
|
|
28
|
+
label ? __mkLabel(gui, textTransformH, id, key, x, y, w, h, false, label) : void 0,
|
|
29
29
|
labelHover ? (
|
|
30
30
|
// prettier-ignore
|
|
31
|
-
|
|
31
|
+
__mkLabel(gui, textTransformH, id, key, x, y, w, h, true, labelHover)
|
|
32
32
|
) : void 0,
|
|
33
33
|
info
|
|
34
34
|
);
|
|
@@ -41,10 +41,10 @@ const buttonV = (gui, layout, id, rows, label, labelHover = label, info) => {
|
|
|
41
41
|
id,
|
|
42
42
|
gui.resource(id, key, () => rect([x, y], [w, h])),
|
|
43
43
|
key,
|
|
44
|
-
label ?
|
|
44
|
+
label ? __mkLabel(gui, textTransformV, id, key, x, y, w, h, false, label) : void 0,
|
|
45
45
|
labelHover ? (
|
|
46
46
|
// prettier-ignore
|
|
47
|
-
|
|
47
|
+
__mkLabel(gui, textTransformV, id, key, x, y, w, h, true, labelHover)
|
|
48
48
|
) : void 0,
|
|
49
49
|
info
|
|
50
50
|
);
|
package/components/dropdown.js
CHANGED
|
@@ -18,7 +18,7 @@ const dropdown = (gui, layout, id, sel, items, title, info) => {
|
|
|
18
18
|
if (open) {
|
|
19
19
|
const bt = buttonH(gui, box, `${id}-title`, title);
|
|
20
20
|
draw && gui.add(
|
|
21
|
-
gui.resource(id, key + 1, () =>
|
|
21
|
+
gui.resource(id, key + 1, () => __triangle(gui, tx, ty, true))
|
|
22
22
|
);
|
|
23
23
|
if (bt) {
|
|
24
24
|
gui.setState(id, false);
|
|
@@ -35,9 +35,9 @@ const dropdown = (gui, layout, id, sel, items, title, info) => {
|
|
|
35
35
|
gui.setState(id, false);
|
|
36
36
|
break;
|
|
37
37
|
case Key.UP:
|
|
38
|
-
return
|
|
38
|
+
return __update(gui, id, clamp0(sel - 1));
|
|
39
39
|
case Key.DOWN:
|
|
40
|
-
return
|
|
40
|
+
return __update(
|
|
41
41
|
gui,
|
|
42
42
|
id,
|
|
43
43
|
Math.min(items.length - 1, sel + 1)
|
|
@@ -51,16 +51,16 @@ const dropdown = (gui, layout, id, sel, items, title, info) => {
|
|
|
51
51
|
gui.setState(id, true);
|
|
52
52
|
}
|
|
53
53
|
draw && gui.add(
|
|
54
|
-
gui.resource(id, key + 2, () =>
|
|
54
|
+
gui.resource(id, key + 2, () => __triangle(gui, tx, ty, false))
|
|
55
55
|
);
|
|
56
56
|
}
|
|
57
57
|
return res;
|
|
58
58
|
};
|
|
59
|
-
const
|
|
59
|
+
const __update = (gui, id, next) => {
|
|
60
60
|
gui.focusID = `${id}-${next}`;
|
|
61
61
|
return next;
|
|
62
62
|
};
|
|
63
|
-
const
|
|
63
|
+
const __triangle = (gui, x, y, open) => {
|
|
64
64
|
const s = open ? 2 : -2;
|
|
65
65
|
return polygon(
|
|
66
66
|
[
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
TESSELLATE_TRI_FAN,
|
|
3
|
+
groupFromTessellation,
|
|
4
|
+
tessellate
|
|
5
|
+
} from "@thi.ng/geom";
|
|
2
6
|
import { centroid } from "@thi.ng/geom/centroid";
|
|
3
7
|
import { circle } from "@thi.ng/geom/circle";
|
|
4
|
-
import { polygon } from "@thi.ng/geom/polygon";
|
|
5
|
-
import { vertices } from "@thi.ng/geom/vertices";
|
|
6
8
|
import { mod } from "@thi.ng/math/prec";
|
|
7
9
|
import { mapIndexed } from "@thi.ng/transducers/map-indexed";
|
|
8
10
|
import { add2 } from "@thi.ng/vectors/add";
|
|
@@ -15,8 +17,7 @@ const radialMenu = (gui, id, x, y, r, items, info) => {
|
|
|
15
17
|
const key = hash([x, y, r, n, ~~gui.disabled]);
|
|
16
18
|
gui.registerID(id, key);
|
|
17
19
|
const cells = gui.resource(id, key, () => [
|
|
18
|
-
...mapIndexed((i,
|
|
19
|
-
const cell = polygon(pts);
|
|
20
|
+
...mapIndexed((i, cell) => {
|
|
20
21
|
const p = add2(
|
|
21
22
|
null,
|
|
22
23
|
[-gui.textWidth(items[i]) >> 1, gui.theme.baseLine],
|
|
@@ -28,7 +29,7 @@ const radialMenu = (gui, id, x, y, r, items, info) => {
|
|
|
28
29
|
textLabelRaw(p, gui.textColor(false), items[i]),
|
|
29
30
|
textLabelRaw(p, gui.textColor(true), items[i])
|
|
30
31
|
];
|
|
31
|
-
},
|
|
32
|
+
}, groupFromTessellation(tessellate(circle([x, y], r, { __samples: n }), [TESSELLATE_TRI_FAN])))
|
|
32
33
|
]);
|
|
33
34
|
let res;
|
|
34
35
|
let sel = -1;
|
package/components/ring.js
CHANGED
|
@@ -12,8 +12,8 @@ import { dialVal } from "../behaviors/dial.js";
|
|
|
12
12
|
import { handleSlider1Keys } from "../behaviors/slider.js";
|
|
13
13
|
import { dialValueLabel } from "./textlabel.js";
|
|
14
14
|
import { tooltipRaw } from "./tooltip.js";
|
|
15
|
-
const
|
|
16
|
-
const
|
|
15
|
+
const __ringHeight = (w, thetaGap) => w / 2 * (1 + Math.sin(HALF_PI + thetaGap / 2));
|
|
16
|
+
const __arcVerts = (o, r, start, end, thetaRes = 12) => r > 1 ? map(
|
|
17
17
|
(t) => cartesian2(null, [r, mix(start, end, t)], o),
|
|
18
18
|
normRange(
|
|
19
19
|
Math.max(1, Math.abs(end - start) / (PI / thetaRes)) | 0
|
|
@@ -23,10 +23,10 @@ const ring = (gui, layout, id, min, max, prec, val, thetaGap, rscale, label, fmt
|
|
|
23
23
|
let h;
|
|
24
24
|
let box;
|
|
25
25
|
if (isLayout(layout)) {
|
|
26
|
-
h =
|
|
26
|
+
h = __ringHeight(layout.cellW, thetaGap);
|
|
27
27
|
box = layout.next([1, layout.rowsForHeight(h) + 1]);
|
|
28
28
|
} else {
|
|
29
|
-
h =
|
|
29
|
+
h = __ringHeight(layout.cw, thetaGap);
|
|
30
30
|
box = layout;
|
|
31
31
|
}
|
|
32
32
|
return ringRaw(
|
|
@@ -53,7 +53,7 @@ const ringGroup = (gui, layout, id, min, max, prec, horizontal, thetaGap, rscale
|
|
|
53
53
|
const n = vals.length;
|
|
54
54
|
const nested = horizontal ? layout.nest(n, [n, 1]) : layout.nest(1, [
|
|
55
55
|
1,
|
|
56
|
-
(layout.rowsForHeight(
|
|
56
|
+
(layout.rowsForHeight(__ringHeight(layout.cellW, thetaGap)) + 1) * n
|
|
57
57
|
]);
|
|
58
58
|
let res;
|
|
59
59
|
let idx = -1;
|
|
@@ -107,8 +107,8 @@ const ringRaw = (gui, id, x, y, w, h, min, max, prec, val, thetaGap, rscale, lx,
|
|
|
107
107
|
const numV = fitClamped(r, 15, 80, 12, 30);
|
|
108
108
|
const shape = (max2) => () => polygon(
|
|
109
109
|
[
|
|
110
|
-
...
|
|
111
|
-
...
|
|
110
|
+
...__arcVerts(pos, r, startTheta, max2, numV),
|
|
111
|
+
...__arcVerts(pos, r2, max2, startTheta, numV)
|
|
112
112
|
],
|
|
113
113
|
{}
|
|
114
114
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/imgui",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.60",
|
|
4
4
|
"description": "Immediate mode GUI with flexible state handling & data only shape output",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "https://github.com/thi-ng/umbrella.git"
|
|
12
12
|
},
|
|
13
|
-
"homepage": "https://
|
|
13
|
+
"homepage": "https://thi.ng/imgui",
|
|
14
14
|
"funding": [
|
|
15
15
|
{
|
|
16
16
|
"type": "github",
|
|
@@ -36,22 +36,20 @@
|
|
|
36
36
|
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@thi.ng/api": "^8.11.
|
|
40
|
-
"@thi.ng/checks": "^3.6.
|
|
41
|
-
"@thi.ng/geom": "^
|
|
42
|
-
"@thi.ng/geom-
|
|
43
|
-
"@thi.ng/
|
|
44
|
-
"@thi.ng/
|
|
45
|
-
"@thi.ng/
|
|
46
|
-
"@thi.ng/
|
|
47
|
-
"@thi.ng/transducers": "^9.0.5",
|
|
48
|
-
"@thi.ng/vectors": "^7.10.31"
|
|
39
|
+
"@thi.ng/api": "^8.11.3",
|
|
40
|
+
"@thi.ng/checks": "^3.6.5",
|
|
41
|
+
"@thi.ng/geom": "^8.0.0",
|
|
42
|
+
"@thi.ng/geom-isec": "^4.0.0",
|
|
43
|
+
"@thi.ng/layout": "^3.0.40",
|
|
44
|
+
"@thi.ng/math": "^5.11.0",
|
|
45
|
+
"@thi.ng/transducers": "^9.0.6",
|
|
46
|
+
"@thi.ng/vectors": "^7.11.0"
|
|
49
47
|
},
|
|
50
48
|
"devDependencies": {
|
|
51
|
-
"@microsoft/api-extractor": "^7.
|
|
52
|
-
"esbuild": "^0.21.
|
|
49
|
+
"@microsoft/api-extractor": "^7.47.0",
|
|
50
|
+
"esbuild": "^0.21.5",
|
|
53
51
|
"typedoc": "^0.25.13",
|
|
54
|
-
"typescript": "^5.
|
|
52
|
+
"typescript": "^5.5.2"
|
|
55
53
|
},
|
|
56
54
|
"keywords": [
|
|
57
55
|
"browser",
|
|
@@ -158,5 +156,5 @@
|
|
|
158
156
|
],
|
|
159
157
|
"year": 2019
|
|
160
158
|
},
|
|
161
|
-
"gitHead": "
|
|
159
|
+
"gitHead": "154c95cf9d6bab32174498ec3b5b5d87e42be7f9\n"
|
|
162
160
|
}
|