Switch Eyedropper/Fill tools from Rmb to Shift+Lmb

This commit is contained in:
Keavon Chambers 2024-03-08 20:13:34 -08:00
parent d780602ecd
commit 9f84661fac
3 changed files with 29 additions and 26 deletions

View File

@ -122,11 +122,12 @@ pub fn default_mapping() -> Mapping {
entry!(KeyUp(Mmb); action_dispatch=NavigateToolMessage::TransformCanvasEnd), entry!(KeyUp(Mmb); action_dispatch=NavigateToolMessage::TransformCanvasEnd),
// //
// EyedropperToolMessage // 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!(PointerMove; action_dispatch=EyedropperToolMessage::PointerMove),
entry!(KeyDown(Lmb); action_dispatch=EyedropperToolMessage::LeftPointerDown), entry!(KeyDown(Rmb); action_dispatch=EyedropperToolMessage::Abort),
entry!(KeyDown(Rmb); action_dispatch=EyedropperToolMessage::RightPointerDown),
entry!(KeyUp(Lmb); action_dispatch=EyedropperToolMessage::LeftPointerUp),
entry!(KeyUp(Rmb); action_dispatch=EyedropperToolMessage::RightPointerUp),
entry!(KeyDown(Escape); action_dispatch=EyedropperToolMessage::Abort), entry!(KeyDown(Escape); action_dispatch=EyedropperToolMessage::Abort),
// //
// TextToolMessage // TextToolMessage
@ -244,8 +245,8 @@ pub fn default_mapping() -> Mapping {
entry!(KeyDown(Enter); action_dispatch=SplineToolMessage::Confirm), entry!(KeyDown(Enter); action_dispatch=SplineToolMessage::Confirm),
// //
// FillToolMessage // FillToolMessage
entry!(KeyDown(Lmb); action_dispatch=FillToolMessage::LeftPointerDown), entry!(KeyDown(Lmb); action_dispatch=FillToolMessage::FillPrimaryColor),
entry!(KeyDown(Rmb); action_dispatch=FillToolMessage::RightPointerDown), entry!(KeyDown(Lmb); modifiers=[Shift], action_dispatch=FillToolMessage::FillSecondaryColor),
// //
// BrushToolMessage // BrushToolMessage
entry!(PointerMove; action_dispatch=BrushToolMessage::PointerMove), entry!(PointerMove; action_dispatch=BrushToolMessage::PointerMove),

View File

@ -14,11 +14,11 @@ pub enum EyedropperToolMessage {
Abort, Abort,
// Tool-specific messages // Tool-specific messages
LeftPointerDown, SamplePrimaryColorBegin,
LeftPointerUp, SamplePrimaryColorEnd,
PointerMove, PointerMove,
RightPointerDown, SampleSecondaryColorBegin,
RightPointerUp, SampleSecondaryColorEnd,
} }
impl ToolMetadata for EyedropperTool { impl ToolMetadata for EyedropperTool {
@ -45,11 +45,11 @@ impl<'a> MessageHandler<ToolMessage, &mut ToolActionHandlerData<'a>> for Eyedrop
} }
advertise_actions!(EyedropperToolMessageDiscriminant; advertise_actions!(EyedropperToolMessageDiscriminant;
LeftPointerDown, SamplePrimaryColorBegin,
LeftPointerUp, SamplePrimaryColorEnd,
SampleSecondaryColorBegin,
SampleSecondaryColorEnd,
PointerMove, PointerMove,
RightPointerDown,
RightPointerUp,
Abort, Abort,
); );
} }
@ -87,10 +87,10 @@ impl Fsm for EyedropperToolFsmState {
}; };
match (self, event) { match (self, event) {
// Ready -> Sampling // 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); update_cursor_preview(responses, input, global_tool_data, None);
if mouse_down == EyedropperToolMessage::LeftPointerDown { if mouse_down == EyedropperToolMessage::SamplePrimaryColorBegin {
EyedropperToolFsmState::SamplingPrimary EyedropperToolFsmState::SamplingPrimary
} else { } else {
EyedropperToolFsmState::SamplingSecondary EyedropperToolFsmState::SamplingSecondary
@ -107,7 +107,7 @@ impl Fsm for EyedropperToolFsmState {
self self
} }
// Sampling -> Ready // 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(); 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)); update_cursor_preview(responses, input, global_tool_data, Some(set_color_choice));
disable_cursor_preview(responses); disable_cursor_preview(responses);
@ -129,9 +129,11 @@ impl Fsm for EyedropperToolFsmState {
let hint_data = match self { let hint_data = match self {
EyedropperToolFsmState::Ready => HintData(vec![HintGroup(vec![ EyedropperToolFsmState::Ready => HintData(vec![HintGroup(vec![
HintInfo::mouse(MouseMotion::Lmb, "Sample to Primary"), 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 }); responses.add(FrontendMessage::UpdateInputHints { hint_data });

View File

@ -11,8 +11,8 @@ pub struct FillTool {
#[derive(PartialEq, Eq, Clone, Debug, Hash, Serialize, Deserialize, specta::Type)] #[derive(PartialEq, Eq, Clone, Debug, Hash, Serialize, Deserialize, specta::Type)]
pub enum FillToolMessage { pub enum FillToolMessage {
// Tool-specific messages // Tool-specific messages
LeftPointerDown, FillPrimaryColor,
RightPointerDown, FillSecondaryColor,
} }
impl ToolMetadata for FillTool { impl ToolMetadata for FillTool {
@ -39,8 +39,8 @@ impl<'a> MessageHandler<ToolMessage, &mut ToolActionHandlerData<'a>> for FillToo
} }
advertise_actions!(FillToolMessageDiscriminant; advertise_actions!(FillToolMessageDiscriminant;
LeftPointerDown, FillPrimaryColor,
RightPointerDown, FillSecondaryColor,
); );
} }
@ -72,8 +72,8 @@ impl Fsm for FillToolFsmState {
return self; return self;
}; };
let color = match event { let color = match event {
FillToolMessage::LeftPointerDown => global_tool_data.primary_color, FillToolMessage::FillPrimaryColor => global_tool_data.primary_color,
FillToolMessage::RightPointerDown => global_tool_data.secondary_color, FillToolMessage::FillSecondaryColor => global_tool_data.secondary_color,
}; };
let fill = Fill::Solid(color); let fill = Fill::Solid(color);
@ -88,7 +88,7 @@ impl Fsm for FillToolFsmState {
let hint_data = match self { let hint_data = match self {
FillToolFsmState::Ready => HintData(vec![HintGroup(vec![ FillToolFsmState::Ready => HintData(vec![HintGroup(vec![
HintInfo::mouse(MouseMotion::Lmb, "Fill with Primary"), 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"),
])]), ])]),
}; };