Skip to content

Commit

Permalink
Change full-screen visualisation shortcut to shift-space (#6663)
Browse files Browse the repository at this point in the history
Fixes #6260: The shortcut to open the full-screen visualisation is now `shift-space` so it doesn't interfere with the `space` shortcut to toggle the mini-visualisation.
  • Loading branch information
Procrat authored May 17, 2023
1 parent 10eeed1 commit 102ce7a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 22 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,16 @@
<kbd>cmd</kbd>+<kbd>alt</kbd>+<kbd>t</kbd>/<kbd>r</kbd>.
- [Fixed a bug where selecting a nested breadcrumb would cause the order of
breadcrumbs to change incorrectly.][6617]
- [Changed the shortcut to show the full-screen visualization for a node from
<kbd>space</kbd> <kbd>space</kbd> to <kbd>shift</kbd>+<kbd>space</kbd>.][6663]
so that it doesn't interfere with the shortcut for toggling the small
visualization.

[6421]: https://github.com/enso-org/enso/pull/6421
[6530]: https://github.com/enso-org/enso/pull/6530
[6620]: https://github.com/enso-org/enso/pull/6620
[6617]: https://github.com/enso-org/enso/pull/6617
[6663]: https://github.com/enso-org/enso/pull/6663

#### EnsoGL (rendering engine)

Expand Down
39 changes: 19 additions & 20 deletions app/gui/view/graph-editor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -562,14 +562,13 @@ ensogl::define_endpoints_2! {
/// other case, it will be disabled as soon as the `release_visualization_visibility` is
/// emitted.
press_visualization_visibility(),
/// Simulates a visualization open double press event. This event toggles the visualization
/// fullscreen mode.
double_press_visualization_visibility(),
/// Simulates a visualization open release event. See `press_visualization_visibility` to
/// learn more.
release_visualization_visibility(),
/// Cycle the visualization for the selected nodes.
cycle_visualization_for_selected_node(),
/// Opens the visualization for the selected node in full-screen mode.
open_fullscreen_visualization(),
/// The visualization currently displayed as fullscreen is
close_fullscreen_visualization(),

Expand Down Expand Up @@ -3535,20 +3534,20 @@ fn new_graph_editor(app: &Application) -> GraphEditor {
// - Release key. If the time passed from key press was short, do nothing.
// - If it was long, disable vis which were disabled (preview mode).

let viz_press_ev = inputs.press_visualization_visibility.clone_ref();
let viz_d_press_ev = inputs.double_press_visualization_visibility.clone_ref();
let viz_release_ev = inputs.release_visualization_visibility.clone_ref();
viz_pressed <- bool(&viz_release_ev,&viz_press_ev);
viz_was_pressed <- viz_pressed.previous();
viz_press <- viz_press_ev.gate_not(&viz_was_pressed);
viz_release <- viz_release_ev.gate(&viz_was_pressed);
viz_press_time <- viz_press . map(|_| {
let viz_press_ev = inputs.press_visualization_visibility.clone_ref();
let viz_open_fs_ev = inputs.open_fullscreen_visualization.clone_ref();
let viz_release_ev = inputs.release_visualization_visibility.clone_ref();
viz_pressed <- bool(&viz_release_ev,&viz_press_ev);
viz_was_pressed <- viz_pressed.previous();
viz_press <- viz_press_ev.gate_not(&viz_was_pressed);
viz_release <- viz_release_ev.gate(&viz_was_pressed);
viz_press_time <- viz_press.map(|_| {
let time = web::window.performance_or_panic().now() as f32;
let frame_counter = Rc::new(web::FrameCounter::start_counting());
(time, Some(frame_counter))
});
viz_release_time <- viz_release . map(|_| web::window.performance_or_panic().now() as f32);
viz_preview_mode <- viz_release_time.map2(&viz_press_time,|t1,(t0,counter)| {
viz_release_time <- viz_release.map(|_| web::window.performance_or_panic().now() as f32);
viz_preview_mode <- viz_release_time.map2(&viz_press_time,|t1,(t0,counter)| {
let diff = t1-t0;
// We check the time between key down and key up. If the time is less than the threshold
// then it was a key press and we do not want to enter preview mode. If it is longer then
Expand All @@ -3566,8 +3565,8 @@ fn new_graph_editor(app: &Application) -> GraphEditor {
long_enough && enough_frames
});
viz_preview_mode_end <- viz_release.gate(&viz_preview_mode).gate_not(&out.is_fs_visualization_displayed);
viz_tgt_nodes <- viz_press.gate_not(&out.is_fs_visualization_displayed).map(f_!(model.nodes.all_selected()));
viz_tgt_nodes_off <- viz_tgt_nodes.map(f!([model](node_ids) {
viz_tgt_nodes <- viz_press.gate_not(&out.is_fs_visualization_displayed).map(f_!(model.nodes.all_selected()));
viz_tgt_nodes_off <- viz_tgt_nodes.map(f!([model](node_ids) {
node_ids.iter().cloned().filter(|node_id| {
model.nodes.get_cloned_ref(node_id)
.map(|node| !node.visualization_enabled.value())
Expand All @@ -3576,12 +3575,12 @@ fn new_graph_editor(app: &Application) -> GraphEditor {
}));

viz_tgt_nodes_all_on <- viz_tgt_nodes_off.map(|t| t.is_empty());
viz_enable_by_press <= viz_tgt_nodes.gate_not(&viz_tgt_nodes_all_on);
viz_enable <- any(viz_enable_by_press,inputs.enable_visualization);
viz_enable_by_press <= viz_tgt_nodes.gate_not(&viz_tgt_nodes_all_on);
viz_enable <- any(viz_enable_by_press,inputs.enable_visualization);
viz_disable_by_press <= viz_tgt_nodes.gate(&viz_tgt_nodes_all_on);
viz_disable <- any(viz_disable_by_press,inputs.disable_visualization);
viz_preview_disable <= viz_tgt_nodes_off.sample(&viz_preview_mode_end);
viz_fullscreen_on <= viz_d_press_ev.map(f_!(model.nodes.last_selected()));
viz_disable <- any(viz_disable_by_press,inputs.disable_visualization);
viz_preview_disable <= viz_tgt_nodes_off.sample(&viz_preview_mode_end);
viz_fullscreen_on <= viz_open_fs_ev.map(f_!(model.nodes.last_selected()));

eval viz_enable ((id) model.enable_visualization(id));
eval viz_disable ((id) model.disable_visualization(id));
Expand Down
10 changes: 8 additions & 2 deletions app/gui/view/graph-editor/src/shortcuts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,16 @@ pub const SHORTCUTS: &[(ensogl::application::shortcut::ActionType, &str, &str, &
(Press, "!read_only", "cmd g", "collapse_selected_nodes"),
// === Visualization ===
(Press, "!node_editing", "space", "press_visualization_visibility"),
(DoublePress, "!node_editing", "space", "double_press_visualization_visibility"),
(
Press,
"!node_editing & !is_fs_visualization_displayed",
"shift space",
"open_fullscreen_visualization",
),
(Release, "!node_editing", "space", "release_visualization_visibility"),
(Press, "", "cmd i", "reload_visualization_registry"),
(Press, "is_fs_visualization_displayed", "space", "close_fullscreen_visualization"),
(Press, "is_fs_visualization_displayed", "shift space", "close_fullscreen_visualization"),
(Press, "is_fs_visualization_displayed", "escape", "close_fullscreen_visualization"),
(Press, "", "cmd", "enable_quick_visualization_preview"),
(Release, "", "cmd", "disable_quick_visualization_preview"),
// === Selection ===
Expand Down

0 comments on commit 102ce7a

Please sign in to comment.