feat: keyboard and mouse shortcut overview window
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
3e0d0de325
commit
018b98eddf
6 files changed
+248
-3
No files matched your search
@@ -0,0 +1,80 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
#include "shortcuts.hpp"
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
|
||||
namespace udpscope {
|
||||
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",
|
||||
"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",
|
||||
"Acquisition"},
|
||||
{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",
|
||||
"Panes and editors"},
|
||||
{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",
|
||||
"Panes and editors"},
|
||||
{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",
|
||||
"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+/",
|
||||
"Open this shortcut overview", "Files and windows"},
|
||||
{GDK_KEY_q, GDK_CONTROL_MASK, AppAction::Quit, "Ctrl+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.
|
||||
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"},
|
||||
};
|
||||
constexpr int kGestureCount = static_cast<int>(sizeof(kGestures) / sizeof(kGestures[0]));
|
||||
|
||||
/// The only modifiers a table row may require. Lock, Num-Lock and the pointer buttons all
|
||||
/// arrive in the same mask and must be masked out or no row ever matches.
|
||||
constexpr unsigned kModMask = GDK_CONTROL_MASK | GDK_SHIFT_MASK | GDK_ALT_MASK;
|
||||
|
||||
} // namespace
|
||||
|
||||
const Accel* app_accels(int* count) {
|
||||
if (count != nullptr) *count = kAccelCount;
|
||||
return kAccels;
|
||||
}
|
||||
|
||||
const Gesture* plot_gestures(int* count) {
|
||||
if (count != nullptr) *count = kGestureCount;
|
||||
return kGestures;
|
||||
}
|
||||
|
||||
const Accel* find_accel(unsigned keyval, unsigned mods) {
|
||||
const unsigned wanted = mods & kModMask;
|
||||
for (const Accel& accel : kAccels) {
|
||||
if (accel.keyval == keyval && accel.mods == wanted) return &accel;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace udpscope
|
||||
Reference in new issue
Block a user