From 9f84661facd545bfdfeaa5d37038abeacc00ee08 Mon Sep 17 00:00:00 2001 From: Keavon Chambers Date: Fri, 8 Mar 2024 20:13:34 -0800 Subject: [PATCH] Switch Eyedropper/Fill tools from Rmb to Shift+Lmb --- .../messages/input_mapper/default_mapping.rs | 13 +++++---- .../tool/tool_messages/eyedropper_tool.rs | 28 ++++++++++--------- .../messages/tool/tool_messages/fill_tool.rs | 14 +++++----- 3 files changed, 29 insertions(+), 26 deletions(-) diff --git a/editor/src/messages/input_mapper/default_mapping.rs b/editor/src/messages/input_mapper/default_mapping.rs index 5428b8c8..588a9f83 100644 --- a/editor/src/messages/input_mapper/default_mapping.rs +++ b/editor/src/messages/input_mapper/default_mapping.rs @@ -122,11 +122,12 @@ pub fn default_mapping() -> Mapping { entry!(KeyUp(Mmb); action_dispatch=NavigateToolMessage::TransformCanvasEnd), // // EyedropperToolMessage + entry!(KeyDown(Lmb); action_dispatch=EyedropperToolMessage::SamplePrimaryColorBegin), + entry!(KeyDown(Lmb); modifiers=[Shift], action_dispatch=EyedropperToolMessage::SampleSecondaryColorBegin), + entry!(KeyUp(Lmb); action_dispatch=EyedropperToolMessage::SamplePrimaryColorEnd), + entry!(KeyUp(Lmb); modifiers=[Shift], action_dispatch=EyedropperToolMessage::SampleSecondaryColorEnd), entry!(PointerMove; action_dispatch=EyedropperToolMessage::PointerMove), - entry!(KeyDown(Lmb); action_dispatch=EyedropperToolMessage::LeftPointerDown), - entry!(KeyDown(Rmb); action_dispatch=EyedropperToolMessage::RightPointerDown), - entry!(KeyUp(Lmb); action_dispatch=EyedropperToolMessage::LeftPointerUp), - entry!(KeyUp(Rmb); action_dispatch=EyedropperToolMessage::RightPointerUp), + entry!(KeyDown(Rmb); action_dispatch=EyedropperToolMessage::Abort), entry!(KeyDown(Escape); action_dispatch=EyedropperToolMessage::Abort), // // TextToolMessage @@ -244,8 +245,8 @@ pub fn default_mapping() -> Mapping { entry!(KeyDown(Enter); action_dispatch=SplineToolMessage::Confirm), // // FillToolMessage - entry!(KeyDown(Lmb); action_dispatch=FillToolMessage::LeftPointerDown), - entry!(KeyDown(Rmb); action_dispatch=FillToolMessage::RightPointerDown), + entry!(KeyDown(Lmb); action_dispatch=FillToolMessage::FillPrimaryColor), + entry!(KeyDown(Lmb); modifiers=[Shift], action_dispatch=FillToolMessage::FillSecondaryColor), // // BrushToolMessage entry!(PointerMove; action_dispatch=BrushToolMessage::PointerMove), diff --git a/editor/src/messages/tool/tool_messages/eyedropper_tool.rs b/editor/src/messages/tool/tool_messages/eyedropper_tool.rs index a846b57a..1c8c389e 100644 --- a/editor/src/messages/tool/tool_messages/eyedropper_tool.rs +++ b/editor/src/messages/tool/tool_messages/eyedropper_tool.rs @@ -14,11 +14,11 @@ pub enum EyedropperToolMessage { Abort, // Tool-specific messages - LeftPointerDown, - LeftPointerUp, + SamplePrimaryColorBegin, + SamplePrimaryColorEnd, PointerMove, - RightPointerDown, - RightPointerUp, + SampleSecondaryColorBegin, + SampleSecondaryColorEnd, } impl ToolMetadata for EyedropperTool { @@ -45,11 +45,11 @@ impl<'a> MessageHandler> for Eyedrop } advertise_actions!(EyedropperToolMessageDiscriminant; - LeftPointerDown, - LeftPointerUp, + SamplePrimaryColorBegin, + SamplePrimaryColorEnd, + SampleSecondaryColorBegin, + SampleSecondaryColorEnd, PointerMove, - RightPointerDown, - RightPointerUp, Abort, ); } @@ -87,10 +87,10 @@ impl Fsm for EyedropperToolFsmState { }; match (self, event) { // Ready -> Sampling - (EyedropperToolFsmState::Ready, mouse_down) if matches!(mouse_down, EyedropperToolMessage::LeftPointerDown | EyedropperToolMessage::RightPointerDown) => { + (EyedropperToolFsmState::Ready, mouse_down) if matches!(mouse_down, EyedropperToolMessage::SamplePrimaryColorBegin | EyedropperToolMessage::SampleSecondaryColorBegin) => { update_cursor_preview(responses, input, global_tool_data, None); - if mouse_down == EyedropperToolMessage::LeftPointerDown { + if mouse_down == EyedropperToolMessage::SamplePrimaryColorBegin { EyedropperToolFsmState::SamplingPrimary } else { EyedropperToolFsmState::SamplingSecondary @@ -107,7 +107,7 @@ impl Fsm for EyedropperToolFsmState { self } // Sampling -> Ready - (EyedropperToolFsmState::SamplingPrimary, EyedropperToolMessage::LeftPointerUp) | (EyedropperToolFsmState::SamplingSecondary, EyedropperToolMessage::RightPointerUp) => { + (EyedropperToolFsmState::SamplingPrimary, EyedropperToolMessage::SamplePrimaryColorEnd) | (EyedropperToolFsmState::SamplingSecondary, EyedropperToolMessage::SampleSecondaryColorEnd) => { let set_color_choice = if self == EyedropperToolFsmState::SamplingPrimary { "Primary" } else { "Secondary" }.to_string(); update_cursor_preview(responses, input, global_tool_data, Some(set_color_choice)); disable_cursor_preview(responses); @@ -129,9 +129,11 @@ impl Fsm for EyedropperToolFsmState { let hint_data = match self { EyedropperToolFsmState::Ready => HintData(vec![HintGroup(vec![ HintInfo::mouse(MouseMotion::Lmb, "Sample to Primary"), - HintInfo::mouse(MouseMotion::Rmb, "Sample to Secondary"), + HintInfo::keys_and_mouse([Key::Shift], MouseMotion::Lmb, "Sample to Secondary"), ])]), - EyedropperToolFsmState::SamplingPrimary | EyedropperToolFsmState::SamplingSecondary => HintData(vec![HintGroup(vec![HintInfo::keys([Key::Escape], "Cancel")])]), + EyedropperToolFsmState::SamplingPrimary | EyedropperToolFsmState::SamplingSecondary => { + HintData(vec![HintGroup(vec![HintInfo::mouse(MouseMotion::Rmb, ""), HintInfo::keys([Key::Escape], "Cancel").prepend_slash()])]) + } }; responses.add(FrontendMessage::UpdateInputHints { hint_data }); diff --git a/editor/src/messages/tool/tool_messages/fill_tool.rs b/editor/src/messages/tool/tool_messages/fill_tool.rs index 6c29b76c..45aa64ca 100644 --- a/editor/src/messages/tool/tool_messages/fill_tool.rs +++ b/editor/src/messages/tool/tool_messages/fill_tool.rs @@ -11,8 +11,8 @@ pub struct FillTool { #[derive(PartialEq, Eq, Clone, Debug, Hash, Serialize, Deserialize, specta::Type)] pub enum FillToolMessage { // Tool-specific messages - LeftPointerDown, - RightPointerDown, + FillPrimaryColor, + FillSecondaryColor, } impl ToolMetadata for FillTool { @@ -39,8 +39,8 @@ impl<'a> MessageHandler> for FillToo } advertise_actions!(FillToolMessageDiscriminant; - LeftPointerDown, - RightPointerDown, + FillPrimaryColor, + FillSecondaryColor, ); } @@ -72,8 +72,8 @@ impl Fsm for FillToolFsmState { return self; }; let color = match event { - FillToolMessage::LeftPointerDown => global_tool_data.primary_color, - FillToolMessage::RightPointerDown => global_tool_data.secondary_color, + FillToolMessage::FillPrimaryColor => global_tool_data.primary_color, + FillToolMessage::FillSecondaryColor => global_tool_data.secondary_color, }; let fill = Fill::Solid(color); @@ -88,7 +88,7 @@ impl Fsm for FillToolFsmState { let hint_data = match self { FillToolFsmState::Ready => HintData(vec![HintGroup(vec![ HintInfo::mouse(MouseMotion::Lmb, "Fill with Primary"), - HintInfo::mouse(MouseMotion::Rmb, "Fill with Secondary"), + HintInfo::keys_and_mouse([Key::Shift], MouseMotion::Lmb, "Fill with Secondary"), ])]), };