8.18.1.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.18.1.55.1. Walkthrough

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

8.18.1.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.18.1.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.