Skip to content

Commit

Permalink
Change the "slow-down-camera" modifier to Alt on non-Mac (#3051)
Browse files Browse the repository at this point in the history
This Fixes #1867. Setting Alt as the slowdown behaviour for the camera
movement. Note, that this also sets it to alt for wasm architecture, let
me know if you wish for an extra check for wasm (and leave it as alt).

Thanks.

* [X] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [X] I've included a screenshot or gif (if applicable)
* [X] I have tested [demo.rerun.io](https://demo.rerun.io/pr/{{
pr.number }}) (if applicable)

- [PR Build Summary](https://build.rerun.io/pr/{{ pr.number }})
- [Docs preview](https://rerun.io/preview/{{
"pr:%s"|format(pr.branch)|encode_uri_component }}/docs)
- [Examples preview](https://rerun.io/preview/{{
"pr:%s"|format(pr.branch)|encode_uri_component }}/examples)
- [Recent benchmark results](https://ref.rerun.io/dev/bench/)
- [Wasm size tracking](https://ref.rerun.io/dev/sizes/)

---------

Co-authored-by: hemosphere <hemosphere@proton.me>
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
  • Loading branch information
3 people authored and jleibs committed Aug 31, 2023
1 parent d02ce9e commit 46ca167
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
16 changes: 13 additions & 3 deletions crates/re_space_view/src/controls.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use egui::{os::OperatingSystem, Modifiers};

/// Modifier to press for scroll to zoom.
pub const ZOOM_SCROLL_MODIFIER: egui::Modifiers = egui::Modifiers::COMMAND;

Expand Down Expand Up @@ -35,11 +37,19 @@ pub const ROLL_MOUSE_MODIFIER: egui::Modifiers = egui::Modifiers::ALT;
/// Which modifier speeds up the 3D camera movement.
pub const SPEED_UP_3D_MODIFIER: egui::Modifiers = egui::Modifiers::SHIFT;

/// Which modifier slows down the 3D camera movement.
pub const SLOW_DOWN_3D_MODIFIER: egui::Modifiers = egui::Modifiers::CTRL;

/// Key to restore the camera.
pub const TRACKED_CAMERA_RESTORE_KEY: egui::Key = egui::Key::Escape;

/// Description text for which action resets a space view.
pub const RESET_VIEW_BUTTON_TEXT: &str = "double click";

pub struct RuntimeModifiers {}

impl RuntimeModifiers {
pub fn slow_down(os: &OperatingSystem) -> Modifiers {
match os {
egui::os::OperatingSystem::Mac => egui::Modifiers::CTRL,
_ => egui::Modifiers::ALT,
}
}
}
9 changes: 6 additions & 3 deletions crates/re_space_view_spatial/src/eye.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use glam::Affine3A;
use macaw::{vec3, BoundingBox, IsoTransform, Mat4, Quat, Vec3};

use re_space_view::controls::{
DRAG_PAN3D_BUTTON, ROLL_MOUSE, ROLL_MOUSE_ALT, ROLL_MOUSE_MODIFIER, ROTATE3D_BUTTON,
SLOW_DOWN_3D_MODIFIER, SPEED_UP_3D_MODIFIER,
RuntimeModifiers, DRAG_PAN3D_BUTTON, ROLL_MOUSE, ROLL_MOUSE_ALT, ROLL_MOUSE_MODIFIER,
ROTATE3D_BUTTON, SPEED_UP_3D_MODIFIER,
};

use crate::space_camera_3d::SpaceCamera3D;
Expand Down Expand Up @@ -389,7 +389,10 @@ impl OrbitEye {
} else {
1.0
})
* (if input.modifiers.contains(SLOW_DOWN_3D_MODIFIER) {
* (if input
.modifiers
.contains(RuntimeModifiers::slow_down(&egui_ctx.os()))
{
0.1
} else {
1.0
Expand Down
8 changes: 4 additions & 4 deletions crates/re_space_view_spatial/src/ui_3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use re_renderer::{
LineStripSeriesBuilder, Size,
};
use re_space_view::controls::{
DRAG_PAN3D_BUTTON, RESET_VIEW_BUTTON_TEXT, ROLL_MOUSE, ROLL_MOUSE_ALT, ROLL_MOUSE_MODIFIER,
ROTATE3D_BUTTON, SLOW_DOWN_3D_MODIFIER, SPEED_UP_3D_MODIFIER, TRACKED_CAMERA_RESTORE_KEY,
RuntimeModifiers, DRAG_PAN3D_BUTTON, RESET_VIEW_BUTTON_TEXT, ROLL_MOUSE, ROLL_MOUSE_ALT,
ROLL_MOUSE_MODIFIER, ROTATE3D_BUTTON, SPEED_UP_3D_MODIFIER, TRACKED_CAMERA_RESTORE_KEY,
};
use re_viewer_context::{
gpu_bridge, HoveredSpace, Item, SpaceViewSystemExecutionError, ViewContextCollection,
Expand Down Expand Up @@ -291,9 +291,9 @@ pub fn help_text(re_ui: &re_ui::ReUi) -> egui::WidgetText {
layout.add_button_text("QE");
layout.add("\n");

layout.add(SPEED_UP_3D_MODIFIER);
layout.add(RuntimeModifiers::slow_down(&re_ui.egui_ctx.os()));
layout.add(" slows down, ");
layout.add(SLOW_DOWN_3D_MODIFIER);
layout.add(SPEED_UP_3D_MODIFIER);
layout.add(" speeds up\n\n");

layout.add_button_text("double-click");
Expand Down

0 comments on commit 46ca167

Please sign in to comment.