ui: compact cursor and measurement readouts at the top of the dock
Both views are written from the same variable at the same call site, so the dock cannot disagree with the full panels. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
a7a1609d48
commit
a0fc0762d5
7 files changed
+350
-22
No files matched your search
@@ -4339,6 +4339,53 @@ gboolean exit_probe_step1(gpointer user) {
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
/// The dock's readouts against the pages they copy: every dock label's text must equal the page
|
||||
/// label's (they are written from the same variable), and the Readouts box must fit the sidebar.
|
||||
static int dock_width_fits(App& a, int* dock_w, int* side_w) {
|
||||
*dock_w = a.dock_readouts != nullptr ? gtk_widget_get_width(a.dock_readouts) : -1;
|
||||
*side_w = a.dock_scroller != nullptr ? gtk_widget_get_width(a.dock_scroller) : -1;
|
||||
return *dock_w >= 0 && *side_w > 0 && *dock_w <= *side_w ? 1 : 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) {
|
||||
const App::CursorLine& p = a.cursors_lines[i];
|
||||
const App::DockCursorLine& d = a.dock_cursor_lines[i];
|
||||
const auto text = [](GtkWidget* w) { return std::string(gtk_label_get_text(GTK_LABEL(w))); };
|
||||
if (text(p.label) != text(d.label) || text(p.a) != text(d.a) || text(p.b) != text(d.b) ||
|
||||
text(p.d) != text(d.d)) {
|
||||
same = 0;
|
||||
}
|
||||
}
|
||||
int dock_w = 0;
|
||||
int side_w = 0;
|
||||
const int fits = dock_width_fits(a, &dock_w, &side_w);
|
||||
std::fprintf(stderr,
|
||||
"[cursors-probe] %-14s dock cursors: lines=%zu page_lines=%zu same_text=%d dock_w=%d "
|
||||
"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);
|
||||
}
|
||||
|
||||
static void dock_measures_report(App& a, const char* what) {
|
||||
int same = a.dock_measure_labels.size() == a.measure_labels.size() ? 1 : 0;
|
||||
for (std::size_t i = 0; same != 0 && i < a.measure_labels.size(); ++i) {
|
||||
if (std::strcmp(gtk_label_get_text(GTK_LABEL(a.measure_labels[i])),
|
||||
gtk_label_get_text(GTK_LABEL(a.dock_measure_labels[i]))) != 0) {
|
||||
same = 0;
|
||||
}
|
||||
}
|
||||
int dock_w = 0;
|
||||
int side_w = 0;
|
||||
const int fits = dock_width_fits(a, &dock_w, &side_w);
|
||||
std::fprintf(stderr,
|
||||
"[measures-probe] %-14s dock measures: lines=%zu page_rows=%zu same_text=%d dock_w=%d "
|
||||
"side_w=%d fits=%d\n",
|
||||
what, a.dock_measure_labels.size(), a.measure_labels.size(), same, dock_w, side_w,
|
||||
fits);
|
||||
}
|
||||
|
||||
void cursors_probe_report(App& a, const char* what) {
|
||||
static const char* const kModes[] = {"vertical", "horizontal", "both", "mix"};
|
||||
const int mode = static_cast<int>(a.rows->cursor_mode());
|
||||
@@ -4381,6 +4428,7 @@ void cursors_probe_report(App& a, const char* what) {
|
||||
if (have_mark) {
|
||||
std::fprintf(stderr, "[cursors-probe] %-14s first mark at x=%.6f y=%.6g\n", what, mx, my);
|
||||
}
|
||||
dock_cursors_report(a, what);
|
||||
std::fflush(stderr);
|
||||
}
|
||||
|
||||
@@ -4649,10 +4697,12 @@ gboolean measures_probe_step(gpointer user) {
|
||||
// the count with nothing to attribute it to -- which is how a window that lagged the screen
|
||||
// read `0/6` with no way to tell a stale recompute from a mark placed correctly.
|
||||
g_timeout_add(250, measure_trace, a);
|
||||
dock_measures_report(*a, "added");
|
||||
measures_probe_next(*a, 1, 400);
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
dock_measures_report(*a, "settled");
|
||||
open_measure_dialog(*a, 0); // the edit path: this and the delete are what aborted
|
||||
measures_probe_next(*a, 2, 400);
|
||||
break;
|
||||
@@ -4717,6 +4767,7 @@ gboolean measures_probe_step(gpointer user) {
|
||||
std::fabs(restored - want) < 1.0e-9 ? 1 : 0);
|
||||
std::fflush(stderr);
|
||||
measure_dialog_report(*a, "final");
|
||||
dock_measures_report(*a, "final");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user