Skip to content

Commit 9f84661

Browse files
committed
Switch Eyedropper/Fill tools from Rmb to Shift+Lmb
1 parent d780602 commit 9f84661

File tree

3 files changed

+29
-26
lines changed

3 files changed

+29
-26
lines changed

editor/src/messages/input_mapper/default_mapping.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,12 @@ pub fn default_mapping() -> Mapping {
122122
entry!(KeyUp(Mmb); action_dispatch=NavigateToolMessage::TransformCanvasEnd),
123123
//
124124
// EyedropperToolMessage
125+
entry!(KeyDown(Lmb); action_dispatch=EyedropperToolMessage::SamplePrimaryColorBegin),
126+
entry!(KeyDown(Lmb); modifiers=[Shift], action_dispatch=EyedropperToolMessage::SampleSecondaryColorBegin),
127+
entry!(KeyUp(Lmb); action_dispatch=EyedropperToolMessage::SamplePrimaryColorEnd),
128+
entry!(KeyUp(Lmb); modifiers=[Shift], action_dispatch=EyedropperToolMessage::SampleSecondaryColorEnd),
125129
entry!(PointerMove; action_dispatch=EyedropperToolMessage::PointerMove),
126-
entry!(KeyDown(Lmb); action_dispatch=EyedropperToolMessage::LeftPointerDown),
127-
entry!(KeyDown(Rmb); action_dispatch=EyedropperToolMessage::RightPointerDown),
128-
entry!(KeyUp(Lmb); action_dispatch=EyedropperToolMessage::LeftPointerUp),
129-
entry!(KeyUp(Rmb); action_dispatch=EyedropperToolMessage::RightPointerUp),
130+
entry!(KeyDown(Rmb); action_dispatch=EyedropperToolMessage::Abort),
130131
entry!(KeyDown(Escape); action_dispatch=EyedropperToolMessage::Abort),
131132
//
132133
// TextToolMessage
@@ -244,8 +245,8 @@ pub fn default_mapping() -> Mapping {
244245
entry!(KeyDown(Enter); action_dispatch=SplineToolMessage::Confirm),
245246
//
246247
// FillToolMessage
247-
entry!(KeyDown(Lmb); action_dispatch=FillToolMessage::LeftPointerDown),
248-
entry!(KeyDown(Rmb); action_dispatch=FillToolMessage::RightPointerDown),
248+
entry!(KeyDown(Lmb); action_dispatch=FillToolMessage::FillPrimaryColor),
249+
entry!(KeyDown(Lmb); modifiers=[Shift], action_dispatch=FillToolMessage::FillSecondaryColor),
249250
//
250251
// BrushToolMessage
251252
entry!(PointerMove; action_dispatch=BrushToolMessage::PointerMove),

editor/src/messages/tool/tool_messages/eyedropper_tool.rs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ pub enum EyedropperToolMessage {
1414
Abort,
1515

1616
// Tool-specific messages
17-
LeftPointerDown,
18-
LeftPointerUp,
17+
SamplePrimaryColorBegin,
18+
SamplePrimaryColorEnd,
1919
PointerMove,
20-
RightPointerDown,
21-
RightPointerUp,
20+
SampleSecondaryColorBegin,
21+
SampleSecondaryColorEnd,
2222
}
2323

2424
impl ToolMetadata for EyedropperTool {
@@ -45,11 +45,11 @@ impl<'a> MessageHandler<ToolMessage, &mut ToolActionHandlerData<'a>> for Eyedrop
4545
}
4646

4747
advertise_actions!(EyedropperToolMessageDiscriminant;
48-
LeftPointerDown,
49-
LeftPointerUp,
48+
SamplePrimaryColorBegin,
49+
SamplePrimaryColorEnd,
50+
SampleSecondaryColorBegin,
51+
SampleSecondaryColorEnd,
5052
PointerMove,
51-
RightPointerDown,
52-
RightPointerUp,
5353
Abort,
5454
);
5555
}
@@ -87,10 +87,10 @@ impl Fsm for EyedropperToolFsmState {
8787
};
8888
match (self, event) {
8989
// Ready -> Sampling
90-
(EyedropperToolFsmState::Ready, mouse_down) if matches!(mouse_down, EyedropperToolMessage::LeftPointerDown | EyedropperToolMessage::RightPointerDown) => {
90+
(EyedropperToolFsmState::Ready, mouse_down) if matches!(mouse_down, EyedropperToolMessage::SamplePrimaryColorBegin | EyedropperToolMessage::SampleSecondaryColorBegin) => {
9191
update_cursor_preview(responses, input, global_tool_data, None);
9292

93-
if mouse_down == EyedropperToolMessage::LeftPointerDown {
93+
if mouse_down == EyedropperToolMessage::SamplePrimaryColorBegin {
9494
EyedropperToolFsmState::SamplingPrimary
9595
} else {
9696
EyedropperToolFsmState::SamplingSecondary
@@ -107,7 +107,7 @@ impl Fsm for EyedropperToolFsmState {
107107
self
108108
}
109109
// Sampling -> Ready
110-
(EyedropperToolFsmState::SamplingPrimary, EyedropperToolMessage::LeftPointerUp) | (EyedropperToolFsmState::SamplingSecondary, EyedropperToolMessage::RightPointerUp) => {
110+
(EyedropperToolFsmState::SamplingPrimary, EyedropperToolMessage::SamplePrimaryColorEnd) | (EyedropperToolFsmState::SamplingSecondary, EyedropperToolMessage::SampleSecondaryColorEnd) => {
111111
let set_color_choice = if self == EyedropperToolFsmState::SamplingPrimary { "Primary" } else { "Secondary" }.to_string();
112112
update_cursor_preview(responses, input, global_tool_data, Some(set_color_choice));
113113
disable_cursor_preview(responses);
@@ -129,9 +129,11 @@ impl Fsm for EyedropperToolFsmState {
129129
let hint_data = match self {
130130
EyedropperToolFsmState::Ready => HintData(vec![HintGroup(vec![
131131
HintInfo::mouse(MouseMotion::Lmb, "Sample to Primary"),
132-
HintInfo::mouse(MouseMotion::Rmb, "Sample to Secondary"),
132+
HintInfo::keys_and_mouse([Key::Shift], MouseMotion::Lmb, "Sample to Secondary"),
133133
])]),
134-
EyedropperToolFsmState::SamplingPrimary | EyedropperToolFsmState::SamplingSecondary => HintData(vec![HintGroup(vec![HintInfo::keys([Key::Escape], "Cancel")])]),
134+
EyedropperToolFsmState::SamplingPrimary | EyedropperToolFsmState::SamplingSecondary => {
135+
HintData(vec![HintGroup(vec![HintInfo::mouse(MouseMotion::Rmb, ""), HintInfo::keys([Key::Escape], "Cancel").prepend_slash()])])
136+
}
135137
};
136138

137139
responses.add(FrontendMessage::UpdateInputHints { hint_data });

editor/src/messages/tool/tool_messages/fill_tool.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ pub struct FillTool {
1111
#[derive(PartialEq, Eq, Clone, Debug, Hash, Serialize, Deserialize, specta::Type)]
1212
pub enum FillToolMessage {
1313
// Tool-specific messages
14-
LeftPointerDown,
15-
RightPointerDown,
14+
FillPrimaryColor,
15+
FillSecondaryColor,
1616
}
1717

1818
impl ToolMetadata for FillTool {
@@ -39,8 +39,8 @@ impl<'a> MessageHandler<ToolMessage, &mut ToolActionHandlerData<'a>> for FillToo
3939
}
4040

4141
advertise_actions!(FillToolMessageDiscriminant;
42-
LeftPointerDown,
43-
RightPointerDown,
42+
FillPrimaryColor,
43+
FillSecondaryColor,
4444
);
4545
}
4646

@@ -72,8 +72,8 @@ impl Fsm for FillToolFsmState {
7272
return self;
7373
};
7474
let color = match event {
75-
FillToolMessage::LeftPointerDown => global_tool_data.primary_color,
76-
FillToolMessage::RightPointerDown => global_tool_data.secondary_color,
75+
FillToolMessage::FillPrimaryColor => global_tool_data.primary_color,
76+
FillToolMessage::FillSecondaryColor => global_tool_data.secondary_color,
7777
};
7878
let fill = Fill::Solid(color);
7979

@@ -88,7 +88,7 @@ impl Fsm for FillToolFsmState {
8888
let hint_data = match self {
8989
FillToolFsmState::Ready => HintData(vec![HintGroup(vec![
9090
HintInfo::mouse(MouseMotion::Lmb, "Fill with Primary"),
91-
HintInfo::mouse(MouseMotion::Rmb, "Fill with Secondary"),
91+
HintInfo::keys_and_mouse([Key::Shift], MouseMotion::Lmb, "Fill with Secondary"),
9292
])]),
9393
};
9494

0 commit comments

Comments
 (0)