UNPKG

@mori2003/jsimgui

Version:

JavaScript bindings for Dear ImGui.

1,443 lines 353 kB
// @ts-nocheck export const Mod = { // biome-ignore lint/suspicious/noExplicitAny: _ export: null, async init(enableFreeType, extensions, loaderPath) { // biome-ignore lint/suspicious/noExplicitAny: _ let MainExport; if (loaderPath) { MainExport = await import(loaderPath); } else if (enableFreeType) { MainExport = extensions ? // @ts-expect-error await import("./loader-freetype-extensions.js") : // @ts-expect-error await import("./loader-freetype.js"); } else { MainExport = extensions ? // @ts-expect-error await import("./loader-extensions.js") : // @ts-expect-error await import("./loader.js"); } Mod.export = await MainExport.default(); }, }; /** * Base class for value structs (passed by value, no native pointer). */ export class ValueStruct { } /** * Base class for reference structs (carry native pointer/reference). * These structs manage native memory and require explicit cleanup. */ export class ReferenceStruct { /** * The native pointer to the struct. */ ptr = null; /** * Construct a new JavaScript class instance and allocate native memory. */ static New() { const obj = new this(); obj.ptr = new Mod.export[this.name](); return obj; } /** * Create a JavaScript class instance from a native pointer. */ static From(ptr) { const obj = new this(); obj.ptr = ptr; return obj; } /** * Free the struct's native allocated memory. */ Drop() { this.ptr?.delete(); } } const IM_COL32_WHITE = 0xFFFFFFFF; /** * Flags for ImGui::Begin() * (Those are per-window flags. There are shared flags in ImGuiIO: io.ConfigWindowsResizeFromEdges and io.ConfigWindowsMoveFromTitleBarOnly) */ export const ImGuiWindowFlags = { None: 0, /** * Disable title-bar */ NoTitleBar: 1, /** * Disable user resizing with the lower-right grip */ NoResize: 2, /** * Disable user moving the window */ NoMove: 4, /** * Disable scrollbars (window can still scroll with mouse or programmatically) */ NoScrollbar: 8, /** * Disable user vertically scrolling with mouse wheel. On child window, mouse wheel will be forwarded to the parent unless NoScrollbar is also set. */ NoScrollWithMouse: 16, /** * Disable user collapsing window by double-clicking on it. Also referred to as Window Menu Button (e.g. within a docking node). */ NoCollapse: 32, /** * Resize every window to its content every frame */ AlwaysAutoResize: 64, /** * Disable drawing background color (WindowBg, etc.) and outside border. Similar as using SetNextWindowBgAlpha(0.0f). */ NoBackground: 128, /** * Never load/save settings in .ini file */ NoSavedSettings: 256, /** * Disable catching mouse, hovering test with pass through. */ NoMouseInputs: 512, /** * Has a menu-bar */ MenuBar: 1024, /** * Allow horizontal scrollbar to appear (off by default). You may use SetNextWindowContentSize(ImVec2(width,0.0f)); prior to calling Begin() to specify width. Read code in imgui_demo in the "Horizontal Scrolling" section. */ HorizontalScrollbar: 2048, /** * Disable taking focus when transitioning from hidden to visible state */ NoFocusOnAppearing: 4096, /** * Disable bringing window to front when taking focus (e.g. clicking on it or programmatically giving it focus) */ NoBringToFrontOnFocus: 8192, /** * Always show vertical scrollbar (even if ContentSize.y < Size.y) */ AlwaysVerticalScrollbar: 16384, /** * Always show horizontal scrollbar (even if ContentSize.x < Size.x) */ AlwaysHorizontalScrollbar: 32768, /** * No keyboard/gamepad navigation within the window */ NoNavInputs: 65536, /** * No focusing toward this window with keyboard/gamepad navigation (e.g. skipped by Ctrl+Tab) */ NoNavFocus: 131072, /** * Display a dot next to the title. When used in a tab/docking context, tab is selected when clicking the X + closure is not assumed (will wait for user to stop submitting the tab). Otherwise closure is assumed when pressing the X, so if you keep submitting the tab may reappear at end of tab bar. */ UnsavedDocument: 262144, /** * Disable docking of this window */ NoDocking: 524288, NoNav: 196608, NoDecoration: 43, NoInputs: 197120, }; /** * Flags for ImGui::BeginChild() * (Legacy: bit 0 must always correspond to ImGuiChildFlags_Borders to be backward compatible with old API using 'bool border = false'.) * About using AutoResizeX/AutoResizeY flags: * - May be combined with SetNextWindowSizeConstraints() to set a min/max size for each axis (see "Demo->Child->Auto-resize with Constraints"). * - Size measurement for a given axis is only performed when the child window is within visible boundaries, or is just appearing. * - This allows BeginChild() to return false when not within boundaries (e.g. when scrolling), which is more optimal. BUT it won't update its auto-size while clipped. * While not perfect, it is a better default behavior as the always-on performance gain is more valuable than the occasional "resizing after becoming visible again" glitch. * - You may also use ImGuiChildFlags_AlwaysAutoResize to force an update even when child window is not in view. * HOWEVER PLEASE UNDERSTAND THAT DOING SO WILL PREVENT BeginChild() FROM EVER RETURNING FALSE, disabling benefits of coarse clipping. */ export const ImGuiChildFlags = { None: 0, /** * Show an outer border and enable WindowPadding. (IMPORTANT: this is always == 1 == true for legacy reason) */ Borders: 1, /** * Pad with style.WindowPadding even if no border are drawn (no padding by default for non-bordered child windows because it makes more sense) */ AlwaysUseWindowPadding: 2, /** * Allow resize from right border (layout direction). Enable .ini saving (unless ImGuiWindowFlags_NoSavedSettings passed to window flags) */ ResizeX: 4, /** * Allow resize from bottom border (layout direction). " */ ResizeY: 8, /** * Enable auto-resizing width. Read "IMPORTANT: Size measurement" details above. */ AutoResizeX: 16, /** * Enable auto-resizing height. Read "IMPORTANT: Size measurement" details above. */ AutoResizeY: 32, /** * Combined with AutoResizeX/AutoResizeY. Always measure size even when child is hidden, always return true, always disable clipping optimization! NOT RECOMMENDED. */ AlwaysAutoResize: 64, /** * Style the child window like a framed item: use FrameBg, FrameRounding, FrameBorderSize, FramePadding instead of ChildBg, ChildRounding, ChildBorderSize, WindowPadding. */ FrameStyle: 128, /** * [BETA] Share focus scope, allow keyboard/gamepad navigation to cross over parent border to this child or between sibling child windows. */ NavFlattened: 256, }; /** * Flags for ImGui::PushItemFlag() * (Those are shared by all submitted items) */ export const ImGuiItemFlags = { /** * (Default) */ None: 0, /** * false // Disable keyboard tabbing. This is a "lighter" version of ImGuiItemFlags_NoNav. */ NoTabStop: 1, /** * false // Disable any form of focusing (keyboard/gamepad directional navigation and SetKeyboardFocusHere() calls). */ NoNav: 2, /** * false // Disable item being a candidate for default focus (e.g. used by title bar items). */ NoNavDefaultFocus: 4, /** * false // Any button-like behavior will have repeat mode enabled (based on io.KeyRepeatDelay and io.KeyRepeatRate values). Note that you can also call IsItemActive() after any button to tell if it is being held. */ ButtonRepeat: 8, /** * true // MenuItem()/Selectable() automatically close their parent popup window. */ AutoClosePopups: 16, /** * false // Allow submitting an item with the same identifier as an item already submitted this frame without triggering a warning tooltip if io.ConfigDebugHighlightIdConflicts is set. */ AllowDuplicateId: 32, /** * false // [Internal] Disable interactions. DOES NOT affect visuals. This is used by BeginDisabled()/EndDisabled() and only provided here so you can read back via GetItemFlags(). */ Disabled: 64, }; /** * Flags for ImGui::InputText() * (Those are per-item flags. There are shared flags in ImGuiIO: io.ConfigInputTextCursorBlink and io.ConfigInputTextEnterKeepActive) */ export const ImGuiInputTextFlags = { /** * Basic filters (also see ImGuiInputTextFlags_CallbackCharFilter) */ None: 0, /** * Allow 0123456789.+-* / */ CharsDecimal: 1, /** * Allow 0123456789ABCDEFabcdef */ CharsHexadecimal: 2, /** * Allow 0123456789.+-* /eE (Scientific notation input) */ CharsScientific: 4, /** * Turn a..z into A..Z */ CharsUppercase: 8, /** * Filter out spaces, tabs */ CharsNoBlank: 16, // Inputs /** * Pressing TAB input a '\t' character into the text field */ AllowTabInput: 32, /** * Return 'true' when Enter is pressed (as opposed to every time the value was modified). Consider using IsItemDeactivatedAfterEdit() instead! */ EnterReturnsTrue: 64, /** * Escape key clears content if not empty, and deactivate otherwise (contrast to default behavior of Escape to revert) */ EscapeClearsAll: 128, /** * In multi-line mode: validate with Enter, add new line with Ctrl+Enter (default is opposite: validate with Ctrl+Enter, add line with Enter). Note that Shift+Enter always enter a new line either way. */ CtrlEnterForNewLine: 256, // Other options /** * Read-only mode */ ReadOnly: 512, /** * Password mode, display all characters as '*', disable copy */ Password: 1024, /** * Overwrite mode */ AlwaysOverwrite: 2048, /** * Select entire text when first taking mouse focus */ AutoSelectAll: 4096, /** * InputFloat(), InputInt(), InputScalar() etc. only: parse empty string as zero value. */ ParseEmptyRefVal: 8192, /** * InputFloat(), InputInt(), InputScalar() etc. only: when value is zero, do not display it. Generally used with ImGuiInputTextFlags_ParseEmptyRefVal. */ DisplayEmptyRefVal: 16384, /** * Disable following the cursor horizontally */ NoHorizontalScroll: 32768, /** * Disable undo/redo. Note that input text owns the text data while active, if you want to provide your own undo/redo stack you need e.g. to call ClearActiveID(). */ NoUndoRedo: 65536, // Elide display / Alignment /** * When text doesn't fit, elide left side to ensure right side stays visible. Useful for path/filenames. Single-line only! */ ElideLeft: 131072, // Callback features /** * Callback on pressing TAB (for completion handling) */ CallbackCompletion: 262144, /** * Callback on pressing Up/Down arrows (for history handling) */ CallbackHistory: 524288, /** * Callback on each iteration. User code may query cursor position, modify text buffer. */ CallbackAlways: 1048576, /** * Callback on character inputs to replace or discard them. Modify 'EventChar' to replace or discard, or return 1 in callback to discard. */ CallbackCharFilter: 2097152, /** * Callback on buffer capacity changes request (beyond 'buf_size' parameter value), allowing the string to grow. Notify when the string wants to be resized (for string types which hold a cache of their Size). You will be provided a new BufSize in the callback and NEED to honor it. (see misc/cpp/imgui_stdlib.h for an example of using this) */ CallbackResize: 4194304, /** * Callback on any edit. Note that InputText() already returns true on edit + you can always use IsItemEdited(). The callback is useful to manipulate the underlying buffer while focus is active. */ CallbackEdit: 8388608, // Multi-line Word-Wrapping [BETA] // - Not well tested yet. Please report any incorrect cursor movement, selection behavior etc. bug to https://github.com/ocornut/imgui/issues/3237. // - Wrapping style is not ideal. Wrapping of long words/sections (e.g. words larger than total available width) may be particularly unpleasing. // - Wrapping width needs to always account for the possibility of a vertical scrollbar. // - It is much slower than regular text fields. // Ballpark estimate of cost on my 2019 desktop PC: for a 100 KB text buffer: +~0.3 ms (Optimized) / +~1.0 ms (Debug build). // The CPU cost is very roughly proportional to text length, so a 10 KB buffer should cost about ten times less. /** * InputTextMultiline(): word-wrap lines that are too long. */ WordWrap: 16777216, }; /** * Flags for ImGui::TreeNodeEx(), ImGui::CollapsingHeader*() */ export const ImGuiTreeNodeFlags = { None: 0, /** * Draw as selected */ Selected: 1, /** * Draw frame with background (e.g. for CollapsingHeader) */ Framed: 2, /** * Hit testing will allow subsequent widgets to overlap this one. Require previous frame HoveredId to match before being usable. Shortcut to calling SetNextItemAllowOverlap(). */ AllowOverlap: 4, /** * Don't do a TreePush() when open (e.g. for CollapsingHeader) = no extra indent nor pushing on ID stack */ NoTreePushOnOpen: 8, /** * Don't automatically and temporarily open node when Logging is active (by default logging will automatically open tree nodes) */ NoAutoOpenOnLog: 16, /** * Default node to be open */ DefaultOpen: 32, /** * Open on double-click instead of simple click (default for multi-select unless any _OpenOnXXX behavior is set explicitly). Both behaviors may be combined. */ OpenOnDoubleClick: 64, /** * Open when clicking on the arrow part (default for multi-select unless any _OpenOnXXX behavior is set explicitly). Both behaviors may be combined. */ OpenOnArrow: 128, /** * No collapsing, no arrow (use as a convenience for leaf nodes). Note: will always open a tree/id scope and return true. If you never use that scope, add ImGuiTreeNodeFlags_NoTreePushOnOpen. */ Leaf: 256, /** * Display a bullet instead of arrow. IMPORTANT: node can still be marked open/close if you don't set the _Leaf flag! */ Bullet: 512, /** * Use FramePadding (even for an unframed text node) to vertically align text baseline to regular widget height. Equivalent to calling AlignTextToFramePadding() before the node. */ FramePadding: 1024, /** * Extend hit box to the right-most edge, even if not framed. This is not the default in order to allow adding other items on the same line without using AllowOverlap mode. */ SpanAvailWidth: 2048, /** * Extend hit box to the left-most and right-most edges (cover the indent area). */ SpanFullWidth: 4096, /** * Narrow hit box + narrow hovering highlight, will only cover the label text. */ SpanLabelWidth: 8192, /** * Frame will span all columns of its container table (label will still fit in current column) */ SpanAllColumns: 16384, /** * Label will span all columns of its container table */ LabelSpanAllColumns: 32768, // mGuiTreeNodeFlags_NoScrollOnOpen = 1 << 16, // FIXME: TODO: Disable automatic scroll on TreePop() if node got just open and contents is not visible /** * Nav: left arrow moves back to parent. This is processed in TreePop() when there's an unfulfilled Left nav request remaining. */ NavLeftJumpsToParent: 131072, CollapsingHeader: 26, // [EXPERIMENTAL] Draw lines connecting TreeNode hierarchy. Discuss in GitHub issue #2920. // Default value is pulled from style.TreeLinesFlags. May be overridden in TreeNode calls. /** * No lines drawn */ DrawLinesNone: 262144, /** * Horizontal lines to child nodes. Vertical line drawn down to TreePop() position: cover full contents. Faster (for large trees). */ DrawLinesFull: 524288, /** * Horizontal lines to child nodes. Vertical line drawn down to bottom-most child node. Slower (for large trees). */ DrawLinesToNodes: 1048576, }; /** * Flags for OpenPopup*(), BeginPopupContext*(), IsPopupOpen() functions. * - IMPORTANT: If you ever used the left mouse button with BeginPopupContextXXX() helpers before 1.92.6: Read "API BREAKING CHANGES" 2026/01/07 (1.92.6) entry in imgui.cpp or GitHub topic #9157. * - Multiple buttons currently cannot be combined/or-ed in those functions (we could allow it later). */ export const ImGuiPopupFlags = { None: 0, /** * For BeginPopupContext*(): open on Left Mouse release. Only one button allowed! */ MouseButtonLeft: 4, /** * For BeginPopupContext*(): open on Right Mouse release. Only one button allowed! (default) */ MouseButtonRight: 8, /** * For BeginPopupContext*(): open on Middle Mouse release. Only one button allowed! */ MouseButtonMiddle: 12, /** * For OpenPopup*(), BeginPopupContext*(): don't reopen same popup if already open (won't reposition, won't reinitialize navigation) */ NoReopen: 32, // mGuiPopupFlags_NoReopenAlwaysNavInit = 1 << 6, // For OpenPopup*(), BeginPopupContext*(): focus and initialize navigation even when not reopening. /** * For OpenPopup*(), BeginPopupContext*(): don't open if there's already a popup at the same level of the popup stack */ NoOpenOverExistingPopup: 128, /** * For BeginPopupContextWindow(): don't return true when hovering items, only when hovering empty space */ NoOpenOverItems: 256, /** * For IsPopupOpen(): ignore the ImGuiID parameter and test for any popup. */ AnyPopupId: 1024, /** * For IsPopupOpen(): search/test at any level of the popup stack (default test in the current level) */ AnyPopupLevel: 2048, AnyPopup: 3072, }; /** * Flags for ImGui::Selectable() */ export const ImGuiSelectableFlags = { None: 0, /** * Clicking this doesn't close parent popup window (overrides ImGuiItemFlags_AutoClosePopups) */ NoAutoClosePopups: 1, /** * Frame will span all columns of its container table (text will still fit in current column) */ SpanAllColumns: 2, /** * Generate press events on double clicks too */ AllowDoubleClick: 4, /** * Cannot be selected, display grayed out text */ Disabled: 8, /** * Hit testing will allow subsequent widgets to overlap this one. Require previous frame HoveredId to match before being usable. Shortcut to calling SetNextItemAllowOverlap(). */ AllowOverlap: 16, /** * Make the item be displayed as if it is hovered */ Highlight: 32, /** * Auto-select when moved into, unless Ctrl is held. Automatic when in a BeginMultiSelect() block. */ SelectOnNav: 64, }; /** * Flags for ImGui::BeginCombo() */ export const ImGuiComboFlags = { None: 0, /** * Align the popup toward the left by default */ PopupAlignLeft: 1, /** * Max ~4 items visible. Tip: If you want your combo popup to be a specific size you can use SetNextWindowSizeConstraints() prior to calling BeginCombo() */ HeightSmall: 2, /** * Max ~8 items visible (default) */ HeightRegular: 4, /** * Max ~20 items visible */ HeightLarge: 8, /** * As many fitting items as possible */ HeightLargest: 16, /** * Display on the preview box without the square arrow button */ NoArrowButton: 32, /** * Display only a square arrow button */ NoPreview: 64, /** * Width dynamically calculated from preview contents */ WidthFitPreview: 128, }; /** * Flags for ImGui::BeginTabBar() */ export const ImGuiTabBarFlags = { None: 0, /** * Allow manually dragging tabs to re-order them + New tabs are appended at the end of list */ Reorderable: 1, /** * Automatically select new tabs when they appear */ AutoSelectNewTabs: 2, /** * Disable buttons to open the tab list popup */ TabListPopupButton: 4, /** * Disable behavior of closing tabs (that are submitted with p_open != NULL) with middle mouse button. You may handle this behavior manually on user's side with if (IsItemHovered() && IsMouseClicked(2)) *p_open = false. */ NoCloseWithMiddleMouseButton: 8, /** * Disable scrolling buttons (apply when fitting policy is ImGuiTabBarFlags_FittingPolicyScroll) */ NoTabListScrollingButtons: 16, /** * Disable tooltips when hovering a tab */ NoTooltip: 32, /** * Draw selected overline markers over selected tab */ DrawSelectedOverline: 64, // Fitting/Resize policy /** * Shrink down tabs when they don't fit, until width is style.TabMinWidthShrink, then enable scrolling. Setting TabMinWidthShrink to FLT_MAX makes this behave like ImGuiTabBarFlags_FittingPolicyScroll. */ FittingPolicyMixed: 128, /** * Shrink down tabs when they don't fit */ FittingPolicyShrink: 256, /** * Enable scrolling buttons when tabs don't fit */ FittingPolicyScroll: 512, }; /** * Flags for ImGui::BeginTabItem() */ export const ImGuiTabItemFlags = { None: 0, /** * Display a dot next to the title + set ImGuiTabItemFlags_NoAssumedClosure. */ UnsavedDocument: 1, /** * Trigger flag to programmatically make the tab selected when calling BeginTabItem() */ SetSelected: 2, /** * Disable behavior of closing tabs (that are submitted with p_open != NULL) with middle mouse button. You may handle this behavior manually on user's side with if (IsItemHovered() && IsMouseClicked(2)) *p_open = false. */ NoCloseWithMiddleMouseButton: 4, /** * Don't call PushID()/PopID() on BeginTabItem()/EndTabItem() */ NoPushId: 8, /** * Disable tooltip for the given tab */ NoTooltip: 16, /** * Disable reordering this tab or having another tab cross over this tab */ NoReorder: 32, /** * Enforce the tab position to the left of the tab bar (after the tab list popup button) */ Leading: 64, /** * Enforce the tab position to the right of the tab bar (before the scrolling buttons) */ Trailing: 128, /** * Tab is selected when trying to close + closure is not immediately assumed (will wait for user to stop submitting the tab). Otherwise closure is assumed when pressing the X, so if you keep submitting the tab may reappear at end of tab bar. */ NoAssumedClosure: 256, }; /** * Flags for ImGui::IsWindowFocused() */ export const ImGuiFocusedFlags = { None: 0, /** * Return true if any children of the window is focused */ ChildWindows: 1, /** * Test from root window (top most parent of the current hierarchy) */ RootWindow: 2, /** * Return true if any window is focused. Important: If you are trying to tell how to dispatch your low-level inputs, do NOT use this. Use 'io.WantCaptureMouse' instead! Please read the FAQ! */ AnyWindow: 4, /** * Do not consider popup hierarchy (do not treat popup emitter as parent of popup) (when used with _ChildWindows or _RootWindow) */ NoPopupHierarchy: 8, /** * Consider docking hierarchy (treat dockspace host as parent of docked window) (when used with _ChildWindows or _RootWindow) */ DockHierarchy: 16, RootAndChildWindows: 3, }; /** * Flags for ImGui::IsItemHovered(), ImGui::IsWindowHovered() * Note: if you are trying to check whether your mouse should be dispatched to Dear ImGui or to your app, you should use 'io.WantCaptureMouse' instead! Please read the FAQ! * Note: windows with the ImGuiWindowFlags_NoInputs flag are ignored by IsWindowHovered() calls. */ export const ImGuiHoveredFlags = { /** * Return true if directly over the item/window, not obstructed by another window, not obstructed by an active popup or modal blocking inputs under them. */ None: 0, /** * IsWindowHovered() only: Return true if any children of the window is hovered */ ChildWindows: 1, /** * IsWindowHovered() only: Test from root window (top most parent of the current hierarchy) */ RootWindow: 2, /** * IsWindowHovered() only: Return true if any window is hovered */ AnyWindow: 4, /** * IsWindowHovered() only: Do not consider popup hierarchy (do not treat popup emitter as parent of popup) (when used with _ChildWindows or _RootWindow) */ NoPopupHierarchy: 8, /** * IsWindowHovered() only: Consider docking hierarchy (treat dockspace host as parent of docked window) (when used with _ChildWindows or _RootWindow) */ DockHierarchy: 16, /** * Return true even if a popup window is normally blocking access to this item/window */ AllowWhenBlockedByPopup: 32, // mGuiHoveredFlags_AllowWhenBlockedByModal = 1 << 6, // Return true even if a modal popup window is normally blocking access to this item/window. FIXME-TODO: Unavailable yet. /** * Return true even if an active item is blocking access to this item/window. Useful for Drag and Drop patterns. */ AllowWhenBlockedByActiveItem: 128, /** * IsItemHovered() only: Return true even if the item uses AllowOverlap mode and is overlapped by another hoverable item. */ AllowWhenOverlappedByItem: 256, /** * IsItemHovered() only: Return true even if the position is obstructed or overlapped by another window. */ AllowWhenOverlappedByWindow: 512, /** * IsItemHovered() only: Return true even if the item is disabled */ AllowWhenDisabled: 1024, /** * IsItemHovered() only: Disable using keyboard/gamepad navigation state when active, always query mouse */ NoNavOverride: 2048, AllowWhenOverlapped: 768, RectOnly: 928, RootAndChildWindows: 3, // Tooltips mode // - typically used in IsItemHovered() + SetTooltip() sequence. // - this is a shortcut to pull flags from 'style.HoverFlagsForTooltipMouse' or 'style.HoverFlagsForTooltipNav' where you can reconfigure desired behavior. // e.g. 'HoverFlagsForTooltipMouse' defaults to 'ImGuiHoveredFlags_Stationary | ImGuiHoveredFlags_DelayShort | ImGuiHoveredFlags_AllowWhenDisabled'. // - for frequently actioned or hovered items providing a tooltip, you want may to use ImGuiHoveredFlags_ForTooltip (stationary + delay) so the tooltip doesn't show too often. // - for items which main purpose is to be hovered, or items with low affordance, or in less consistent apps, prefer no delay or shorter delay. /** * Shortcut for standard flags when using IsItemHovered() + SetTooltip() sequence. */ ForTooltip: 4096, // (Advanced) Mouse Hovering delays. // - generally you can use ImGuiHoveredFlags_ForTooltip to use application-standardized flags. // - use those if you need specific overrides. /** * Require mouse to be stationary for style.HoverStationaryDelay (~0.15 sec) _at least one time_. After this, can move on same item/window. Using the stationary test tends to reduces the need for a long delay. */ Stationary: 8192, /** * IsItemHovered() only: Return true immediately (default). As this is the default you generally ignore this. */ DelayNone: 16384, /** * IsItemHovered() only: Return true after style.HoverDelayShort elapsed (~0.15 sec) (shared between items) + requires mouse to be stationary for style.HoverStationaryDelay (once per item). */ DelayShort: 32768, /** * IsItemHovered() only: Return true after style.HoverDelayNormal elapsed (~0.40 sec) (shared between items) + requires mouse to be stationary for style.HoverStationaryDelay (once per item). */ DelayNormal: 65536, /** * IsItemHovered() only: Disable shared delay system where moving from one item to the next keeps the previous timer for a short time (standard for tooltips with long delays) */ NoSharedDelay: 131072, }; /** * Flags for ImGui::DockSpace(), shared/inherited by child nodes. * (Some flags can be applied to individual nodes directly) * FIXME-DOCK: Also see ImGuiDockNodeFlagsPrivate_ which may involve using the WIP and internal DockBuilder api. */ export const ImGuiDockNodeFlags = { None: 0, /** * // Don't display the dockspace node but keep it alive. Windows docked into this dockspace node won't be undocked. */ KeepAliveOnly: 1, // mGuiDockNodeFlags_NoCentralNode = 1 << 1, // // Disable Central Node (the node which can stay empty) /** * // Disable docking over the Central Node, which will be always kept empty. */ NoDockingOverCentralNode: 4, /** * // Enable passthru dockspace: 1) DockSpace() will render a ImGuiCol_WindowBg background covering everything excepted the Central Node when empty. Meaning the host window should probably use SetNextWindowBgAlpha(0.0f) prior to Begin() when using this. 2) When Central Node is empty: let inputs pass-through + won't display a DockingEmptyBg background. See demo for details. */ PassthruCentralNode: 8, /** * // Disable other windows/nodes from splitting this node. */ NoDockingSplit: 16, /** * Saved // Disable resizing node using the splitter/separators. Useful with programmatically setup dockspaces. */ NoResize: 32, /** * // Tab bar will automatically hide when there is a single window in the dock node. */ AutoHideTabBar: 64, /** * // Disable undocking this node. */ NoUndocking: 128, }; /** * Flags for ImGui::BeginDragDropSource(), ImGui::AcceptDragDropPayload() */ export const ImGuiDragDropFlags = { None: 0, // BeginDragDropSource() flags /** * Disable preview tooltip. By default, a successful call to BeginDragDropSource opens a tooltip so you can display a preview or description of the source contents. This flag disables this behavior. */ SourceNoPreviewTooltip: 1, /** * By default, when dragging we clear data so that IsItemHovered() will return false, to avoid subsequent user code submitting tooltips. This flag disables this behavior so you can still call IsItemHovered() on the source item. */ SourceNoDisableHover: 2, /** * Disable the behavior that allows to open tree nodes and collapsing header by holding over them while dragging a source item. */ SourceNoHoldToOpenOthers: 4, /** * Allow items such as Text(), Image() that have no unique identifier to be used as drag source, by manufacturing a temporary identifier based on their window-relative position. This is extremely unusual within the dear imgui ecosystem and so we made it explicit. */ SourceAllowNullID: 8, /** * External source (from outside of dear imgui), won't attempt to read current item/window info. Will always return true. Only one Extern source can be active simultaneously. */ SourceExtern: 16, /** * Automatically expire the payload if the source cease to be submitted (otherwise payloads are persisting while being dragged) */ PayloadAutoExpire: 32, /** * Hint to specify that the payload may not be copied outside current dear imgui context. */ PayloadNoCrossContext: 64, /** * Hint to specify that the payload may not be copied outside current process. */ PayloadNoCrossProcess: 128, // AcceptDragDropPayload() flags /** * AcceptDragDropPayload() will returns true even before the mouse button is released. You can then call IsDelivery() to test if the payload needs to be delivered. */ AcceptBeforeDelivery: 1024, /** * Do not draw the default highlight rectangle when hovering over target. */ AcceptNoDrawDefaultRect: 2048, /** * Request hiding the BeginDragDropSource tooltip from the BeginDragDropTarget site. */ AcceptNoPreviewTooltip: 4096, /** * Accepting item will render as if hovered. Useful for e.g. a Button() used as a drop target. */ AcceptDrawAsHovered: 8192, /** * For peeking ahead and inspecting the payload before delivery. */ AcceptPeekOnly: 3072, }; /** * A primary data type */ export const ImGuiDataType = { /** * signed char / char (with sensible compilers) */ S8: 0, /** * unsigned char */ U8: 1, /** * short */ S16: 2, /** * unsigned short */ U16: 3, /** * int */ S32: 4, /** * unsigned int */ U32: 5, /** * long long / __int64 */ S64: 6, /** * unsigned long long / unsigned __int64 */ U64: 7, /** * float */ Float: 8, /** * double */ Double: 9, /** * bool (provided for user convenience, not supported by scalar widgets) */ Bool: 10, /** * char* (provided for user convenience, not supported by scalar widgets) */ String: 11, COUNT: 12, }; // A cardinal direction /** * Forward declared enum type ImGuiDir */ export const ImGuiDir = { _None: -1, _Left: 0, _Right: 1, _Up: 2, _Down: 3, _COUNT: 4, }; // A sorting direction /** * Forward declared enum type ImGuiSortDirection */ export const ImGuiSortDirection = { _None: 0, /** * Ascending = 0->9, A->Z etc. */ _Ascending: 1, /** * Descending = 9->0, Z->A etc. */ _Descending: 2, }; // A key identifier (ImGuiKey_XXX or ImGuiMod_XXX value): can represent Keyboard, Mouse and Gamepad values. // All our named keys are >= 512. Keys value 0 to 511 are left unused and were legacy native/opaque key values (< 1.87). // Support for legacy keys was completely removed in 1.91.5. // Read details about the 1.87+ transition : https://github.com/ocornut/imgui/issues/4921 // Note that "Keys" related to physical keys and are not the same concept as input "Characters", the latter are submitted via io.AddInputCharacter(). // The keyboard key enum values are named after the keys on a standard US keyboard, and on other keyboard types the keys reported may not match the keycaps. /** * Forward declared enum type ImGuiKey */ export const ImGuiKey = { /** * Keyboard */ _None: 0, /** * First valid key value (other than 0) */ _NamedKey_BEGIN: 512, /** * == ImGuiKey_NamedKey_BEGIN */ _Tab: 512, _LeftArrow: 513, _RightArrow: 514, _UpArrow: 515, _DownArrow: 516, _PageUp: 517, _PageDown: 518, _Home: 519, _End: 520, _Insert: 521, _Delete: 522, _Backspace: 523, _Space: 524, _Enter: 525, _Escape: 526, _LeftCtrl: 527, _LeftShift: 528, _LeftAlt: 529, /** * Also see ImGuiMod_Ctrl, ImGuiMod_Shift, ImGuiMod_Alt, ImGuiMod_Super below! */ _LeftSuper: 530, _RightCtrl: 531, _RightShift: 532, _RightAlt: 533, _RightSuper: 534, _Menu: 535, _0: 536, _1: 537, _2: 538, _3: 539, _4: 540, _5: 541, _6: 542, _7: 543, _8: 544, _9: 545, _A: 546, _B: 547, _C: 548, _D: 549, _E: 550, _F: 551, _G: 552, _H: 553, _I: 554, _J: 555, _K: 556, _L: 557, _M: 558, _N: 559, _O: 560, _P: 561, _Q: 562, _R: 563, _S: 564, _T: 565, _U: 566, _V: 567, _W: 568, _X: 569, _Y: 570, _Z: 571, _F1: 572, _F2: 573, _F3: 574, _F4: 575, _F5: 576, _F6: 577, _F7: 578, _F8: 579, _F9: 580, _F10: 581, _F11: 582, _F12: 583, _F13: 584, _F14: 585, _F15: 586, _F16: 587, _F17: 588, _F18: 589, _F19: 590, _F20: 591, _F21: 592, _F22: 593, _F23: 594, _F24: 595, /** * ' */ _Apostrophe: 596, /** * , */ _Comma: 597, /** * - */ _Minus: 598, /** * . */ _Period: 599, /** * / */ _Slash: 600, /** * ; */ _Semicolon: 601, /** * = */ _Equal: 602, /** * [ */ _LeftBracket: 603, /** * \ (this text inhibit multiline comment caused by backslash) */ _Backslash: 604, /** * ] */ _RightBracket: 605, /** * ` */ _GraveAccent: 606, _CapsLock: 607, _ScrollLock: 608, _NumLock: 609, _PrintScreen: 610, _Pause: 611, _Keypad0: 612, _Keypad1: 613, _Keypad2: 614, _Keypad3: 615, _Keypad4: 616, _Keypad5: 617, _Keypad6: 618, _Keypad7: 619, _Keypad8: 620, _Keypad9: 621, _KeypadDecimal: 622, _KeypadDivide: 623, _KeypadMultiply: 624, _KeypadSubtract: 625, _KeypadAdd: 626, _KeypadEnter: 627, _KeypadEqual: 628, /** * Available on some keyboard/mouses. Often referred as "Browser Back" */ _AppBack: 629, _AppForward: 630, /** * Non-US backslash. */ _Oem102: 631, // Gamepad // (analog values are 0.0f to 1.0f) // (download controller mapping PNG/PSD at http://dearimgui.com/controls_sheets) // // XBOX | SWITCH | PLAYSTA. | -> ACTION /** * Menu | + | Options | */ _GamepadStart: 632, /** * View | - | Share | */ _GamepadBack: 633, /** * X | Y | Square | Toggle Menu. Hold for Windowing mode (Focus/Move/Resize windows) */ _GamepadFaceLeft: 634, /** * B | A | Circle | Cancel / Close / Exit */ _GamepadFaceRight: 635, /** * Y | X | Triangle | Open Context Menu */ _GamepadFaceUp: 636, /** * A | B | Cross | Activate / Open / Toggle. Hold for 0.60f to Activate in Text Input mode (e.g. wired to an on-screen keyboard). */ _GamepadFaceDown: 637, /** * D-pad Left | " | " | Move / Tweak / Resize Window (in Windowing mode) */ _GamepadDpadLeft: 638, /** * D-pad Right | " | " | Move / Tweak / Resize Window (in Windowing mode) */ _GamepadDpadRight: 639, /** * D-pad Up | " | " | Move / Tweak / Resize Window (in Windowing mode) */ _GamepadDpadUp: 640, /** * D-pad Down | " | " | Move / Tweak / Resize Window (in Windowing mode) */ _GamepadDpadDown: 641, /** * L Bumper | L | L1 | Tweak Slower / Focus Previous (in Windowing mode) */ _GamepadL1: 642, /** * R Bumper | R | R1 | Tweak Faster / Focus Next (in Windowing mode) */ _GamepadR1: 643, /** * L Trigger | ZL | L2 | [Analog] */ _GamepadL2: 644, /** * R Trigger | ZR | R2 | [Analog] */ _GamepadR2: 645, /** * L Stick | L3 | L3 | */ _GamepadL3: 646, /** * R Stick | R3 | R3 | */ _GamepadR3: 647, /** * | | | [Analog] Move Window (in Windowing mode) */ _GamepadLStickLeft: 648, /** * | | | [Analog] Move Window (in Windowing mode) */ _GamepadLStickRight: 649, /** * | | | [Analog] Move Window (in Windowing mode) */ _GamepadLStickUp: 650, /** * | | | [Analog] Move Window (in Windowing mode) */ _GamepadLStickDown: 651, /** * | | | [Analog] */ _GamepadRStickLeft: 652, /** * | | | [Analog] */ _GamepadRStickRight: 653, /** * | | | [Analog] */ _GamepadRStickUp: 654, /** * | | | [Analog] */ _GamepadRStickDown: 655, /** * Aliases: Mouse Buttons (auto-submitted from AddMouseButtonEvent() calls) * - This is mirroring the data also written to io.MouseDown[], io.MouseWheel, in a format allowing them to be accessed via standard key API. */ _MouseLeft: 656, _MouseRight: 657, _MouseMiddle: 658, _MouseX1: 659, _MouseX2: 660, _MouseWheelX: 661, _MouseWheelY: 662, /** * Keyboard Modifiers (explicitly submitted by backend via AddKeyEvent() calls) * - Any functions taking a ImGuiKeyChord parameter can binary-or those with regular keys, e.g. Shortcut(ImGuiMod_Ctrl | ImGuiKey_S). * - Those are written back into io.KeyCtrl, io.KeyShift, io.KeyAlt, io.KeySuper for convenience, * but may be accessed via standard key API such as IsKeyPressed(), IsKeyReleased(), querying duration etc. * - Code polling every key (e.g. an interface to detect a key press for input mapping) might want to ignore those * and prefer using the real keys (e.g. ImGuiKey_LeftCtrl, ImGuiKey_RightCtrl instead of ImGuiMod_Ctrl). * - In theory the value of keyboard modifiers should be roughly equivalent to a logical or of the equivalent left/right keys. * In practice: it's complicated; mods are often provided from different sources. Keyboard layout, IME, sticky keys and * backends tend to interfere and break that equivalence. The safer decision is to relay that ambiguity down to the end-user... * - On macOS, we swap Cmd(Super) and Ctrl keys at the time of the io.AddKeyEvent() call. */ ImGuiMod_None: 0, /** * Ctrl (non-macOS), Cmd (macOS) */ ImGuiMod_Ctrl: 4096, /** * Shift */ ImGuiMod_Shift: 8192, /** * Option/Menu */ ImGuiMod_Alt: 16384, /** * Windows/Super (non-macOS), Ctrl (macOS) */ ImGuiMod_Super: 32768, }; /** * Flags for Shortcut(), SetNextItemShortcut(), * (and for upcoming extended versions of IsKeyPressed(), IsMouseClicked(), Shortcut(), SetKeyOwner(), SetItemKeyOwner() that are still in imgui_internal.h) * Don't mistake with ImGuiInputTextFlags! (which is for ImGui::InputText() function) */ export const ImGuiInputFlags = { None: 0, /** * Enable repeat. Return true on successive repeats. Default for legacy IsKeyPressed(). NOT Default for legacy IsMouseClicked(). MUST BE == 1. */ Repeat: 1, // Flags for Shortcut(), SetNextItemShortcut() // - Routing policies: RouteGlobal+OverActive >> RouteActive or RouteFocused (if owner is active item) >> RouteGlobal+OverFocused >> RouteFocused (if in focused window stack) >> RouteGlobal. // - Default policy is RouteFocused. Can select only 1 policy among all available. /** * Route to active item only. */ RouteActive: 1024, /** * Route to windows in the focus stack (DEFAULT). Deep-most focused window takes inputs. Active item takes inputs over deep-most focused window. */ RouteFocused: 2048, /** * Global route (unless a focused window or active item registered the route). */ RouteGlobal: 4096, /** * Do not register route, poll keys directly. */ RouteAlways: 8192, // - Routing options /** * Option: global route: higher priority than focused route (unless active item in focused route). */ RouteOverFocused: 16384, /** * Option: global route: higher priority than active item. Unlikely you need to use that: will interfere with every active items, e.g. Ctrl+A registered by InputText will be overridden by this. May not be fully honored as user/internal code is likely to always assume they can access keys when active. */ RouteOverActive: 32768, /** * Option: global route: will not be applied if underlying background/void is focused (== no Dear ImGui windows are focused). Useful for overlay applications. */ RouteUnlessBgFocused: 65536, /** * Option: route evaluated from the point of view of root window rather than current window. */ RouteFromRootWindow: 131072, // Flags for SetNextItemShortcut() /** * Automatically display a tooltip when hovering item [BETA] Unsure of right api (opt-in/opt-out) */ Tooltip: 262144, }; /** * Configuration flags stored in io.ConfigFlags. Set by user/application. * Note that nowadays most of our configuration options are in other ImGuiIO fields, e.g. io.ConfigWindowsMoveFromTitleBarOnly. */ export const ImGuiConfigFlags = { None: 0, /** * Master keyboard navigation enable flag. Enable full Tabbing + directional arrows + Space/Enter to activate. Note: some features such as basic Tabbing and CtrL+Tab are enabled by regardless of this flag (and may be disabled via other means, see #4828, #9218). */ NavEnableKeyboard: 1, /** * Master gamepad navigation enable flag. Backend also needs to set ImGuiBackendFlags_HasGamepad. */ NavEnableGamepad: 2, /** * Instruct dear imgui to disable mouse inputs and interactions. */ NoMouse: 16, /** * Instruct backend to not alter mouse cursor shape and visibility. Use if the backend cursor changes are interfering with yours and you don't want to use SetMouseCursor() to change mouse cursor. You may want to honor requests from imgui by reading GetMouseCursor() yourself instead. */ NoMouseCursorChange: 32, /** * Instruct dear imgui to disable keyboard inputs and interactions. This is done by ignoring keyboard events and clearing existing states. */ NoKeyboard: 64, // [BETA] Docking /** * Docking enable flags. */ DockingEnable: 128, // [BETA] Viewports // When using viewports it is recommended that your default value for ImGuiCol_WindowBg is opaque (Alpha=1.0) so transition to a viewport won't be noticeable. /** * Viewport enable flags (require both ImGuiBackendFlags_PlatformHasViewports + ImGuiBackendFlags_RendererHasViewports set by the respective backends) */ ViewportsEnable: 1024, // [Unused] User storage (to allow your backend/engine to communicate to code that may be shared between multiple projects. Those flags are NOT used by core Dear ImGui) /** * Application is SRGB-aware. */ IsSRGB: 1048576, /** * Application is using a touch screen instead of a mouse. */ IsTouchScreen: 2097152, }; /** * Backend capabilities flags stored in io.BackendFlags. Set by imgui_impl_xxx or custom backend. */ export const ImGuiBackendFlags = { None: 0, /** * Backend Platform supports gamepad and currently has one connected. */ HasGamepad: 1, /** * Backend Platform supports honoring GetMouseCursor() value to change the OS cursor shape. */ HasMouseCursors: 2, /** * Backend Platform supports io.WantSetMousePos requests to reposition the OS mouse position (only used if io.ConfigNavMoveSetMousePos is set). */ HasSetMousePos: 4, /** * Backend Renderer supports ImDrawCmd::VtxOffset. This enables output of large meshes (64K+ vertices) while still using 16-bit indices. */ RendererHasVtxOffset: 8, /** * Backend Renderer supports ImTextureData requests to create/update/destroy textures. This enables incremental texture updates and texture reloads. See https://github.com/ocornut/imgui/blob/master/docs/BACKENDS.md for instructions on how to upgrade your custom backend. */ RendererHasTextures: 16, // [BETA] Multi-Viewports /** * Backend Renderer supports multiple viewports. */ RendererHasViewports: 1024, /** * Backend Platform supports multiple viewports. */ PlatformHasViewports: 2048, /** * Backend Platform supports calling io.AddMouseViewportEvent() with the viewport under the mouse. IF POSSIBLE, ignore viewports with the ImGuiViewportFlags_NoInputs flag (Win32 backend, GLFW 3.30+ backend can do this, SDL backend cannot). If this cannot be done, Dear ImGui needs to use a flawed heuristic to find the viewport under. */ HasMouseHoveredViewport: 4096, /** * Backend Platform supports honoring viewport->ParentViewport/ParentViewportId value, by applying the corresponding parent/child relationship at the Platform level. Child windows always appear in front of their parent window. */ HasParentViewport: 8192, }; /** * Enumeration for PushStyleColor() / PopStyleColor() */ export const ImGuiCol = { Text: 0, TextDisabled: 1, /** * Background of normal windows */ WindowBg: 2, /** * Background of child windows */ ChildBg: 3, /** * Background of popups, menus, tooltips windows */ PopupBg: 4, Border: 5, BorderShadow: 6, /** * Background of checkbox, radio button, plot,