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

Function draw_status_bar

src/host/ui/panels/status_bar.cpp:111–195  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109} // namespace
110
111void draw_status_bar(const UiState& ui,
112 const BufferModel& model,
113 StageManager& stages,
114 const GlfwCanvas& canvas) {
115 std::string line;
116 if (!ui.has_selection()) {
117 line = "no buffer";
118 } else {
119 const std::size_t sel = ui.selected();
120 const BufferRecord& rec = model.at(sel);
121
122 oid::Stage* stage = stages.selected_stage(sel);
123
124 // Negative sentinel: the Stage failed to initialize, or its camera
125 // GameObject/component isn't set up yet, so zoom isn't known this
126 // frame.
127 float zoom_pct = -1.0f;
128 if (stage != nullptr) {
129 if (const oid::Camera* cam = camera_of(*stage); cam != nullptr) {
130 zoom_pct = cam->compute_zoom() * 100.0f;
131 }
132 }
133
134 line = std::format("{} [{}x{}] {}",
135 rec.display_name,
136 rec.width,
137 rec.height,
138 type_label(rec.type, rec.channels));
139 if (zoom_pct >= 0.0f) {
140 line +=
141 std::format(" zoom: {}%", static_cast<int>(zoom_pct + 0.5f));
142 }
143
144 // Pixel value under the (last-hovered) cursor — Qt parity with
145 // MainWindow::update_status_bar in the legacy Qt frontend (see tag
146 // legacy-qt) minus its second zoom readout: this bar already shows
147 // one above.
148 // mouse_x()/mouse_y() persist the last hover position
149 // (main.cpp only feeds them while the canvas is hovered), so
150 // the readout persists after the cursor leaves the canvas, exactly
151 // like Qt's QLabel.
152 if (stage != nullptr) {
153 if (const oid::Buffer* buffer = buffer_of(*stage);
154 buffer != nullptr) {
155 const auto coords =
156 stage_coordinates(*stage,
157 static_cast<float>(canvas.mouse_x()),
158 static_cast<float>(canvas.mouse_y()),
159 canvas.render_width(),
160 canvas.render_height());
161 if (coords.has_value()) {
162 const auto px = static_cast<int>(std::floor(coords->x()));
163 const auto py = static_cast<int>(std::floor(coords->y()));
164 auto pixel = std::stringstream{};
165 // Qt set fixed/setprecision(3) on its status stream
166 // (the legacy Qt frontend; see tag legacy-qt) and that
167 // stream state governs how
168 // get_pixel_info() prints float channels — replicate it or

Callers 1

mainFunction · 0.85

Calls 15

camera_ofFunction · 0.85
type_labelFunction · 0.85
buffer_ofFunction · 0.85
stage_coordinatesFunction · 0.85
values_ofFunction · 0.85
has_selectionMethod · 0.80
selectedMethod · 0.80
selected_stageMethod · 0.80
compute_zoomMethod · 0.80
mouse_xMethod · 0.80
mouse_yMethod · 0.80
render_widthMethod · 0.80

Tested by

no test coverage detected