MCPcopy Create free account
hub / github.com/OpenImageDebugger/OpenImageDebugger / draw_toolbar

Function draw_toolbar

src/host/ui/panels/toolbar_panel.cpp:144–295  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

142} // namespace
143
144void draw_toolbar(UiState& ui,
145 StageManager& stages,
146 const BufferModel& model,
147 bool& goto_open) {
148 const bool has_selection = ui.has_selection();
149
150 // Auto-contrast is global UI state. Sync the selected Stage to it every
151 // frame (not only on click): a Stage's own contrast flag defaults to off
152 // and is otherwise never told about the toggle, so without this the
153 // toggle and the actual render disagree at startup and after buffer
154 // switches / newly-created Stages. AC is global, so syncing the currently
155 // displayed Stage is sufficient -- any buffer shows the toggle's state
156 // when viewed.
157 if (oid::Stage* s = stages.selected_stage(ui.selected()); s != nullptr) {
158 s->set_contrast_enabled(ui.contrast_enabled());
159 }
160
161 // 1. acEdit: shows/hides the min/max intensity editor (contrast panel).
162 // Plain UI-state toggle -- not gated on selection.
163 {
164 bool ac_editor_visible = ui.ac_editor_visible();
165 if (icon_button(kIconAcEdit,
166 "Toggle min and max intensity editor",
167 &ac_editor_visible)) {
168 ui.set_ac_editor_visible(!ui.ac_editor_visible());
169 }
170 }
171 ImGui::SameLine();
172
173 // 2. acToggle: enables/disables contrast modifications. Plain UI-state
174 // toggle -- not gated on selection.
175 {
176 bool contrast_enabled = ui.contrast_enabled();
177 if (icon_button(kIconAcToggle,
178 "Toggle Contrast Modifications",
179 &contrast_enabled)) {
180 ui.set_contrast_enabled(!ui.contrast_enabled());
181 }
182 }
183 ImGui::SameLine();
184
185 ImGui::BeginDisabled(!has_selection);
186
187 // 3. reposition_buffer (recenter). Gated on selection.
188 if (icon_button(kIconRecenter, "Reposition buffer to fit window")) {
189 for_each_target(ui, stages, model, [](oid::Stage& s) {
190 if (oid::Camera* cam = camera_of(s); cam != nullptr) {
191 cam->recenter_camera();
192 }
193 });
194 }
195 ImGui::SameLine();
196
197 ImGui::EndDisabled();
198
199 // 4. linkViewsToggle. Plain UI-state toggle -- not gated on selection.
200 {
201 bool link_views = ui.link_views();

Callers 1

mainFunction · 0.85

Calls 15

icon_buttonFunction · 0.85
for_each_targetFunction · 0.85
camera_ofFunction · 0.85
buffer_ofFunction · 0.85
values_ofFunction · 0.85
current_format_indexFunction · 0.85
apply_formatFunction · 0.85
has_selectionMethod · 0.80
selected_stageMethod · 0.80
selectedMethod · 0.80
contrast_enabledMethod · 0.80
ac_editor_visibleMethod · 0.80

Tested by

no test coverage detected