Item flags

Dear ImGui 1.92 split the private item flags into their own ImGuiItemFlagsPrivate enum and unified the per-item flag push onto PushItemFlag(flag, enabled) (the old PushButtonRepeat / PushTabStop are gone). dasImgui wraps that as the with_item_flag scope guard:

with_item_flag(ImGuiItemFlags.None | ImGuiItemFlagsPrivate.MixedValue, true) {
    checkbox(CB_MIXED, (text = "drawn as a tri-state dash"))
}

Because a private flag and a public flag are different enum types, imgui/imgui_enums supplies cross-enum | operators so they combine into a single ImGuiItemFlags in one push:

with_item_flag(ImGuiItemFlagsPrivate.ReadOnly | ImGuiItemFlags.NoNav, true) {
    slider_float(SL_RO, (text = "read-only, skipped by nav"))
}

The three public flags that already have dedicated wrappers — with_disabled, with_button_repeat, with_tab_stop — should use those; with_item_flag is for the flags without a named guard.

Source: examples/tutorial/item_flags.das.

Walkthrough

  1options gen2
  2
  3require imgui
  4require imgui_app
  5require opengl/opengl_boost
  6require live/glfw_live
  7require live/live_api
  8require live/live_commands
  9require live/live_vars
 10require live_host
 11require imgui/imgui_live
 12require imgui/imgui_boost_runtime
 13require imgui/imgui_boost_v2
 14require imgui/imgui_widgets_builtin
 15require imgui/imgui_containers_builtin
 16require imgui/imgui_scope_builtin
 17require imgui/imgui_enums
 18require imgui/imgui_visual_aids
 19
 20// =============================================================================
 21// TUTORIAL: item_flags — the imgui 1.92 item-flag stack via with_item_flag.
 22//
 23// 1.92 split the private item flags into their own ImGuiItemFlagsPrivate enum,
 24// and replaced PushButtonRepeat / PushTabStop with the unified
 25// PushItemFlag(flag, enabled). The boost layer wraps that as with_item_flag,
 26// and imgui/imgui_enums supplies cross-enum `|` operators so a private flag
 27// combines with a public one in a single push:
 28//
 29//   with_item_flag(ImGuiItemFlags.None | ImGuiItemFlagsPrivate.MixedValue, true) { ... }
 30//   with_item_flag(ImGuiItemFlagsPrivate.ReadOnly | ImGuiItemFlags.NoNav, true) { ... }
 31//
 32// (The dedicated guards with_disabled / with_button_repeat / with_tab_stop
 33// cover the three public flags that have their own wrappers.)
 34//
 35// STANDALONE: daslang.exe modules/dasImgui/examples/tutorial/item_flags.das
 36// LIVE:       daslang-live modules/dasImgui/examples/tutorial/item_flags.das
 37// =============================================================================
 38
 39[export]
 40def init() {
 41    live_create_window("dasImgui item_flags tutorial", 820, 560)
 42    live_imgui_init(live_window)
 43    let io & = unsafe(GetIO())
 44    GetStyle().FontScaleMain = 1.3
 45}
 46
 47[export]
 48def update() {
 49    if (!live_begin_frame()) return
 50    begin_frame()
 51
 52    ImGui_ImplGlfw_NewFrame()
 53    apply_synth_io_override()
 54    NewFrame()
 55
 56    SetNextWindowPos(ImVec2(40.0f, 40.0f), ImGuiCond.Always)
 57    SetNextWindowSize(ImVec2(740.0f, 480.0f), ImGuiCond.Always)
 58    window(IF_WIN, (text = "item_flags", closable = false,
 59                    flags = ImGuiWindowFlags.None)) {
 60        text("with_item_flag pushes an ImGuiItemFlags for the wrapped block.")
 61        separator()
 62
 63        // MixedValue — draws a checkbox as the indeterminate tri-state dash,
 64        // independent of its real checked state.
 65        text("MixedValue (tri-state dash):")
 66        checkbox(CB_PLAIN, (text = "plain checkbox"))
 67        with_item_flag(ImGuiItemFlags.None | ImGuiItemFlagsPrivate.MixedValue, true) {
 68            checkbox(CB_MIXED, (text = "same checkbox, drawn as a dash"))
 69        }
 70        separator()
 71
 72        // ReadOnly | NoNav — a private flag and a public flag combined in one
 73        // push via the cross-enum `|` from imgui/imgui_enums.
 74        text("ReadOnly | NoNav (private + public flag, one push):")
 75        slider_float(SL_RW, (text = "editable"))
 76        with_item_flag(ImGuiItemFlagsPrivate.ReadOnly | ImGuiItemFlags.NoNav, true) {
 77            slider_float(SL_RO, (text = "read-only, skipped by nav"))
 78        }
 79        separator()
 80
 81        // AllowOverlap — the wide button yields hover to a later widget drawn
 82        // on top of it instead of swallowing the overlap.
 83        text("AllowOverlap (small button sits on top of the wide one):")
 84        let p = GetCursorScreenPos()
 85        with_item_flag(ImGuiItemFlags.None | ImGuiItemFlagsPrivate.AllowOverlap, true) {
 86            button(OVL_UNDER, (text = "wide button underneath", size = float2(320.0f, 36.0f)))
 87        }
 88        SetCursorScreenPos(p)
 89        small_button(OVL_OVER, (text = "on top"))
 90    }
 91
 92    end_of_frame()
 93    Render()
 94    var w, h : int
 95    live_get_framebuffer_size(w, h)
 96    glViewport(0, 0, w, h)
 97    glClearColor(0.10f, 0.10f, 0.12f, 1.0f)
 98    glClear(GL_COLOR_BUFFER_BIT)
 99    live_imgui_render()
100
101    live_end_frame()
102}
103
104[export]
105def shutdown() {
106    live_imgui_shutdown()
107    live_destroy_window()
108}
109
110[export]
111def main() {
112    init()
113    while (!exit_requested()) {
114        update()
115    }
116    shutdown()
117}

Requires

with_item_flag is in imgui/imgui_scope_builtin; the cross-enum | operators and ImGuiItemFlagsPrivate come from imgui/imgui_enums (both re-exported by imgui/imgui_boost_v2).

Behaviour

  • MixedValue — draws a checkbox as the indeterminate dash regardless of its real checked state (the classic tri-state look).

  • ReadOnly (private) | NoNav (public) — the slider ignores drags and is skipped by keyboard / gamepad navigation; the two flags are pushed together via the cross-enum operator.

  • AllowOverlap — the wide button yields hover to a later widget drawn on top of it instead of swallowing the overlap.

The flag scope follows the block exactly: PushItemFlag on entry, PopItemFlag on exit, so siblings outside the block are unaffected.

See also

Full source: examples/tutorial/item_flags.das

Feature smoke: examples/features/internal_item_flag.das.

Boost macros — the macro layer.