Add info panel

This commit is contained in:
Skyler Lehmkuhl
2025-11-30 10:01:10 -05:00
parent 4d1e052ee7
commit c943f7bfe6
15 changed files with 2876 additions and 119 deletions
@@ -9,7 +9,10 @@ pub mod add_shape;
pub mod move_clip_instances;
pub mod move_objects;
pub mod paint_bucket;
pub mod set_document_properties;
pub mod set_instance_properties;
pub mod set_layer_properties;
pub mod set_shape_properties;
pub mod transform_clip_instances;
pub mod transform_objects;
pub mod trim_clip_instances;
@@ -20,7 +23,10 @@ pub use add_shape::AddShapeAction;
pub use move_clip_instances::MoveClipInstancesAction;
pub use move_objects::MoveShapeInstancesAction;
pub use paint_bucket::PaintBucketAction;
pub use set_document_properties::SetDocumentPropertiesAction;
pub use set_instance_properties::{InstancePropertyChange, SetInstancePropertiesAction};
pub use set_layer_properties::{LayerProperty, SetLayerPropertiesAction};
pub use set_shape_properties::{SetShapePropertiesAction, ShapePropertyChange};
pub use transform_clip_instances::TransformClipInstancesAction;
pub use transform_objects::TransformShapeInstancesAction;
pub use trim_clip_instances::{TrimClipInstancesAction, TrimData, TrimType};
@@ -0,0 +1,183 @@
//! Set document properties action
//!
//! Handles changing document-level properties (width, height, duration, framerate)
//! with undo/redo support.
use crate::action::Action;
use crate::document::Document;
/// Individual property change for a document
#[derive(Clone, Debug)]
pub enum DocumentPropertyChange {
Width(f64),
Height(f64),
Duration(f64),
Framerate(f64),
}
impl DocumentPropertyChange {
/// Extract the f64 value from any variant
fn value(&self) -> f64 {
match self {
DocumentPropertyChange::Width(v) => *v,
DocumentPropertyChange::Height(v) => *v,
DocumentPropertyChange::Duration(v) => *v,
DocumentPropertyChange::Framerate(v) => *v,
}
}
}
/// Action that sets a property on the document
pub struct SetDocumentPropertiesAction {
/// The new property value
property: DocumentPropertyChange,
/// The old value for undo
old_value: Option<f64>,
}
impl SetDocumentPropertiesAction {
/// Create a new action to set width
pub fn set_width(width: f64) -> Self {
Self {
property: DocumentPropertyChange::Width(width),
old_value: None,
}
}
/// Create a new action to set height
pub fn set_height(height: f64) -> Self {
Self {
property: DocumentPropertyChange::Height(height),
old_value: None,
}
}
/// Create a new action to set duration
pub fn set_duration(duration: f64) -> Self {
Self {
property: DocumentPropertyChange::Duration(duration),
old_value: None,
}
}
/// Create a new action to set framerate
pub fn set_framerate(framerate: f64) -> Self {
Self {
property: DocumentPropertyChange::Framerate(framerate),
old_value: None,
}
}
fn get_current_value(&self, document: &Document) -> f64 {
match &self.property {
DocumentPropertyChange::Width(_) => document.width,
DocumentPropertyChange::Height(_) => document.height,
DocumentPropertyChange::Duration(_) => document.duration,
DocumentPropertyChange::Framerate(_) => document.framerate,
}
}
fn apply_value(&self, document: &mut Document, value: f64) {
match &self.property {
DocumentPropertyChange::Width(_) => document.width = value,
DocumentPropertyChange::Height(_) => document.height = value,
DocumentPropertyChange::Duration(_) => document.duration = value,
DocumentPropertyChange::Framerate(_) => document.framerate = value,
}
}
}
impl Action for SetDocumentPropertiesAction {
fn execute(&mut self, document: &mut Document) {
// Store old value if not already stored
if self.old_value.is_none() {
self.old_value = Some(self.get_current_value(document));
}
// Apply new value
let new_value = self.property.value();
self.apply_value(document, new_value);
}
fn rollback(&mut self, document: &mut Document) {
if let Some(old_value) = self.old_value {
self.apply_value(document, old_value);
}
}
fn description(&self) -> String {
let property_name = match &self.property {
DocumentPropertyChange::Width(_) => "canvas width",
DocumentPropertyChange::Height(_) => "canvas height",
DocumentPropertyChange::Duration(_) => "duration",
DocumentPropertyChange::Framerate(_) => "framerate",
};
format!("Set {}", property_name)
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_set_width() {
let mut document = Document::new("Test");
document.width = 1920.0;
let mut action = SetDocumentPropertiesAction::set_width(1280.0);
action.execute(&mut document);
assert_eq!(document.width, 1280.0);
action.rollback(&mut document);
assert_eq!(document.width, 1920.0);
}
#[test]
fn test_set_height() {
let mut document = Document::new("Test");
document.height = 1080.0;
let mut action = SetDocumentPropertiesAction::set_height(720.0);
action.execute(&mut document);
assert_eq!(document.height, 720.0);
action.rollback(&mut document);
assert_eq!(document.height, 1080.0);
}
#[test]
fn test_set_duration() {
let mut document = Document::new("Test");
document.duration = 10.0;
let mut action = SetDocumentPropertiesAction::set_duration(30.0);
action.execute(&mut document);
assert_eq!(document.duration, 30.0);
action.rollback(&mut document);
assert_eq!(document.duration, 10.0);
}
#[test]
fn test_set_framerate() {
let mut document = Document::new("Test");
document.framerate = 30.0;
let mut action = SetDocumentPropertiesAction::set_framerate(60.0);
action.execute(&mut document);
assert_eq!(document.framerate, 60.0);
action.rollback(&mut document);
assert_eq!(document.framerate, 30.0);
}
#[test]
fn test_description() {
let action = SetDocumentPropertiesAction::set_width(100.0);
assert_eq!(action.description(), "Set canvas width");
let action = SetDocumentPropertiesAction::set_duration(30.0);
assert_eq!(action.description(), "Set duration");
}
}
@@ -0,0 +1,361 @@
//! Set shape instance properties action
//!
//! Handles changing individual properties on shape instances (position, rotation, scale, etc.)
//! with undo/redo support.
use crate::action::Action;
use crate::document::Document;
use crate::layer::AnyLayer;
use uuid::Uuid;
/// Individual property change for a shape instance
#[derive(Clone, Debug)]
pub enum InstancePropertyChange {
X(f64),
Y(f64),
Rotation(f64),
ScaleX(f64),
ScaleY(f64),
SkewX(f64),
SkewY(f64),
Opacity(f64),
}
impl InstancePropertyChange {
/// Extract the f64 value from any variant
fn value(&self) -> f64 {
match self {
InstancePropertyChange::X(v) => *v,
InstancePropertyChange::Y(v) => *v,
InstancePropertyChange::Rotation(v) => *v,
InstancePropertyChange::ScaleX(v) => *v,
InstancePropertyChange::ScaleY(v) => *v,
InstancePropertyChange::SkewX(v) => *v,
InstancePropertyChange::SkewY(v) => *v,
InstancePropertyChange::Opacity(v) => *v,
}
}
}
/// Action that sets a property on one or more shape instances
pub struct SetInstancePropertiesAction {
/// Layer containing the instances
layer_id: Uuid,
/// Instance IDs to modify and their old values
instance_changes: Vec<(Uuid, Option<f64>)>,
/// Property to change
property: InstancePropertyChange,
}
impl SetInstancePropertiesAction {
/// Create a new action to set a property on a single instance
pub fn new(layer_id: Uuid, instance_id: Uuid, property: InstancePropertyChange) -> Self {
Self {
layer_id,
instance_changes: vec![(instance_id, None)],
property,
}
}
/// Create a new action to set a property on multiple instances
pub fn new_batch(layer_id: Uuid, instance_ids: Vec<Uuid>, property: InstancePropertyChange) -> Self {
Self {
layer_id,
instance_changes: instance_ids.into_iter().map(|id| (id, None)).collect(),
property,
}
}
fn get_instance_value(&self, document: &Document, instance_id: &Uuid) -> Option<f64> {
if let Some(layer) = document.get_layer(&self.layer_id) {
if let AnyLayer::Vector(vector_layer) = layer {
if let Some(instance) = vector_layer.get_object(instance_id) {
return Some(match &self.property {
InstancePropertyChange::X(_) => instance.transform.x,
InstancePropertyChange::Y(_) => instance.transform.y,
InstancePropertyChange::Rotation(_) => instance.transform.rotation,
InstancePropertyChange::ScaleX(_) => instance.transform.scale_x,
InstancePropertyChange::ScaleY(_) => instance.transform.scale_y,
InstancePropertyChange::SkewX(_) => instance.transform.skew_x,
InstancePropertyChange::SkewY(_) => instance.transform.skew_y,
InstancePropertyChange::Opacity(_) => instance.opacity,
});
}
}
}
None
}
fn apply_to_instance(&self, document: &mut Document, instance_id: &Uuid, value: f64) {
if let Some(layer) = document.get_layer_mut(&self.layer_id) {
if let AnyLayer::Vector(vector_layer) = layer {
vector_layer.modify_object_internal(instance_id, |instance| {
match &self.property {
InstancePropertyChange::X(_) => instance.transform.x = value,
InstancePropertyChange::Y(_) => instance.transform.y = value,
InstancePropertyChange::Rotation(_) => instance.transform.rotation = value,
InstancePropertyChange::ScaleX(_) => instance.transform.scale_x = value,
InstancePropertyChange::ScaleY(_) => instance.transform.scale_y = value,
InstancePropertyChange::SkewX(_) => instance.transform.skew_x = value,
InstancePropertyChange::SkewY(_) => instance.transform.skew_y = value,
InstancePropertyChange::Opacity(_) => instance.opacity = value,
}
});
}
}
}
}
impl Action for SetInstancePropertiesAction {
fn execute(&mut self, document: &mut Document) {
let new_value = self.property.value();
let layer_id = self.layer_id;
// First pass: collect old values for instances that don't have them yet
for (instance_id, old_value) in &mut self.instance_changes {
if old_value.is_none() {
// Get old value inline to avoid borrow issues
if let Some(layer) = document.get_layer(&layer_id) {
if let AnyLayer::Vector(vector_layer) = layer {
if let Some(instance) = vector_layer.get_object(instance_id) {
*old_value = Some(match &self.property {
InstancePropertyChange::X(_) => instance.transform.x,
InstancePropertyChange::Y(_) => instance.transform.y,
InstancePropertyChange::Rotation(_) => instance.transform.rotation,
InstancePropertyChange::ScaleX(_) => instance.transform.scale_x,
InstancePropertyChange::ScaleY(_) => instance.transform.scale_y,
InstancePropertyChange::SkewX(_) => instance.transform.skew_x,
InstancePropertyChange::SkewY(_) => instance.transform.skew_y,
InstancePropertyChange::Opacity(_) => instance.opacity,
});
}
}
}
}
}
// Second pass: apply new values
for (instance_id, _) in &self.instance_changes {
self.apply_to_instance(document, instance_id, new_value);
}
}
fn rollback(&mut self, document: &mut Document) {
for (instance_id, old_value) in &self.instance_changes {
if let Some(value) = old_value {
self.apply_to_instance(document, instance_id, *value);
}
}
}
fn description(&self) -> String {
let property_name = match &self.property {
InstancePropertyChange::X(_) => "X position",
InstancePropertyChange::Y(_) => "Y position",
InstancePropertyChange::Rotation(_) => "rotation",
InstancePropertyChange::ScaleX(_) => "scale X",
InstancePropertyChange::ScaleY(_) => "scale Y",
InstancePropertyChange::SkewX(_) => "skew X",
InstancePropertyChange::SkewY(_) => "skew Y",
InstancePropertyChange::Opacity(_) => "opacity",
};
if self.instance_changes.len() == 1 {
format!("Set {}", property_name)
} else {
format!("Set {} on {} objects", property_name, self.instance_changes.len())
}
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::layer::VectorLayer;
use crate::object::{ShapeInstance, Transform};
#[test]
fn test_set_x_position() {
let mut document = Document::new("Test");
let mut layer = VectorLayer::new("Test Layer");
let shape_id = Uuid::new_v4();
let mut instance = ShapeInstance::new(shape_id);
let instance_id = instance.id;
instance.transform = Transform::with_position(10.0, 20.0);
layer.add_object(instance);
let layer_id = document.root_mut().add_child(AnyLayer::Vector(layer));
// Create and execute action
let mut action = SetInstancePropertiesAction::new(
layer_id,
instance_id,
InstancePropertyChange::X(50.0),
);
action.execute(&mut document);
// Verify position changed
if let Some(AnyLayer::Vector(vl)) = document.get_layer_mut(&layer_id) {
let obj = vl.get_object(&instance_id).unwrap();
assert_eq!(obj.transform.x, 50.0);
assert_eq!(obj.transform.y, 20.0); // Y unchanged
}
// Rollback
action.rollback(&mut document);
// Verify restored
if let Some(AnyLayer::Vector(vl)) = document.get_layer_mut(&layer_id) {
let obj = vl.get_object(&instance_id).unwrap();
assert_eq!(obj.transform.x, 10.0);
}
}
#[test]
fn test_set_rotation() {
let mut document = Document::new("Test");
let mut layer = VectorLayer::new("Test Layer");
let shape_id = Uuid::new_v4();
let mut instance = ShapeInstance::new(shape_id);
let instance_id = instance.id;
instance.transform.rotation = 0.0;
layer.add_object(instance);
let layer_id = document.root_mut().add_child(AnyLayer::Vector(layer));
// Create and execute action
let mut action = SetInstancePropertiesAction::new(
layer_id,
instance_id,
InstancePropertyChange::Rotation(45.0),
);
action.execute(&mut document);
// Verify rotation changed
if let Some(AnyLayer::Vector(vl)) = document.get_layer_mut(&layer_id) {
let obj = vl.get_object(&instance_id).unwrap();
assert_eq!(obj.transform.rotation, 45.0);
}
// Rollback
action.rollback(&mut document);
// Verify restored
if let Some(AnyLayer::Vector(vl)) = document.get_layer_mut(&layer_id) {
let obj = vl.get_object(&instance_id).unwrap();
assert_eq!(obj.transform.rotation, 0.0);
}
}
#[test]
fn test_set_opacity() {
let mut document = Document::new("Test");
let mut layer = VectorLayer::new("Test Layer");
let shape_id = Uuid::new_v4();
let mut instance = ShapeInstance::new(shape_id);
let instance_id = instance.id;
instance.opacity = 1.0;
layer.add_object(instance);
let layer_id = document.root_mut().add_child(AnyLayer::Vector(layer));
// Create and execute action
let mut action = SetInstancePropertiesAction::new(
layer_id,
instance_id,
InstancePropertyChange::Opacity(0.5),
);
action.execute(&mut document);
// Verify opacity changed
if let Some(AnyLayer::Vector(vl)) = document.get_layer_mut(&layer_id) {
let obj = vl.get_object(&instance_id).unwrap();
assert_eq!(obj.opacity, 0.5);
}
// Rollback
action.rollback(&mut document);
// Verify restored
if let Some(AnyLayer::Vector(vl)) = document.get_layer_mut(&layer_id) {
let obj = vl.get_object(&instance_id).unwrap();
assert_eq!(obj.opacity, 1.0);
}
}
#[test]
fn test_batch_set_scale() {
let mut document = Document::new("Test");
let mut layer = VectorLayer::new("Test Layer");
let shape_id = Uuid::new_v4();
let mut instance1 = ShapeInstance::new(shape_id);
let instance1_id = instance1.id;
instance1.transform.scale_x = 1.0;
let mut instance2 = ShapeInstance::new(shape_id);
let instance2_id = instance2.id;
instance2.transform.scale_x = 1.0;
layer.add_object(instance1);
layer.add_object(instance2);
let layer_id = document.root_mut().add_child(AnyLayer::Vector(layer));
// Create and execute batch action
let mut action = SetInstancePropertiesAction::new_batch(
layer_id,
vec![instance1_id, instance2_id],
InstancePropertyChange::ScaleX(2.0),
);
action.execute(&mut document);
// Verify both changed
if let Some(AnyLayer::Vector(vl)) = document.get_layer_mut(&layer_id) {
assert_eq!(vl.get_object(&instance1_id).unwrap().transform.scale_x, 2.0);
assert_eq!(vl.get_object(&instance2_id).unwrap().transform.scale_x, 2.0);
}
// Rollback
action.rollback(&mut document);
// Verify both restored
if let Some(AnyLayer::Vector(vl)) = document.get_layer_mut(&layer_id) {
assert_eq!(vl.get_object(&instance1_id).unwrap().transform.scale_x, 1.0);
assert_eq!(vl.get_object(&instance2_id).unwrap().transform.scale_x, 1.0);
}
}
#[test]
fn test_description() {
let layer_id = Uuid::new_v4();
let instance_id = Uuid::new_v4();
let action1 = SetInstancePropertiesAction::new(
layer_id,
instance_id,
InstancePropertyChange::X(0.0),
);
assert_eq!(action1.description(), "Set X position");
let action2 = SetInstancePropertiesAction::new(
layer_id,
instance_id,
InstancePropertyChange::Rotation(0.0),
);
assert_eq!(action2.description(), "Set rotation");
let action3 = SetInstancePropertiesAction::new_batch(
layer_id,
vec![Uuid::new_v4(), Uuid::new_v4()],
InstancePropertyChange::Opacity(1.0),
);
assert_eq!(action3.description(), "Set opacity on 2 objects");
}
}
@@ -0,0 +1,261 @@
//! Set shape properties action
//!
//! Handles changing shape properties (fill color, stroke color, stroke width)
//! with undo/redo support.
use crate::action::Action;
use crate::document::Document;
use crate::layer::AnyLayer;
use crate::shape::{ShapeColor, StrokeStyle};
use uuid::Uuid;
/// Property change for a shape
#[derive(Clone, Debug)]
pub enum ShapePropertyChange {
FillColor(Option<ShapeColor>),
StrokeColor(Option<ShapeColor>),
StrokeWidth(f64),
}
/// Action that sets properties on a shape
pub struct SetShapePropertiesAction {
/// Layer containing the shape
layer_id: Uuid,
/// Shape to modify
shape_id: Uuid,
/// New property value
new_value: ShapePropertyChange,
/// Old property value (stored after first execution)
old_value: Option<ShapePropertyChange>,
}
impl SetShapePropertiesAction {
/// Create a new action to set a property on a shape
pub fn new(layer_id: Uuid, shape_id: Uuid, new_value: ShapePropertyChange) -> Self {
Self {
layer_id,
shape_id,
new_value,
old_value: None,
}
}
/// Create action to set fill color
pub fn set_fill_color(layer_id: Uuid, shape_id: Uuid, color: Option<ShapeColor>) -> Self {
Self::new(layer_id, shape_id, ShapePropertyChange::FillColor(color))
}
/// Create action to set stroke color
pub fn set_stroke_color(layer_id: Uuid, shape_id: Uuid, color: Option<ShapeColor>) -> Self {
Self::new(layer_id, shape_id, ShapePropertyChange::StrokeColor(color))
}
/// Create action to set stroke width
pub fn set_stroke_width(layer_id: Uuid, shape_id: Uuid, width: f64) -> Self {
Self::new(layer_id, shape_id, ShapePropertyChange::StrokeWidth(width))
}
}
impl Action for SetShapePropertiesAction {
fn execute(&mut self, document: &mut Document) {
if let Some(layer) = document.get_layer_mut(&self.layer_id) {
if let AnyLayer::Vector(vector_layer) = layer {
if let Some(shape) = vector_layer.shapes.get_mut(&self.shape_id) {
// Store old value if not already stored
if self.old_value.is_none() {
self.old_value = Some(match &self.new_value {
ShapePropertyChange::FillColor(_) => {
ShapePropertyChange::FillColor(shape.fill_color)
}
ShapePropertyChange::StrokeColor(_) => {
ShapePropertyChange::StrokeColor(shape.stroke_color)
}
ShapePropertyChange::StrokeWidth(_) => {
let width = shape
.stroke_style
.as_ref()
.map(|s| s.width)
.unwrap_or(1.0);
ShapePropertyChange::StrokeWidth(width)
}
});
}
// Apply new value
match &self.new_value {
ShapePropertyChange::FillColor(color) => {
shape.fill_color = *color;
}
ShapePropertyChange::StrokeColor(color) => {
shape.stroke_color = *color;
}
ShapePropertyChange::StrokeWidth(width) => {
if let Some(ref mut style) = shape.stroke_style {
style.width = *width;
} else {
// Create stroke style if it doesn't exist
shape.stroke_style = Some(StrokeStyle {
width: *width,
..Default::default()
});
}
}
}
}
}
}
}
fn rollback(&mut self, document: &mut Document) {
if let Some(old_value) = &self.old_value {
if let Some(layer) = document.get_layer_mut(&self.layer_id) {
if let AnyLayer::Vector(vector_layer) = layer {
if let Some(shape) = vector_layer.shapes.get_mut(&self.shape_id) {
match old_value {
ShapePropertyChange::FillColor(color) => {
shape.fill_color = *color;
}
ShapePropertyChange::StrokeColor(color) => {
shape.stroke_color = *color;
}
ShapePropertyChange::StrokeWidth(width) => {
if let Some(ref mut style) = shape.stroke_style {
style.width = *width;
}
}
}
}
}
}
}
}
fn description(&self) -> String {
match &self.new_value {
ShapePropertyChange::FillColor(_) => "Set fill color".to_string(),
ShapePropertyChange::StrokeColor(_) => "Set stroke color".to_string(),
ShapePropertyChange::StrokeWidth(_) => "Set stroke width".to_string(),
}
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::layer::VectorLayer;
use crate::shape::Shape;
use kurbo::BezPath;
fn create_test_shape() -> Shape {
let mut path = BezPath::new();
path.move_to((0.0, 0.0));
path.line_to((100.0, 0.0));
path.line_to((100.0, 100.0));
path.line_to((0.0, 100.0));
path.close_path();
let mut shape = Shape::new(path);
shape.fill_color = Some(ShapeColor::rgb(255, 0, 0));
shape.stroke_color = Some(ShapeColor::rgb(0, 0, 0));
shape.stroke_style = Some(StrokeStyle {
width: 2.0,
..Default::default()
});
shape
}
#[test]
fn test_set_fill_color() {
let mut document = Document::new("Test");
let mut layer = VectorLayer::new("Test Layer");
let shape = create_test_shape();
let shape_id = shape.id;
layer.shapes.insert(shape_id, shape);
let layer_id = document.root_mut().add_child(AnyLayer::Vector(layer));
// Verify initial color
if let Some(AnyLayer::Vector(vl)) = document.get_layer_mut(&layer_id) {
let shape = vl.shapes.get(&shape_id).unwrap();
assert_eq!(shape.fill_color.unwrap().r, 255);
}
// Create and execute action
let new_color = Some(ShapeColor::rgb(0, 255, 0));
let mut action = SetShapePropertiesAction::set_fill_color(layer_id, shape_id, new_color);
action.execute(&mut document);
// Verify color changed
if let Some(AnyLayer::Vector(vl)) = document.get_layer_mut(&layer_id) {
let shape = vl.shapes.get(&shape_id).unwrap();
assert_eq!(shape.fill_color.unwrap().g, 255);
}
// Rollback
action.rollback(&mut document);
// Verify restored
if let Some(AnyLayer::Vector(vl)) = document.get_layer_mut(&layer_id) {
let shape = vl.shapes.get(&shape_id).unwrap();
assert_eq!(shape.fill_color.unwrap().r, 255);
}
}
#[test]
fn test_set_stroke_width() {
let mut document = Document::new("Test");
let mut layer = VectorLayer::new("Test Layer");
let shape = create_test_shape();
let shape_id = shape.id;
layer.shapes.insert(shape_id, shape);
let layer_id = document.root_mut().add_child(AnyLayer::Vector(layer));
// Verify initial width
if let Some(AnyLayer::Vector(vl)) = document.get_layer_mut(&layer_id) {
let shape = vl.shapes.get(&shape_id).unwrap();
assert_eq!(shape.stroke_style.as_ref().unwrap().width, 2.0);
}
// Create and execute action
let mut action = SetShapePropertiesAction::set_stroke_width(layer_id, shape_id, 5.0);
action.execute(&mut document);
// Verify width changed
if let Some(AnyLayer::Vector(vl)) = document.get_layer_mut(&layer_id) {
let shape = vl.shapes.get(&shape_id).unwrap();
assert_eq!(shape.stroke_style.as_ref().unwrap().width, 5.0);
}
// Rollback
action.rollback(&mut document);
// Verify restored
if let Some(AnyLayer::Vector(vl)) = document.get_layer_mut(&layer_id) {
let shape = vl.shapes.get(&shape_id).unwrap();
assert_eq!(shape.stroke_style.as_ref().unwrap().width, 2.0);
}
}
#[test]
fn test_description() {
let layer_id = Uuid::new_v4();
let shape_id = Uuid::new_v4();
let action1 =
SetShapePropertiesAction::set_fill_color(layer_id, shape_id, Some(ShapeColor::rgb(0, 0, 0)));
assert_eq!(action1.description(), "Set fill color");
let action2 =
SetShapePropertiesAction::set_stroke_color(layer_id, shape_id, Some(ShapeColor::rgb(0, 0, 0)));
assert_eq!(action2.description(), "Set stroke color");
let action3 = SetShapePropertiesAction::set_stroke_width(layer_id, shape_id, 3.0);
assert_eq!(action3.description(), "Set stroke width");
}
}