mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-17 07:18:04 +08:00
* 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>
72 lines
1.8 KiB
Rust
72 lines
1.8 KiB
Rust
use crate::messages::prelude::*;
|
|
|
|
use graphite_proc_macros::*;
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
use std::collections::hash_map::DefaultHasher;
|
|
use std::hash::{Hash, Hasher};
|
|
|
|
#[remain::sorted]
|
|
#[impl_message]
|
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
|
pub enum Message {
|
|
#[remain::unsorted]
|
|
NoOp,
|
|
#[remain::unsorted]
|
|
Init,
|
|
|
|
#[child]
|
|
Broadcast(BroadcastMessage),
|
|
#[child]
|
|
Debug(DebugMessage),
|
|
#[child]
|
|
Dialog(DialogMessage),
|
|
#[child]
|
|
Frontend(FrontendMessage),
|
|
#[child]
|
|
Globals(GlobalsMessage),
|
|
#[child]
|
|
InputPreprocessor(InputPreprocessorMessage),
|
|
#[child]
|
|
KeyMapping(KeyMappingMessage),
|
|
#[child]
|
|
Layout(LayoutMessage),
|
|
#[child]
|
|
Portfolio(PortfolioMessage),
|
|
#[child]
|
|
Preferences(PreferencesMessage),
|
|
#[child]
|
|
Tool(ToolMessage),
|
|
#[child]
|
|
Workspace(WorkspaceMessage),
|
|
}
|
|
|
|
impl Message {
|
|
/// Returns the byte representation of the message.
|
|
///
|
|
/// # Safety
|
|
/// This function reads from uninitialized memory!!!
|
|
/// Only use if you know what you are doing.
|
|
unsafe fn as_slice(&self) -> &[u8] {
|
|
core::slice::from_raw_parts(self as *const Message as *const u8, std::mem::size_of::<Message>())
|
|
}
|
|
|
|
/// Returns a pseudo hash that should uniquely identify the message.
|
|
/// This is needed because `Hash` is not implemented for `f64`s
|
|
///
|
|
/// # Safety
|
|
/// This function reads from uninitialized memory but the generated value should be fine.
|
|
pub fn pseudo_hash(&self) -> u64 {
|
|
let mut s = DefaultHasher::new();
|
|
unsafe { self.as_slice() }.hash(&mut s);
|
|
s.finish()
|
|
}
|
|
}
|
|
|
|
/// Provides an impl of `specta::Type` for `MessageDiscriminant`, the struct created by `impl_message`.
|
|
/// Specta isn't integrated with `impl_message`, so a remote impl must be provided using this
|
|
/// struct.
|
|
#[derive(specta::Type)]
|
|
#[specta(inline, remote = "MessageDiscriminant")]
|
|
pub struct MessageDiscriminantDef(u8);
|