mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-02 21:28:11 +08:00
Rename Shape tool to Polygon tool
This commit is contained in:
@@ -95,7 +95,7 @@ Spline Tool | <kbd> </kbd> | <kbd>P</kbd> |
|
|||||||
Line Tool | <kbd>L</kbd> | <kbd>U</kbd> | <kbd>\\</kbd> | **<kbd>L</kbd>** | <kbd>P</kbd> | | |
|
Line Tool | <kbd>L</kbd> | <kbd>U</kbd> | <kbd>\\</kbd> | **<kbd>L</kbd>** | <kbd>P</kbd> | | |
|
||||||
Rectangle Tool | <kbd>M</kbd> | <kbd>U</kbd>/**<kbd>M</kbd>** | **<kbd>M</kbd>** | <kbd>R</kbd> | **<kbd>M</kbd>** | | |
|
Rectangle Tool | <kbd>M</kbd> | <kbd>U</kbd>/**<kbd>M</kbd>** | **<kbd>M</kbd>** | <kbd>R</kbd> | **<kbd>M</kbd>** | | |
|
||||||
Ellipse Tool | <kbd>E</kbd> | <kbd>U</kbd>/<kbd>M</kbd> | <kbd>L</kbd> | **<kbd>E</kbd>** | <kbd>M</kbd> | | |
|
Ellipse Tool | <kbd>E</kbd> | <kbd>U</kbd>/<kbd>M</kbd> | <kbd>L</kbd> | **<kbd>E</kbd>** | <kbd>M</kbd> | | |
|
||||||
Shape Tool | <kbd>Y</kbd> | <kbd>U</kbd> | | **<kbd>Y</kbd>** | | | |
|
Polygon Tool | <kbd>Y</kbd> | <kbd>U</kbd> | | **<kbd>Y</kbd>** | | | |
|
||||||
Text Tool | <kbd>T</kbd> | **<kbd>T</kbd>** | **<kbd>T</kbd>** | **<kbd>T</kbd>** | **<kbd>T</kbd>** | | |
|
Text Tool | <kbd>T</kbd> | **<kbd>T</kbd>** | **<kbd>T</kbd>** | **<kbd>T</kbd>** | **<kbd>T</kbd>** | | |
|
||||||
Brush Tool | <kbd>B</kbd> | **<kbd>B</kbd>** | **<kbd>B</kbd>** | | **<kbd>B</kbd>** | | |
|
Brush Tool | <kbd>B</kbd> | **<kbd>B</kbd>** | **<kbd>B</kbd>** | | **<kbd>B</kbd>** | | |
|
||||||
Heal Tool | <kbd>J</kbd> | **<kbd>J</kbd>** | | | | | |
|
Heal Tool | <kbd>J</kbd> | **<kbd>J</kbd>** | | | | | |
|
||||||
@@ -138,7 +138,7 @@ Excluding mouse inputs and modifier keys.
|
|||||||
|
|
||||||
##### Ellipse Tool
|
##### Ellipse Tool
|
||||||
|
|
||||||
##### Shape Tool
|
##### Polygon Tool
|
||||||
|
|
||||||
##### Text Tool
|
##### Text Tool
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,8 @@ pub enum DocumentError {
|
|||||||
LayerNotFound(Vec<LayerId>),
|
LayerNotFound(Vec<LayerId>),
|
||||||
InvalidPath,
|
InvalidPath,
|
||||||
IndexOutOfBounds,
|
IndexOutOfBounds,
|
||||||
NotAFolder,
|
NotFolder,
|
||||||
NonReorderableSelection,
|
|
||||||
NotShape,
|
NotShape,
|
||||||
NotText,
|
NotLayer,
|
||||||
NotNodeGraph,
|
|
||||||
InvalidFile(String),
|
InvalidFile(String),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ use std::fmt::Write;
|
|||||||
pub enum LayerDataType {
|
pub enum LayerDataType {
|
||||||
/// A layer that wraps a [FolderLayer] struct.
|
/// A layer that wraps a [FolderLayer] struct.
|
||||||
Folder(FolderLayer),
|
Folder(FolderLayer),
|
||||||
/// A layer that wraps a [ShapeLayer] struct.
|
/// A layer that wraps a [ShapeLayer] struct. Still used by the overlays system, but will be removed in the future.
|
||||||
Shape(ShapeLayer),
|
Shape(ShapeLayer),
|
||||||
/// A layer that wraps an [LayerLayer] struct.
|
/// A layer that wraps an [LayerLayer] struct.
|
||||||
Layer(LayerLayer),
|
Layer(LayerLayer),
|
||||||
@@ -438,7 +438,7 @@ impl Layer {
|
|||||||
pub fn as_folder_mut(&mut self) -> Result<&mut FolderLayer, DocumentError> {
|
pub fn as_folder_mut(&mut self) -> Result<&mut FolderLayer, DocumentError> {
|
||||||
match &mut self.data {
|
match &mut self.data {
|
||||||
LayerDataType::Folder(f) => Ok(f),
|
LayerDataType::Folder(f) => Ok(f),
|
||||||
_ => Err(DocumentError::NotAFolder),
|
_ => Err(DocumentError::NotFolder),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -461,7 +461,7 @@ impl Layer {
|
|||||||
pub fn as_folder(&self) -> Result<&FolderLayer, DocumentError> {
|
pub fn as_folder(&self) -> Result<&FolderLayer, DocumentError> {
|
||||||
match &self.data {
|
match &self.data {
|
||||||
LayerDataType::Folder(f) => Ok(f),
|
LayerDataType::Folder(f) => Ok(f),
|
||||||
_ => Err(DocumentError::NotAFolder),
|
_ => Err(DocumentError::NotFolder),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -470,7 +470,7 @@ impl Layer {
|
|||||||
pub fn as_layer_network_mut(&mut self) -> Result<&mut graph_craft::document::NodeNetwork, DocumentError> {
|
pub fn as_layer_network_mut(&mut self) -> Result<&mut graph_craft::document::NodeNetwork, DocumentError> {
|
||||||
match &mut self.data {
|
match &mut self.data {
|
||||||
LayerDataType::Layer(layer) => Ok(&mut layer.network),
|
LayerDataType::Layer(layer) => Ok(&mut layer.network),
|
||||||
_ => Err(DocumentError::NotNodeGraph),
|
_ => Err(DocumentError::NotLayer),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -479,14 +479,14 @@ impl Layer {
|
|||||||
pub fn as_layer_network(&self) -> Result<&graph_craft::document::NodeNetwork, DocumentError> {
|
pub fn as_layer_network(&self) -> Result<&graph_craft::document::NodeNetwork, DocumentError> {
|
||||||
match &self.data {
|
match &self.data {
|
||||||
LayerDataType::Layer(layer) => Ok(&layer.network),
|
LayerDataType::Layer(layer) => Ok(&layer.network),
|
||||||
_ => Err(DocumentError::NotNodeGraph),
|
_ => Err(DocumentError::NotLayer),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn as_layer(&self) -> Result<&LayerLayer, DocumentError> {
|
pub fn as_layer(&self) -> Result<&LayerLayer, DocumentError> {
|
||||||
match &self.data {
|
match &self.data {
|
||||||
LayerDataType::Layer(layer) => Ok(layer),
|
LayerDataType::Layer(layer) => Ok(layer),
|
||||||
_ => Err(DocumentError::NotNodeGraph),
|
_ => Err(DocumentError::NotLayer),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
//! Layers allow the user to mutate part of the document while leaving the rest unchanged.
|
//! Layers allow the user to mutate part of the document while leaving the rest unchanged.
|
||||||
//! There are currently these different types of layers:
|
//! There are currently these different types of layers:
|
||||||
//! * [Folder layers](folder_layer::FolderLayer), which encapsulate sub-layers
|
//! * [Folder layers](folder_layer::FolderLayer), which encapsulate sub-layers
|
||||||
//! * [Shape layers](shape_layer::ShapeLayer), which contain generic SVG [`<path>`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/path)s
|
//! * [Shape layers](shape_layer::ShapeLayer), which contain generic SVG [`<path>`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/path)s (deprecated but still used by the overlays system).
|
||||||
//! * [Layer layers](layer_layer::NodegraphLayer), which contain a node graph layer
|
//! * [Layer layers](layer_layer::LayerLayer), which contain a node graph layer
|
||||||
//!
|
//!
|
||||||
//! Refer to the module-level documentation for detailed information on each layer.
|
//! Refer to the module-level documentation for detailed information on each layer.
|
||||||
//!
|
//!
|
||||||
@@ -20,7 +20,7 @@ pub mod blend_mode;
|
|||||||
pub mod folder_layer;
|
pub mod folder_layer;
|
||||||
/// Contains the base [Layer](layer_info::Layer) type, an abstraction over the different types of layers.
|
/// Contains the base [Layer](layer_info::Layer) type, an abstraction over the different types of layers.
|
||||||
pub mod layer_info;
|
pub mod layer_info;
|
||||||
/// Contains the [NodegraphLayer](nodegraph_layer::NodegraphLayer) type that contains a node graph.
|
/// Contains the [LayerLayer](nodegraph_layer::LayerLayer) type that contains a node graph.
|
||||||
pub mod layer_layer;
|
pub mod layer_layer;
|
||||||
// TODO: Remove shape layers after rewriting the overlay system
|
// TODO: Remove shape layers after rewriting the overlay system
|
||||||
/// Contains the [ShapeLayer](shape_layer::ShapeLayer) type, a generic SVG element defined using Bezier paths.
|
/// Contains the [ShapeLayer](shape_layer::ShapeLayer) type, a generic SVG element defined using Bezier paths.
|
||||||
|
|||||||
@@ -282,7 +282,7 @@ mod test {
|
|||||||
editor.draw_rect(100., 200., 300., 400.);
|
editor.draw_rect(100., 200., 300., 400.);
|
||||||
|
|
||||||
editor.select_primary_color(Color::BLUE);
|
editor.select_primary_color(Color::BLUE);
|
||||||
editor.draw_shape(10., 1200., 1300., 400.);
|
editor.draw_polygon(10., 1200., 1300., 400.);
|
||||||
|
|
||||||
editor.select_primary_color(Color::GREEN);
|
editor.select_primary_color(Color::GREEN);
|
||||||
editor.draw_ellipse(104., 1200., 1300., 400.);
|
editor.draw_ellipse(104., 1200., 1300., 400.);
|
||||||
|
|||||||
@@ -159,12 +159,12 @@ pub fn default_mapping() -> Mapping {
|
|||||||
entry!(KeyDown(Escape); action_dispatch=EllipseToolMessage::Abort),
|
entry!(KeyDown(Escape); action_dispatch=EllipseToolMessage::Abort),
|
||||||
entry!(PointerMove; refresh_keys=[Alt, Shift], action_dispatch=EllipseToolMessage::Resize { center: Alt, lock_ratio: Shift }),
|
entry!(PointerMove; refresh_keys=[Alt, Shift], action_dispatch=EllipseToolMessage::Resize { center: Alt, lock_ratio: Shift }),
|
||||||
//
|
//
|
||||||
// ShapeToolMessage
|
// PolygonToolMessage
|
||||||
entry!(KeyDown(Lmb); action_dispatch=ShapeToolMessage::DragStart),
|
entry!(KeyDown(Lmb); action_dispatch=PolygonToolMessage::DragStart),
|
||||||
entry!(KeyUp(Lmb); action_dispatch=ShapeToolMessage::DragStop),
|
entry!(KeyUp(Lmb); action_dispatch=PolygonToolMessage::DragStop),
|
||||||
entry!(KeyDown(Rmb); action_dispatch=ShapeToolMessage::Abort),
|
entry!(KeyDown(Rmb); action_dispatch=PolygonToolMessage::Abort),
|
||||||
entry!(KeyDown(Escape); action_dispatch=ShapeToolMessage::Abort),
|
entry!(KeyDown(Escape); action_dispatch=PolygonToolMessage::Abort),
|
||||||
entry!(PointerMove; refresh_keys=[Alt, Shift], action_dispatch=ShapeToolMessage::Resize { center: Alt, lock_ratio: Shift }),
|
entry!(PointerMove; refresh_keys=[Alt, Shift], action_dispatch=PolygonToolMessage::Resize { center: Alt, lock_ratio: Shift }),
|
||||||
//
|
//
|
||||||
// LineToolMessage
|
// LineToolMessage
|
||||||
entry!(KeyDown(Lmb); action_dispatch=LineToolMessage::DragStart),
|
entry!(KeyDown(Lmb); action_dispatch=LineToolMessage::DragStart),
|
||||||
@@ -253,7 +253,7 @@ pub fn default_mapping() -> Mapping {
|
|||||||
entry!(KeyDown(KeyL); action_dispatch=ToolMessage::ActivateToolLine),
|
entry!(KeyDown(KeyL); action_dispatch=ToolMessage::ActivateToolLine),
|
||||||
entry!(KeyDown(KeyM); action_dispatch=ToolMessage::ActivateToolRectangle),
|
entry!(KeyDown(KeyM); action_dispatch=ToolMessage::ActivateToolRectangle),
|
||||||
entry!(KeyDown(KeyE); action_dispatch=ToolMessage::ActivateToolEllipse),
|
entry!(KeyDown(KeyE); action_dispatch=ToolMessage::ActivateToolEllipse),
|
||||||
entry!(KeyDown(KeyY); action_dispatch=ToolMessage::ActivateToolShape),
|
entry!(KeyDown(KeyY); action_dispatch=ToolMessage::ActivateToolPolygon),
|
||||||
entry!(KeyDown(KeyB); action_dispatch=ToolMessage::ActivateToolBrush),
|
entry!(KeyDown(KeyB); action_dispatch=ToolMessage::ActivateToolBrush),
|
||||||
entry!(KeyDown(KeyX); modifiers=[Shift, Accel], action_dispatch=ToolMessage::ResetColors),
|
entry!(KeyDown(KeyX); modifiers=[Shift, Accel], action_dispatch=ToolMessage::ResetColors),
|
||||||
entry!(KeyDown(KeyX); modifiers=[Shift], action_dispatch=ToolMessage::SwapColors),
|
entry!(KeyDown(KeyX); modifiers=[Shift], action_dispatch=ToolMessage::SwapColors),
|
||||||
|
|||||||
@@ -44,9 +44,9 @@ pub use crate::messages::tool::tool_messages::line_tool::{LineToolMessage, LineT
|
|||||||
pub use crate::messages::tool::tool_messages::navigate_tool::{NavigateToolMessage, NavigateToolMessageDiscriminant};
|
pub use crate::messages::tool::tool_messages::navigate_tool::{NavigateToolMessage, NavigateToolMessageDiscriminant};
|
||||||
pub use crate::messages::tool::tool_messages::path_tool::{PathToolMessage, PathToolMessageDiscriminant};
|
pub use crate::messages::tool::tool_messages::path_tool::{PathToolMessage, PathToolMessageDiscriminant};
|
||||||
pub use crate::messages::tool::tool_messages::pen_tool::{PenToolMessage, PenToolMessageDiscriminant};
|
pub use crate::messages::tool::tool_messages::pen_tool::{PenToolMessage, PenToolMessageDiscriminant};
|
||||||
|
pub use crate::messages::tool::tool_messages::polygon_tool::{PolygonToolMessage, PolygonToolMessageDiscriminant};
|
||||||
pub use crate::messages::tool::tool_messages::rectangle_tool::{RectangleToolMessage, RectangleToolMessageDiscriminant};
|
pub use crate::messages::tool::tool_messages::rectangle_tool::{RectangleToolMessage, RectangleToolMessageDiscriminant};
|
||||||
pub use crate::messages::tool::tool_messages::select_tool::{SelectToolMessage, SelectToolMessageDiscriminant};
|
pub use crate::messages::tool::tool_messages::select_tool::{SelectToolMessage, SelectToolMessageDiscriminant};
|
||||||
pub use crate::messages::tool::tool_messages::shape_tool::{ShapeToolMessage, ShapeToolMessageDiscriminant};
|
|
||||||
pub use crate::messages::tool::tool_messages::spline_tool::{SplineToolMessage, SplineToolMessageDiscriminant};
|
pub use crate::messages::tool::tool_messages::spline_tool::{SplineToolMessage, SplineToolMessageDiscriminant};
|
||||||
pub use crate::messages::tool::tool_messages::text_tool::{TextToolMessage, TextToolMessageDiscriminant};
|
pub use crate::messages::tool::tool_messages::text_tool::{TextToolMessage, TextToolMessageDiscriminant};
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ pub enum ToolMessage {
|
|||||||
Ellipse(EllipseToolMessage),
|
Ellipse(EllipseToolMessage),
|
||||||
#[remain::unsorted]
|
#[remain::unsorted]
|
||||||
#[child]
|
#[child]
|
||||||
Shape(ShapeToolMessage),
|
Polygon(PolygonToolMessage),
|
||||||
#[remain::unsorted]
|
#[remain::unsorted]
|
||||||
#[child]
|
#[child]
|
||||||
Text(TextToolMessage),
|
Text(TextToolMessage),
|
||||||
@@ -117,7 +117,7 @@ pub enum ToolMessage {
|
|||||||
#[remain::unsorted]
|
#[remain::unsorted]
|
||||||
ActivateToolEllipse,
|
ActivateToolEllipse,
|
||||||
#[remain::unsorted]
|
#[remain::unsorted]
|
||||||
ActivateToolShape,
|
ActivateToolPolygon,
|
||||||
|
|
||||||
#[remain::unsorted]
|
#[remain::unsorted]
|
||||||
ActivateToolBrush,
|
ActivateToolBrush,
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ impl MessageHandler<ToolMessage, (&DocumentMessageHandler, u64, &InputPreprocess
|
|||||||
#[remain::unsorted]
|
#[remain::unsorted]
|
||||||
ToolMessage::ActivateToolEllipse => responses.add_front(ToolMessage::ActivateTool { tool_type: ToolType::Ellipse }),
|
ToolMessage::ActivateToolEllipse => responses.add_front(ToolMessage::ActivateTool { tool_type: ToolType::Ellipse }),
|
||||||
#[remain::unsorted]
|
#[remain::unsorted]
|
||||||
ToolMessage::ActivateToolShape => responses.add_front(ToolMessage::ActivateTool { tool_type: ToolType::Shape }),
|
ToolMessage::ActivateToolPolygon => responses.add_front(ToolMessage::ActivateTool { tool_type: ToolType::Polygon }),
|
||||||
|
|
||||||
#[remain::unsorted]
|
#[remain::unsorted]
|
||||||
ToolMessage::ActivateToolBrush => responses.add_front(ToolMessage::ActivateTool { tool_type: ToolType::Brush }),
|
ToolMessage::ActivateToolBrush => responses.add_front(ToolMessage::ActivateTool { tool_type: ToolType::Brush }),
|
||||||
@@ -282,7 +282,7 @@ impl MessageHandler<ToolMessage, (&DocumentMessageHandler, u64, &InputPreprocess
|
|||||||
ActivateToolLine,
|
ActivateToolLine,
|
||||||
ActivateToolRectangle,
|
ActivateToolRectangle,
|
||||||
ActivateToolEllipse,
|
ActivateToolEllipse,
|
||||||
ActivateToolShape,
|
ActivateToolPolygon,
|
||||||
|
|
||||||
ActivateToolBrush,
|
ActivateToolBrush,
|
||||||
ActivateToolImaginate,
|
ActivateToolImaginate,
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ pub mod line_tool;
|
|||||||
pub mod navigate_tool;
|
pub mod navigate_tool;
|
||||||
pub mod path_tool;
|
pub mod path_tool;
|
||||||
pub mod pen_tool;
|
pub mod pen_tool;
|
||||||
|
pub mod polygon_tool;
|
||||||
pub mod rectangle_tool;
|
pub mod rectangle_tool;
|
||||||
pub mod select_tool;
|
pub mod select_tool;
|
||||||
pub mod shape_tool;
|
|
||||||
pub mod spline_tool;
|
pub mod spline_tool;
|
||||||
pub mod text_tool;
|
pub mod text_tool;
|
||||||
|
|||||||
+60
-60
@@ -15,13 +15,13 @@ use glam::DVec2;
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct ShapeTool {
|
pub struct PolygonTool {
|
||||||
fsm_state: ShapeToolFsmState,
|
fsm_state: PolygonToolFsmState,
|
||||||
tool_data: ShapeToolData,
|
tool_data: PolygonToolData,
|
||||||
options: ShapeOptions,
|
options: PolygonOptions,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ShapeOptions {
|
pub struct PolygonOptions {
|
||||||
line_weight: f64,
|
line_weight: f64,
|
||||||
fill: ToolColorOptions,
|
fill: ToolColorOptions,
|
||||||
stroke: ToolColorOptions,
|
stroke: ToolColorOptions,
|
||||||
@@ -29,7 +29,7 @@ pub struct ShapeOptions {
|
|||||||
primitive_shape_type: PrimitiveShapeType,
|
primitive_shape_type: PrimitiveShapeType,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for ShapeOptions {
|
impl Default for PolygonOptions {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
vertices: 5,
|
vertices: 5,
|
||||||
@@ -42,9 +42,9 @@ impl Default for ShapeOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[remain::sorted]
|
#[remain::sorted]
|
||||||
#[impl_message(Message, ToolMessage, Shape)]
|
#[impl_message(Message, ToolMessage, Polygon)]
|
||||||
#[derive(PartialEq, Clone, Debug, Serialize, Deserialize, specta::Type)]
|
#[derive(PartialEq, Clone, Debug, Serialize, Deserialize, specta::Type)]
|
||||||
pub enum ShapeToolMessage {
|
pub enum PolygonToolMessage {
|
||||||
// Standard messages
|
// Standard messages
|
||||||
#[remain::unsorted]
|
#[remain::unsorted]
|
||||||
Abort,
|
Abort,
|
||||||
@@ -58,7 +58,7 @@ pub enum ShapeToolMessage {
|
|||||||
center: Key,
|
center: Key,
|
||||||
lock_ratio: Key,
|
lock_ratio: Key,
|
||||||
},
|
},
|
||||||
UpdateOptions(ShapeOptionsUpdate),
|
UpdateOptions(PolygonOptionsUpdate),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Copy, Clone, Debug, Serialize, Deserialize, specta::Type)]
|
#[derive(PartialEq, Copy, Clone, Debug, Serialize, Deserialize, specta::Type)]
|
||||||
@@ -69,7 +69,7 @@ pub enum PrimitiveShapeType {
|
|||||||
|
|
||||||
#[remain::sorted]
|
#[remain::sorted]
|
||||||
#[derive(PartialEq, Clone, Debug, Serialize, Deserialize, specta::Type)]
|
#[derive(PartialEq, Clone, Debug, Serialize, Deserialize, specta::Type)]
|
||||||
pub enum ShapeOptionsUpdate {
|
pub enum PolygonOptionsUpdate {
|
||||||
FillColor(Option<Color>),
|
FillColor(Option<Color>),
|
||||||
FillColorType(ToolColorType),
|
FillColorType(ToolColorType),
|
||||||
LineWeight(f64),
|
LineWeight(f64),
|
||||||
@@ -80,15 +80,15 @@ pub enum ShapeOptionsUpdate {
|
|||||||
WorkingColors(Option<Color>, Option<Color>),
|
WorkingColors(Option<Color>, Option<Color>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToolMetadata for ShapeTool {
|
impl ToolMetadata for PolygonTool {
|
||||||
fn icon_name(&self) -> String {
|
fn icon_name(&self) -> String {
|
||||||
"VectorShapeTool".into()
|
"VectorPolygonTool".into()
|
||||||
}
|
}
|
||||||
fn tooltip(&self) -> String {
|
fn tooltip(&self) -> String {
|
||||||
"Shape Tool".into()
|
"Polygon Tool".into()
|
||||||
}
|
}
|
||||||
fn tool_type(&self) -> crate::messages::tool::utility_types::ToolType {
|
fn tool_type(&self) -> crate::messages::tool::utility_types::ToolType {
|
||||||
ToolType::Shape
|
ToolType::Polygon
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,14 +99,14 @@ fn create_sides_widget(vertices: u32) -> WidgetHolder {
|
|||||||
.min(3.)
|
.min(3.)
|
||||||
.max(1000.)
|
.max(1000.)
|
||||||
.mode(NumberInputMode::Increment)
|
.mode(NumberInputMode::Increment)
|
||||||
.on_update(|number_input: &NumberInput| ShapeToolMessage::UpdateOptions(ShapeOptionsUpdate::Vertices(number_input.value.unwrap() as u32)).into())
|
.on_update(|number_input: &NumberInput| PolygonToolMessage::UpdateOptions(PolygonOptionsUpdate::Vertices(number_input.value.unwrap() as u32)).into())
|
||||||
.widget_holder()
|
.widget_holder()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_star_option_widget(primitive_shape_type: PrimitiveShapeType) -> WidgetHolder {
|
fn create_star_option_widget(primitive_shape_type: PrimitiveShapeType) -> WidgetHolder {
|
||||||
let entries = vec![
|
let entries = vec![
|
||||||
RadioEntryData::new("Polygon").on_update(move |_| ShapeToolMessage::UpdateOptions(ShapeOptionsUpdate::PrimitiveShapeType(PrimitiveShapeType::Polygon)).into()),
|
RadioEntryData::new("Polygon").on_update(move |_| PolygonToolMessage::UpdateOptions(PolygonOptionsUpdate::PrimitiveShapeType(PrimitiveShapeType::Polygon)).into()),
|
||||||
RadioEntryData::new("Star").on_update(move |_| ShapeToolMessage::UpdateOptions(ShapeOptionsUpdate::PrimitiveShapeType(PrimitiveShapeType::Star)).into()),
|
RadioEntryData::new("Star").on_update(move |_| PolygonToolMessage::UpdateOptions(PolygonOptionsUpdate::PrimitiveShapeType(PrimitiveShapeType::Star)).into()),
|
||||||
];
|
];
|
||||||
RadioInput::new(entries).selected_index(primitive_shape_type as u32).widget_holder()
|
RadioInput::new(entries).selected_index(primitive_shape_type as u32).widget_holder()
|
||||||
}
|
}
|
||||||
@@ -116,11 +116,11 @@ fn create_weight_widget(line_weight: f64) -> WidgetHolder {
|
|||||||
.unit(" px")
|
.unit(" px")
|
||||||
.label("Weight")
|
.label("Weight")
|
||||||
.min(0.)
|
.min(0.)
|
||||||
.on_update(|number_input: &NumberInput| ShapeToolMessage::UpdateOptions(ShapeOptionsUpdate::LineWeight(number_input.value.unwrap())).into())
|
.on_update(|number_input: &NumberInput| PolygonToolMessage::UpdateOptions(PolygonOptionsUpdate::LineWeight(number_input.value.unwrap())).into())
|
||||||
.widget_holder()
|
.widget_holder()
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LayoutHolder for ShapeTool {
|
impl LayoutHolder for PolygonTool {
|
||||||
fn layout(&self) -> Layout {
|
fn layout(&self) -> Layout {
|
||||||
let mut widgets = vec![
|
let mut widgets = vec![
|
||||||
create_star_option_widget(self.options.primitive_shape_type),
|
create_star_option_widget(self.options.primitive_shape_type),
|
||||||
@@ -133,9 +133,9 @@ impl LayoutHolder for ShapeTool {
|
|||||||
widgets.append(&mut self.options.fill.create_widgets(
|
widgets.append(&mut self.options.fill.create_widgets(
|
||||||
"Fill",
|
"Fill",
|
||||||
true,
|
true,
|
||||||
|_| ShapeToolMessage::UpdateOptions(ShapeOptionsUpdate::FillColor(None)).into(),
|
|_| PolygonToolMessage::UpdateOptions(PolygonOptionsUpdate::FillColor(None)).into(),
|
||||||
|color_type: ToolColorType| WidgetCallback::new(move |_| ShapeToolMessage::UpdateOptions(ShapeOptionsUpdate::FillColorType(color_type.clone())).into()),
|
|color_type: ToolColorType| WidgetCallback::new(move |_| PolygonToolMessage::UpdateOptions(PolygonOptionsUpdate::FillColorType(color_type.clone())).into()),
|
||||||
|color: &ColorInput| ShapeToolMessage::UpdateOptions(ShapeOptionsUpdate::FillColor(color.value)).into(),
|
|color: &ColorInput| PolygonToolMessage::UpdateOptions(PolygonOptionsUpdate::FillColor(color.value)).into(),
|
||||||
));
|
));
|
||||||
|
|
||||||
widgets.push(Separator::new(SeparatorType::Section).widget_holder());
|
widgets.push(Separator::new(SeparatorType::Section).widget_holder());
|
||||||
@@ -143,9 +143,9 @@ impl LayoutHolder for ShapeTool {
|
|||||||
widgets.append(&mut self.options.stroke.create_widgets(
|
widgets.append(&mut self.options.stroke.create_widgets(
|
||||||
"Stroke",
|
"Stroke",
|
||||||
true,
|
true,
|
||||||
|_| ShapeToolMessage::UpdateOptions(ShapeOptionsUpdate::StrokeColor(None)).into(),
|
|_| PolygonToolMessage::UpdateOptions(PolygonOptionsUpdate::StrokeColor(None)).into(),
|
||||||
|color_type: ToolColorType| WidgetCallback::new(move |_| ShapeToolMessage::UpdateOptions(ShapeOptionsUpdate::StrokeColorType(color_type.clone())).into()),
|
|color_type: ToolColorType| WidgetCallback::new(move |_| PolygonToolMessage::UpdateOptions(PolygonOptionsUpdate::StrokeColorType(color_type.clone())).into()),
|
||||||
|color: &ColorInput| ShapeToolMessage::UpdateOptions(ShapeOptionsUpdate::StrokeColor(color.value)).into(),
|
|color: &ColorInput| PolygonToolMessage::UpdateOptions(PolygonOptionsUpdate::StrokeColor(color.value)).into(),
|
||||||
));
|
));
|
||||||
widgets.push(Separator::new(SeparatorType::Unrelated).widget_holder());
|
widgets.push(Separator::new(SeparatorType::Unrelated).widget_holder());
|
||||||
widgets.push(create_weight_widget(self.options.line_weight));
|
widgets.push(create_weight_widget(self.options.line_weight));
|
||||||
@@ -153,24 +153,24 @@ impl LayoutHolder for ShapeTool {
|
|||||||
Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets }]))
|
Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets }]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<'a> MessageHandler<ToolMessage, &mut ToolActionHandlerData<'a>> for ShapeTool {
|
impl<'a> MessageHandler<ToolMessage, &mut ToolActionHandlerData<'a>> for PolygonTool {
|
||||||
fn process_message(&mut self, message: ToolMessage, responses: &mut VecDeque<Message>, tool_data: &mut ToolActionHandlerData<'a>) {
|
fn process_message(&mut self, message: ToolMessage, responses: &mut VecDeque<Message>, tool_data: &mut ToolActionHandlerData<'a>) {
|
||||||
if let ToolMessage::Shape(ShapeToolMessage::UpdateOptions(action)) = message {
|
if let ToolMessage::Polygon(PolygonToolMessage::UpdateOptions(action)) = message {
|
||||||
match action {
|
match action {
|
||||||
ShapeOptionsUpdate::Vertices(vertices) => self.options.vertices = vertices,
|
PolygonOptionsUpdate::Vertices(vertices) => self.options.vertices = vertices,
|
||||||
ShapeOptionsUpdate::PrimitiveShapeType(primitive_shape_type) => self.options.primitive_shape_type = primitive_shape_type,
|
PolygonOptionsUpdate::PrimitiveShapeType(primitive_shape_type) => self.options.primitive_shape_type = primitive_shape_type,
|
||||||
ShapeOptionsUpdate::FillColor(color) => {
|
PolygonOptionsUpdate::FillColor(color) => {
|
||||||
self.options.fill.custom_color = color;
|
self.options.fill.custom_color = color;
|
||||||
self.options.fill.color_type = ToolColorType::Custom;
|
self.options.fill.color_type = ToolColorType::Custom;
|
||||||
}
|
}
|
||||||
ShapeOptionsUpdate::FillColorType(color_type) => self.options.fill.color_type = color_type,
|
PolygonOptionsUpdate::FillColorType(color_type) => self.options.fill.color_type = color_type,
|
||||||
ShapeOptionsUpdate::LineWeight(line_weight) => self.options.line_weight = line_weight,
|
PolygonOptionsUpdate::LineWeight(line_weight) => self.options.line_weight = line_weight,
|
||||||
ShapeOptionsUpdate::StrokeColor(color) => {
|
PolygonOptionsUpdate::StrokeColor(color) => {
|
||||||
self.options.stroke.custom_color = color;
|
self.options.stroke.custom_color = color;
|
||||||
self.options.stroke.color_type = ToolColorType::Custom;
|
self.options.stroke.color_type = ToolColorType::Custom;
|
||||||
}
|
}
|
||||||
ShapeOptionsUpdate::StrokeColorType(color_type) => self.options.stroke.color_type = color_type,
|
PolygonOptionsUpdate::StrokeColorType(color_type) => self.options.stroke.color_type = color_type,
|
||||||
ShapeOptionsUpdate::WorkingColors(primary, secondary) => {
|
PolygonOptionsUpdate::WorkingColors(primary, secondary) => {
|
||||||
self.options.stroke.primary_working_color = primary;
|
self.options.stroke.primary_working_color = primary;
|
||||||
self.options.stroke.secondary_working_color = secondary;
|
self.options.stroke.secondary_working_color = secondary;
|
||||||
self.options.fill.primary_working_color = primary;
|
self.options.fill.primary_working_color = primary;
|
||||||
@@ -187,13 +187,13 @@ impl<'a> MessageHandler<ToolMessage, &mut ToolActionHandlerData<'a>> for ShapeTo
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn actions(&self) -> ActionList {
|
fn actions(&self) -> ActionList {
|
||||||
use ShapeToolFsmState::*;
|
use PolygonToolFsmState::*;
|
||||||
|
|
||||||
match self.fsm_state {
|
match self.fsm_state {
|
||||||
Ready => actions!(ShapeToolMessageDiscriminant;
|
Ready => actions!(PolygonToolMessageDiscriminant;
|
||||||
DragStart,
|
DragStart,
|
||||||
),
|
),
|
||||||
Drawing => actions!(ShapeToolMessageDiscriminant;
|
Drawing => actions!(PolygonToolMessageDiscriminant;
|
||||||
DragStop,
|
DragStop,
|
||||||
Abort,
|
Abort,
|
||||||
Resize,
|
Resize,
|
||||||
@@ -202,31 +202,31 @@ impl<'a> MessageHandler<ToolMessage, &mut ToolActionHandlerData<'a>> for ShapeTo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToolTransition for ShapeTool {
|
impl ToolTransition for PolygonTool {
|
||||||
fn event_to_message_map(&self) -> EventToMessageMap {
|
fn event_to_message_map(&self) -> EventToMessageMap {
|
||||||
EventToMessageMap {
|
EventToMessageMap {
|
||||||
tool_abort: Some(ShapeToolMessage::Abort.into()),
|
tool_abort: Some(PolygonToolMessage::Abort.into()),
|
||||||
working_color_changed: Some(ShapeToolMessage::WorkingColorChanged.into()),
|
working_color_changed: Some(PolygonToolMessage::WorkingColorChanged.into()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||||
enum ShapeToolFsmState {
|
enum PolygonToolFsmState {
|
||||||
#[default]
|
#[default]
|
||||||
Ready,
|
Ready,
|
||||||
Drawing,
|
Drawing,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default)]
|
#[derive(Clone, Debug, Default)]
|
||||||
struct ShapeToolData {
|
struct PolygonToolData {
|
||||||
data: Resize,
|
data: Resize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Fsm for ShapeToolFsmState {
|
impl Fsm for PolygonToolFsmState {
|
||||||
type ToolData = ShapeToolData;
|
type ToolData = PolygonToolData;
|
||||||
type ToolOptions = ShapeOptions;
|
type ToolOptions = PolygonOptions;
|
||||||
|
|
||||||
fn transition(
|
fn transition(
|
||||||
self,
|
self,
|
||||||
@@ -242,18 +242,18 @@ impl Fsm for ShapeToolFsmState {
|
|||||||
tool_options: &Self::ToolOptions,
|
tool_options: &Self::ToolOptions,
|
||||||
responses: &mut VecDeque<Message>,
|
responses: &mut VecDeque<Message>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
use ShapeToolFsmState::*;
|
use PolygonToolFsmState::*;
|
||||||
use ShapeToolMessage::*;
|
use PolygonToolMessage::*;
|
||||||
|
|
||||||
let shape_data = &mut tool_data.data;
|
let polygon_data = &mut tool_data.data;
|
||||||
|
|
||||||
if let ToolMessage::Shape(event) = event {
|
if let ToolMessage::Polygon(event) = event {
|
||||||
match (self, event) {
|
match (self, event) {
|
||||||
(Ready, DragStart) => {
|
(Ready, DragStart) => {
|
||||||
shape_data.start(responses, document, input, render_data);
|
polygon_data.start(responses, document, input, render_data);
|
||||||
responses.add(DocumentMessage::StartTransaction);
|
responses.add(DocumentMessage::StartTransaction);
|
||||||
let layer_path = document.get_path_for_new_layer();
|
let layer_path = document.get_path_for_new_layer();
|
||||||
shape_data.path = Some(layer_path.clone());
|
polygon_data.path = Some(layer_path.clone());
|
||||||
|
|
||||||
let subpath = match tool_options.primitive_shape_type {
|
let subpath = match tool_options.primitive_shape_type {
|
||||||
PrimitiveShapeType::Polygon => bezier_rs::Subpath::new_regular_polygon(DVec2::ZERO, tool_options.vertices as u64, 1.),
|
PrimitiveShapeType::Polygon => bezier_rs::Subpath::new_regular_polygon(DVec2::ZERO, tool_options.vertices as u64, 1.),
|
||||||
@@ -275,27 +275,27 @@ impl Fsm for ShapeToolFsmState {
|
|||||||
Drawing
|
Drawing
|
||||||
}
|
}
|
||||||
(state, Resize { center, lock_ratio }) => {
|
(state, Resize { center, lock_ratio }) => {
|
||||||
if let Some(message) = shape_data.calculate_transform(responses, document, input, center, lock_ratio, false) {
|
if let Some(message) = polygon_data.calculate_transform(responses, document, input, center, lock_ratio, false) {
|
||||||
responses.add(message);
|
responses.add(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
state
|
state
|
||||||
}
|
}
|
||||||
(Drawing, DragStop) => {
|
(Drawing, DragStop) => {
|
||||||
input.mouse.finish_transaction(shape_data.viewport_drag_start(document), responses);
|
input.mouse.finish_transaction(polygon_data.viewport_drag_start(document), responses);
|
||||||
shape_data.cleanup(responses);
|
polygon_data.cleanup(responses);
|
||||||
|
|
||||||
Ready
|
Ready
|
||||||
}
|
}
|
||||||
(Drawing, Abort) => {
|
(Drawing, Abort) => {
|
||||||
responses.add(DocumentMessage::AbortTransaction);
|
responses.add(DocumentMessage::AbortTransaction);
|
||||||
|
|
||||||
shape_data.cleanup(responses);
|
polygon_data.cleanup(responses);
|
||||||
|
|
||||||
Ready
|
Ready
|
||||||
}
|
}
|
||||||
(_, WorkingColorChanged) => {
|
(_, WorkingColorChanged) => {
|
||||||
responses.add(ShapeToolMessage::UpdateOptions(ShapeOptionsUpdate::WorkingColors(
|
responses.add(PolygonToolMessage::UpdateOptions(PolygonOptionsUpdate::WorkingColors(
|
||||||
Some(global_tool_data.primary_color),
|
Some(global_tool_data.primary_color),
|
||||||
Some(global_tool_data.secondary_color),
|
Some(global_tool_data.secondary_color),
|
||||||
)));
|
)));
|
||||||
@@ -310,12 +310,12 @@ impl Fsm for ShapeToolFsmState {
|
|||||||
|
|
||||||
fn update_hints(&self, responses: &mut VecDeque<Message>) {
|
fn update_hints(&self, responses: &mut VecDeque<Message>) {
|
||||||
let hint_data = match self {
|
let hint_data = match self {
|
||||||
ShapeToolFsmState::Ready => HintData(vec![HintGroup(vec![
|
PolygonToolFsmState::Ready => HintData(vec![HintGroup(vec![
|
||||||
HintInfo::mouse(MouseMotion::LmbDrag, "Draw Shape"),
|
HintInfo::mouse(MouseMotion::LmbDrag, "Draw Polygon"),
|
||||||
HintInfo::keys([Key::Shift], "Constrain 1:1 Aspect").prepend_plus(),
|
HintInfo::keys([Key::Shift], "Constrain 1:1 Aspect").prepend_plus(),
|
||||||
HintInfo::keys([Key::Alt], "From Center").prepend_plus(),
|
HintInfo::keys([Key::Alt], "From Center").prepend_plus(),
|
||||||
])]),
|
])]),
|
||||||
ShapeToolFsmState::Drawing => HintData(vec![HintGroup(vec![HintInfo::keys([Key::Shift], "Constrain 1:1 Aspect"), HintInfo::keys([Key::Alt], "From Center")])]),
|
PolygonToolFsmState::Drawing => HintData(vec![HintGroup(vec![HintInfo::keys([Key::Shift], "Constrain 1:1 Aspect"), HintInfo::keys([Key::Alt], "From Center")])]),
|
||||||
};
|
};
|
||||||
|
|
||||||
responses.add(FrontendMessage::UpdateInputHints { hint_data });
|
responses.add(FrontendMessage::UpdateInputHints { hint_data });
|
||||||
@@ -348,7 +348,7 @@ pub enum ToolType {
|
|||||||
Line,
|
Line,
|
||||||
Rectangle,
|
Rectangle,
|
||||||
Ellipse,
|
Ellipse,
|
||||||
Shape,
|
Polygon,
|
||||||
Text,
|
Text,
|
||||||
|
|
||||||
// Raster tool group
|
// Raster tool group
|
||||||
@@ -388,7 +388,7 @@ fn list_tools_in_groups() -> Vec<Vec<ToolAvailability>> {
|
|||||||
ToolAvailability::Available(Box::<line_tool::LineTool>::default()),
|
ToolAvailability::Available(Box::<line_tool::LineTool>::default()),
|
||||||
ToolAvailability::Available(Box::<rectangle_tool::RectangleTool>::default()),
|
ToolAvailability::Available(Box::<rectangle_tool::RectangleTool>::default()),
|
||||||
ToolAvailability::Available(Box::<ellipse_tool::EllipseTool>::default()),
|
ToolAvailability::Available(Box::<ellipse_tool::EllipseTool>::default()),
|
||||||
ToolAvailability::Available(Box::<shape_tool::ShapeTool>::default()),
|
ToolAvailability::Available(Box::<polygon_tool::PolygonTool>::default()),
|
||||||
ToolAvailability::Available(Box::<text_tool::TextTool>::default()),
|
ToolAvailability::Available(Box::<text_tool::TextTool>::default()),
|
||||||
],
|
],
|
||||||
vec![
|
vec![
|
||||||
@@ -423,7 +423,7 @@ pub fn tool_message_to_tool_type(tool_message: &ToolMessage) -> ToolType {
|
|||||||
ToolMessage::Line(_) => ToolType::Line,
|
ToolMessage::Line(_) => ToolType::Line,
|
||||||
ToolMessage::Rectangle(_) => ToolType::Rectangle,
|
ToolMessage::Rectangle(_) => ToolType::Rectangle,
|
||||||
ToolMessage::Ellipse(_) => ToolType::Ellipse,
|
ToolMessage::Ellipse(_) => ToolType::Ellipse,
|
||||||
ToolMessage::Shape(_) => ToolType::Shape,
|
ToolMessage::Polygon(_) => ToolType::Polygon,
|
||||||
ToolMessage::Text(_) => ToolType::Text,
|
ToolMessage::Text(_) => ToolType::Text,
|
||||||
|
|
||||||
// Raster tool group
|
// Raster tool group
|
||||||
@@ -460,7 +460,7 @@ pub fn tool_type_to_activate_tool_message(tool_type: ToolType) -> ToolMessageDis
|
|||||||
ToolType::Line => ToolMessageDiscriminant::ActivateToolLine,
|
ToolType::Line => ToolMessageDiscriminant::ActivateToolLine,
|
||||||
ToolType::Rectangle => ToolMessageDiscriminant::ActivateToolRectangle,
|
ToolType::Rectangle => ToolMessageDiscriminant::ActivateToolRectangle,
|
||||||
ToolType::Ellipse => ToolMessageDiscriminant::ActivateToolEllipse,
|
ToolType::Ellipse => ToolMessageDiscriminant::ActivateToolEllipse,
|
||||||
ToolType::Shape => ToolMessageDiscriminant::ActivateToolShape,
|
ToolType::Polygon => ToolMessageDiscriminant::ActivateToolPolygon,
|
||||||
ToolType::Text => ToolMessageDiscriminant::ActivateToolText,
|
ToolType::Text => ToolMessageDiscriminant::ActivateToolText,
|
||||||
|
|
||||||
// Raster tool group
|
// Raster tool group
|
||||||
@@ -582,14 +582,14 @@ mod tool_crash_on_layer_delete_tests {
|
|||||||
|
|
||||||
use test_case::test_case;
|
use test_case::test_case;
|
||||||
|
|
||||||
#[test_case(ToolType::Pen; "while using pen tool")]
|
#[test_case(ToolType::Pen; "while using Pen tool")]
|
||||||
#[test_case(ToolType::Freehand; "while using freehand tool")]
|
#[test_case(ToolType::Freehand; "while using Freehand tool")]
|
||||||
#[test_case(ToolType::Spline; "while using spline tool")]
|
#[test_case(ToolType::Spline; "while using Spline tool")]
|
||||||
#[test_case(ToolType::Line; "while using line tool")]
|
#[test_case(ToolType::Line; "while using Line tool")]
|
||||||
#[test_case(ToolType::Rectangle; "while using rectangle tool")]
|
#[test_case(ToolType::Rectangle; "while using Rectangle tool")]
|
||||||
#[test_case(ToolType::Ellipse; "while using ellipse tool")]
|
#[test_case(ToolType::Ellipse; "while using Ellipse tool")]
|
||||||
#[test_case(ToolType::Shape; "while using shape tool")]
|
#[test_case(ToolType::Polygon; "while using Polygon tool")]
|
||||||
#[test_case(ToolType::Path; "while using path tool")]
|
#[test_case(ToolType::Path; "while using Path tool")]
|
||||||
fn should_not_crash_when_layer_is_deleted(tool: ToolType) {
|
fn should_not_crash_when_layer_is_deleted(tool: ToolType) {
|
||||||
set_uuid_seed(0);
|
set_uuid_seed(0);
|
||||||
let mut test_editor = Editor::new();
|
let mut test_editor = Editor::new();
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ pub trait EditorTestUtils {
|
|||||||
fn new_document(&mut self);
|
fn new_document(&mut self);
|
||||||
|
|
||||||
fn draw_rect(&mut self, x1: f64, y1: f64, x2: f64, y2: f64);
|
fn draw_rect(&mut self, x1: f64, y1: f64, x2: f64, y2: f64);
|
||||||
fn draw_shape(&mut self, x1: f64, y1: f64, x2: f64, y2: f64);
|
fn draw_polygon(&mut self, x1: f64, y1: f64, x2: f64, y2: f64);
|
||||||
fn draw_ellipse(&mut self, x1: f64, y1: f64, x2: f64, y2: f64);
|
fn draw_ellipse(&mut self, x1: f64, y1: f64, x2: f64, y2: f64);
|
||||||
|
|
||||||
/// Select given tool and drag it from (x1, y1) to (x2, y2)
|
/// Select given tool and drag it from (x1, y1) to (x2, y2)
|
||||||
@@ -52,8 +52,8 @@ impl EditorTestUtils for Editor {
|
|||||||
self.drag_tool(ToolType::Rectangle, x1, y1, x2, y2);
|
self.drag_tool(ToolType::Rectangle, x1, y1, x2, y2);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_shape(&mut self, x1: f64, y1: f64, x2: f64, y2: f64) {
|
fn draw_polygon(&mut self, x1: f64, y1: f64, x2: f64, y2: f64) {
|
||||||
self.drag_tool(ToolType::Shape, x1, y1, x2, y2);
|
self.drag_tool(ToolType::Polygon, x1, y1, x2, y2);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_ellipse(&mut self, x1: f64, y1: f64, x2: f64, y2: f64) {
|
fn draw_ellipse(&mut self, x1: f64, y1: f64, x2: f64, y2: f64) {
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 273 B After Width: | Height: | Size: 273 B |
@@ -251,7 +251,7 @@ import VectorLineTool from "@graphite-frontend/assets/icon-24px-two-tone/vector-
|
|||||||
import VectorPathTool from "@graphite-frontend/assets/icon-24px-two-tone/vector-path-tool.svg";
|
import VectorPathTool from "@graphite-frontend/assets/icon-24px-two-tone/vector-path-tool.svg";
|
||||||
import VectorPenTool from "@graphite-frontend/assets/icon-24px-two-tone/vector-pen-tool.svg";
|
import VectorPenTool from "@graphite-frontend/assets/icon-24px-two-tone/vector-pen-tool.svg";
|
||||||
import VectorRectangleTool from "@graphite-frontend/assets/icon-24px-two-tone/vector-rectangle-tool.svg";
|
import VectorRectangleTool from "@graphite-frontend/assets/icon-24px-two-tone/vector-rectangle-tool.svg";
|
||||||
import VectorShapeTool from "@graphite-frontend/assets/icon-24px-two-tone/vector-shape-tool.svg";
|
import VectorPolygonTool from "@graphite-frontend/assets/icon-24px-two-tone/vector-polygon-tool.svg";
|
||||||
import VectorSplineTool from "@graphite-frontend/assets/icon-24px-two-tone/vector-spline-tool.svg";
|
import VectorSplineTool from "@graphite-frontend/assets/icon-24px-two-tone/vector-spline-tool.svg";
|
||||||
import VectorTextTool from "@graphite-frontend/assets/icon-24px-two-tone/vector-text-tool.svg";
|
import VectorTextTool from "@graphite-frontend/assets/icon-24px-two-tone/vector-text-tool.svg";
|
||||||
|
|
||||||
@@ -276,7 +276,7 @@ const TWO_TONE_24PX = {
|
|||||||
VectorPathTool: { svg: VectorPathTool, size: 24 },
|
VectorPathTool: { svg: VectorPathTool, size: 24 },
|
||||||
VectorPenTool: { svg: VectorPenTool, size: 24 },
|
VectorPenTool: { svg: VectorPenTool, size: 24 },
|
||||||
VectorRectangleTool: { svg: VectorRectangleTool, size: 24 },
|
VectorRectangleTool: { svg: VectorRectangleTool, size: 24 },
|
||||||
VectorShapeTool: { svg: VectorShapeTool, size: 24 },
|
VectorPolygonTool: { svg: VectorPolygonTool, size: 24 },
|
||||||
VectorSplineTool: { svg: VectorSplineTool, size: 24 },
|
VectorSplineTool: { svg: VectorSplineTool, size: 24 },
|
||||||
VectorTextTool: { svg: VectorTextTool, size: 24 },
|
VectorTextTool: { svg: VectorTextTool, size: 24 },
|
||||||
} as const;
|
} as const;
|
||||||
|
|||||||
Reference in New Issue
Block a user