Skip to content

Commit dda1cda

Browse files
committed
Remove double-tap tests (moved to separate PR) and add Ctrl+Space for Focus Document
1 parent ae2c82d commit dda1cda

2 files changed

Lines changed: 2 additions & 180 deletions

File tree

editor/src/messages/input_mapper/input_mappings.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,7 @@ pub fn input_mappings(zoom_with_scroll: bool) -> Mapping {
449449
entry!(KeyDown(KeyR); modifiers=[Alt], action_dispatch=PortfolioMessage::ToggleRulers),
450450
entry!(KeyDown(KeyD); modifiers=[Alt], action_dispatch=PortfolioMessage::ToggleDataPanelOpen),
451451
entry!(KeyDown(Enter); modifiers=[Alt], action_dispatch=PortfolioMessage::ToggleFocusDocument),
452+
entry!(KeyDown(Space); modifiers=[Accel], action_dispatch=PortfolioMessage::ToggleFocusDocument),
452453
//
453454
// DialogMessage
454455
entry!(KeyDown(KeyE); modifiers=[Accel], action_dispatch=DialogMessage::RequestExportDialog),

editor/src/messages/input_preprocessor/input_preprocessor_message_handler.rs

Lines changed: 1 addition & 180 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,8 @@ impl InputPreprocessorMessageHandler {
218218

219219
#[cfg(test)]
220220
mod test {
221-
use crate::consts::DOUBLE_CLICK_MILLISECONDS;
222221
use crate::messages::input_mapper::utility_types::input_keyboard::{Key, ModifierKeys};
223-
use crate::messages::input_mapper::utility_types::input_mouse::{EditorMouseState, MouseKeys, ScrollDelta};
222+
use crate::messages::input_mapper::utility_types::input_mouse::{EditorMouseState, ScrollDelta};
224223
use crate::messages::prelude::*;
225224

226225
#[test]
@@ -326,182 +325,4 @@ mod test {
326325
assert!(responses.contains(&InputMapperMessage::KeyDown(Key::Control).into()));
327326
assert!(responses.contains(&InputMapperMessage::KeyDown(Key::Control).into()));
328327
}
329-
330-
fn key_down(input_preprocessor: &mut InputPreprocessorMessageHandler, key: Key, responses: &mut VecDeque<Message>) {
331-
input_preprocessor.process_message(
332-
InputPreprocessorMessage::KeyDown {
333-
key,
334-
key_repeat: false,
335-
modifier_keys: ModifierKeys::empty(),
336-
},
337-
responses,
338-
InputPreprocessorMessageContext {
339-
viewport: &ViewportMessageHandler::default(),
340-
},
341-
);
342-
}
343-
344-
fn key_up(input_preprocessor: &mut InputPreprocessorMessageHandler, key: Key, responses: &mut VecDeque<Message>) {
345-
input_preprocessor.process_message(
346-
InputPreprocessorMessage::KeyUp {
347-
key,
348-
key_repeat: false,
349-
modifier_keys: ModifierKeys::empty(),
350-
},
351-
responses,
352-
InputPreprocessorMessageContext {
353-
viewport: &ViewportMessageHandler::default(),
354-
},
355-
);
356-
}
357-
358-
fn process_input(input_preprocessor: &mut InputPreprocessorMessageHandler, message: InputPreprocessorMessage, responses: &mut VecDeque<Message>) {
359-
input_preprocessor.process_message(
360-
message,
361-
responses,
362-
InputPreprocessorMessageContext {
363-
viewport: &ViewportMessageHandler::default(),
364-
},
365-
);
366-
}
367-
368-
#[test]
369-
fn process_double_tap_within_threshold() {
370-
let mut input_preprocessor = InputPreprocessorMessageHandler::default();
371-
let mut responses = VecDeque::new();
372-
373-
key_down(&mut input_preprocessor, Key::Space, &mut responses);
374-
key_up(&mut input_preprocessor, Key::Space, &mut responses);
375-
responses.clear();
376-
377-
input_preprocessor.time = 50;
378-
key_down(&mut input_preprocessor, Key::Space, &mut responses);
379-
380-
assert!(!responses.contains(&InputMapperMessage::DoubleTap(Key::Space).into()));
381-
assert_eq!(input_preprocessor.double_tap_key, Some((Key::Space, 50)));
382-
383-
responses.clear();
384-
key_up(&mut input_preprocessor, Key::Space, &mut responses);
385-
386-
assert!(responses.contains(&InputMapperMessage::DoubleTap(Key::Space).into()));
387-
assert!(input_preprocessor.double_tap_key.is_none());
388-
}
389-
390-
#[test]
391-
fn process_double_tap_outside_threshold() {
392-
let mut input_preprocessor = InputPreprocessorMessageHandler::default();
393-
let mut responses = VecDeque::new();
394-
395-
key_down(&mut input_preprocessor, Key::Space, &mut responses);
396-
key_up(&mut input_preprocessor, Key::Space, &mut responses);
397-
responses.clear();
398-
399-
input_preprocessor.time = DOUBLE_CLICK_MILLISECONDS + 1;
400-
key_down(&mut input_preprocessor, Key::Space, &mut responses);
401-
402-
assert!(!responses.contains(&InputMapperMessage::DoubleTap(Key::Space).into()));
403-
assert!(input_preprocessor.double_tap_key.is_none());
404-
405-
responses.clear();
406-
key_up(&mut input_preprocessor, Key::Space, &mut responses);
407-
408-
assert!(!responses.contains(&InputMapperMessage::DoubleTap(Key::Space).into()));
409-
}
410-
411-
#[test]
412-
fn process_double_tap_held_too_long() {
413-
let mut input_preprocessor = InputPreprocessorMessageHandler::default();
414-
let mut responses = VecDeque::new();
415-
416-
key_down(&mut input_preprocessor, Key::Space, &mut responses);
417-
key_up(&mut input_preprocessor, Key::Space, &mut responses);
418-
responses.clear();
419-
420-
input_preprocessor.time = 50;
421-
key_down(&mut input_preprocessor, Key::Space, &mut responses);
422-
responses.clear();
423-
424-
input_preprocessor.time = 50 + DOUBLE_CLICK_MILLISECONDS + 1;
425-
key_up(&mut input_preprocessor, Key::Space, &mut responses);
426-
427-
assert!(!responses.contains(&InputMapperMessage::DoubleTap(Key::Space).into()));
428-
}
429-
430-
#[test]
431-
fn process_double_tap_interrupted_by_pointer_down() {
432-
let mut input_preprocessor = InputPreprocessorMessageHandler::default();
433-
let mut responses = VecDeque::new();
434-
435-
key_down(&mut input_preprocessor, Key::Space, &mut responses);
436-
key_up(&mut input_preprocessor, Key::Space, &mut responses);
437-
responses.clear();
438-
439-
input_preprocessor.time = 50;
440-
key_down(&mut input_preprocessor, Key::Space, &mut responses);
441-
responses.clear();
442-
443-
process_input(
444-
&mut input_preprocessor,
445-
InputPreprocessorMessage::PointerDown {
446-
editor_mouse_state: EditorMouseState::default(),
447-
modifier_keys: ModifierKeys::empty(),
448-
},
449-
&mut responses,
450-
);
451-
responses.clear();
452-
453-
key_up(&mut input_preprocessor, Key::Space, &mut responses);
454-
455-
assert!(!responses.contains(&InputMapperMessage::DoubleTap(Key::Space).into()));
456-
}
457-
458-
#[test]
459-
fn process_double_tap_not_interrupted_by_mouse_movement() {
460-
let mut input_preprocessor = InputPreprocessorMessageHandler::default();
461-
let mut responses = VecDeque::new();
462-
463-
key_down(&mut input_preprocessor, Key::Space, &mut responses);
464-
key_up(&mut input_preprocessor, Key::Space, &mut responses);
465-
responses.clear();
466-
467-
input_preprocessor.time = 50;
468-
key_down(&mut input_preprocessor, Key::Space, &mut responses);
469-
responses.clear();
470-
471-
process_input(
472-
&mut input_preprocessor,
473-
InputPreprocessorMessage::PointerMove {
474-
editor_mouse_state: EditorMouseState::default(),
475-
modifier_keys: ModifierKeys::empty(),
476-
},
477-
&mut responses,
478-
);
479-
responses.clear();
480-
481-
key_up(&mut input_preprocessor, Key::Space, &mut responses);
482-
483-
assert!(responses.contains(&InputMapperMessage::DoubleTap(Key::Space).into()));
484-
}
485-
486-
#[test]
487-
fn process_double_tap_blocked_by_mouse_button_held() {
488-
let mut input_preprocessor = InputPreprocessorMessageHandler::default();
489-
let mut responses = VecDeque::new();
490-
491-
input_preprocessor.mouse.mouse_keys = MouseKeys::LEFT;
492-
493-
key_down(&mut input_preprocessor, Key::Space, &mut responses);
494-
key_up(&mut input_preprocessor, Key::Space, &mut responses);
495-
responses.clear();
496-
497-
input_preprocessor.time = 50;
498-
key_down(&mut input_preprocessor, Key::Space, &mut responses);
499-
500-
assert!(input_preprocessor.double_tap_key.is_none());
501-
502-
responses.clear();
503-
key_up(&mut input_preprocessor, Key::Space, &mut responses);
504-
505-
assert!(!responses.contains(&InputMapperMessage::DoubleTap(Key::Space).into()));
506-
}
507328
}

0 commit comments

Comments
 (0)