fix: the guided tour selects the page a stop's target lives on
A stop whose target is on another page of a stack was entered without switching to that page, so the spotlight aimed at a widget that was not on screen. A stop now declares the page it stands on (`TourStop::page`) and the tour selects it as the step is entered -- the window's trigger and signals stops put the sidebar on Signals, the chooser's tabs stop shows the Waveforms page and stepping off it brings Sources back. The stop filter moved into `tour_begin()` and now runs on `gtk_widget_get_mapped()`: GTK 4.24's `is_visible()` ignores `child_visible`, so it kept a stop on another page *and* one in a collapsed pane alike. A wrong page is kept and selected; a collapsed pane, whose stack is unmapped too, is still dropped.
This commit is contained in:
1 parent
829176248a
commit
d549223889
9 files changed
+385
-89
No files matched your search
+58
-26
@@ -21,6 +21,7 @@
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -752,26 +753,30 @@ void chooser_help_sync(Chooser& c) {
|
||||
/// does -- which is the whole reason the stops cannot live in the window's table.
|
||||
struct ChooserStop {
|
||||
GtkWidget* Chooser::* target;
|
||||
/// The page of the chooser's own stack the stop stands on. The tabs stop is the one about the two
|
||||
/// kinds of input, so it shows the *waveforms* page while it is up; every other stop stands on the
|
||||
/// sources page, and naming it is what brings the page back when the walk steps off the tabs stop.
|
||||
const char* page;
|
||||
const char* title;
|
||||
const char* body;
|
||||
};
|
||||
|
||||
constexpr ChooserStop kChooserStops[] = {
|
||||
{&Chooser::list, "Choosing a source",
|
||||
{&Chooser::list, "sources", "Choosing a source",
|
||||
"Every source you have saved, newest first. Clicking one opens it -- that is the choice this "
|
||||
"dialog exists to make -- and the arrows on a row edit or forget its configuration."},
|
||||
{&Chooser::switcher, "Two kinds of input",
|
||||
{&Chooser::switcher, "waveforms", "Two kinds of input",
|
||||
"A *source* is a stream to receive; a *waveform* is a recording an earlier run exported. They "
|
||||
"are the two answers to \u201cwhat should be on the screen\u201d, and these are the tabs "
|
||||
"between them."},
|
||||
{&Chooser::new_host, "A source that is not listed",
|
||||
{&Chooser::new_host, "sources", "A source that is not listed",
|
||||
"Opens the form for an address that has no configuration yet: host, port, the settings a source "
|
||||
"can only be given before it is opened, and the name its session will be saved under."},
|
||||
{&Chooser::help_button, "The manual, and this tour",
|
||||
{&Chooser::help_button, "sources", "The manual, and this tour",
|
||||
"Documentation opens the manual in the desktop help viewer. This tour walks this window and "
|
||||
"then the application's own window. Contextual help is the switch below it: on, every surface "
|
||||
"carries a small \u201c(i)\u201d saying what it is for."},
|
||||
{&Chooser::prefs_button, "Preferences",
|
||||
{&Chooser::prefs_button, "sources", "Preferences",
|
||||
"The event cache, relative time and the interface theme. This is the last moment relative time "
|
||||
"can still change this run -- the buffers are planned as soon as a source is picked -- which is "
|
||||
"why the button is here and not only in the window's menu."},
|
||||
@@ -806,16 +811,16 @@ void chooser_tour_mark_seen() {
|
||||
void chooser_tour_begin(Chooser& c) {
|
||||
if (c.tour.card == nullptr) return;
|
||||
chooser_tour_mark_seen();
|
||||
// The stops whose target is on screen, in table order, the same filter the window's tour uses: a
|
||||
// surface that is not there is not walked over.
|
||||
// The chooser's own stack, so a stop can name the page it stands on (the window does the same with
|
||||
// its sidebar in `start_tour()`).
|
||||
c.tour.page_stack = c.page_stack;
|
||||
// The whole table, in walk order: `tour_begin()` drops the stops whose surface is not on screen.
|
||||
std::vector<ui_impl::TourStop> stops;
|
||||
stops.reserve(kChooserStopCount);
|
||||
for (int i = 0; i < kChooserStopCount; ++i) {
|
||||
GtkWidget* target = c.*(kChooserStops[i].target);
|
||||
if (target != nullptr && gtk_widget_is_visible(target)) {
|
||||
stops.push_back({target, kChooserStops[i].title, kChooserStops[i].body});
|
||||
}
|
||||
stops.push_back({target, kChooserStops[i].page, kChooserStops[i].title, kChooserStops[i].body});
|
||||
}
|
||||
if (stops.empty()) return;
|
||||
ui_impl::tour_begin(c.tour, std::move(stops), chooser_tour_done, &c);
|
||||
}
|
||||
|
||||
@@ -851,26 +856,53 @@ gboolean chooser_tour_autostart(gpointer user) {
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
/// `UDPSCOPE_PROBE_CHOOSER_TOUR_MS`: the chooser's tour, read and walked the way the window's is --
|
||||
/// where it stands, then every stop, then the handoff. It reports the walk by *stepping* it (the
|
||||
/// button the user presses), so what it reads is what a first run sees, not the state the probe set.
|
||||
/// Whether the probe has done its one Back step. One chooser runs per process, so a file-static is
|
||||
/// enough and simpler than a field on `Chooser` that exists only for the probe.
|
||||
bool g_chooser_tour_backed = false;
|
||||
|
||||
/// `UDPSCOPE_PROBE_CHOOSER_TOUR_MS`: the chooser's tour, read and walked a stop per tick -- the
|
||||
/// cadence the window's own tour probe walks at, and for its reason: a page a stop selects is laid
|
||||
/// out on the frame *after* the switch, so a reading taken in the switch's own tick would be of the
|
||||
/// page the walk has just left. It starts the walk if one is not already running, so it does not
|
||||
/// depend on the throwaway config being a first run; it reports the page the stack shows at every
|
||||
/// stop; it steps **Back** off the stop that stands on the waveforms page and reads the page again
|
||||
/// -- the other direction; then it finishes the walk. `page=waveforms` on that stop and `page=sources`
|
||||
/// after the Back step is the pair the surface switch is read by.
|
||||
gboolean chooser_tour_probe(gpointer user) {
|
||||
Chooser& c = *static_cast<Chooser*>(user);
|
||||
c.tour_probe_source = 0;
|
||||
std::fprintf(stderr, "[sources] chooser tour: visible=%d steps=%d step=%d\n",
|
||||
c.tour.running ? 1 : 0, static_cast<int>(c.tour.plan.size()), c.tour.index);
|
||||
while (c.tour.running) {
|
||||
const int before = c.tour.index;
|
||||
const auto page = [&c]() {
|
||||
const char* name = adw_view_stack_get_visible_child_name(ADW_VIEW_STACK(c.page_stack));
|
||||
return name != nullptr ? name : "?";
|
||||
};
|
||||
if (!c.tour.running) chooser_tour_begin(c);
|
||||
if (!c.tour.running) {
|
||||
std::fprintf(stderr, "[sources] chooser tour: nothing to walk (page=%s)\n", page());
|
||||
std::fflush(stderr);
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
const std::size_t idx = static_cast<std::size_t>(c.tour.index);
|
||||
const int n = static_cast<int>(c.tour.plan.size());
|
||||
const ui_impl::TourStop& stop = c.tour.plan[idx];
|
||||
std::fprintf(stderr, "[sources] chooser tour: step=%d/%d page=%s stop_page=%s target_mapped=%d\n",
|
||||
c.tour.index + 1, n, page(), stop.page != nullptr ? stop.page : "-",
|
||||
stop.target != nullptr && gtk_widget_get_mapped(stop.target) ? 1 : 0);
|
||||
if (stop.page != nullptr && std::strcmp(stop.page, "waveforms") == 0 && !g_chooser_tour_backed) {
|
||||
// Off it, Back: the previous stop stands on the sources page, and the page has to come back with
|
||||
// it -- the other direction a surface switch has to work in.
|
||||
g_chooser_tour_backed = true;
|
||||
ui_impl::tour_advance(c.tour, -1);
|
||||
std::fprintf(stderr, "[sources] chooser tour: back off the waveforms stop: step=%d/%d page=%s\n",
|
||||
c.tour.index + 1, n, page());
|
||||
} else {
|
||||
ui_impl::tour_advance(c.tour, 1);
|
||||
if (c.tour.running) {
|
||||
std::fprintf(stderr, "[sources] chooser tour: next -> step=%d/%d\n", c.tour.index,
|
||||
static_cast<int>(c.tour.plan.size()));
|
||||
} else {
|
||||
std::fprintf(stderr, "[sources] chooser tour: Next past stop %d finished the walk\n", before + 1);
|
||||
}
|
||||
}
|
||||
if (c.tour.running) {
|
||||
c.tour_probe_source = g_timeout_add(250, chooser_tour_probe, &c);
|
||||
} else {
|
||||
std::fprintf(stderr, "[sources] chooser tour: after finish visible=0 page=%s tour_pending=%d\n",
|
||||
page(), c.cfg->tour_pending ? 1 : 0);
|
||||
}
|
||||
std::fprintf(stderr, "[sources] chooser tour: after finish visible=%d tour_pending=%d\n",
|
||||
c.tour.running ? 1 : 0, c.cfg->tour_pending ? 1 : 0);
|
||||
std::fflush(stderr);
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
@@ -5808,6 +5808,9 @@ int run_ui(int argc, char** argv, const Config& cfg, ScopeModel& model, Acquisit
|
||||
if (const char* env = g_getenv("UDPSCOPE_PROBE_HELPUI_MS")) {
|
||||
helpui_probe_next(app, 0, static_cast<guint>(std::atoi(env)));
|
||||
}
|
||||
if (const char* env = g_getenv("UDPSCOPE_PROBE_TOUR_SURFACE_MS")) {
|
||||
tour_surface_probe_next(app, static_cast<guint>(std::atoi(env)));
|
||||
}
|
||||
if (const char* env = g_getenv("UDPSCOPE_PROBE_CONFIGS_MS")) {
|
||||
g_timeout_add(static_cast<guint>(std::atoi(env)), configs_probe, &app);
|
||||
}
|
||||
|
||||
+21
-4
@@ -67,10 +67,15 @@ enum class EventGroupKind {
|
||||
// is only the *stops*: a stop's target is a widget the owner resolves, so each window keeps its own
|
||||
// table (the chooser runs before `App` exists and could not name one of `App`'s fields).
|
||||
|
||||
/// One stop of a guided tour: the widget to spotlight, and the two paragraphs of text beside it.
|
||||
/// The target is resolved when the tour starts, so the table may name widgets that do not exist yet.
|
||||
/// One stop of a guided tour: the widget to spotlight, the page it stands on, and the two paragraphs
|
||||
/// of text beside it. The target is resolved when the tour starts, so the table may name widgets that
|
||||
/// do not exist yet.
|
||||
struct TourStop {
|
||||
GtkWidget* target;
|
||||
/// The named page of the view's `page_stack` the target lives on, or nullptr when the stop needs no
|
||||
/// page. The tour selects it as the stop is entered, so a target on a page the user has left is
|
||||
/// made visible instead of being walked over or spotlighted where it is not.
|
||||
const char* page;
|
||||
const char* title;
|
||||
const char* body;
|
||||
};
|
||||
@@ -93,6 +98,10 @@ struct TourView {
|
||||
bool running = false;
|
||||
int index = 0;
|
||||
std::vector<TourStop> plan;
|
||||
/// The stack whose pages the stops' `page` names select. A window has exactly one such surface (the
|
||||
/// sidebar; the chooser's two pages), so it is the view's and not each stop's. Set where the walk
|
||||
/// begins, when the widgets exist; null leaves every stop on the page it finds.
|
||||
GtkWidget* page_stack = nullptr;
|
||||
/// Runs when the walk passes its last stop (Next/Finish, never Skip): the chooser's hands the tour
|
||||
/// on to the application through `Config::tour_pending`.
|
||||
void (*on_done)(void* user) = nullptr;
|
||||
@@ -312,6 +321,8 @@ struct App {
|
||||
/// left nothing behind.
|
||||
int dbg_helpui_step = 0;
|
||||
int dbg_helpui_controllers = -1;
|
||||
/// `UDPSCOPE_PROBE_TOUR_SURFACE_MS`: which step of that probe runs next.
|
||||
int dbg_tour_surface_step = 0;
|
||||
/// Where the panel controls ended up, decided once at build time: the dump runs after the window
|
||||
/// is destroyed and cannot ask GTK anything about a widget.
|
||||
std::string dbg_panel_controls;
|
||||
@@ -1745,6 +1756,10 @@ gboolean keys_probe(gpointer user);
|
||||
gboolean help_probe(gpointer user);
|
||||
void helpui_probe_next(App& a, int step, guint delay_ms);
|
||||
gboolean helpui_probe_step(gpointer user);
|
||||
/// `UDPSCOPE_PROBE_TOUR_SURFACE_MS`: a stop that stands on another page of a stack, entered from the
|
||||
/// page it is not on -- the sidebar put on Measure, the walk to the signals stop, the reading of the
|
||||
/// page and of the spotlight, and then the same walk with the sidebar *collapsed*.
|
||||
void tour_surface_probe_next(App& a, guint delay_ms);
|
||||
|
||||
// --- the help affordance layer (ui_context_help.cpp, ui_tour.cpp) ----------
|
||||
//
|
||||
@@ -1784,8 +1799,10 @@ void context_help_size(App& app, int* width, int* height);
|
||||
/// Builds a tour's overlay children (the four dim rectangles, the spotlight outline and the card)
|
||||
/// inside `overlay`. Called once, as the overlay is inserted, by either window that draws a tour.
|
||||
void tour_build(TourView& view, GtkWidget* overlay);
|
||||
/// Starts at the first stop. `stops` is the walk, already filtered to what is on screen; `on_done`
|
||||
/// (may be null) runs when the walk passes its last stop, and is how the chooser hands off.
|
||||
/// Starts at the first stop. `stops` is the whole table, in walk order: the stops whose surface is
|
||||
/// not on screen are filtered out here, by the one rule both windows use (a wrong page is kept and
|
||||
/// selected, a collapsed pane is dropped). `on_done` (may be null) runs when the walk passes its last
|
||||
/// stop, and is how the chooser hands off.
|
||||
void tour_begin(TourView& view, std::vector<TourStop> stops, void (*on_done)(void* user),
|
||||
void* done_user);
|
||||
/// Moves `delta` stops, finishing the walk (and calling `on_done`) on the way past the last one.
|
||||
|
||||
+120
-9
@@ -4557,16 +4557,19 @@ GtkWidget* helpui_menu_view(App* a) {
|
||||
}
|
||||
|
||||
/// One line: the spotlight, the widget it spotlights, and the card, all in **window coordinates** --
|
||||
/// the frame a screenshot is cropped in. `contains` is the spotlight covering its target (it is the
|
||||
/// target's own rectangle, grown three pixels) and `clear` is the card missing the target.
|
||||
void helpui_report_geometry(App& a, const char* what) {
|
||||
/// the frame a screenshot is cropped in -- with the window's own record of the sidebar page beside
|
||||
/// them, so a stop that had to change the page to find its target is readable as such. `contains` is
|
||||
/// the spotlight covering its target (it is the target's own rectangle, grown three pixels) and
|
||||
/// `clear` is the card missing the target. `probe` is the tag it is printed under, so a window with
|
||||
/// more than one tour probe can tell its lines apart.
|
||||
void tour_geometry_line(App& a, const char* probe, const char* what) {
|
||||
graphene_rect_t spot = GRAPHENE_RECT_INIT(0, 0, 0, 0);
|
||||
graphene_rect_t target = GRAPHENE_RECT_INIT(0, 0, 0, 0);
|
||||
graphene_rect_t card = GRAPHENE_RECT_INIT(0, 0, 0, 0);
|
||||
GtkWidget* t = tour_target(a);
|
||||
const bool have_spot =
|
||||
a.tour.spot != nullptr && gtk_widget_compute_bounds(a.tour.spot, a.window, &spot);
|
||||
const bool have_target = t != nullptr && gtk_widget_is_visible(t) &&
|
||||
const bool have_target = t != nullptr && gtk_widget_get_mapped(t) &&
|
||||
gtk_widget_compute_bounds(t, a.window, &target);
|
||||
const bool have_card =
|
||||
a.tour.card != nullptr && gtk_widget_compute_bounds(a.tour.card, a.window, &card);
|
||||
@@ -4580,11 +4583,11 @@ void helpui_report_geometry(App& a, const char* what) {
|
||||
p.origin.y < q.origin.y + q.size.height && q.origin.y < p.origin.y + p.size.height;
|
||||
};
|
||||
std::fprintf(stderr,
|
||||
"[helpui] %s=%d/%d visible=%d spot=[%.0f,%.0f %.0fx%.0f] "
|
||||
"[%s] %s=%d/%d visible=%d side_tab=%s spot=[%.0f,%.0f %.0fx%.0f] "
|
||||
"target=[%.0f,%.0f %.0fx%.0f] contains=%d card=[%.0f,%.0f %.0fx%.0f] clear=%d\n",
|
||||
what, tour_step_index(a) + 1, tour_step_count(a), tour_active(a) ? 1 : 0,
|
||||
spot.origin.x, spot.origin.y, spot.size.width, spot.size.height, target.origin.x,
|
||||
target.origin.y, target.size.width, target.size.height,
|
||||
probe, what, tour_step_index(a) + 1, tour_step_count(a), tour_active(a) ? 1 : 0,
|
||||
a.side_tab.c_str(), spot.origin.x, spot.origin.y, spot.size.width, spot.size.height,
|
||||
target.origin.x, target.origin.y, target.size.width, target.size.height,
|
||||
have_spot && have_target && contains(spot, target) ? 1 : 0, card.origin.x,
|
||||
card.origin.y, card.size.width, card.size.height,
|
||||
have_card && have_target && !overlaps(card, target) ? 1 : 0);
|
||||
@@ -4715,7 +4718,7 @@ gboolean helpui_probe_step(gpointer user) {
|
||||
// spotlight must *contain* the target, and the card must not overlap it when the window has room
|
||||
// for a card beside or above/below it. All of it is an allocation, so it is read one frame after
|
||||
// the step it describes: `update_tour()` places this frame from the allocation the last one left.
|
||||
helpui_report_geometry(*a, "step");
|
||||
tour_geometry_line(*a, "helpui", "step");
|
||||
if (step == 4) {
|
||||
// Next, which is what a user presses to walk the tour.
|
||||
tour_step(*a, 1);
|
||||
@@ -4774,5 +4777,113 @@ gboolean helpui_probe_step(gpointer user) {
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
// --- the tour's surface switch: a stop that stands on another stack page -------
|
||||
|
||||
/// Whether the walk's plan holds `target`. `steps=` alone cannot say a stop was *filtered out* rather
|
||||
/// than merely reordered, so the two cases the filter tells apart are read against the plan itself.
|
||||
bool tour_plan_holds(const App& a, GtkWidget* target) {
|
||||
for (const TourStop& stop : a.tour.plan) {
|
||||
if (stop.target == target) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
gboolean tour_surface_probe_step(gpointer user);
|
||||
|
||||
void tour_surface_probe_next(App& a, guint delay_ms) {
|
||||
g_timeout_add(delay_ms, tour_surface_probe_step, &a);
|
||||
}
|
||||
|
||||
/// `UDPSCOPE_PROBE_TOUR_SURFACE_MS`: the stop that stands on a page it is not on. It puts the sidebar
|
||||
/// on **Measure**, starts the window's tour, and walks it a stop per tick -- a tick apart on purpose,
|
||||
/// because a stack's new page is allocated on the frame *after* the switch, so a reading taken in the
|
||||
/// switch's own tick would be of the page the walk has just left (and `update_tour()` places the hole
|
||||
/// from the frame that *has* been laid out). Every step prints the sidebar's page and whether the
|
||||
/// stop's target is mapped, and the stop whose target is the signal list prints the same geometry
|
||||
/// `[helpui]` does: **`side_tab=signals` with `target=signal_list` and `contains=1`** is the reading
|
||||
/// that the stop was not merely kept but *made* visible. It then puts the sidebar away --
|
||||
/// `sidebar_wanted` is the wish the tick re-asserts -- and starts the tour again: a *collapsed* pane
|
||||
/// leaves the stack unmapped, so the stops that need it are dropped and `steps=` falls. That pair is
|
||||
/// the filter's two cases, read rather than assumed.
|
||||
gboolean tour_surface_probe_step(gpointer user) {
|
||||
App* a = static_cast<App*>(user);
|
||||
if (a->window == nullptr) return G_SOURCE_REMOVE;
|
||||
const auto mapped = [](GtkWidget* w) { return w != nullptr && gtk_widget_get_mapped(w) ? 1 : 0; };
|
||||
switch (a->dbg_tour_surface_step) {
|
||||
case 0: {
|
||||
// Where the run starts: a fresh config's sidebar is on Signals, so this is a *first* run's
|
||||
// state. The auto-start's walk (if one began) would only confuse the reading; it goes first.
|
||||
std::fprintf(stderr, "[toursurface] before: side_tab=%s signal_list_mapped=%d running=%d\n",
|
||||
a->side_tab.c_str(), mapped(a->signal_list), tour_active(*a) ? 1 : 0);
|
||||
tour_dismiss(*a);
|
||||
select_side_tab(*a, "measure");
|
||||
a->dbg_tour_surface_step = 1;
|
||||
tour_surface_probe_next(*a, 500);
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
case 1: {
|
||||
// A frame after the switch, so the Measure page has been laid out and the list really is off
|
||||
// screen. The tour is started *here*, from this state.
|
||||
std::fprintf(stderr,
|
||||
"[toursurface] on measure: side_tab=%s signal_list_mapped=%d side_stack_mapped=%d\n",
|
||||
a->side_tab.c_str(), mapped(a->signal_list), mapped(a->side_stack));
|
||||
start_tour(*a);
|
||||
std::fprintf(stderr, "[toursurface] tour: visible=%d steps=%d step=%d signals_stop=%d\n",
|
||||
tour_active(*a) ? 1 : 0, tour_step_count(*a), tour_step_index(*a),
|
||||
tour_plan_holds(*a, a->signal_list) ? 1 : 0);
|
||||
a->dbg_tour_surface_step = 2;
|
||||
tour_surface_probe_next(*a, 400);
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
case 2: {
|
||||
if (!tour_active(*a)) {
|
||||
std::fprintf(stderr, "[toursurface] walk ended before the signals stop\n");
|
||||
std::fflush(stderr);
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
GtkWidget* target = tour_target(*a);
|
||||
const bool is_list = target != nullptr && target == a->signal_list;
|
||||
std::fprintf(stderr, "[toursurface] step=%d/%d side_tab=%s target_mapped=%d%s\n",
|
||||
tour_step_index(*a) + 1, tour_step_count(*a), a->side_tab.c_str(), mapped(target),
|
||||
is_list ? " target=signal_list" : "");
|
||||
if (is_list) {
|
||||
// The frame after the switch: the page has been laid out and `update_tour()` has placed the
|
||||
// hole from it, so this is the reading that the spotlight is on the list.
|
||||
tour_geometry_line(*a, "toursurface", "signals stop");
|
||||
tour_dismiss(*a);
|
||||
a->dbg_tour_surface_step = 3;
|
||||
tour_surface_probe_next(*a, 400);
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
tour_step(*a, 1);
|
||||
tour_surface_probe_next(*a, 400);
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
case 3: {
|
||||
// The other half of the filter. `sidebar_wanted` is the user's wish that the tick re-asserts
|
||||
// (`update_side_visibility`), so setting it here is how a probe puts the sidebar away for good;
|
||||
// the delay leaves the split view time to animate the column shut and unmap it.
|
||||
a->sidebar_wanted = false;
|
||||
a->dbg_tour_surface_step = 4;
|
||||
tour_surface_probe_next(*a, 700);
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
default: {
|
||||
start_tour(*a);
|
||||
std::fprintf(stderr,
|
||||
"[toursurface] collapsed: side_stack_mapped=%d steps=%d signals_stop=%d "
|
||||
"side_stop=%d\n",
|
||||
mapped(a->side_stack), tour_step_count(*a),
|
||||
tour_plan_holds(*a, a->signal_list) ? 1 : 0,
|
||||
tour_plan_holds(*a, a->side_box) ? 1 : 0);
|
||||
tour_dismiss(*a);
|
||||
a->sidebar_wanted = true;
|
||||
std::fflush(stderr);
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
}
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
} // namespace ui_impl
|
||||
} // namespace udpscope
|
||||
+63
-15
@@ -76,10 +76,42 @@ const TourStop* current_stop(const TourView& view) {
|
||||
return &view.plan[static_cast<std::size_t>(view.index)];
|
||||
}
|
||||
|
||||
/// Selects a stop's page on the view's stack, before anything is measured against the target. Both
|
||||
/// windows' stacks are `AdwViewStack`s and their page names are the ones the same tables name their
|
||||
/// `.ui` pages with, so the machinery can do this itself; the `get_child_by_name()` guard keeps a
|
||||
/// stop that names a page a later `.ui` dropped from blanking the stack. The stack's own
|
||||
/// `notify::visible-child-name` is what tells the window which page it is now on.
|
||||
void select_view_page(TourView& view, const char* page) {
|
||||
if (view.page_stack == nullptr || page == nullptr) return;
|
||||
if (adw_view_stack_get_child_by_name(ADW_VIEW_STACK(view.page_stack), page) == nullptr) return;
|
||||
adw_view_stack_set_visible_child_name(ADW_VIEW_STACK(view.page_stack), page);
|
||||
}
|
||||
|
||||
/// Whether a stop belongs in the walk. `get_mapped()`, not `is_visible()`: a stack hides its other
|
||||
/// pages, and the split view its sidebar, with `gtk_widget_set_child_visible()`, which leaves the
|
||||
/// widget's own visible flag -- the one `is_visible()` walks up the parents -- **true**. So the only
|
||||
/// honest "is this on screen" test is whether it is mapped, and it is the one that keeps the filter's
|
||||
/// two cases apart:
|
||||
/// * a target not mapped because it is on *another page* is walked over when the stop names that
|
||||
/// page and the stack itself is on screen -- selecting the page is what puts the target there;
|
||||
/// * a target not mapped because its *pane is collapsed* leaves the stack unmapped too, so no page
|
||||
/// can reveal it and the stop is still dropped.
|
||||
bool stop_is_walkable(const TourView& view, const TourStop& stop) {
|
||||
if (stop.target == nullptr) return false;
|
||||
if (gtk_widget_get_mapped(stop.target)) return true;
|
||||
return stop.page != nullptr && view.page_stack != nullptr &&
|
||||
gtk_widget_get_mapped(view.page_stack);
|
||||
}
|
||||
|
||||
/// Restates the card's text for the current stop. Called on a change of step, not per frame.
|
||||
void show_step(TourView& view) {
|
||||
const TourStop* stop = current_stop(view);
|
||||
if (stop == nullptr || view.card == nullptr) return;
|
||||
// The surface first, and nothing is measured here: the stop may live on a page the user has left,
|
||||
// and a stack's new page is allocated on the frame *after* the switch, so a one-shot measure in
|
||||
// this tick would read the page the walk has just left. `tour_update()` runs every frame and fills
|
||||
// the hole in on the next one.
|
||||
select_view_page(view, stop->page);
|
||||
// The hole belongs to the step: reusing the last one for a frame would put the spotlight on the
|
||||
// surface the tour has just left, and the next frame fills this one in.
|
||||
view.hole[0] = view.hole[1] = view.hole[2] = view.hole[3] = 0;
|
||||
@@ -170,8 +202,16 @@ void tour_build(TourView& view, GtkWidget* overlay) {
|
||||
void tour_begin(TourView& view, std::vector<TourStop> stops, void (*on_done)(void* user),
|
||||
void* done_user) {
|
||||
if (view.overlay == nullptr || view.card == nullptr) return;
|
||||
view.plan = std::move(stops);
|
||||
if (view.plan.empty()) return;
|
||||
// The walk is the stops whose surface is on screen *or* can be selected into view, filtered here
|
||||
// rather than by each caller so the two windows cannot drift into two rules -- and because the
|
||||
// rule needs the view's own `page_stack`, which the caller's table does not carry. See
|
||||
// `stop_is_walkable()` for what separates a wrong page from a collapsed pane.
|
||||
std::vector<TourStop> plan;
|
||||
for (const TourStop& stop : stops) {
|
||||
if (stop_is_walkable(view, stop)) plan.push_back(stop);
|
||||
}
|
||||
if (plan.empty()) return;
|
||||
view.plan = std::move(plan);
|
||||
view.on_done = on_done;
|
||||
view.done_user = done_user;
|
||||
view.index = 0;
|
||||
@@ -228,7 +268,10 @@ void tour_update(TourView& view) {
|
||||
// one-shot measurement would leave the hole in the corner.
|
||||
GtkWidget* target = tour_target(view);
|
||||
graphene_rect_t bounds = GRAPHENE_RECT_INIT(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
const bool target_present = target != nullptr && gtk_widget_is_visible(target);
|
||||
// Mapped, not `is_visible()`: a widget on another page of a stack, or in a collapsed pane, keeps
|
||||
// its own visible flag -- a stack hides its pages with `set_child_visible()` -- and a widget that
|
||||
// is not on screen is not one to leave the spotlight standing on.
|
||||
const bool target_present = target != nullptr && gtk_widget_get_mapped(target);
|
||||
if (target_present && gtk_widget_compute_bounds(target, view.overlay, &bounds)) {
|
||||
// The hole: the target, grown by three pixels so the outline sits *around* the widget rather than
|
||||
// on it, and clamped to the overlay -- a target partly off screen is an ordinary case (a sidebar
|
||||
@@ -331,29 +374,33 @@ namespace {
|
||||
/// point of re-measuring every frame is that nothing here knows where the widget is.
|
||||
struct TourStep {
|
||||
const char* id;
|
||||
/// The sidebar page the target lives on, or nullptr when the stop is not on either page. The
|
||||
/// trigger and the channel list are both on the Signals page, so a stop about either has to put
|
||||
/// the sidebar there before it can spotlight one.
|
||||
const char* page;
|
||||
const char* title;
|
||||
const char* body;
|
||||
GtkWidget* App::* target;
|
||||
};
|
||||
|
||||
constexpr TourStep kTourSteps[] = {
|
||||
{"plot", "The plot",
|
||||
{"plot", nullptr, "The plot",
|
||||
"Every signal you have switched on is drawn here, all rows sharing one time axis. The wheel "
|
||||
"zooms, a drag pans, and a right-click on a row opens that plot's own menu.",
|
||||
&App::area_overlay},
|
||||
{"side", "The side panel",
|
||||
{"side", nullptr, "The side panel",
|
||||
"The working surface beside the plot. Measure holds the cursors and the measurements; Signals "
|
||||
"holds the trigger and the list of signals. The buttons in the bar above show and hide it.",
|
||||
&App::side_box},
|
||||
{"trigger", "The trigger",
|
||||
{"trigger", "signals", "The trigger",
|
||||
"Describe an event -- a signal, a condition, a level and the window around it -- and arm it: "
|
||||
"the view then freezes on the first event that matches, however rare it is.",
|
||||
&App::trigger_body},
|
||||
{"signals", "The signals",
|
||||
{"signals", "signals", "The signals",
|
||||
"Every signal the source declares, each with the switch that acquires it. A signal has to be "
|
||||
"switched on before it can be plotted, measured or searched.",
|
||||
&App::signal_list},
|
||||
{"status", "The status line",
|
||||
{"status", nullptr, "The status line",
|
||||
"The stream's own report, once a second: the display mode, the rate arriving, the window on "
|
||||
"screen and the buffer holding it. The information button opens the counters behind it.",
|
||||
&App::status_row},
|
||||
@@ -375,17 +422,18 @@ void start_tour(App& app) {
|
||||
app.settings.tour_seen = true;
|
||||
(void)save_settings(app.settings);
|
||||
}
|
||||
// The stops whose target is on screen, in table order. A surface that is not there is not walked
|
||||
// over -- the point of asking `is_visible()` rather than `get_visible()` is that a widget under a
|
||||
// hidden parent still reports its own flag as true.
|
||||
// The sidebar's own stack, so a stop can name the page it stands on. Set here and not in
|
||||
// `build_tour()`: the overlay is inserted above the window's content *before* `App::side_stack` is
|
||||
// assigned, so the member does not exist yet at build time -- and the walk cannot start before the
|
||||
// window is up anyway.
|
||||
app.tour.page_stack = app.side_stack;
|
||||
// The whole table, in walk order: `tour_begin()` drops the stops whose surface is not on screen.
|
||||
std::vector<TourStop> stops;
|
||||
stops.reserve(kTourStepCount);
|
||||
for (int i = 0; i < kTourStepCount; ++i) {
|
||||
GtkWidget* target = app.*(kTourSteps[i].target);
|
||||
if (target != nullptr && gtk_widget_is_visible(target)) {
|
||||
stops.push_back({target, kTourSteps[i].title, kTourSteps[i].body});
|
||||
}
|
||||
stops.push_back({target, kTourSteps[i].page, kTourSteps[i].title, kTourSteps[i].body});
|
||||
}
|
||||
if (stops.empty()) return;
|
||||
tour_begin(app.tour, std::move(stops), nullptr, nullptr);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user