refactor: build the shortcut overview from AdwShortcutsDialog
The hand-rolled grid existed to avoid GTK's deprecated GtkShortcutsWindow; libadwaita 1.8's AdwShortcutsDialog is the supported replacement, so use the platform widget and get its search, sectioning and shortcut labels for free. The table strings become GTK accelerator syntax, since the shortcut label parses them. The six mouse rows cannot: no accelerator syntax names a wheel or a drag, so they carry an empty accelerator and prose in the new subtitle field. adw_init() is called in run_ui() and in choose_source() (replacing its gtk_init()), which means the whole app is drawn with libadwaita's stylesheet. Verified settled: viewport.w 870..870, axes.w changes 2, x-desync 0. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
018b98eddf
commit
d65a121a9a
7 files changed
+123
-92
No files matched your search
+29
-24
@@ -9,47 +9,52 @@ namespace {
|
||||
/// Bare letters are toggles, Ctrl is for files and windows. Nothing here shadows a key the
|
||||
/// plot's own controller handles ('+', '-', 'f', the arrows, Escape).
|
||||
constexpr Accel kAccels[] = {
|
||||
{GDK_KEY_space, 0, AppAction::PauseToggle, "Space", "Pause or resume the display",
|
||||
{GDK_KEY_space, 0, AppAction::PauseToggle, "space", "Pause or resume the display",
|
||||
"Acquisition"},
|
||||
{GDK_KEY_a, 0, AppAction::TriggerArm, "A", "Arm or disarm the trigger", "Acquisition"},
|
||||
{GDK_KEY_t, 0, AppAction::TriggerPanel, "T", "Show or hide the trigger panel",
|
||||
{GDK_KEY_a, 0, AppAction::TriggerArm, "a", "Arm or disarm the trigger", "Acquisition"},
|
||||
{GDK_KEY_t, 0, AppAction::TriggerPanel, "t", "Show or hide the trigger panel",
|
||||
"Acquisition"},
|
||||
{GDK_KEY_c, 0, AppAction::CursorsPane, "C", "Show or hide the cursors pane",
|
||||
{GDK_KEY_c, 0, AppAction::CursorsPane, "c", "Show or hide the cursors pane",
|
||||
"Panes and editors"},
|
||||
{GDK_KEY_m, 0, AppAction::MeasuresPane, "M", "Show or hide the measurements pane",
|
||||
{GDK_KEY_m, 0, AppAction::MeasuresPane, "m", "Show or hide the measurements pane",
|
||||
"Panes and editors"},
|
||||
{GDK_KEY_g, 0, AppAction::MathPane, "G", "Show or hide the math pane",
|
||||
{GDK_KEY_g, 0, AppAction::MathPane, "g", "Show or hide the math pane",
|
||||
"Panes and editors"},
|
||||
{GDK_KEY_l, 0, AppAction::LayoutEditor, "L", "Show or hide the layout editor",
|
||||
{GDK_KEY_l, 0, AppAction::LayoutEditor, "l", "Show or hide the layout editor",
|
||||
"Panes and editors"},
|
||||
{GDK_KEY_s, 0, AppAction::SidePanel, "S", "Show or hide the side panel",
|
||||
{GDK_KEY_s, 0, AppAction::SidePanel, "s", "Show or hide the side panel",
|
||||
"Panes and editors"},
|
||||
{GDK_KEY_e, GDK_CONTROL_MASK, AppAction::Export, "Ctrl+E",
|
||||
{GDK_KEY_e, GDK_CONTROL_MASK, AppAction::Export, "<Control>e",
|
||||
"Export the visible range", "Files and windows"},
|
||||
{GDK_KEY_F1, 0, AppAction::Help, "F1", "Open the help window", "Files and windows"},
|
||||
{GDK_KEY_slash, GDK_CONTROL_MASK, AppAction::Shortcuts, "Ctrl+/",
|
||||
{GDK_KEY_slash, GDK_CONTROL_MASK, AppAction::Shortcuts, "<Control>slash",
|
||||
"Open this shortcut overview", "Files and windows"},
|
||||
{GDK_KEY_q, GDK_CONTROL_MASK, AppAction::Quit, "Ctrl+Q", "Quit udpscope",
|
||||
{GDK_KEY_q, GDK_CONTROL_MASK, AppAction::Quit, "<Control>q", "Quit udpscope",
|
||||
"Files and windows"},
|
||||
};
|
||||
constexpr int kAccelCount = static_cast<int>(sizeof(kAccels) / sizeof(kAccels[0]));
|
||||
|
||||
/// The plot's own interactions, documentation only. The keyboard's modifiers are not the
|
||||
/// wheel's: '+' is shift+'=' on common layouts, so Shift could not mean anything there.
|
||||
///
|
||||
/// A space-separated accelerator is the two-key alternative form the shortcut label draws
|
||||
/// as `+ / -`. The mouse rows carry no accelerator at all: neither GTK's accelerator
|
||||
/// syntax nor libadwaita's knows a wheel or a drag, and asking either to parse "Wheel"
|
||||
/// is a parse warning and an empty cell. Those rows are prose in the subtitle instead.
|
||||
constexpr Gesture kGestures[] = {
|
||||
{"+ / -", "Zoom in or out, both axes", "Plot keyboard"},
|
||||
{"Ctrl + / Ctrl -", "Zoom the time axis only", "Plot keyboard"},
|
||||
{"Alt + / Alt -", "Zoom the value axis only", "Plot keyboard"},
|
||||
{"Left / Right", "Pan along time", "Plot keyboard"},
|
||||
{"Up / Down", "Pan along values", "Plot keyboard"},
|
||||
{"F", "Fit the view to the data", "Plot keyboard"},
|
||||
{"Escape", "Cancel the gesture in progress", "Plot keyboard"},
|
||||
{"Wheel", "Zoom about the pointer, both axes", "Plot mouse"},
|
||||
{"Shift+wheel", "Zoom the time axis only", "Plot mouse"},
|
||||
{"Ctrl+wheel", "Zoom the value axis only", "Plot mouse"},
|
||||
{"Drag", "Pan", "Plot mouse"},
|
||||
{"Ctrl+drag", "Box zoom on time", "Plot mouse"},
|
||||
{"Alt+drag", "Box zoom on values", "Plot mouse"},
|
||||
{"plus minus", "", "Zoom in or out, both axes", "Plot keyboard"},
|
||||
{"<Control>plus <Control>minus", "", "Zoom the time axis only", "Plot keyboard"},
|
||||
{"<Alt>plus <Alt>minus", "", "Zoom the value axis only", "Plot keyboard"},
|
||||
{"Left Right", "", "Pan along time", "Plot keyboard"},
|
||||
{"Up Down", "", "Pan along values", "Plot keyboard"},
|
||||
{"f", "", "Fit the view to the data", "Plot keyboard"},
|
||||
{"Escape", "", "Cancel the gesture in progress", "Plot keyboard"},
|
||||
{"", "Wheel", "Zoom about the pointer, both axes", "Plot mouse"},
|
||||
{"", "Shift and wheel", "Zoom the time axis only", "Plot mouse"},
|
||||
{"", "Ctrl and wheel", "Zoom the value axis only", "Plot mouse"},
|
||||
{"", "Drag", "Pan", "Plot mouse"},
|
||||
{"", "Ctrl and drag", "Box zoom on time", "Plot mouse"},
|
||||
{"", "Alt and drag", "Box zoom on values", "Plot mouse"},
|
||||
};
|
||||
constexpr int kGestureCount = static_cast<int>(sizeof(kGestures) / sizeof(kGestures[0]));
|
||||
|
||||
|
||||
Reference in new issue
Block a user