8.18.1.23. Flat tooltips
The container form tooltip(IDENT) { ... } (already in v1) wraps a full
layout scope — useful when the tooltip needs nested widgets or its own
state. For one-liner annotations that just need one line of text on a
hovered item, v2 ships two flat-form rails that fire without opening a
scope:
set_tooltip(IDENT, (text = ...))— always shows; rare in practice, shown for completeness.set_item_tooltip(IDENT, (text = ...))— shows when the most-recently-submitted item is hovered. The canonical replacement for the imgui_demoHelpMarkerhelper.
if (button(SAVE_BTN, (text = "Save"))) { /* ... */ }
set_item_tooltip(SAVE_TIP, (text = "Persists current state to disk."))
Chain them one per row — the tooltip attaches to whatever was just submitted. No layout scope, no extra widgets, no nested block.
Source: modules/dasImgui/examples/tutorial/flat_tooltips.das.
8.18.1.23.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_visual_aids
18
19// =============================================================================
20// TUTORIAL: flat_tooltips — boost v2 flat-form tooltip widgets.
21//
22// The container form `tooltip(IDENT) { ... }` (already in v1) wraps a full
23// scope. For one-liner tooltips with no inner layout, use the flat forms:
24//
25// set_tooltip(IDENT, (text = ...)) — always shows; rare
26// set_item_tooltip(IDENT, (text = ...)) — shows when previous item hovered
27//
28// set_item_tooltip is the canonical replacement for the imgui_demo HelpMarker
29// idiom (call after the widget you want to annotate).
30//
31// STANDALONE: daslang.exe modules/dasImgui/examples/tutorial/flat_tooltips.das
32// LIVE: daslang-live modules/dasImgui/examples/tutorial/flat_tooltips.das
33// =============================================================================
34
35[export]
36def init() {
37 live_create_window("dasImgui flat tooltips", 720, 420)
38 live_imgui_init(live_window)
39 let io & = unsafe(GetIO())
40 GetStyle().FontScaleMain = 1.4
41}
42
43[export]
44def update() {
45 if (!live_begin_frame()) return
46 begin_frame()
47
48 ImGui_ImplGlfw_NewFrame()
49 apply_synth_io_override()
50 NewFrame()
51
52 SetNextWindowPos(ImVec2(60.0, 60.0), ImGuiCond.Always)
53 SetNextWindowSize(ImVec2(600.0, 300.0), ImGuiCond.Always)
54 window(TOOLTIP_WIN, (text = "Flat tooltips", closable = false,
55 flags = ImGuiWindowFlags.None)) {
56 text("Hover the buttons - tooltips fire on item hover.")
57
58 // set_item_tooltip — fires on the most-recently-submitted item.
59 if (button(SAVE_BTN, (text = "Save"))) {
60 print("save\n")
61 }
62 set_item_tooltip(SAVE_TIP, (text = "Persists current state to disk."))
63
64 spacing(SP_BTNS)
65
66 if (button(LOAD_BTN, (text = "Load"))) {
67 print("load\n")
68 }
69 set_item_tooltip(LOAD_TIP, (text = "Restores the last saved state."))
70
71 spacing(SP_HELP)
72
73 // Classic "(?)" disabled marker + item_tooltip — replaces the old
74 // HelpMarker / demo_help_marker helpers in v1 imgui_demo.
75 text("Verbose option (with help marker):")
76 same_line(SL_HINT)
77 text_disabled(HELP_GLYPH, (text = "(?)"))
78 set_item_tooltip(HELP_TIP, (text = "The imgui_demo HelpMarker idiom, in two lines."))
79 }
80
81 end_of_frame()
82 Render()
83 var w, h : int
84 live_get_framebuffer_size(w, h)
85 glViewport(0, 0, w, h)
86 glClearColor(0.10f, 0.10f, 0.12f, 1.0f)
87 glClear(GL_COLOR_BUFFER_BIT)
88 live_imgui_render()
89
90 live_end_frame()
91}
92
93[export]
94def shutdown() {
95 live_imgui_shutdown()
96 live_destroy_window()
97}
98
99[export]
100def main() {
101 init()
102 while (!exit_requested()) {
103 update()
104 }
105 shutdown()
106}
8.18.1.23.1.1. Requires
Baseline boost layer — both rails live in imgui/imgui_boost_v2.
8.18.1.23.1.2. set_item_tooltip vs the container form
tooltip(IDENT) { ... } is still the right tool when:
The tooltip body needs nested widgets — separators, colored text, inline checkboxes, indented bullets.
The hover bool is computed at the call site and you want a custom block to fire only on certain conditions.
set_item_tooltip is the right tool when:
You want exactly one line of text on hover.
The tooltip is purely informational (no nested layout).
You want to chain many of them — one per button, slider, etc.
8.18.1.23.1.3. The HelpMarker pattern
The imgui_demo’s HelpMarker(...) helper renders a disabled (?)
glyph and shows a tooltip on hover. v2 replaces it with two source lines:
text("Verbose option (with help marker):")
same_line(SL_HINT)
text_disabled(HELP_GLYPH, (text = "(?)"))
set_item_tooltip(HELP_TIP, (text = "short explanation here"))
The text_disabled(HELP_GLYPH, ...) renders the dim glyph;
set_item_tooltip attaches the tooltip to that disabled-text item. No
helper function, no extra abstraction — just two boost rails composed.
8.18.1.23.1.4. Standalone vs live
Same convention as the other widget tutorials: daslang for standalone
or daslang-live for live-reload + telemetry. set_item_tooltip’s
state struct (NarrativeState) carries the text string into the
snapshot for downstream playwright tests.
See also
Full source: modules/dasImgui/examples/tutorial/flat_tooltips.das
Integration test: modules/dasImgui/tests/test_tooltip_flat.das.
Boost macros — the macro layer.