@thi.ng/imgui
Version:
Immediate mode GUI with flexible state handling & data only shape output
97 lines (96 loc) • 2.6 kB
JavaScript
var MouseButton = /* @__PURE__ */ ((MouseButton2) => {
MouseButton2[MouseButton2["LEFT"] = 1] = "LEFT";
MouseButton2[MouseButton2["RIGHT"] = 2] = "RIGHT";
MouseButton2[MouseButton2["MIDDLE"] = 4] = "MIDDLE";
return MouseButton2;
})(MouseButton || {});
var KeyModifier = /* @__PURE__ */ ((KeyModifier2) => {
KeyModifier2[KeyModifier2["SHIFT"] = 1] = "SHIFT";
KeyModifier2[KeyModifier2["CONTROL"] = 2] = "CONTROL";
KeyModifier2[KeyModifier2["META"] = 4] = "META";
KeyModifier2[KeyModifier2["ALT"] = 8] = "ALT";
return KeyModifier2;
})(KeyModifier || {});
var Key = /* @__PURE__ */ ((Key2) => {
Key2["ALT"] = "Alt";
Key2["BACKSPACE"] = "Backspace";
Key2["CAPSLOCK"] = "CapsLock";
Key2["CONTEXT_MENU"] = "ContextMenu";
Key2["CONTROL"] = "Control";
Key2["DELETE"] = "Delete";
Key2["DOWN"] = "ArrowDown";
Key2["END"] = "End";
Key2["ENTER"] = "Enter";
Key2["ESC"] = "Escape";
Key2["HELP"] = "Help";
Key2["HOME"] = "Home";
Key2["LEFT"] = "ArrowLeft";
Key2["META"] = "Meta";
Key2["NUM_LOCK"] = "NumLock";
Key2["PAGE_DOWN"] = "PageDown";
Key2["PAGE_UP"] = "PageUp";
Key2["RIGHT"] = "ArrowRight";
Key2["SHIFT"] = "Shift";
Key2["SPACE"] = " ";
Key2["TAB"] = "Tab";
Key2["UP"] = "ArrowUp";
return Key2;
})(Key || {});
const CONTROL_KEYS = /* @__PURE__ */ new Set([
"Alt" /* ALT */,
"Backspace" /* BACKSPACE */,
"CapsLock" /* CAPSLOCK */,
"ContextMenu" /* CONTEXT_MENU */,
"Control" /* CONTROL */,
"Delete" /* DELETE */,
"ArrowDown" /* DOWN */,
"End" /* END */,
"Enter" /* ENTER */,
"Escape" /* ESC */,
"Help" /* HELP */,
"Home" /* HOME */,
"ArrowLeft" /* LEFT */,
"Meta" /* META */,
"NumLock" /* NUM_LOCK */,
"PageDown" /* PAGE_DOWN */,
"PageUp" /* PAGE_UP */,
"ArrowRight" /* RIGHT */,
"Shift" /* SHIFT */,
"Tab" /* TAB */,
"ArrowUp" /* UP */
]);
const NONE = "__NONE__";
const DEFAULT_THEME = {
font: "10px Menlo, monospace",
fontSize: 10,
charWidth: 6,
baseLine: 4,
pad: 8,
globalBg: "#ccc",
focus: [0, 1, 0, 1],
cursor: [0, 0, 0, 1],
cursorBlink: 2,
bg: [1, 1, 1, 0.66],
bgDisabled: [1, 1, 1, 0.33],
bgHover: [1, 1, 1, 0.9],
fg: [0.2, 0.8, 1, 1],
fgDisabled: [0.2, 0.8, 1, 0.5],
fgHover: [0.3, 0.9, 1, 1],
text: [0.3, 0.3, 0.3, 1],
textDisabled: [0.3, 0.3, 0.3, 0.5],
textHover: [0.2, 0.2, 0.4, 1],
bgTooltip: [1, 1, 0.8, 0.85],
textTooltip: [0, 0, 0, 1]
};
const INPUT_ALPHA = (x) => /^\w$/.test(x);
const INPUT_DIGITS = (x) => /^\d$/.test(x);
export {
CONTROL_KEYS,
DEFAULT_THEME,
INPUT_ALPHA,
INPUT_DIGITS,
Key,
KeyModifier,
MouseButton,
NONE
};