Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure Select Tool hints update only when selection is moved. #2248

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion editor/src/messages/tool/tool_messages/artboard_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ impl Fsm for ArtboardToolFsmState {
}
}

fn update_hints(&self, responses: &mut VecDeque<Message>) {
fn update_hints(&self, responses: &mut VecDeque<Message>, _tool_data: &mut Self::ToolData) {
let hint_data = match self {
ArtboardToolFsmState::Ready { .. } => HintData(vec![
HintGroup(vec![HintInfo::mouse(MouseMotion::LmbDrag, "Draw Artboard")]),
Expand Down
2 changes: 1 addition & 1 deletion editor/src/messages/tool/tool_messages/brush_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ impl Fsm for BrushToolFsmState {
}
}

fn update_hints(&self, responses: &mut VecDeque<Message>) {
fn update_hints(&self, responses: &mut VecDeque<Message>, _tool_data: &mut Self::ToolData) {
let hint_data = match self {
BrushToolFsmState::Ready => HintData(vec![
HintGroup(vec![HintInfo::mouse(MouseMotion::LmbDrag, "Draw")]),
Expand Down
2 changes: 1 addition & 1 deletion editor/src/messages/tool/tool_messages/ellipse_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ impl Fsm for EllipseToolFsmState {
}
}

fn update_hints(&self, responses: &mut VecDeque<Message>) {
fn update_hints(&self, responses: &mut VecDeque<Message>, _tool_data: &mut Self::ToolData) {
let hint_data = match self {
EllipseToolFsmState::Ready => HintData(vec![HintGroup(vec![
HintInfo::mouse(MouseMotion::LmbDrag, "Draw Ellipse"),
Expand Down
2 changes: 1 addition & 1 deletion editor/src/messages/tool/tool_messages/eyedropper_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ impl Fsm for EyedropperToolFsmState {
}
}

fn update_hints(&self, responses: &mut VecDeque<Message>) {
fn update_hints(&self, responses: &mut VecDeque<Message>, _tool_data: &mut Self::ToolData) {
let hint_data = match self {
EyedropperToolFsmState::Ready => HintData(vec![HintGroup(vec![
HintInfo::mouse(MouseMotion::Lmb, "Sample to Primary"),
Expand Down
2 changes: 1 addition & 1 deletion editor/src/messages/tool/tool_messages/fill_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl Fsm for FillToolFsmState {
}
}

fn update_hints(&self, responses: &mut VecDeque<Message>) {
fn update_hints(&self, responses: &mut VecDeque<Message>, _tool_data: &mut Self::ToolData) {
let hint_data = match self {
FillToolFsmState::Ready => HintData(vec![HintGroup(vec![
HintInfo::mouse(MouseMotion::Lmb, "Fill with Primary"),
Expand Down
2 changes: 1 addition & 1 deletion editor/src/messages/tool/tool_messages/freehand_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ impl Fsm for FreehandToolFsmState {
}
}

fn update_hints(&self, responses: &mut VecDeque<Message>) {
fn update_hints(&self, responses: &mut VecDeque<Message>, _tool_data: &mut Self::ToolData) {
let hint_data = match self {
FreehandToolFsmState::Ready => HintData(vec![HintGroup(vec![
HintInfo::mouse(MouseMotion::LmbDrag, "Draw Polyline"),
Expand Down
2 changes: 1 addition & 1 deletion editor/src/messages/tool/tool_messages/gradient_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ impl Fsm for GradientToolFsmState {
}
}

fn update_hints(&self, responses: &mut VecDeque<Message>) {
fn update_hints(&self, responses: &mut VecDeque<Message>, _tool_data: &mut Self::ToolData) {
let hint_data = match self {
GradientToolFsmState::Ready => HintData(vec![HintGroup(vec![
HintInfo::mouse(MouseMotion::LmbDrag, "Draw Gradient"),
Expand Down
2 changes: 1 addition & 1 deletion editor/src/messages/tool/tool_messages/imaginate_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ impl Fsm for ImaginateToolFsmState {
}
}

fn update_hints(&self, responses: &mut VecDeque<Message>) {
fn update_hints(&self, responses: &mut VecDeque<Message>, _tool_data: &mut Self::ToolData) {
let hint_data = match self {
ImaginateToolFsmState::Ready => HintData(vec![HintGroup(vec![
HintInfo::mouse(MouseMotion::LmbDrag, "Draw Repaint Frame"),
Expand Down
2 changes: 1 addition & 1 deletion editor/src/messages/tool/tool_messages/line_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ impl Fsm for LineToolFsmState {
}
}

fn update_hints(&self, responses: &mut VecDeque<Message>) {
fn update_hints(&self, responses: &mut VecDeque<Message>, _tool_data: &mut Self::ToolData) {
let hint_data = match self {
LineToolFsmState::Ready => HintData(vec![HintGroup(vec![
HintInfo::mouse(MouseMotion::LmbDrag, "Draw Line"),
Expand Down
2 changes: 1 addition & 1 deletion editor/src/messages/tool/tool_messages/navigate_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl Fsm for NavigateToolFsmState {
}
}

fn update_hints(&self, responses: &mut VecDeque<Message>) {
fn update_hints(&self, responses: &mut VecDeque<Message>, _tool_data: &mut Self::ToolData) {
let hint_data = match self {
NavigateToolFsmState::Ready | NavigateToolFsmState::ZoomOrClickZooming => HintData(vec![
HintGroup(vec![
Expand Down
2 changes: 1 addition & 1 deletion editor/src/messages/tool/tool_messages/path_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,7 @@ impl Fsm for PathToolFsmState {
}
}

fn update_hints(&self, responses: &mut VecDeque<Message>) {
fn update_hints(&self, responses: &mut VecDeque<Message>, _tool_data: &mut Self::ToolData) {
let hint_data = match self {
PathToolFsmState::Ready => HintData(vec![
HintGroup(vec![HintInfo::mouse(MouseMotion::Lmb, "Select Point"), HintInfo::keys([Key::Shift], "Extend Selection").prepend_plus()]),
Expand Down
2 changes: 1 addition & 1 deletion editor/src/messages/tool/tool_messages/pen_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ impl Fsm for PenToolFsmState {
}
}

fn update_hints(&self, responses: &mut VecDeque<Message>) {
fn update_hints(&self, responses: &mut VecDeque<Message>, _tool_data: &mut Self::ToolData) {
let hint_data = match self {
PenToolFsmState::Ready | PenToolFsmState::GRSHandle => HintData(vec![HintGroup(vec![
HintInfo::mouse(MouseMotion::Lmb, "Draw Path"),
Expand Down
2 changes: 1 addition & 1 deletion editor/src/messages/tool/tool_messages/polygon_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ impl Fsm for PolygonToolFsmState {
}
}

fn update_hints(&self, responses: &mut VecDeque<Message>) {
fn update_hints(&self, responses: &mut VecDeque<Message>, _tool_data: &mut Self::ToolData) {
let hint_data = match self {
PolygonToolFsmState::Ready => HintData(vec![HintGroup(vec![
HintInfo::mouse(MouseMotion::LmbDrag, "Draw Polygon"),
Expand Down
2 changes: 1 addition & 1 deletion editor/src/messages/tool/tool_messages/rectangle_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ impl Fsm for RectangleToolFsmState {
}
}

fn update_hints(&self, responses: &mut VecDeque<Message>) {
fn update_hints(&self, responses: &mut VecDeque<Message>, _tool_data: &mut Self::ToolData) {
let hint_data = match self {
RectangleToolFsmState::Ready => HintData(vec![HintGroup(vec![
HintInfo::mouse(MouseMotion::LmbDrag, "Draw Rectangle"),
Expand Down
14 changes: 10 additions & 4 deletions editor/src/messages/tool/tool_messages/select_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,12 @@ impl<'a> MessageHandler<ToolMessage, &mut ToolActionHandlerData<'a>> for SelectT
responses.add(ToolMessage::UpdateHints);
}

if let ToolMessage::Select(SelectToolMessage::PointerMove(ref _modifier_keys)) = message {
if !self.tool_data.has_dragged {
responses.add(ToolMessage::UpdateHints);
}
}

self.fsm_state.process_event(message, &mut self.tool_data, tool_data, &(), responses, false);

if self.tool_data.pivot.should_refresh_pivot_position() || self.tool_data.selected_layers_changed {
Expand Down Expand Up @@ -1234,11 +1240,11 @@ impl Fsm for SelectToolFsmState {
}
}

fn standard_tool_messages(&self, message: &ToolMessage, responses: &mut VecDeque<Message>, _tool_data: &mut Self::ToolData) -> bool {
fn standard_tool_messages(&self, message: &ToolMessage, responses: &mut VecDeque<Message>, tool_data: &mut Self::ToolData) -> bool {
// Check for standard hits or cursor events
match message {
ToolMessage::UpdateHints => {
self.update_hints(responses);
self.update_hints(responses, tool_data);
true
}
ToolMessage::UpdateCursor => {
Expand All @@ -1249,7 +1255,7 @@ impl Fsm for SelectToolFsmState {
}
}

fn update_hints(&self, responses: &mut VecDeque<Message>) {
fn update_hints(&self, responses: &mut VecDeque<Message>, tool_data: &mut Self::ToolData) {
match self {
SelectToolFsmState::Ready { selection } => {
let hint_data = HintData(vec![
Expand Down Expand Up @@ -1281,7 +1287,7 @@ impl Fsm for SelectToolFsmState {
]);
responses.add(FrontendMessage::UpdateInputHints { hint_data });
}
SelectToolFsmState::Dragging => {
SelectToolFsmState::Dragging if tool_data.has_dragged => {
let hint_data = HintData(vec![
HintGroup(vec![HintInfo::mouse(MouseMotion::Rmb, ""), HintInfo::keys([Key::Escape], "Cancel").prepend_slash()]),
HintGroup(vec![HintInfo::keys([Key::Shift], "Constrain to Axis")]),
Expand Down
2 changes: 1 addition & 1 deletion editor/src/messages/tool/tool_messages/spline_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ impl Fsm for SplineToolFsmState {
}
}

fn update_hints(&self, responses: &mut VecDeque<Message>) {
fn update_hints(&self, responses: &mut VecDeque<Message>, _tool_data: &mut Self::ToolData) {
let hint_data = match self {
SplineToolFsmState::Ready => HintData(vec![HintGroup(vec![
HintInfo::mouse(MouseMotion::Lmb, "Draw Spline"),
Expand Down
2 changes: 1 addition & 1 deletion editor/src/messages/tool/tool_messages/text_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ impl Fsm for TextToolFsmState {
}
}

fn update_hints(&self, responses: &mut VecDeque<Message>) {
fn update_hints(&self, responses: &mut VecDeque<Message>, _tool_data: &mut Self::ToolData) {
let hint_data = match self {
TextToolFsmState::Ready => HintData(vec![
HintGroup(vec![HintInfo::mouse(MouseMotion::Lmb, "Place Text")]),
Expand Down
8 changes: 4 additions & 4 deletions editor/src/messages/tool/utility_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,16 @@ pub trait Fsm {
fn transition(self, message: ToolMessage, tool_data: &mut Self::ToolData, transition_data: &mut ToolActionHandlerData, options: &Self::ToolOptions, responses: &mut VecDeque<Message>) -> Self;

/// Implementing this trait function lets a specific tool provide a list of hints (user input actions presently available) to draw in the footer bar.
fn update_hints(&self, responses: &mut VecDeque<Message>);
fn update_hints(&self, responses: &mut VecDeque<Message>, tool_data: &mut Self::ToolData);
/// Implementing this trait function lets a specific tool set the current mouse cursor icon.
fn update_cursor(&self, responses: &mut VecDeque<Message>);

/// If this message is a standard tool message, process it and return true. Standard tool messages are those which are common across every tool.
fn standard_tool_messages(&self, message: &ToolMessage, responses: &mut VecDeque<Message>, _tool_data: &mut Self::ToolData) -> bool {
fn standard_tool_messages(&self, message: &ToolMessage, responses: &mut VecDeque<Message>, tool_data: &mut Self::ToolData) -> bool {
// Check for standard hits or cursor events
match message {
ToolMessage::UpdateHints => {
self.update_hints(responses);
self.update_hints(responses, tool_data);
true
}
ToolMessage::UpdateCursor => {
Expand Down Expand Up @@ -100,7 +100,7 @@ pub trait Fsm {
// Update state
if *self != new_state {
*self = new_state;
self.update_hints(responses);
self.update_hints(responses, tool_data);
if update_cursor_on_transition {
self.update_cursor(responses);
}
Expand Down
Loading