diff --git a/src/ui.cpp b/src/ui.cpp index 8d08b3e..7ef4664 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -817,10 +817,17 @@ void apply_layout(App& app, const LayoutState& st) { apply_math_channels(app); app.measures = st.measures; app.measure_stats_on = st.measure_stats; + app.updating_panels = true; if (app.measures_stats_check != nullptr) { gtk_check_button_set_active(GTK_CHECK_BUTTON(app.measures_stats_check), app.measure_stats_on); } + // The toggled handler is guarded by updating_panels, so the Reset button's sensitivity + // and the stats-label visibility are set directly from the loaded state here; the labels' + // visibility is also set per-row inside rebuild_measures_pane via measures_row(). + if (app.measures_stats_reset != nullptr) + gtk_widget_set_sensitive(app.measures_stats_reset, app.measure_stats_on); + app.updating_panels = false; rebuild_measures_pane(app); int rows = static_cast(st.rows.size()); @@ -2615,8 +2622,9 @@ void update_measures(App& app, bool force); void open_measure_dialog(App& app, int edit_index); /// One pane row: the measurement's badge, its type, its value and an `edit` button. The value -/// label is the one widget `update_measures()` rewrites; everything else is rebuilt with the -/// list. +/// label and the statistics line below it are the two widgets `update_measures()` rewrites; +/// everything else is rebuilt with the list. The row is two visual lines so that the +/// statistics figures do not push the reading itself off a narrow pane. GtkWidget* measures_row(App& app, std::size_t index, const Measure& m) { // The row is two lines: the reading, and the statistics under it. A vertical wrapper // rather than more columns, because the statistics line is four figures wide and would @@ -2683,6 +2691,9 @@ GtkWidget* measures_row(App& app, std::size_t index, const Measure& m) { gtk_widget_set_halign(stats, GTK_ALIGN_END); gtk_widget_add_css_class(stats, "dim-label"); gtk_label_set_selectable(GTK_LABEL(stats), true); + // Ellipsize so the label's minimum width is bounded: without this, a long reading would + // widen the pane just as the `kind` label would without its own ellipsize. + gtk_label_set_ellipsize(GTK_LABEL(stats), PANGO_ELLIPSIZE_END); gtk_widget_set_tooltip_text(stats, "how this reading has varied since the last reset: the number " "of passes, the mean, the standard deviation, and the extremes"); @@ -5140,13 +5151,15 @@ GtkWidget* build_measures_panel(App& app) { g_signal_connect(app.measures_stats_check, "toggled", G_CALLBACK(+[](GtkCheckButton* b, gpointer user) { App* a = static_cast(user); + if (a->updating_panels) return; a->measure_stats_on = gtk_check_button_get_active(b); // Deliberately *not* a rebuild: that would reset the statistics the // user just asked to look at. The rows are already there and hidden. for (GtkWidget* w : a->measure_stats_labels) { if (w != nullptr) gtk_widget_set_visible(w, a->measure_stats_on); } - gtk_widget_set_sensitive(a->measures_stats_reset, a->measure_stats_on); + if (a->measures_stats_reset != nullptr) + gtk_widget_set_sensitive(a->measures_stats_reset, a->measure_stats_on); update_measures(*a, true); schedule_layout_save(*a); }),