8.19.55. 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: modules/dasImgui/examples/tutorial/item_flags.das.

8.19.55.1. Walkthrough

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

8.19.55.1.1. 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).

8.19.55.1.2. 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: modules/dasImgui/examples/tutorial/item_flags.das

Feature smoke: modules/dasImgui/examples/features/internal_item_flag.das.

Boost macros — the macro layer.