ui: the readouts strip hides when there are no cursors or measurements

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Martino FerrariandClaude Sonnet 4.6 committed 2026-11-03 11:14:49 +01:00
1 parent 61d0925144
commit 5653a3a66b
5 files changed
+63 -25

No files matched your search

+32 -19
View File
@@ -154,17 +154,22 @@ void build_readouts_strip(App& app) {
clear_box(app.strip_box);
app.strip_cursor_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
app.strip_measure_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
gtk_box_append(GTK_BOX(app.strip_box),
// Each section is a group of its own so the strip can show only the one that has something to say.
app.strip_cursor_group = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
gtk_box_append(GTK_BOX(app.strip_cursor_group),
strip_button("Cursors", G_CALLBACK(on_edit_cursors), &app, "the cursors' full panel"));
gtk_box_append(GTK_BOX(app.strip_box), app.strip_cursor_box);
GtkWidget* sep = gtk_separator_new(GTK_ORIENTATION_VERTICAL);
gtk_widget_set_margin_top(sep, 5);
gtk_widget_set_margin_bottom(sep, 5);
gtk_box_append(GTK_BOX(app.strip_box), sep);
gtk_box_append(GTK_BOX(app.strip_box),
gtk_box_append(GTK_BOX(app.strip_cursor_group), app.strip_cursor_box);
app.strip_sep = gtk_separator_new(GTK_ORIENTATION_VERTICAL);
gtk_widget_set_margin_top(app.strip_sep, 5);
gtk_widget_set_margin_bottom(app.strip_sep, 5);
app.strip_measure_group = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
gtk_box_append(GTK_BOX(app.strip_measure_group),
strip_button("Measures", G_CALLBACK(on_edit_measures), &app,
"the measurements' full panel"));
gtk_box_append(GTK_BOX(app.strip_box), app.strip_measure_box);
gtk_box_append(GTK_BOX(app.strip_measure_group), app.strip_measure_box);
gtk_box_append(GTK_BOX(app.strip_box), app.strip_cursor_group);
gtk_box_append(GTK_BOX(app.strip_box), app.strip_sep);
gtk_box_append(GTK_BOX(app.strip_box), app.strip_measure_group);
}
} // namespace
@@ -264,12 +269,7 @@ void dock_rebuild_measures(App& app) {
gtk_widget_add_css_class(none, "caption");
gtk_widget_add_css_class(none, "dim-label");
gtk_box_append(GTK_BOX(app.dock_measures_box), none);
if (app.strip_measure_box != nullptr) {
GtkWidget* strip_none = gtk_label_new("no measurements");
gtk_widget_add_css_class(strip_none, "caption");
gtk_widget_add_css_class(strip_none, "dim-label");
gtk_box_append(GTK_BOX(app.strip_measure_box), strip_none);
}
// The strip has no placeholder: its Measures group is hidden while there are no measurements.
return;
}
for (std::size_t i = 0; i < app.measures.size(); ++i) {
@@ -351,12 +351,25 @@ void sync_readouts_strip(App& app) {
// open -- and is not a readout you can keep an eye on while looking at the trace. `collapsed` is the
// split view's value from the previous frame (the tick calls this before `set_collapsed()`), so the
// strip follows a collapse or a widening one tick late; `show-sidebar` is the wish just re-asserted.
//
// And only with something to read: a section is there when its feature is (cursors switched on,
// at least one measurement), and with neither the strip is gone -- it is a readout, not a control
// strip, and an empty line under the plot is 26 px of nothing. (The one place "hide" beats "disable":
// the dock keeps both blocks on screen, so the empty state is never invisible.)
AdwOverlaySplitView* split = ADW_OVERLAY_SPLIT_VIEW(app.side_view);
const bool want = !adw_overlay_split_view_get_show_sidebar(split) ||
adw_overlay_split_view_get_collapsed(split);
if ((gtk_widget_get_visible(app.readouts_strip) != FALSE) != want) {
gtk_widget_set_visible(app.readouts_strip, want);
}
const bool cursors = app.cursors_toggle != nullptr &&
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(app.cursors_toggle));
const bool measures = !app.measures.empty();
const bool want = (!adw_overlay_split_view_get_show_sidebar(split) ||
adw_overlay_split_view_get_collapsed(split)) &&
(cursors || measures);
auto show = [](GtkWidget* w, bool v) {
if (w != nullptr && (gtk_widget_get_visible(w) != FALSE) != v) gtk_widget_set_visible(w, v);
};
show(app.strip_cursor_group, cursors);
show(app.strip_measure_group, measures);
show(app.strip_sep, cursors && measures);
show(app.readouts_strip, want);
}
namespace {