Add 'Zoom with Scroll' input navigation scheme to preferences (#1021)

* Add use_scroll_as_zoom field to preference handler

* Add {Create,Delete}Mapping variants to message

* Revert "Add {Create,Delete}Mapping variants to message"

This reverts commit 0ba74754c9fb0c78d0b590c96e1d4fe2cfdd13e7.

* Revert "Add use_scroll_as_zoom field to preference handler"

This reverts commit d30f7c9edfa6d6e156939ca07f4db81f288975fd.

* Add basic scroll_as_zoom mapping

* Create overengineered mapping patch abstraction

* Add (for now passthrough) input layout manager

* Actually handle ModifyLayout messages (untested)

* Add backend preferences <-> layout manager comms

* Add scroll-as-zoom to actual preferences UI

* Rename LayoutManager -> KeyMapping

* Add Input section to preferences and title case

* Add scrollAsZoom frontend handling code (untested)

* Handle frontend <-> preferences comms

* (broken) Move scrollAsZoom persistence into state

* Fix scrollAsZoom having no effect on node graph

* Remove debugging helpers

* Fix confusion between horizontal and vertical

* Rename feature

* Move new message handler into folder

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
multisn8
2023-02-24 07:18:04 +01:00
committed by Keavon Chambers
co-authored by Keavon Chambers
parent c2234ce3fe
commit 7a52e50a94
19 changed files with 242 additions and 33 deletions
@@ -0,0 +1,24 @@
use crate::messages::prelude::*;
use serde::{Deserialize, Serialize};
#[remain::sorted]
#[impl_message(Message, KeyMapping)]
#[derive(PartialEq, Eq, Clone, Debug, Hash, Serialize, Deserialize)]
pub enum KeyMappingMessage {
#[child]
Lookup(InputMapperMessage),
#[child]
ModifyMapping(MappingVariant),
}
#[remain::sorted]
#[impl_message(Message, KeyMappingMessage, ModifyMapping)]
#[derive(PartialEq, Eq, Clone, Debug, Default, Hash, Serialize, Deserialize)]
pub enum MappingVariant {
#[remain::unsorted]
#[default]
Default,
ZoomWithScroll,
}
@@ -0,0 +1,23 @@
use crate::messages::input_mapper::utility_types::input_keyboard::KeysGroup;
use crate::messages::prelude::*;
#[derive(Debug, Default)]
pub struct KeyMappingMessageHandler {
mapping_handler: InputMapperMessageHandler,
}
impl MessageHandler<KeyMappingMessage, (&InputPreprocessorMessageHandler, ActionList)> for KeyMappingMessageHandler {
fn process_message(&mut self, message: KeyMappingMessage, responses: &mut VecDeque<Message>, data: (&InputPreprocessorMessageHandler, ActionList)) {
match message {
KeyMappingMessage::Lookup(input) => self.mapping_handler.process_message(input, responses, data),
KeyMappingMessage::ModifyMapping(new_layout) => self.mapping_handler.set_mapping(new_layout.into()),
}
}
advertise_actions!();
}
impl KeyMappingMessageHandler {
pub fn action_input_mapping(&self, action_to_find: &MessageDiscriminant) -> Vec<KeysGroup> {
self.mapping_handler.action_input_mapping(action_to_find)
}
}
@@ -0,0 +1,7 @@
mod key_mapping_message;
mod key_mapping_message_handler;
#[doc(inline)]
pub use key_mapping_message::{KeyMappingMessage, KeyMappingMessageDiscriminant, MappingVariant, MappingVariantDiscriminant};
#[doc(inline)]
pub use key_mapping_message_handler::KeyMappingMessageHandler;