diff --git a/apps/camera_lidar_calibration/App.cpp b/apps/camera_lidar_calibration/App.cpp index 8bbdee6f..aba7d8c8 100644 --- a/apps/camera_lidar_calibration/App.cpp +++ b/apps/camera_lidar_calibration/App.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -106,7 +107,8 @@ void AppState::setPendingImagePoint(float u, float v) } else { - statusMsg = "Image point set -- Shift+click the matching point in the 3D View, or Shift+Alt+click it in the Image View"; + statusMsg = + "Image point set -- Shift+click the matching point in the 3D View, or Shift+" SHORTCUT_ALT "+click it in the Image View"; } } @@ -1040,7 +1042,7 @@ void App::run() else { state.pairsPath = pendingPairs; - state.statusMsg = "New pairs file " + pendingPairs + ": Ctrl+S saves the picked pairs there"; + state.statusMsg = "New pairs file " + pendingPairs + ": " SHORTCUT_CTRL "+S saves the picked pairs there"; } } diff --git a/apps/camera_lidar_calibration/UI.cpp b/apps/camera_lidar_calibration/UI.cpp index c63c9b9e..a0c5df68 100644 --- a/apps/camera_lidar_calibration/UI.cpp +++ b/apps/camera_lidar_calibration/UI.cpp @@ -3,6 +3,7 @@ #include "imgui.h" #include "rlImGui.h" #include +#include #include #include #include @@ -99,10 +100,12 @@ void UI::draw(AppState& state) drawSensorIds(state); - // Alt/Cmd = toggle Camera RGB ↔ Intensity (works anywhere in the window). - // Cmd (Super) alongside Alt for macOS, where Option is awkward to use as - // a modifier (it composes special characters). Fires on release, unless - // Shift joined in: Shift+Alt is the Image View's LiDAR-pick chord. + // Alt/Super = toggle Camera RGB ↔ Intensity (works anywhere in the window). + // Super alongside Alt for macOS, where Option is awkward to use as a + // modifier (it composes special characters); ImGui swaps Cmd and Ctrl + // there, so Super is the physical Ctrl key and Cmd stays free for + // shortcuts. Fires on release, unless Shift joined in: Shift+Alt is the + // Image View's LiDAR-pick chord. const bool altDown = ImGui::IsKeyDown(ImGuiKey_LeftAlt) || ImGui::IsKeyDown(ImGuiKey_RightAlt) || ImGui::IsKeyDown(ImGuiKey_LeftSuper) || ImGui::IsKeyDown(ImGuiKey_RightSuper); if (altDown && io.KeyShift) @@ -194,8 +197,8 @@ void UI::drawImageView(AppState& state) const bool pickingLidar = picking && ImGui::GetIO().KeyAlt; ImGui::TextColored( ImVec4(1, 1, 0, 0.8f), - pickingLidar ? "LiDAR intensity image: Shift+Alt+click to pick a LiDAR point" - : picking ? "Shift+click to pick a pixel | add Alt to pick a LiDAR point" + pickingLidar ? "LiDAR intensity image: Shift+" SHORTCUT_ALT "+click to pick a LiDAR point" + : picking ? "Shift+click to pick a pixel | add " SHORTCUT_ALT " to pick a LiDAR point" : "Scroll: zoom | Drag: pan with middle | Dbl-click: reset zoom"); ImGui::BeginChild("image_scroll", ImVec2(0, 0), false, ImGuiWindowFlags_HorizontalScrollbar | ImGuiWindowFlags_NoScrollWithMouse); @@ -476,24 +479,24 @@ void UI::panelMenuBar(AppState& state) if (ImGui::BeginMenu("File")) { - if (ImGui::MenuItem("Open Image...", "Ctrl+I")) + if (ImGui::MenuItem("Open Image...", SHORTCUT_CTRL "+I")) actionOpenImage(state); - if (ImGui::MenuItem("Open Point Cloud...", "Ctrl+O")) + if (ImGui::MenuItem("Open Point Cloud...", SHORTCUT_CTRL "+O")) actionOpenPointCloud(state); - if (ImGui::MenuItem("Add Point Cloud...", "Ctrl+Shift+O")) + if (ImGui::MenuItem("Add Point Cloud...", SHORTCUT_CTRL "+Shift+O")) actionAddPointCloud(state); ImGui::Separator(); - if (ImGui::MenuItem("Open Intrinsics...", "Ctrl+K")) + if (ImGui::MenuItem("Open Intrinsics...", SHORTCUT_CTRL "+K")) actionOpenIntrinsics(state); ImGui::Separator(); - if (ImGui::MenuItem("Open Calibration...", "Ctrl+L")) + if (ImGui::MenuItem("Open Calibration...", SHORTCUT_CTRL "+L")) actionOpenCalibration(state); - if (ImGui::MenuItem("Save Calibration...", "Ctrl+Shift+S")) + if (ImGui::MenuItem("Save Calibration...", SHORTCUT_CTRL "+Shift+S")) actionSaveCalibration(state); ImGui::Separator(); if (ImGui::MenuItem("Load Pairs...")) actionLoadPairs(state); - if (ImGui::MenuItem("Save Pairs", "Ctrl+S", false, !state.pairs.empty() || !state.pairsPath.empty())) + if (ImGui::MenuItem("Save Pairs", SHORTCUT_CTRL "+S", false, !state.pairs.empty() || !state.pairsPath.empty())) actionSavePairs(state); if (ImGui::MenuItem("Save Pairs As...", nullptr, false, !state.pairs.empty())) actionSavePairsAs(state); @@ -607,7 +610,7 @@ void UI::panelIntrinsics(AppState& state) drag("p1", &K.p1, 0.0001f, -1.f, 1.f, "%.5f"); drag("p2", &K.p2, 0.0001f, -1.f, 1.f, "%.5f"); helpMarker( - "Drag to adjust. Hold Ctrl+click to type a value.\nUnlike Pinhole, the displayed image is never undistorted for " + "Drag to adjust. Hold " SHORTCUT_CTRL "+click to type a value.\nUnlike Pinhole, the displayed image is never undistorted for " "Mei -- the projection overlay and Camera RGB coloring apply this distortion to the raw image directly."); ImGui::Text("Refine with \"Solve Extrinsics from Pairs\":"); @@ -636,7 +639,7 @@ void UI::panelIntrinsics(AppState& state) drag("k3", &K.k3, 0.001f, -100.f, 100.f, "%.4f"); drag("k4", &K.k4, 0.001f, -100.f, 100.f, "%.4f"); helpMarker( - "Drag to adjust. Hold Ctrl+click to type a value.\nUnlike Pinhole, the displayed image is never undistorted for " + "Drag to adjust. Hold " SHORTCUT_CTRL "+click to type a value.\nUnlike Pinhole, the displayed image is never undistorted for " "Fisheye -- the projection overlay and Camera RGB coloring apply this distortion to the raw image directly."); } else @@ -651,7 +654,7 @@ void UI::panelIntrinsics(AppState& state) ImGui::Text("Tangential:"); drag("p1", &K.p1, 0.0001f, -1.f, 1.f, "%.5f"); drag("p2", &K.p2, 0.0001f, -1.f, 1.f, "%.5f"); - helpMarker("Drag to adjust. Hold Ctrl+click to type a value."); + helpMarker("Drag to adjust. Hold " SHORTCUT_CTRL "+click to type a value."); } ImGui::PopItemWidth(); @@ -839,7 +842,8 @@ void UI::panelVisualization(AppState& state) void UI::panelCorrespondences(AppState& state) { ImGui::TextWrapped( - "Shift+click the pixel in the Image View, and the LiDAR point in the 3D View -- or Shift+Alt+click it in the Image View, " + "Shift+click the pixel in the Image View, and the LiDAR point in the 3D View -- or Shift+" SHORTCUT_ALT + "+click it in the Image View, " "which shows the LiDAR intensity image while both are held. Picking both sides completes a pair."); ImGui::Text("Pending pair:"); @@ -904,16 +908,16 @@ void UI::panelCorrespondences(AppState& state) if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled)) { if (state.pairsPath.empty()) - ImGui::SetTooltip("Ctrl+S; asks for a file"); + ImGui::SetTooltip(SHORTCUT_CTRL "+S; asks for a file"); else - ImGui::SetTooltip("Ctrl+S, to %s", state.pairsPath.c_str()); + ImGui::SetTooltip(SHORTCUT_CTRL "+S, to %s", state.pairsPath.c_str()); } ImGui::SameLine(); if (ImGui::Button("Load pairs...")) actionLoadPairs(state); helpMarker( "Or drop a saved pairs .json on the window, or pass --pairs .\n" - "Loading replaces the current pairs. Ctrl+S saves to the last pairs file\n" + "Loading replaces the current pairs. " SHORTCUT_CTRL "+S saves to the last pairs file\n" "loaded or saved, or the --pairs one (created if it does not exist yet).\n" "Pixels are of the shown image (rectified or raw) -- load the same image and calibration first."); if (!state.pairsPath.empty()) diff --git a/apps/camera_lidar_calibration/main.cpp b/apps/camera_lidar_calibration/main.cpp index 4cd54aa8..5a41761b 100644 --- a/apps/camera_lidar_calibration/main.cpp +++ b/apps/camera_lidar_calibration/main.cpp @@ -1,5 +1,6 @@ #include "App.h" #include +#include #include #include #include @@ -42,8 +43,9 @@ static void preloadByExt(App& app, const std::string& p) static constexpr const char* kClosestToLaz = " --closest_to_laz with --camera_dir : load the image taken closest\n" " to the middle of the --laz clouds' point times"; -static constexpr const char* kPairs = " --pairs picked pairs: loaded when the file exists; Ctrl+S saves\n" - " the pairs to it"; +static constexpr const char* kPairs = + " --pairs picked pairs: loaded when the file exists; " SHORTCUT_CTRL "+S saves\n" + " the pairs to it"; int main(int argc, char* argv[]) { diff --git a/apps/camera_lidar_trajectory_viewer/TrajectoryViewer.cpp b/apps/camera_lidar_trajectory_viewer/TrajectoryViewer.cpp index 54463504..0bb87e50 100644 --- a/apps/camera_lidar_trajectory_viewer/TrajectoryViewer.cpp +++ b/apps/camera_lidar_trajectory_viewer/TrajectoryViewer.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -56,11 +57,11 @@ static const std::vector appShortcuts = { { "Normal keys", "C", "Toggle compass/ruler" }, { "", "P", "Toggle show path" }, { "", "V", "Toggle show frustums" }, - { "", "Ctrl (tap)", "Toggle Intensity <-> RGB point color" }, - { "", "Ctrl+O", "Select session (.mjs)" }, - { "", "Ctrl+Shift+O", "Select CAMERA_0 directory" }, - { "", "Ctrl+Shift+C", "Open calibration" }, - { "", "Ctrl+S", "Export colored point cloud (LAS/LAZ)" }, + { "", SHORTCUT_CTRL " (tap)", "Toggle Intensity <-> RGB point color" }, + { "", SHORTCUT_CTRL "+O", "Select session (.mjs)" }, + { "", SHORTCUT_CTRL "+Shift+O", "Select CAMERA_0 directory" }, + { "", SHORTCUT_CTRL "+Shift+C", "Open calibration" }, + { "", SHORTCUT_CTRL "+S", "Export colored point cloud (LAS/LAZ)" }, { "Camera", "F", "Front view" }, { "", "B", "Back view" }, { "", "L", "Left view" }, @@ -77,8 +78,8 @@ static const std::vector appShortcuts = { { "Mouse related", "Left click + drag", "Orbit camera (flyover: look around)" }, { "", "Right click + drag", "Pan camera" }, { "", "Scroll", "Zoom camera" }, - { "", "Ctrl+Right click", "Set center of rotation (ground plane)" }, - { "", "Ctrl+Middle click", "Set center of rotation (nearest trajectory point)" }, + { "", SHORTCUT_CTRL "+Right click", "Set center of rotation (ground plane)" }, + { "", SHORTCUT_CTRL "+Middle click", "Set center of rotation (nearest trajectory point)" }, { "", "Shift+R", "Open 'Center of rotation' dialog" }, }; @@ -2483,14 +2484,12 @@ int main(int argc, char* argv[]) // Ctrl toggles point coloring: intensity (jet) <-> RGB if (!ImGui::GetIO().WantCaptureKeyboard) { - if (IsKeyPressed(KEY_LEFT_CONTROL) || IsKeyPressed(KEY_RIGHT_CONTROL)) + if (raylib_widgets::isShortcutModifierPressed()) s.colorMode = (s.colorMode == 1) ? 0 : 1; // Chords avoid colliding in meaning with step2's, and keep Ctrl+O - // and bare C/P aligned with it. Super counts as ctrlDown so macOS - // Cmd works, where it is a distinct key from Ctrl. - bool ctrlDown = - IsKeyDown(KEY_LEFT_CONTROL) || IsKeyDown(KEY_RIGHT_CONTROL) || IsKeyDown(KEY_LEFT_SUPER) || IsKeyDown(KEY_RIGHT_SUPER); + // and bare C/P aligned with it. Ctrl here is Cmd on macOS. + bool ctrlDown = raylib_widgets::isShortcutModifierDown(); bool shiftDown = IsKeyDown(KEY_LEFT_SHIFT) || IsKeyDown(KEY_RIGHT_SHIFT); if (ctrlDown && shiftDown && IsKeyPressed(KEY_O)) actionSelectCamera0Dir(s); @@ -2770,17 +2769,17 @@ int main(int argc, char* argv[]) { if (ImGui::BeginMenu("File")) { - if (ImGui::MenuItem("Select Session (.mjs)...", "Ctrl+O")) + if (ImGui::MenuItem("Select Session (.mjs)...", SHORTCUT_CTRL "+O")) actionSelectSession(s); - if (ImGui::MenuItem("Select CAMERA_0 Directory...", "Ctrl+Shift+O")) + if (ImGui::MenuItem("Select CAMERA_0 Directory...", SHORTCUT_CTRL "+Shift+O")) actionSelectCamera0Dir(s); ImGui::Separator(); - if (ImGui::MenuItem("Open Calibration...", "Ctrl+Shift+C")) + if (ImGui::MenuItem("Open Calibration...", SHORTCUT_CTRL "+Shift+C")) actionOpenCalibration(s); if (ImGui::MenuItem("Open Image Mask...")) actionOpenMask(s); ImGui::Separator(); - if (ImGui::MenuItem("Export Colored Point Cloud (LAS/LAZ)...", "Ctrl+S")) + if (ImGui::MenuItem("Export Colored Point Cloud (LAS/LAZ)...", SHORTCUT_CTRL "+S")) actionExportColoredLAZ(s); if (ImGui::MenuItem("Export Colored Point Cloud (E57)...")) actionExportColoredE57(s); @@ -2862,12 +2861,12 @@ int main(int argc, char* argv[]) } if (s.lazHasRgb && s.imagesFilenamesInTime.empty()) { - if (ImGui::MenuItem("RGB (LAZ)", "Ctrl", s.colorMode == 1)) + if (ImGui::MenuItem("RGB (LAZ)", SHORTCUT_CTRL, s.colorMode == 1)) s.colorMode = 1; } if (!s.imagesFilenamesInTime.empty()) { - if (ImGui::MenuItem(s.lazHasRgb ? "RGB (image, LAZ fallback)" : "RGB (image)", "Ctrl", s.colorMode == 1)) + if (ImGui::MenuItem(s.lazHasRgb ? "RGB (image, LAZ fallback)" : "RGB (image)", SHORTCUT_CTRL, s.colorMode == 1)) s.colorMode = 1; if (ImGui::MenuItem("Camera ID", nullptr, s.colorMode == 2)) s.colorMode = 2; @@ -3349,7 +3348,7 @@ int main(int argc, char* argv[]) ImGui::SetNextItemWidth(160.f); ImGui::SliderFloat("Speed", &s.flyoverSpeed, 0.1f, 50.f, "%.1fx", ImGuiSliderFlags_Logarithmic); if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Playback rate, as a multiple of real time (Ctrl+click to type)"); + ImGui::SetTooltip("Playback rate, as a multiple of real time (" SHORTCUT_CTRL "+click to type)"); ImGui::SameLine(); ImGui::SetNextItemWidth(120.f); ImGui::SliderFloat("Smoothing", &s.flyoverSmoothingSec, 0.f, 5.f, "%.1f s"); diff --git a/apps/lidar_odometry_step_1/lidar_odometry_gui.cpp b/apps/lidar_odometry_step_1/lidar_odometry_gui.cpp index ef86ca8a..d07a0d08 100644 --- a/apps/lidar_odometry_step_1/lidar_odometry_gui.cpp +++ b/apps/lidar_odometry_step_1/lidar_odometry_gui.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include "toml_io.h" #include @@ -74,7 +75,7 @@ static const std::vector appShortcuts = { { "Help", "F1", "Show / { "", "Shift + scroll", "Faster zoom in perspective view" }, { "", "Double left click", "Explore nearest trajectory point" }, { "", "Double right click", "Return to processing head" }, - { "Camera", "Ctrl + arrows", "Rotate camera" }, + { "Camera", SHORTCUT_CTRL " + arrows", "Rotate camera" }, { "", "Shift + arrows", "Pan camera" }, { "", "F / B", "Front / back view" }, { "", "L / R", "Left / right view" }, @@ -86,9 +87,9 @@ static const std::vector appShortcuts = { { "Help", "F1", "Show / { "", "C", "Show / hide compass and ruler" }, { "", "X", "Show / hide axes" }, { "", "1-9", "Set point size" }, - { "Data", "Ctrl + O", "Load and process data when idle" }, + { "Data", SHORTCUT_CTRL " + O", "Load and process data when idle" }, { "Free exploration", "Shift + R", "Open rotation-center coordinates" }, - { "", "Ctrl + right/middle click", "Choose rotation center on Z=0" } }; + { "", SHORTCUT_CTRL " + right/middle click", "Choose rotation center on Z=0" } }; namespace fs = std::filesystem; @@ -2559,7 +2560,8 @@ void display() if (ImGui::Button("Load & process scanning")) openData(); if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Select folder from where to load data and start processing (Ctrl+O), or drop the folder on the window"); + ImGui::SetTooltip( + "Select folder from where to load data and start processing (" SHORTCUT_CTRL "+O), or drop the folder on the window"); ImGui::SameLine(); ImGui::Dummy(ImVec2(20, 0)); diff --git a/apps/mandeye_raw_data_viewer/mandeye_raw_data_viewer.cpp b/apps/mandeye_raw_data_viewer/mandeye_raw_data_viewer.cpp index 535df552..46161202 100644 --- a/apps/mandeye_raw_data_viewer/mandeye_raw_data_viewer.cpp +++ b/apps/mandeye_raw_data_viewer/mandeye_raw_data_viewer.cpp @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -1739,7 +1740,7 @@ static void playbackBar() ImGui::SetNextItemWidth(160.f); ImGui::SliderFloat("Speed", &playback_speed, 0.1f, 50.f, "%.1fx", ImGuiSliderFlags_Logarithmic); if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Playback rate, as a multiple of real time (Ctrl+click to type)"); + ImGui::SetTooltip("Playback rate, as a multiple of real time (" SHORTCUT_CTRL "+click to type)"); ImGui::SameLine(); ImGui::Dummy(ImVec2(20, 0)); @@ -2039,7 +2040,7 @@ void display() if (ImGui::Button("Open folder")) openFolder(); if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Select folder containing files for analyze (Ctrl+O), or drop folders/files on the window"); + ImGui::SetTooltip("Select folder containing files for analyze (" SHORTCUT_CTRL "+O), or drop folders/files on the window"); ImGui::SameLine(); diff --git a/apps/multi_session_registration/multi_session_registration.cpp b/apps/multi_session_registration/multi_session_registration.cpp index ce206194..00da92f0 100644 --- a/apps/multi_session_registration/multi_session_registration.cpp +++ b/apps/multi_session_registration/multi_session_registration.cpp @@ -39,6 +39,8 @@ #include #include +#include + #ifdef _WIN32 #include "resource.h" @@ -59,73 +61,73 @@ std::vector infoLines = { // App specific shortcuts (Type and Shortcut are just for easy reference) static const std::vector appShortcuts = { { "Normal keys", "A", "" }, - { "", "Ctrl+A", "Add session(s)" }, + { "", SHORTCUT_CTRL "+A", "Add session(s)" }, { "", "B", "" }, - { "", "Ctrl+B", "" }, + { "", SHORTCUT_CTRL "+B", "" }, { "", "C", "" }, - { "", "Ctrl+C", "" }, + { "", SHORTCUT_CTRL "+C", "" }, { "", "D", "" }, - { "", "Ctrl+D", "Remove session(s)" }, + { "", SHORTCUT_CTRL "+D", "Remove session(s)" }, { "", "E", "" }, - { "", "Ctrl+E", "" }, + { "", SHORTCUT_CTRL "+E", "" }, { "", "F", "" }, - { "", "Ctrl+F", "" }, + { "", SHORTCUT_CTRL "+F", "" }, { "", "G", "" }, - { "", "Ctrl+G", "Move center of rotation to gizmo" }, + { "", SHORTCUT_CTRL "+G", "Move center of rotation to gizmo" }, { "", "H", "" }, - { "", "Ctrl+H", "" }, + { "", SHORTCUT_CTRL "+H", "" }, { "", "I", "" }, - { "", "Ctrl+I", "" }, + { "", SHORTCUT_CTRL "+I", "" }, { "", "J", "" }, - { "", "Ctrl+K", "" }, + { "", SHORTCUT_CTRL "+K", "" }, { "", "K", "" }, - { "", "Ctrl+K", "" }, + { "", SHORTCUT_CTRL "+K", "" }, { "", "L", "" }, - { "", "Ctrl+L", "Load sessions" }, + { "", SHORTCUT_CTRL "+L", "Load sessions" }, { "", "M", "" }, - { "", "Ctrl+M", "Manual loop closure" }, + { "", SHORTCUT_CTRL "+M", "Manual loop closure" }, { "", "N", "" }, - { "", "Ctrl+N", "" }, + { "", SHORTCUT_CTRL "+N", "" }, { "", "O", "" }, - { "", "Ctrl+O", "Open project" }, + { "", SHORTCUT_CTRL "+O", "Open project" }, { "", "P", "" }, - { "", "Ctrl+P", "" }, + { "", SHORTCUT_CTRL "+P", "" }, { "", "Q", "" }, - { "", "Ctrl+Q", "" }, + { "", SHORTCUT_CTRL "+Q", "" }, { "", "R", "" }, - { "", "Ctrl+R", "Random colors per session" }, + { "", SHORTCUT_CTRL "+R", "Random colors per session" }, { "", "Shift+R", "" }, { "", "S", "" }, - { "", "Ctrl+S", "Save project" }, - { "", "Ctrl+Shift+S", "Save project as" }, + { "", SHORTCUT_CTRL "+S", "Save project" }, + { "", SHORTCUT_CTRL "+Shift+S", "Save project as" }, { "", "T", "" }, - { "", "Ctrl+T", "" }, + { "", SHORTCUT_CTRL "+T", "" }, { "", "U", "" }, - { "", "Ctrl+U", "" }, + { "", SHORTCUT_CTRL "+U", "" }, { "", "V", "" }, - { "", "Ctrl+V", "" }, + { "", SHORTCUT_CTRL "+V", "" }, { "", "W", "" }, - { "", "Ctrl+W", "" }, + { "", SHORTCUT_CTRL "+W", "" }, { "", "X", "" }, - { "", "Ctrl+X", "" }, + { "", SHORTCUT_CTRL "+X", "" }, { "", "Y", "" }, - { "", "Ctrl+Y", "" }, + { "", SHORTCUT_CTRL "+Y", "" }, { "", "Z", "" }, - { "", "Ctrl+Z", "" }, + { "", SHORTCUT_CTRL "+Z", "" }, { "", "Shift+Z", "" }, { "", "1-9", "" }, { "Special keys", "Up arrow", "" }, { "", "Shift + up arrow", "" }, - { "", "Ctrl + up arrow", "" }, + { "", SHORTCUT_CTRL " + up arrow", "" }, { "", "Down arrow", "" }, { "", "Shift + down arrow", "" }, - { "", "Ctrl + down arrow", "" }, + { "", SHORTCUT_CTRL " + down arrow", "" }, { "", "Left arrow", "" }, { "", "Shift + left arrow", "" }, - { "", "Ctrl + left arrow", "" }, + { "", SHORTCUT_CTRL " + left arrow", "" }, { "", "Right arrow", "" }, { "", "Shift + right arrow", "" }, - { "", "Ctrl + right arrow", "" }, + { "", SHORTCUT_CTRL " + right arrow", "" }, { "", "Pg down", "" }, { "", "Pg up", "" }, { "", "- key", "" }, @@ -135,9 +137,9 @@ static const std::vector appShortcuts = { { "Normal keys", "A", " { "", "Scroll", "" }, { "", "Shift + scroll", "" }, { "", "Shift + drag", "" }, - { "", "Ctrl + left click", "" }, - { "", "Ctrl + right click", "change center of rotation" }, - { "", "Ctrl + middle click", "change center of rotation" } }; + { "", SHORTCUT_CTRL " + left click", "" }, + { "", SHORTCUT_CTRL " + right click", "change center of rotation" }, + { "", SHORTCUT_CTRL " + middle click", "change center of rotation" } }; float m_gizmo[] = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }; @@ -3126,23 +3128,24 @@ void display() { if (ImGui::BeginMenu("File")) { - if (ImGui::MenuItem("Open project", "Ctrl+O")) + if (ImGui::MenuItem("Open project", SHORTCUT_CTRL "+O")) openProject(); - if (ImGui::MenuItem("Save project", "Ctrl+S", nullptr, project_settings.session_file_names.size() > 0)) + if (ImGui::MenuItem("Save project", SHORTCUT_CTRL "+S", nullptr, project_settings.session_file_names.size() > 0)) saveProject(); - if (ImGui::MenuItem("Save project as...", "Ctrl+Shift+S", nullptr, project_settings.session_file_names.size() > 0)) + if (ImGui::MenuItem("Save project as...", SHORTCUT_CTRL "+Shift+S", nullptr, project_settings.session_file_names.size() > 0)) saveProjectAs(); if (ImGui::IsItemHovered() && !project_file_name.empty()) ImGui::SetTooltip("Current project: %s", project_file_name.c_str()); ImGui::Separator(); - if (ImGui::MenuItem("Add session(s)", "Ctrl+A")) + if (ImGui::MenuItem("Add session(s)", SHORTCUT_CTRL "+A")) addSession(); - if (ImGui::MenuItem("Remove session(s)", "Ctrl+D", nullptr, project_settings.session_file_names.size() > 0)) + if (ImGui::MenuItem("Remove session(s)", SHORTCUT_CTRL "+D", nullptr, project_settings.session_file_names.size() > 0)) remove_gui = true; - if (ImGui::MenuItem("Load sessions", "Ctrl+L", nullptr, (project_settings.session_file_names.size() > 0) && !loaded_sessions)) + if (ImGui::MenuItem( + "Load sessions", SHORTCUT_CTRL "+L", nullptr, (project_settings.session_file_names.size() > 0) && !loaded_sessions)) loadSessions(); ImGui::Separator(); @@ -3702,7 +3705,10 @@ void display() // bool prev_is_loop_closure_gui ImGui::MenuItem( - "Manual Loop Closure", "Ctrl+M", &is_loop_closure_gui, (number_visible_sessions == 1 || number_visible_sessions == 2)); + "Manual Loop Closure", + SHORTCUT_CTRL "+M", + &is_loop_closure_gui, + (number_visible_sessions == 1 || number_visible_sessions == 2)); if (ImGui::IsItemHovered()) ImGui::SetTooltip("Manually connect overlapping scan sections"); diff --git a/apps/multi_view_tls_registration/multi_view_tls_registration_gui.cpp b/apps/multi_view_tls_registration/multi_view_tls_registration_gui.cpp index b232aa28..e9eac35c 100644 --- a/apps/multi_view_tls_registration/multi_view_tls_registration_gui.cpp +++ b/apps/multi_view_tls_registration/multi_view_tls_registration_gui.cpp @@ -126,6 +126,7 @@ #include #include #include +#include #include #include #include @@ -888,86 +889,88 @@ std::vector infoLines = { // a "Ctrl+J" entry, silently shifting every entry after "J" by one row // against the generic list's descriptions; and "Right click + drag" had a // stray "n" instead of its real "camera pan" description. -static const std::vector appShortcuts = { { "Normal keys", "A", "" }, - { "", "Ctrl+A", "point cloud Alignment" }, - { "", "B", "camera Back" }, - { "", "Ctrl+B", "" }, - { "", "C", "Compass/ruler" }, - { "", "Ctrl+C", "Control points" }, - { "", "D", "" }, - { "", "Ctrl+D", "" }, - { "", "E", "" }, - { "", "Ctrl+E", "lio segments Editor" }, - { "", "F", "camera Front" }, - { "", "Ctrl+F", "" }, - { "", "G", "" }, - { "", "Ctrl+G", "Ground control points" }, - { "", "H", "" }, - { "", "Ctrl+H", "" }, - { "", "I", "camera Isometric" }, - { "", "Ctrl+I", "" }, - { "", "J", "" }, - { "", "Ctrl+J", "" }, - { "", "K", "" }, - { "", "Ctrl+K", "" }, - { "", "L", "camera Left" }, - { "", "Ctrl+L", "manual Loop closure" }, - { "", "M", "" }, - { "", "Ctrl+M", "Measure distance" }, - { "", "N", "Next edge (manual loop closure, BoW preview)" }, - { "", "Ctrl+N", "" }, - { "", "O", "Ortographic view" }, - { "", "Ctrl+O", "Open/load session/data" }, - { "", "P", "Previous edge (manual loop closure, BoW preview)" }, - { "", "Ctrl+P", "Pose graph slam" }, - { "", "Q", "" }, - { "", "Ctrl+Q", "" }, - { "", "R", "camera Right" }, - { "", "Ctrl+R", "Random cloud colors" }, - { "", "Shift+R", "Rotation center" }, - { "", "S", "" }, - { "", "Ctrl+S", "Save session" }, - { "", "Ctrl+Shift+S", "Save subsession" }, - { "", "T", "camera Top" }, - { "", "Ctrl+T", "Solid cloud color" }, - { "", "U", "camera bottom (Under)" }, - { "", "Ctrl+U", "" }, - { "", "V", "" }, - { "", "Ctrl+V", "" }, - { "", "W", "" }, - { "", "Ctrl+W", "" }, - { "", "X", "show aXes" }, - { "", "Ctrl+X", "" }, - { "", "Y", "" }, - { "", "Ctrl+Y", "" }, - { "", "Z", "camera reset" }, - { "", "Ctrl+Z", "" }, - { "", "Shift+Z", "Lock Z" }, - { "", "1-9", "point size" }, - { "Special keys", "Up arrow", "" }, - { "", "Shift + up arrow", "camera translate Up" }, - { "", "Ctrl + up arrow", "" }, - { "", "Down arrow", "" }, - { "", "Shift + down arrow", "camera translate Down" }, - { "", "Ctrl + down arrow", "" }, - { "", "Left arrow", "" }, - { "", "Shift + left arrow", "camera translate Left" }, - { "", "Ctrl + left arrow", "" }, - { "", "Right arrow", "" }, - { "", "Shift + right arrow", "camera translate Right" }, - { "", "Ctrl + right arrow", "" }, - { "", "Pg down", "" }, - { "", "Pg up", "" }, - { "", "- key", "" }, - { "", "+ key", "" }, - { "Mouse related", "Left click + drag", "camera rotate" }, - { "", "Right click + drag", "camera pan" }, - { "", "Scroll", "camera zoom" }, - { "", "Shift + scroll", "camera 5x zoom" }, - { "", "Shift + drag", "Dock window to screen edges" }, - { "", "Ctrl + left click", "" }, - { "", "Ctrl + right click", "change center of rotation" }, - { "", "Ctrl + middle click", "change center of rotation (if no CP GUI active)" } }; +static const std::vector appShortcuts = { + { "Normal keys", "A", "" }, + { "", SHORTCUT_CTRL "+A", "point cloud Alignment" }, + { "", "B", "camera Back" }, + { "", SHORTCUT_CTRL "+B", "" }, + { "", "C", "Compass/ruler" }, + { "", SHORTCUT_CTRL "+C", "Control points" }, + { "", "D", "" }, + { "", SHORTCUT_CTRL "+D", "" }, + { "", "E", "" }, + { "", SHORTCUT_CTRL "+E", "lio segments Editor" }, + { "", "F", "camera Front" }, + { "", SHORTCUT_CTRL "+F", "" }, + { "", "G", "" }, + { "", SHORTCUT_CTRL "+G", "Ground control points" }, + { "", "H", "" }, + { "", SHORTCUT_CTRL "+H", "" }, + { "", "I", "camera Isometric" }, + { "", SHORTCUT_CTRL "+I", "" }, + { "", "J", "" }, + { "", SHORTCUT_CTRL "+J", "" }, + { "", "K", "" }, + { "", SHORTCUT_CTRL "+K", "" }, + { "", "L", "camera Left" }, + { "", SHORTCUT_CTRL "+L", "manual Loop closure" }, + { "", "M", "" }, + { "", SHORTCUT_CTRL "+M", "Measure distance" }, + { "", "N", "Next edge (manual loop closure, BoW preview)" }, + { "", SHORTCUT_CTRL "+N", "" }, + { "", "O", "Ortographic view" }, + { "", SHORTCUT_CTRL "+O", "Open/load session/data" }, + { "", "P", "Previous edge (manual loop closure, BoW preview)" }, + { "", SHORTCUT_CTRL "+P", "Pose graph slam" }, + { "", "Q", "" }, + { "", SHORTCUT_CTRL "+Q", "" }, + { "", "R", "camera Right" }, + { "", SHORTCUT_CTRL "+R", "Random cloud colors" }, + { "", "Shift+R", "Rotation center" }, + { "", "S", "" }, + { "", SHORTCUT_CTRL "+S", "Save session" }, + { "", SHORTCUT_CTRL "+Shift+S", "Save subsession" }, + { "", "T", "camera Top" }, + { "", SHORTCUT_CTRL "+T", "Solid cloud color" }, + { "", "U", "camera bottom (Under)" }, + { "", SHORTCUT_CTRL "+U", "" }, + { "", "V", "" }, + { "", SHORTCUT_CTRL "+V", "" }, + { "", "W", "" }, + { "", SHORTCUT_CTRL "+W", "" }, + { "", "X", "show aXes" }, + { "", SHORTCUT_CTRL "+X", "" }, + { "", "Y", "" }, + { "", SHORTCUT_CTRL "+Y", "" }, + { "", "Z", "camera reset" }, + { "", SHORTCUT_CTRL "+Z", "" }, + { "", "Shift+Z", "Lock Z" }, + { "", "1-9", "point size" }, + { "Special keys", "Up arrow", "" }, + { "", "Shift + up arrow", "camera translate Up" }, + { "", SHORTCUT_CTRL " + up arrow", "" }, + { "", "Down arrow", "" }, + { "", "Shift + down arrow", "camera translate Down" }, + { "", SHORTCUT_CTRL " + down arrow", "" }, + { "", "Left arrow", "" }, + { "", "Shift + left arrow", "camera translate Left" }, + { "", SHORTCUT_CTRL " + left arrow", "" }, + { "", "Right arrow", "" }, + { "", "Shift + right arrow", "camera translate Right" }, + { "", SHORTCUT_CTRL " + right arrow", "" }, + { "", "Pg down", "" }, + { "", "Pg up", "" }, + { "", "- key", "" }, + { "", "+ key", "" }, + { "Mouse related", "Left click + drag", "camera rotate" }, + { "", "Right click + drag", "camera pan" }, + { "", "Scroll", "camera zoom" }, + { "", "Shift + scroll", "camera 5x zoom" }, + { "", "Shift + drag", "Dock window to screen edges" }, + { "", SHORTCUT_CTRL " + left click", "" }, + { "", SHORTCUT_CTRL " + right click", "change center of rotation" }, + { "", SHORTCUT_CTRL " + middle click", "change center of rotation (if no CP GUI active)" } +}; namespace fs = std::filesystem; @@ -5878,7 +5881,7 @@ void display() if (ImGui::Button("Open session")) openSession(); if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Select session to open (Ctrl+O)"); + ImGui::SetTooltip("Select session to open (" SHORTCUT_CTRL "+O)"); ImGui::SameLine(); @@ -5926,7 +5929,7 @@ void display() if (ImGui::MenuItem("Open session")) openSession(); if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Replace the current session with another one (Ctrl+O)"); + ImGui::SetTooltip("Replace the current session with another one (" SHORTCUT_CTRL "+O)"); if (ImGui::MenuItem("Open las/laz")) openLaz(fillInSession); @@ -5966,7 +5969,7 @@ void display() ImGui::Separator(); - if (ImGui::MenuItem("Save session as", "Ctrl+S")) + if (ImGui::MenuItem("Save session as", SHORTCUT_CTRL "+S")) saveSession(); if (ImGui::IsItemHovered()) ImGui::SetTooltip("Save changes of full session with posibility to change filename"); @@ -5974,7 +5977,7 @@ void display() // ImGui::BeginDisabled(!((index_begin > 0) || (index_end < // static_cast(session.point_clouds_container.point_clouds.size() - 1)))); //{ - if (ImGui::MenuItem("Save subsession", "Ctrl+Shift+S")) + if (ImGui::MenuItem("Save subsession", SHORTCUT_CTRL "+Shift+S")) saveSubsession(); if (ImGui::IsItemHovered()) ImGui::SetTooltip("Save session according to selections from 'LIO segments editor' window"); @@ -6604,7 +6607,7 @@ void display() if (ImGui::BeginMenu("Tools")) { - ImGui::MenuItem("Point Cloud Alignment", "Ctrl+A", &is_pca_gui); + ImGui::MenuItem("Point Cloud Alignment", SHORTCUT_CTRL "+A", &is_pca_gui); if (ImGui::IsItemHovered()) { ImGui::BeginTooltip(); @@ -6618,21 +6621,22 @@ void display() ImGui::EndTooltip(); } ImGui::Separator(); - ImGui::MenuItem("Pose Graph SLAM", "Ctrl+P", &is_pose_graph_slam); + ImGui::MenuItem("Pose Graph SLAM", SHORTCUT_CTRL "+P", &is_pose_graph_slam); ImGui::MenuItem("Observations", nullptr, &is_manual_analisys); ImGui::Separator(); - ImGui::MenuItem("Control Points", "Ctrl+C", &session.control_points.is_imgui, !session.ground_control_points.is_imgui); + ImGui::MenuItem( + "Control Points", SHORTCUT_CTRL "+C", &session.control_points.is_imgui, !session.ground_control_points.is_imgui); if (ImGui::IsItemHovered()) ImGui::SetTooltip("Known reference points used to align or verify the scan"); ImGui::MenuItem( - "Ground Control Points", "Ctrl+G", &session.ground_control_points.is_imgui, !session.control_points.is_imgui); + "Ground Control Points", SHORTCUT_CTRL "+G", &session.ground_control_points.is_imgui, !session.control_points.is_imgui); if (ImGui::IsItemHovered()) ImGui::SetTooltip("Accurate real-world points used to georeference the scan"); - ImGui::MenuItem("Manual Loop Closure", "Ctrl+L", &is_loop_closure_gui, !is_lio_segments_gui); + ImGui::MenuItem("Manual Loop Closure", SHORTCUT_CTRL "+L", &is_loop_closure_gui, !is_lio_segments_gui); if (ImGui::IsItemHovered()) ImGui::SetTooltip("Manually connect overlapping scan sections"); @@ -6641,7 +6645,7 @@ void display() ImGui::SetTooltip("Detect loop closure candidates from CAMERA_0 images (fbow); review before adding edges"); ImGui::Separator(); - ImGui::MenuItem("LIO segments editor", "Ctrl+E", &is_lio_segments_gui, !is_loop_closure_gui); + ImGui::MenuItem("LIO segments editor", SHORTCUT_CTRL "+E", &is_lio_segments_gui, !is_loop_closure_gui); if (ImGui::IsItemHovered()) ImGui::SetTooltip("Manually adjust or review Lidar Inertial Odometry trajectory segments"); @@ -6650,7 +6654,7 @@ void display() if (ImGui::IsItemHovered()) ImGui::SetTooltip("Define new coordinate frame from 3 picked points and transform all clouds"); - ImGui::MenuItem("Measure distance", "Ctrl+M", &is_measure_gui); + ImGui::MenuItem("Measure distance", SHORTCUT_CTRL "+M", &is_measure_gui); if (ImGui::IsItemHovered()) ImGui::SetTooltip("Pick 2 points on the point cloud and measure the distance between them"); @@ -6818,7 +6822,7 @@ void display() if (ImGui::MenuItem("> Solid", nullptr, (csPointCloud == CS_SOLID))) csPointCloud = CS_SOLID; - if (ImGui::MenuItem("> Random per segment", "Ctrl+R", (csPointCloud == CS_RANDOM))) + if (ImGui::MenuItem("> Random per segment", SHORTCUT_CTRL "+R", (csPointCloud == CS_RANDOM))) { csPointCloud = CS_RANDOM; diff --git a/raylib_widgets/CMakeLists.txt b/raylib_widgets/CMakeLists.txt index dfef7c5f..a9ed214f 100644 --- a/raylib_widgets/CMakeLists.txt +++ b/raylib_widgets/CMakeLists.txt @@ -18,6 +18,7 @@ add_library(raylib_widgets STATIC src/CompassRuler.cpp src/WindowFit.cpp src/ShortcutsTable.cpp + src/PlatformKeys.cpp src/OrbitCamera.cpp src/CenterOfRotationWindow.cpp src/PointPicking.cpp diff --git a/raylib_widgets/include/RaylibWidgets/PlatformKeys.h b/raylib_widgets/include/RaylibWidgets/PlatformKeys.h new file mode 100644 index 00000000..56f56df8 --- /dev/null +++ b/raylib_widgets/include/RaylibWidgets/PlatformKeys.h @@ -0,0 +1,23 @@ +#pragma once + +// Platform names of the shortcut modifier keys, as string literals so they join adjacent literals at compile +// time: SHORTCUT_CTRL "+O" is "Ctrl+O" on Windows and Linux, "Cmd+O" on macOS. Dear ImGui swaps Cmd and +// Ctrl on macOS (io.ConfigMacOSXBehaviors), so io.KeyCtrl / ImGuiMod_Ctrl already mean Cmd there. +#ifdef __APPLE__ +#define SHORTCUT_CTRL "Cmd" +#define SHORTCUT_ALT "Option" +#else +#define SHORTCUT_CTRL "Ctrl" +#define SHORTCUT_ALT "Alt" +#endif + +namespace raylib_widgets +{ + + //! True while the platform's shortcut modifier is held, read from raylib: Cmd on macOS, Ctrl elsewhere. + bool isShortcutModifierDown(); + + //! True on the frame the platform's shortcut modifier is pressed, read from raylib: Cmd on macOS, Ctrl elsewhere. + bool isShortcutModifierPressed(); + +} // namespace raylib_widgets diff --git a/raylib_widgets/src/PlatformKeys.cpp b/raylib_widgets/src/PlatformKeys.cpp new file mode 100644 index 00000000..ebd8b89c --- /dev/null +++ b/raylib_widgets/src/PlatformKeys.cpp @@ -0,0 +1,28 @@ +#include +#include + +namespace raylib_widgets +{ + + namespace + { +#ifdef __APPLE__ + constexpr int kModifierLeft = KEY_LEFT_SUPER; + constexpr int kModifierRight = KEY_RIGHT_SUPER; +#else + constexpr int kModifierLeft = KEY_LEFT_CONTROL; + constexpr int kModifierRight = KEY_RIGHT_CONTROL; +#endif + } // namespace + + bool isShortcutModifierDown() + { + return IsKeyDown(kModifierLeft) || IsKeyDown(kModifierRight); + } + + bool isShortcutModifierPressed() + { + return IsKeyPressed(kModifierLeft) || IsKeyPressed(kModifierRight); + } + +} // namespace raylib_widgets