Refactor internal shape and reduce reliance on Kurbo (#617)

* Dissolve Points from path

* Add handling for removing the first anchor

* Add function to turn handles into bez_paths

* Created overlay manager, wip

* WIP Refactor of VectorShape / Overlays / ShapeEditor

* WIP stripping vector shape, anchor, point.

* WIP Removed kurbo deps from vector shape, anchor, point

* WIP Further work to make vector shapes / anchors / points more standalone.

* WIP more pruning

* WIP Progress on overlay_renderer

* WIP more overlay_renderer work

* WIP more pruning, cleared warnings

* WIP decided ShapeRenderer wasn't an accurate name, ShapeAdapter now. Error squashing continues.

* WIP squashed more errors, now need to decide if anchors should have unique IDs

* WIP Errors squashed, now to actually make it work.

* WIP Moved vector structs to graphene, beginning to remove bezpath from shape_layer

* Refactoring: disentangle kurbo from apply_affine

* Refactor internal shape and remove reliance on Kurbo (PR #617) - Disentangle Kurbo (#619)

* Refactoring: disentangle kurbo from apply_affine

* Broke boolean operations, refactor in state which compiles

* "fixed" boolean operation refactor related errors

* fixed apply_affine, which would not have applied any type of affine

* Small Cleanup, readability

* Fix issue with overlay styles no longer showing selection state.

* Resolved error with point option

* WIP, figuring out how to have one source of truth for VectorShape. Trying to avoid cloning.

* WIP work on single source of truth vectorshapes

* More steps toward single source of truth VectorShape

* Continued wip on making VectorShapes mutably accessible without cloning

* Wip using paths to reference vectorshapes instead, need to restructure ShapeEditor

* Decided to allow temporary copies of vectorshapes.

* Removed HashSet for selected shape indices

* Added @TrueDoctor's id_storage.rs with some heavy modification. Added it to VectorShape. Isn't yet used for folders.

* Integrated UniqueElements<T> with VectorShape to store VectorAnchors

* Improved storage_id.rs perf and cleaned up it's interface

* Iterator Implementations and fixes (#637)

* Refactoring: disentangle kurbo from apply_affine

* Broke boolean operations, refactor in state which compiles

* "fixed" boolean operation refactor related errors

* fixed apply_affine, which would not have applied any type of affine

* implemented transforms for VectorAnchors
implemented Not for VectorControlPointType

* started adding Vector Shape implementations of shape prototypes

* added several useful implemtations to UniqueElements

* added another implemnation for UniqueElements to make working with iterators easier, fixed vector-shape errors

* package-lock.json

* clean up rebase, added back Layer paths

* added deref implementation for VectorShape

* unnecesary variable

* simplify code by removing levels of indirection

* fixed errors

* merge cleanup

* removed package-lock.json

* Removed .selected from VectorShape, it isn't needed as layers are selected not shapes specifically.

* Removed transform and layer_path from VectorShape

* Auto-saving tentitively working. Work toward Overlay transform issues.

* Overlays properly hiding and caching. Not clearing cache yet and some tool switching issues remain, but progress.

* Putting layers in folders changes their unique ID. This is problematic. Assumed this was not the case.

* Removed need for closed bool, changed VectorShape to a tuple struct.

* WIP Switched to layer paths as opposed to VectorShapes. Next up add messages for changing VectorShapes.

* Added initial messages to edit VectorShape points.

* DeleteSelectedPoints messages implemented, selection isn't working currently though.

* Selection messages arriving in document, but transform is wrong.

* Selection, Deselection working, delete working for first point.

* Working towards moving points again

* Removed extra vec from UniqueElements, attempting to squash ordering bug. Still appears to occur though.

* Delete more stable, clean up, renamed to HandleIn, HandleOut

* Further vec_unique cleanup

* Further cleanup

* Removed Deref / DerefMut from VectorShape

* Document version++, will likely revert before merge into master

* Seleting / deleting handles tentitively working again.

* Version number bump, fixed tests.

* Fixed comment in VecUnique

* Improved VecUnique descriptor comment

* Renamed VecUnique to IdBackedVec to further clarify usage.

* Resolved formatting.

* WIP Fixing dragging points

* Fixed an instance where an OverlayMessage could be sent to the main document incorrectly.

* Deleting all of a shapes points now gracefully deletes the layer instead of crashing.

* Fixed handle configurations that would panic on deletion

* Single anchor dragging restored with multi-dragging next plus handles

* sides.into()

* Handle and Multi-point dragging working

* WIP Handle symmetry working again

* Handle mirroring functional again.

* Cleaned up warnings

* Fixed overlay outline not matching shape

* Git branch fix of compatibility with new master

* Fixed closed shape bug, replaced kurbo ellipse

* Removed unused func, updated comments

* Deleting points can undo, multiple shape selection deletes now working

* Removed AddOverlay* operations

* Partial fix for select drift, added helpers

* Don't snap against dragging points

* Properly cleanup path outline with multiple shapes

* Clear all points in other selected shapes

* Actually don't snap against dragging points

* Fix path tool & add snap angle and break handle

* Fix handle being set to NaN causing render issues

* Fix cached overlays not showing line -> curve

* Add operations for modifying paths

* Remove kurbo from pen tool

* Do not snap against handles when anchor selected

* Fix overlays not being cleaned up on path tool

* Fix handle position after dragging

* Use `Anchor` for text & no kurbo in operations

* Replace kurbo to_svg function

* Ngon no longer center scales by default, still some weird behaviour when holding alt

* Cleanup overlays

* Fix render and bounding box doctests

* Fix fun to_svg error

* Fix compile error

* Some code review

* Remove legacy `SelectPoint` on doubleclick

* Remove font from test document

* Fix the pen tool selection changed

* Reorder imports

Co-authored-by: Dennis <dennis@kobert.dev>
Co-authored-by: Caleb Dennis <caleb.dennis429@gmail.com>
Co-authored-by: caleb <56044292+caleb-ad@users.noreply.github.com>
Co-authored-by: Keavon Chambers <keavon@keavon.com>
Co-authored-by: 0hypercube <0hypercube@gmail.com>
Co-authored-by: 0HyperCube <78500760+0HyperCube@users.noreply.github.com>
This commit is contained in:
Oliver Davies
2022-07-05 15:02:18 -07:00
committed by Keavon Chambers
parent 6042b32a86
commit 20cfd5f600
48 changed files with 2461 additions and 1807 deletions

View File

@@ -2,6 +2,9 @@ use crate::boolean_ops::BooleanOperation as BooleanOperationType;
use crate::layers::blend_mode::BlendMode;
use crate::layers::layer_info::Layer;
use crate::layers::style::{self, Stroke};
use crate::layers::vector::constants::ControlPointType;
use crate::layers::vector::vector_anchor::VectorAnchor;
use crate::layers::vector::vector_shape::VectorShape;
use crate::LayerId;
use serde::{Deserialize, Serialize};
@@ -19,33 +22,18 @@ pub enum Operation {
transform: [f64; 6],
style: style::PathStyle,
},
AddOverlayEllipse {
path: Vec<LayerId>,
transform: [f64; 6],
style: style::PathStyle,
},
AddRect {
path: Vec<LayerId>,
insert_index: isize,
transform: [f64; 6],
style: style::PathStyle,
},
AddOverlayRect {
path: Vec<LayerId>,
transform: [f64; 6],
style: style::PathStyle,
},
AddLine {
path: Vec<LayerId>,
insert_index: isize,
transform: [f64; 6],
style: style::PathStyle,
},
AddOverlayLine {
path: Vec<LayerId>,
transform: [f64; 6],
style: style::PathStyle,
},
AddText {
path: Vec<LayerId>,
transform: [f64; 6],
@@ -97,19 +85,12 @@ pub enum Operation {
sides: u32,
style: style::PathStyle,
},
AddOverlayShape {
path: Vec<LayerId>,
bez_path: kurbo::BezPath,
style: style::PathStyle,
closed: bool,
},
AddShape {
path: Vec<LayerId>,
transform: [f64; 6],
insert_index: isize,
bez_path: kurbo::BezPath,
vector_path: VectorShape,
style: style::PathStyle,
closed: bool,
},
BooleanOperation {
operation: BooleanOperationType,
@@ -118,6 +99,16 @@ pub enum Operation {
DeleteLayer {
path: Vec<LayerId>,
},
DeleteSelectedVectorPoints {
layer_paths: Vec<Vec<LayerId>>,
},
DeselectVectorPoints {
layer_path: Vec<LayerId>,
point_ids: Vec<(u64, ControlPointType)>,
},
DeselectAllVectorPoints {
layer_path: Vec<LayerId>,
},
DuplicateLayer {
path: Vec<LayerId>,
},
@@ -127,6 +118,11 @@ pub enum Operation {
font_style: String,
size: f64,
},
MoveSelectedVectorPoints {
layer_path: Vec<LayerId>,
delta: (f64, f64),
absolute_position: (f64, f64),
},
RenameLayer {
layer_path: Vec<LayerId>,
new_name: String,
@@ -151,14 +147,38 @@ pub enum Operation {
path: Vec<LayerId>,
transform: [f64; 6],
},
SelectVectorPoints {
layer_path: Vec<LayerId>,
point_ids: Vec<(u64, ControlPointType)>,
add: bool,
},
SetShapePath {
path: Vec<LayerId>,
bez_path: kurbo::BezPath,
vector_path: VectorShape,
},
SetShapePathInViewport {
path: Vec<LayerId>,
bez_path: kurbo::BezPath,
transform: [f64; 6],
InsertVectorAnchor {
layer_path: Vec<LayerId>,
anchor: VectorAnchor,
after_id: u64,
},
PushVectorAnchor {
layer_path: Vec<LayerId>,
anchor: VectorAnchor,
},
RemoveVectorAnchor {
layer_path: Vec<LayerId>,
id: u64,
},
MoveVectorPoint {
layer_path: Vec<LayerId>,
id: u64,
control_type: ControlPointType,
position: (f64, f64),
},
RemoveVectorPoint {
layer_path: Vec<LayerId>,
id: u64,
control_type: ControlPointType,
},
TransformLayerInScope {
path: Vec<LayerId>,
@@ -205,6 +225,11 @@ pub enum Operation {
path: Vec<LayerId>,
stroke: Stroke,
},
SetSelectedHandleMirroring {
layer_path: Vec<LayerId>,
toggle_distance: bool,
toggle_angle: bool,
},
}
impl Operation {