diff --git a/editor/src/messages/tool/tool_message_handler.rs b/editor/src/messages/tool/tool_message_handler.rs index 0a263e1996..29f6022767 100644 --- a/editor/src/messages/tool/tool_message_handler.rs +++ b/editor/src/messages/tool/tool_message_handler.rs @@ -1,5 +1,5 @@ use super::common_functionality::shape_editor::ShapeState; -use super::common_functionality::shapes::shape_utility::ShapeType::{self, Ellipse, Line, Rectangle}; +use super::common_functionality::shapes::shape_utility::ShapeType::{Ellipse, Line, Rectangle}; use super::utility_types::{ToolActionMessageContext, ToolFsmState, tool_message_to_tool_type}; use crate::application::generate_uuid; use crate::messages::layout::utility_types::widget_prelude::*; @@ -77,7 +77,8 @@ impl MessageHandler> for ToolMessageHandler self.tool_state.tool_data.active_tool_type = ToolType::Shape; } responses.add_front(ToolMessage::ActivateTool { tool_type: ToolType::Shape }); - responses.add(ShapeToolMessage::SetShape { shape: ShapeType::Polygon }); + // Sync current_shape with the dropdown selection (options.shape_type) + responses.add(ShapeToolMessage::SyncShapeWithOptions); responses.add(ShapeToolMessage::HideShapeTypeWidget { hide: false }) } ToolMessage::ActivateToolBrush => responses.add_front(ToolMessage::ActivateTool { tool_type: ToolType::Brush }), diff --git a/editor/src/messages/tool/tool_messages/shape_tool.rs b/editor/src/messages/tool/tool_messages/shape_tool.rs index 39ab4b902c..7e4aa04098 100644 --- a/editor/src/messages/tool/tool_messages/shape_tool.rs +++ b/editor/src/messages/tool/tool_messages/shape_tool.rs @@ -103,6 +103,7 @@ pub enum ShapeToolMessage { PointerOutsideViewport { modifier: ShapeToolModifierKey }, UpdateOptions { options: ShapeOptionsUpdate }, SetShape { shape: ShapeType }, + SyncShapeWithOptions, IncreaseSides, DecreaseSides, @@ -178,30 +179,12 @@ fn create_shape_option_widget(shape_type: ShapeType) -> WidgetInstance { } .into() }), - MenuListEntry::new("Rectangle").label("Rectangle").on_commit(move |_| { - ShapeToolMessage::UpdateOptions { - options: ShapeOptionsUpdate::ShapeType(ShapeType::Rectangle), - } - .into() - }), - MenuListEntry::new("Ellipse").label("Ellipse").on_commit(move |_| { - ShapeToolMessage::UpdateOptions { - options: ShapeOptionsUpdate::ShapeType(ShapeType::Ellipse), - } - .into() - }), MenuListEntry::new("Arrow").label("Arrow").on_commit(move |_| { ShapeToolMessage::UpdateOptions { options: ShapeOptionsUpdate::ShapeType(ShapeType::Arrow), } .into() }), - MenuListEntry::new("Line").label("Line").on_commit(move |_| { - ShapeToolMessage::UpdateOptions { - options: ShapeOptionsUpdate::ShapeType(ShapeType::Line), - } - .into() - }), ]]; DropdownInput::new(entries).selected_index(Some(shape_type as u32)).widget_instance() } @@ -1170,15 +1153,16 @@ impl Fsm for ShapeToolFsmState { responses.add(DocumentMessage::AbortTransaction); tool_data.data.cleanup(responses); tool_data.current_shape = shape; - responses.add(ShapeToolMessage::UpdateOptions { - options: ShapeOptionsUpdate::ShapeType(shape), - }); - - responses.add(ShapeToolMessage::UpdateOptions { - options: ShapeOptionsUpdate::ShapeType(shape), - }); + // Update hints for the new shape (without updating options.shape_type) + update_dynamic_hints(&ShapeToolFsmState::Ready(shape), responses, tool_data); ShapeToolFsmState::Ready(shape) } + (_, ShapeToolMessage::SyncShapeWithOptions) => { + // Sync current_shape with the dropdown selection when returning from alias tools + tool_data.current_shape = tool_options.shape_type; + update_dynamic_hints(&ShapeToolFsmState::Ready(tool_options.shape_type), responses, tool_data); + ShapeToolFsmState::Ready(tool_options.shape_type) + } (_, ShapeToolMessage::HideShapeTypeWidget { hide }) => { tool_data.hide_shape_option_widget = hide; responses.add(ToolMessage::RefreshToolOptions);