-
-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(imgui): update button, dropdown, radio, sliderHGroup
- update buttonRaw to allow any IShape - update button to provide rect - update dropdown, radio, sliderHGroup to use nested layout - update radio to support horizontal/vertical layouts - remove dropdownRaw, radioRaw, sliderHGroupRaw
- Loading branch information
1 parent
0c1d483
commit 588a321
Showing
4 changed files
with
41 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,31 @@ | ||
import { IGridLayout } from "../api"; | ||
import { IMGUI } from "../gui"; | ||
import { isLayout } from "../layout"; | ||
import { toggleRaw } from "./toggle"; | ||
|
||
export const radioH = ( | ||
export const radio = ( | ||
gui: IMGUI, | ||
layout: IGridLayout, | ||
id: string, | ||
horizontal: boolean, | ||
val: number[], | ||
idx: number, | ||
labels: string[], | ||
info: string[] = [] | ||
) => { | ||
const { x, y, cw, ch, gap } = isLayout(layout) | ||
? layout.next([labels.length, 1]) | ||
: layout; | ||
// prettier-ignore | ||
return radioRaw(gui, id, x, y, ch, ch, ch, cw + gap, 0, val, idx, labels, info); | ||
}; | ||
|
||
export const radioRaw = ( | ||
gui: IMGUI, | ||
id: string, | ||
x: number, | ||
y: number, | ||
w: number, | ||
h: number, | ||
lx: number, | ||
offX: number, | ||
offY: number, | ||
val: number[], | ||
idx: number, | ||
labels: string[], | ||
info: string[] = [] | ||
) => { | ||
const n = labels.length; | ||
const nested = horizontal ? layout.nest(n, [n, 1]) : layout.nest(1, [1, n]); | ||
let res = false; | ||
const tmp: boolean[] = []; | ||
// prettier-ignore | ||
for (let n = labels.length, sel = val[idx], i = 0; i < n; i++) { | ||
const lx = nested.cellH; | ||
const sel = val[idx]; | ||
for (let i = 0; i < n; i++) { | ||
tmp[0] = sel === i; | ||
if (toggleRaw(gui, `${id}-${i}`, x, y, w, h, lx, tmp, 0, labels[i], info[i])) { | ||
const { x, y, h } = nested.next(); | ||
// prettier-ignore | ||
if (toggleRaw(gui, `${id}-${i}`, x, y, h, h, lx, tmp, 0, labels[i], info[i])) { | ||
val[idx] = i; | ||
res = true; | ||
} | ||
x += offX; | ||
y += offY; | ||
} | ||
return res; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters