Skip to main content
Module

x/dwm/ext/imgui.ts

Deno Window Manager: Cross-platform window creation and management
Go to Latest
import * as dwm from "https://deno.land/x/dwm@0.3.3/ext/imgui.ts";

Classes

Helper to manually clip large list of items

ImVec2: 2D vector used to store positions, sizes etc.

ImVec4: 4D vector used to store clipping rectangles, colors etc.

Functions

vertically align upcoming text baseline to FramePadding.y so that it will align properly to regularly framed items (call if you have text on a line before a framed item)

square button with an arrow shape

lock horizontal starting position

"bool* p_selected" point to the selection state (read-write), as a convenient helper.

draw a small circle + keep the cursor on the same line. advance cursor x position by GetTreeNodeToLabelSpacing(), same distance that TreeNode() uses

button

width of item given pushed settings and current cursor position. NOT necessarily the width of last item unlike most 'Item' functions.

checkbox

This is called by IMGUI_CHECKVERSION() macro.

add a dummy item of given size. unlike InvisibleButton(), Dummy() won't take the mouse click or be navigable into.

ends the Dear ImGui frame. automatically called by Render(). If you don't need to render data (skipping rendering) you may call EndFrame() without Render()... but you'll have wasted CPU already! If you don't need to render, better to not create any windows and not call NewFrame() at all!

unlock horizontal starting position + capture the whole group bounding box into one "item" (so you can use IsItemHovered() or layout primitives such as SameLine() on whole group, etc.)

== GetContentRegionMax() - GetCursorPos().

current content boundaries (typically window boundaries including scrolling, or current column boundaries), in windows coordinates.

cursor position in window coordinates (relative to window position)

cursor position in absolute coordinates (useful to work with ImDrawList API). generally top-left == GetMainViewport()->Pos == (0,0) in single viewport mode, and bottom-right == GetMainViewport()->Pos+Size == io.DisplaySize in single-viewport mode.

initial cursor position in window coordinates

valid after Render() and until the next call to NewFrame(). this is what you have to render.

FontSize + style.FramePadding.y * 2

FontSize + style.FramePadding.y * 2 + style.ItemSpacing.y (distance in pixels between 2 consecutive lines of framed widgets)

calculate unique ID (hash of whole ID stack + given parameter). e.g. if you want to query into ImGuiStorage yourself

access the IO structure (mouse/keyboard/gamepad inputs, time, various configuration options/flags)

get maximum scrolling amount ~~ ContentSize.x - WindowSize.x - DecorationsSize.x

get maximum scrolling amount ~~ ContentSize.y - WindowSize.y - DecorationsSize.y

get scrolling amount [0 .. GetScrollMaxX()]

get scrolling amount [0 .. GetScrollMaxY()]

access the Style structure (colors, sizes). Always use PushStyleCol(), PushStyleVar() to modify style mid-frame!

FontSize

FontSize + style.ItemSpacing.y (distance in pixels between 2 consecutive lines of text)

get the compiled version string e.g. "1.80 WIP" (essentially the value for IMGUI_VERSION from the compiled version of imgui.cpp)

content boundaries max for the full window (roughly (0,0)+Size-Scroll) where Size can be overridden with SetNextWindowContentSize(), in window coordinates.

content boundaries min for the full window (roughly (0,0)-Scroll), in window coordinates.

get DPI scale currently associated to the current window's viewport.

get draw list associated to the current window, to append your own drawing primitives

get current window height (shortcut for GetWindowSize().y)

get current window position in screen space (useful if you want to do your own drawing via the DrawList API).

get current window size.

get viewport currently associated to the current window.

get current window width (shortcut for GetWindowSize().x)

move content position toward the right, by indent_w, or style.IndentSpacing if indent_w <= 0

flexible button behavior without the visuals, frequently useful to build custom behaviors using the public api (along with IsItemActive, IsItemHovered, etc.)

is current window focused? or its root/child, depending on flags. see flags for options.

is current window hovered (and typically: not blocked by a popup/modal)? see flags for options. NB: If you are trying to check whether your mouse should be dispatched to imgui or to your app, you should use the 'io.WantCaptureMouse' boolean for that! Please read the FAQ!

call after CreateContext() and before the first call to NewFrame(). NewFrame() automatically calls LoadIniSettingsFromDisk(io.IniFilename).

call after CreateContext() and before the first call to NewFrame() to provide .ini data from your own data source. set ini_size to 0 if ini_data is a zero-terminated string.

start a new Dear ImGui frame, you can submit any command from this point until Render()/EndFrame().

undo a SameLine() or force a new line when in a horizontal-layout context.

pop from the ID stack.

== tab stop enable. Allow focusing using TAB/Shift-TAB, enabled by default but you can disable it for certain widgets

in 'repeat' mode, Button*() functions return repeated true in a typematic manner (using io.KeyRepeatDelay/io.KeyRepeatRate setting). Note that you can call IsItemActive() after any Button() to tell if the button is held in the current frame.

use NULL as a shortcut to push default font

push string into the ID stack (will hash id).

push width of items for common large "item+label" widgets. >0.0f: width in pixels.; <0.0f: align xx pixels to the right of window (so -FLT_MIN always align width to the right side).

modify a style color. always use this if you modify the style after NewFrame().

modify a style float variable. always use this if you modify the style after NewFrame().

push word-wrapping position for Text*() commands. <0.0f: no wrapping; 0.0f: wrap to end of window (or column); >0.0f: wrap at 'wrap_pos_x' position in window local space

ends the Dear ImGui frame, finalize the draw data. You can then get call GetDrawData().

call between widgets or groups to layout them horizontally. X position given in window coordinates.

this is automatically called (if io.IniFilename is not empty) a few seconds after any modification that should be reflected in the .ini file (and also by DestroyContext).

return a zero-terminated string with the .ini data which you can save by your own mean. call when io.WantSaveIniSettings is set, then save data by your own mean and clear io.WantSaveIniSettings.

"bool selected" carry the selection state (read-only). Selectable() is clicked is returns true so you can modify your selection state.

  • size.x==0.0: use remaining width.
  • size.x> 0.0: specify width.
  • size.y==0.0: use label height.
  • size.y> 0.0: specify height.

separator, generally horizontal. inside a menu bar or in horizontal layout mode, this becomes a vertical separator.

initialize current options (generally on application startup) if you want to select a default format, picker type, etc. User will be able to change many settings, unless you pass the _NoOptions flag to your calls.

cursor position in absolute coordinates

set width of the next common large "item+label" widget. >0.0f: width in pixels; <0.0f: align xx pixels to the right of window (so -FLT_MIN always align width to the right side).

set next window background color alpha. helper to easily override the Alpha component of ImGuiCol_WindowBg/ChildBg/PopupBg. you may also use ImGuiWindowFlags_NoBackground.

set next window collapsed state. call before Begin()

set next window content size (~ scrollable client area, which enforce the range of scrollbars). Not including window decorations (title bar, menu bar, etc.) nor WindowPadding. set an axis to 0.0f to leave it automatic. call before Begin()

set next window to be focused / top-most. call before Begin()

set next window position. call before Begin(). use pivot=(0.5f,0.5f) to center on given point, etc.

set next window scrolling value (use < 0.0f to not affect a given axis).

set next window size. set axis to 0.0f to force an auto-fit on this axis. call before Begin()

set next window viewport

adjust scrolling amount to make given position visible. Generally GetCursorStartPos() + offset to compute a valid position.

adjust scrolling amount to make given position visible. Generally GetCursorStartPos() + offset to compute a valid position.

adjust scrolling amount to make current cursor position visible. center_x_ratio=0.0: left, 0.5: center, 1.0: right. When using to make a "default/current item" visible, consider using SetItemDefaultFocus() instead.

adjust scrolling amount to make current cursor position visible. center_x_ratio=0.0: left, 0.5: center, 1.0: right. When using to make a "default/current item" visible, consider using SetItemDefaultFocus() instead.

set scrolling amount [0 .. GetScrollMaxX()]

set scrolling amount [0 .. GetScrollMaxY()]

set named window collapsed state

set named window to be focused / top-most. pass undefined or empty string to remove focus.

set named window position.

set named window size. set axis to 0.0f to force an auto-fit on this axis.

create About window. display Dear ImGui version, credits and build/system information.

create Debug Log window. display a simplified log of important dear imgui events.

create Demo window. demonstrate most ImGui features. call this to learn about the library! try to make it always available in your application!

add font selector block (not a window), essentially a combo listing the loaded fonts.

create Metrics/Debugger window. display Dear ImGui internals: windows, draw commands, various internal state, etc.

create Stack Tool window. hover items with mouse to query information about the source of their unique ID.

add style editor block (not a window). you can pass in a reference ImGuiStyle structure to compare to, revert to and save to (else it uses the default style)

add style selector block (not a window), essentially a combo listing the default styles.

add basic help/info block (not a window): how to manipulate ImGui as an end-user (mouse/keyboard controls).

button with FramePadding=(0,0) to easily embed within text

add vertical spacing.

classic imgui style

new, recommended style (default)

best used with borders and a custom, thicker font

move content position back to the left, by indent_w, or style.IndentSpacing if indent_w <= 0

vertical silder

vertical silder

Type Aliases

Temporary storage to output draw commands out of order, used by ImDrawListSplitter and ImDrawList::ChannelsSplit()

A single draw command within a parent ImDrawList (generally maps to 1 GPU draw call, unless it is a callback)

All draw command lists required to render the frame + pos/size coordinates to use for the projection matrix.

A single draw command list (generally one per window, conceptually you may see this as a dynamic "mesh" builder)

Data shared among multiple draw lists (typically owned by parent ImGui context, but you may create one yourself)

Helper to split a draw list into different layers which can be drawn into out of order, then flattened back.

A single vertex (pos + uv + col = 20 bytes by default. Override layout with IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT)

Runtime data for a single font within a parent ImFontAtlas

Opaque interface to a font builder (stb_truetype or FreeType).

Configuration data when adding a font or merging fonts

A single font glyph (code point + coordinates within in ImFontAtlas + offset)

Helper to build glyph ranges from text/string data

Dear ImGui context (opaque structure, unless including imgui_internal.h)

A unique ID used by widgets (typically the result of hashing a stack of string)

Storage for ImGuiIO and IsKeyDown(), IsKeyPressed() etc functions.

Helper for running a block of code not more than once a frame

User data payload for drag and drop operations

Platform IME data for io.SetPlatformImeDataFn() function.

Multi-viewport support: interface for Platform/Renderer backends + viewports to render

Multi-viewport support: user-provided bounds for each connected monitor/display. Used when positioning popups and tooltips to avoid them straddling monitors

Callback data when using SetNextWindowSizeConstraints() (rare/advanced use)

Helper for key->value storage

Sorting specification for one column of a table

Sorting specifications for a table (often handling sort specs for a single column, occasionally more)

Helper to hold and append into a text buffer (~string builder)

Helper to parse and apply text filters (e.g. "aaaaa[,bbbbb][,ccccc]")

A Platform Window (always 1 unless multi-viewport are enabled. One per platform window to output to). In the future may represent Platform Monitor

Window class (rare/advanced uses: provide hints to the platform backend via altered viewport flags and parent/child info)

often used to store packed colors