ui: the readouts show in a strip under the plot when the dock is hidden

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Martino FerrariandClaude Sonnet 4.6 committed 2026-11-03 10:47:11 +01:00
1 parent 54f2722fea
commit c8d9d04f59
7 files changed
+282 -22

No files matched your search

+88
View File
@@ -4337,6 +4337,90 @@ static int dock_width_fits(App& a, int* dock_w, int* side_w) {
return *dock_w >= 0 && *side_w > 0 && *dock_w <= *side_w ? 1 : 0;
}
/// The readouts strip against the dock it mirrors: `same_text=1` when every strip label's text equals the
/// dock's (the cursors' `who` and delta cells, the measurements' values) and the counts agree. `visible` must
/// be the opposite of `dock_shown` (`show-sidebar`), and `h` the strip's fixed 26 whenever it is visible.
/// `sens_same` is the strip's cursor chips sharing the dock grid's sensitivity.
static void strip_report(App& a, const char* tag, const char* what) {
const auto text = [](GtkWidget* w) { return std::string(gtk_label_get_text(GTK_LABEL(w))); };
int same = a.strip_cursor_deltas.size() == a.dock_cursor_lines.size() &&
a.strip_cursor_who.size() == a.dock_cursor_lines.size() &&
a.strip_measure_labels.size() == a.dock_measure_labels.size()
? 1 : 0;
for (std::size_t i = 0; same != 0 && i < a.dock_cursor_lines.size(); ++i) {
if (text(a.strip_cursor_deltas[i]) != text(a.dock_cursor_lines[i].d) ||
text(a.strip_cursor_who[i]) != text(a.dock_cursor_lines[i].label)) {
same = 0;
}
}
for (std::size_t i = 0; same != 0 && i < a.dock_measure_labels.size(); ++i) {
if (text(a.strip_measure_labels[i]) != text(a.dock_measure_labels[i])) same = 0;
}
const bool dock_shown =
a.side_view != nullptr &&
adw_overlay_split_view_get_show_sidebar(ADW_OVERLAY_SPLIT_VIEW(a.side_view)) != FALSE;
const bool visible = a.readouts_strip != nullptr && gtk_widget_get_visible(a.readouts_strip);
const bool collapsed =
a.side_view != nullptr &&
adw_overlay_split_view_get_collapsed(ADW_OVERLAY_SPLIT_VIEW(a.side_view)) != FALSE;
const bool sens_same =
a.strip_cursor_box != nullptr && a.dock_cursor_grid != nullptr &&
gtk_widget_get_sensitive(a.strip_cursor_box) == gtk_widget_get_sensitive(a.dock_cursor_grid);
std::fprintf(stderr,
"[%s-probe] %-14s strip: visible=%d dock_shown=%d cursors=%zu measures=%zu same_text=%d "
"h=%d sens_same=%d collapsed=%d window=%d\n",
tag, what, visible ? 1 : 0, dock_shown ? 1 : 0, a.strip_cursor_deltas.size(),
a.strip_measure_labels.size(), same, a.readouts_strip != nullptr
? gtk_widget_get_height(a.readouts_strip) : -1,
sens_same ? 1 : 0, collapsed ? 1 : 0,
a.window != nullptr ? gtk_widget_get_width(a.window) : -1);
}
/// Puts the dock away through the wish the tick re-asserts and reads the strip with it hidden
/// (`<tag>-probe ... strip:`: visible must be 1, h 26, same_text 1), then restores the wish and reads it
/// again (visible must be 0). Under `xvfb-run` the window is 756 px wide, below `kSidebarRoom`, so the split
/// view is `collapsed` on every line: both legs are the collapsed case (the tick keeps a wished dock
/// overlaid, a hidden one off), and `collapsed=0` is not reachable from a probe -- a window with no
/// manager cannot be resized by `gtk_window_set_default_size()`.
struct StripDrive {
App* app;
const char* tag;
int step;
};
static gboolean strip_drive_step(gpointer user) {
auto* d = static_cast<StripDrive*>(user);
App& a = *d->app;
if (a.window == nullptr) {
delete d;
return G_SOURCE_REMOVE;
}
switch (d->step) {
case 0:
a.sidebar_wanted = false;
update_side_visibility(a);
break;
case 1:
strip_report(a, d->tag, "dock hidden");
a.sidebar_wanted = true;
update_side_visibility(a);
break;
default:
strip_report(a, d->tag, "dock restored");
std::fflush(stderr);
delete d;
return G_SOURCE_REMOVE;
}
std::fflush(stderr);
++d->step;
g_timeout_add(600, strip_drive_step, d);
return G_SOURCE_REMOVE;
}
static void strip_drive(App& a, const char* tag) {
g_timeout_add(100, strip_drive_step, new StripDrive{&a, tag, 0});
}
static void dock_cursors_report(App& a, const char* what) {
int same = a.dock_cursor_lines.size() == a.cursors_lines.size() ? 1 : 0;
for (std::size_t i = 0; same != 0 && i < a.cursors_lines.size(); ++i) {
@@ -4356,6 +4440,7 @@ static void dock_cursors_report(App& a, const char* what) {
"side_w=%d fits=%d dock_sensitive=%d\n",
what, a.dock_cursor_lines.size(), a.cursors_lines.size(), same, dock_w, side_w, fits,
a.dock_cursor_grid != nullptr && gtk_widget_get_sensitive(a.dock_cursor_grid) ? 1 : 0);
strip_report(a, "cursors", what);
}
static void dock_measures_report(App& a, const char* what) {
@@ -4374,6 +4459,7 @@ static void dock_measures_report(App& a, const char* what) {
"side_w=%d fits=%d\n",
what, a.dock_measure_labels.size(), a.measure_labels.size(), same, dock_w, side_w,
fits);
strip_report(a, "measures", what);
}
void cursors_probe_report(App& a, const char* what) {
@@ -4646,6 +4732,7 @@ gboolean cursors_probe_step(gpointer user) {
}
default:
cursors_probe_report(*a, "after ruler drag");
strip_drive(*a, "cursors"); // the dock put away and the window narrowed, the strip read at each
break;
}
return G_SOURCE_REMOVE;
@@ -4758,6 +4845,7 @@ gboolean measures_probe_step(gpointer user) {
std::fflush(stderr);
measure_dialog_report(*a, "final");
dock_measures_report(*a, "final");
strip_drive(*a, "measures");
break;
}
}