Skip to content
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
5 changes: 3 additions & 2 deletions editor/src/messages/tool/tool_message_handler.rs
Original file line number Diff line number Diff line change
@@ -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::*;
Expand Down Expand Up @@ -75,9 +75,10 @@ impl MessageHandler<ToolMessage, ToolMessageContext<'_>> for ToolMessageHandler
if self.tool_state.tool_data.active_shape_type.is_some() {
self.tool_state.tool_data.active_shape_type = None;
self.tool_state.tool_data.active_tool_type = ToolType::Shape;
// Restore current_shape from the preserved dropdown selection (options.shape_type)
responses.add(ShapeToolMessage::RestoreShapeFromOptions);
}
responses.add_front(ToolMessage::ActivateTool { tool_type: ToolType::Shape });
responses.add(ShapeToolMessage::SetShape { shape: ShapeType::Polygon });
responses.add(ShapeToolMessage::HideShapeTypeWidget { hide: false })
}
ToolMessage::ActivateToolBrush => responses.add_front(ToolMessage::ActivateTool { tool_type: ToolType::Brush }),
Expand Down
46 changes: 32 additions & 14 deletions editor/src/messages/tool/tool_messages/shape_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,23 +82,42 @@ pub enum ShapeOptionsUpdate {
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize, specta::Type)]
pub enum ShapeToolMessage {
// Standard messages
Overlays { context: OverlayContext },
Overlays {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These formatting changes are required else the CI formatting is failing , the versions I am using locally are

  • rustfmt 1.8.0-stable
  • rustc 1.92.0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whereas the CI uses rustc 1.93.0

context: OverlayContext,
},
Abort,
WorkingColorChanged,

// Tool-specific messages
DragStart,
DragStop,
HideShapeTypeWidget { hide: bool },
PointerMove { modifier: ShapeToolModifierKey },
PointerOutsideViewport { modifier: ShapeToolModifierKey },
UpdateOptions { options: ShapeOptionsUpdate },
SetShape { shape: ShapeType },
HideShapeTypeWidget {
hide: bool,
},
PointerMove {
modifier: ShapeToolModifierKey,
},
PointerOutsideViewport {
modifier: ShapeToolModifierKey,
},
UpdateOptions {
options: ShapeOptionsUpdate,
},
SetShape {
shape: ShapeType,
},
/// Restores current_shape from the dropdown selection (options.shape_type)
RestoreShapeFromOptions,

IncreaseSides,
DecreaseSides,

NudgeSelectedLayers { delta_x: f64, delta_y: f64, resize: Key, resize_opposite_corner: Key },
NudgeSelectedLayers {
delta_x: f64,
delta_y: f64,
resize: Key,
resize_opposite_corner: Key,
},
}

fn create_sides_widget(vertices: u32) -> WidgetInstance {
Expand Down Expand Up @@ -1090,16 +1109,15 @@ impl Fsm for ShapeToolFsmState {
(_, ShapeToolMessage::SetShape { shape }) => {
responses.add(DocumentMessage::AbortTransaction);
tool_data.data.cleanup(responses);
// Only update current_shape for drawing, preserve options.shape_type (dropdown selection)
tool_data.current_shape = shape;
responses.add(ShapeToolMessage::UpdateOptions {
options: ShapeOptionsUpdate::ShapeType(shape),
});

responses.add(ShapeToolMessage::UpdateOptions {
options: ShapeOptionsUpdate::ShapeType(shape),
});
ShapeToolFsmState::Ready(shape)
}
(_, ShapeToolMessage::RestoreShapeFromOptions) => {
// Restore current_shape from the dropdown selection when returning from Line/Rectangle/Ellipse aliases
tool_data.current_shape = tool_options.shape_type;
ShapeToolFsmState::Ready(tool_options.shape_type)
}
(_, ShapeToolMessage::HideShapeTypeWidget { hide }) => {
tool_data.hide_shape_option_widget = hide;
responses.add(ToolMessage::RefreshToolOptions);
Expand Down
Loading