Rename the legacy Graphene crate to document-legacy (#899)

* Rename /graphene to /document-legacy

* Update names in code
This commit is contained in:
Keavon Chambers 2022-12-22 02:12:05 -08:00
parent 5b3c015f71
commit 49b9b8cfec
95 changed files with 492 additions and 491 deletions

64
Cargo.lock generated
View file

@ -1515,37 +1515,7 @@ dependencies = [
]
[[package]]
name = "graphite-editor"
version = "0.0.0"
dependencies = [
"bezier-rs",
"bitflags",
"borrow_stack",
"derivative",
"dyn-any",
"env_logger",
"glam",
"graph-craft",
"graphene-core",
"graphene-std",
"graphite-graphene",
"graphite-proc-macros",
"image",
"interpreted-executor",
"kurbo",
"log",
"once_cell",
"rand_chacha 0.3.1",
"remain",
"serde",
"serde_json",
"spin",
"test-case",
"thiserror",
]
[[package]]
name = "graphite-graphene"
name = "graphite-document-legacy"
version = "0.0.0"
dependencies = [
"base64",
@ -1561,6 +1531,36 @@ dependencies = [
"ttf-parser",
]
[[package]]
name = "graphite-editor"
version = "0.0.0"
dependencies = [
"bezier-rs",
"bitflags",
"borrow_stack",
"derivative",
"dyn-any",
"env_logger",
"glam",
"graph-craft",
"graphene-core",
"graphene-std",
"graphite-document-legacy",
"graphite-proc-macros",
"image",
"interpreted-executor",
"kurbo",
"log",
"once_cell",
"rand_chacha 0.3.1",
"remain",
"serde",
"serde_json",
"spin",
"test-case",
"thiserror",
]
[[package]]
name = "graphite-proc-macros"
version = "0.0.0"
@ -1577,8 +1577,8 @@ name = "graphite-wasm"
version = "0.0.0"
dependencies = [
"graph-craft",
"graphite-document-legacy",
"graphite-editor",
"graphite-graphene",
"js-sys",
"log",
"ron",

View file

@ -1,7 +1,7 @@
[workspace]
members = [
"editor",
"graphene",
"document-legacy",
"proc-macros",
"frontend/wasm",
"frontend/src-tauri",

View file

@ -8,49 +8,49 @@ TODO
TODO: Add more to make a comprehensive list, finish writing definitions, separate into categories, alphabetize
- ## Document
A design source file created and edited in the Graphite editor. Saved to disk as a Graphite Design Document in a *GDD file*. Documents can be included as *layers* inside other documents, and in doing so they take the form of *groups*. The *layer graph* contents of a *group* actually belong to the *embedded* document's *subgraph*. Because a document is a *group* which is a *layer* in the *layer graph*, documents have *properties* such as the *frames* in the *canvas*. Documents are composed of a layer graph, a defined set of properties of set *data types* that are *imported* and *exported*, and the *properties* of the *root layer*.
- ## Asset
A portable mechanism for distributing a "compiled" Graphite *document* in a format that is immediately ready for rendering. Saved to disk as a Graphite Digital Asset in a *GDA file*. Assets are created by "flattening" a *document's* complex, nested *layer graph* structure into a single, simple directed acyclic graph (DAG). The Graphite editor internally maintains an asset version of any open *document* in order to draw the *canvas* live in the *viewport*. An asset also includes certain exposed *properties* of specified *data types* that are *imported* and *exported*, as defined by the asset's author in the source *document's* *layer graph*. They can be shared and *embedded* in another *layer graph* as a black box (meaning it can't be expanded to reveal or edit its interior graph), as compared to *embedded* *documents* from *GDD files* which are white boxes (they can be expanded to reveal their *subgraph* which can be edited). Assets are helpful for defining custom *nodes* that perform some useful functionality. Tangible examples include custom procedural effects, shape generators, and image filters. Many of the Graphite editor's own built-in *nodes* are actually assets rather than being implemented directly in code. The *Asset Manager* panel helps maintain these assets from various sources. The *Asset Store* can be used to share and sell assets for easy inclusion in other projects.
- ## GDD file
Graphite Design Document. A binary serialization of a *document* source file. The format includes a chain of *operations* that describe changes to the *layer graph* and the *properties* of *layers* throughout the history of the document since its creation. It also stores certain metadata and the raw data of *embedded* files. Because GDD files are editable (unlike *GDA files*), the *layers* of GDD files imported into another *document* may be expanded in its *layer graph* to reveal and modify their contents using a copy-on-write scheme stored to the *asset's* *layer*.
- ## GDA file
Graphite Digital Asset. A binary serialization of an *asset* file. Because GDA files are read-only and can't be edited (unlike *GDD files*), the *layers* created from *assets* do not offer an ability to be expanded in the *layer graph* of a *document* that *embeds* them. GDA files are useful for sharing *assets* when their authors do not wish to provide the source *documents* to author them. *DGA files* are also the input format included in games that utilize the *Graphite Renderer Core Library* to render graphical content at runtime, as well as similar applications like headless renderers on web servers and image processing pipelines.
- ## Document
A design source file created and edited in the Graphite editor. Saved to disk as a Graphite Design Document in a _GDD file_. Documents can be included as _layers_ inside other documents, and in doing so they take the form of _groups_. The _layer graph_ contents of a _group_ actually belong to the _embedded_ document's _subgraph_. Because a document is a _group_ which is a _layer_ in the _layer graph_, documents have _properties_ such as the _frames_ in the _canvas_. Documents are composed of a layer graph, a defined set of properties of set _data types_ that are _imported_ and _exported_, and the _properties_ of the _root layer_.
- ## Asset
A portable mechanism for distributing a "compiled" Graphite _document_ in a format that is immediately ready for rendering. Saved to disk as a Graphite Digital Asset in a _GDA file_. Assets are created by "flattening" a _document's_ complex, nested _layer graph_ structure into a single, simple directed acyclic graph (DAG). The Graphite editor internally maintains an asset version of any open _document_ in order to draw the _canvas_ live in the _viewport_. An asset also includes certain exposed _properties_ of specified _data types_ that are _imported_ and _exported_, as defined by the asset's author in the source _document's_ _layer graph_. They can be shared and _embedded_ in another _layer graph_ as a black box (meaning it can't be expanded to reveal or edit its interior graph), as compared to _embedded_ _documents_ from _GDD files_ which are white boxes (they can be expanded to reveal their _subgraph_ which can be edited). Assets are helpful for defining custom _nodes_ that perform some useful functionality. Tangible examples include custom procedural effects, shape generators, and image filters. Many of the Graphite editor's own built-in _nodes_ are actually assets rather than being implemented directly in code. The _Asset Manager_ panel helps maintain these assets from various sources. The _Asset Store_ can be used to share and sell assets for easy inclusion in other projects.
- ## GDD file
Graphite Design Document. A binary serialization of a _document_ source file. The format includes a chain of _operations_ that describe changes to the _layer graph_ and the _properties_ of _layers_ throughout the history of the document since its creation. It also stores certain metadata and the raw data of _embedded_ files. Because GDD files are editable (unlike _GDA files_), the _layers_ of GDD files imported into another _document_ may be expanded in its _layer graph_ to reveal and modify their contents using a copy-on-write scheme stored to the _asset's_ _layer_.
- ## GDA file
Graphite Digital Asset. A binary serialization of an _asset_ file. Because GDA files are read-only and can't be edited (unlike _GDD files_), the _layers_ created from _assets_ do not offer an ability to be expanded in the _layer graph_ of a _document_ that _embeds_ them. GDA files are useful for sharing _assets_ when their authors do not wish to provide the source _documents_ to author them. _DGA files_ are also the input format included in games that utilize the _Graphite Renderer Core Library_ to render graphical content at runtime, as well as similar applications like headless renderers on web servers and image processing pipelines.
- ## Window
- ## Main window
- ## Popout window
- ## Title bar
- ## Status bar
- ## Workspace
The part of the Graphite editor's UI that houses the *panels* in a *window*. The workspace occupies the large space below the *title bar* and above the *status bar* of the *main window*. It occupies the entirety of *popout windows* (window buttons are added in the *tab bar*).
- ## Workspace layout
The specific configuration of panels in the *main window* and any *popout windows*. Workspace layout presets are provided by the Graphite editor and users may customize and save their own.
- ## Tab bar
The bar at the top of a *panel group* which includes a clickable tab for each panel that is docked there. Each tab bar has at least one tab and one active tab.
- ## Active tab
The one tab in a *tab bar* that is currently active. The user can click any inactive tab to make it become the active tab. The active tab shows the *panel content* beneath it unless it is a *folded panel*.
- ## Folded panel
A shrunken *panel* showing only the *tab bar*. A *panel* consists of the *tab bar* and *panel body* except when the latter is folded away. The user may click the *active tab* to fold and restore a panel, however a panel cannot be folded if there are no other unfolded panels in its column.
- ## Workspace
The part of the Graphite editor's UI that houses the _panels_ in a _window_. The workspace occupies the large space below the _title bar_ and above the _status bar_ of the _main window_. It occupies the entirety of _popout windows_ (window buttons are added in the _tab bar_).
- ## Workspace layout
The specific configuration of panels in the _main window_ and any _popout windows_. Workspace layout presets are provided by the Graphite editor and users may customize and save their own.
- ## Tab bar
The bar at the top of a _panel group_ which includes a clickable tab for each panel that is docked there. Each tab bar has at least one tab and one active tab.
- ## Active tab
The one tab in a _tab bar_ that is currently active. The user can click any inactive tab to make it become the active tab. The active tab shows the _panel content_ beneath it unless it is a _folded panel_.
- ## Folded panel
A shrunken _panel_ showing only the _tab bar_. A _panel_ consists of the _tab bar_ and _panel body_ except when the latter is folded away. The user may click the _active tab_ to fold and restore a panel, however a panel cannot be folded if there are no other unfolded panels in its column.
- ## Panel
- ## Panel body
- ## Options bar
The bar that spans horizontally across the top of a *panel* (located under the *tab bar*) which displays options related to the *panel*.
- ## Viewport
The area that takes up the main space in a *panel* (located beneath the *options bar*) which displays the primary content of the *panel*.
- ## Shelf
The bar that spans vertically along the left side of some *panels* (located left of the *viewport*) which displays a catalog of available items, such as document editing *tools* or common *nodes*.
- ## Tool
An instrument for interactively editing *documents* through a collection of related behavior. Each tool puts the editor into a mode that provides the ability to perform certain *operations* on the document interactively. Each *operation* is run based on the current context of mouse and modifier buttons, key presses, tool options, selected layers, editor state, and document state. The *operations* that get run are appended to the document history and update the underlying *layer graph* in real time.
- ## Canvas
The infinite coordinate system that shows the visual output of an open *document* at the current zoom level and pan position. It is drawn in the document panel's *viewport* within the area inside the scroll bars on the bottom/right edges and the *rulers* on the top/left edges. The canvas can be panned and zoomed in order to display all or part of the artwork in any *frames*. A canvas has a coordinate system spanning infinitely in all directions with an origin always located at the top left of the primary *artboard*. The purpose of an infinite canvas is to offer a convenient editing experience when there is no logical edge to the artwork, for example a loosely-arranged board of logo design concepts, a mood board, or whiteboard-style notes.
- ## Artboard
An area inside a *canvas* that provides rectangular bounds to the artwork contained within, as well as default bounds for an exported image. The *Artboard tool* adjusts the bounds and placement of frames in the *document* and each artboard is stored in a "artboard list" property of the *root layer*. When there is at least one artboard, the infinite *canvas* area outside any artboard displays a configurable background color. Artwork can be placed outside of a artboard but it will appear mostly transparent. The purpose of using one artboard is to provide convenient cropping to the edges of the artwork, such as a single digital painting or photograph. The purpose of using multiple frames is to work on related artwork with separate bounds, such as the layout for a book.
- ## Layer graph
A (directed acyclic) graph structure composed of *layers* with *connections* between their input and output *ports*. This is commonly referred to as a "node graph" in other software, but Graphite's layer graph is more suited towards layer-based compositing compared to traditional compositor node graphs.
- ## Node
A definition of a *layer*. A node is a graph "operation" or "function" that receives input and generates deterministic output.
- ## Layer
Any instance of a *node* that lives in the *layer graph*. Layers (usually) take input data, then they transform it or synthesize new data, then they provide it as output. Layers have *properties* as well as exposed input and output *ports* for sending and receiving data.
- ## Options bar
The bar that spans horizontally across the top of a _panel_ (located under the _tab bar_) which displays options related to the _panel_.
- ## Viewport
The area that takes up the main space in a _panel_ (located beneath the _options bar_) which displays the primary content of the _panel_.
- ## Shelf
The bar that spans vertically along the left side of some _panels_ (located left of the _viewport_) which displays a catalog of available items, such as document editing _tools_ or common _nodes_.
- ## Tool
An instrument for interactively editing _documents_ through a collection of related behavior. Each tool puts the editor into a mode that provides the ability to perform certain _operations_ on the document interactively. Each _operation_ is run based on the current context of mouse and modifier buttons, key presses, tool options, selected layers, editor state, and document state. The _operations_ that get run are appended to the document history and update the underlying _layer graph_ in real time.
- ## Canvas
The infinite coordinate system that shows the visual output of an open _document_ at the current zoom level and pan position. It is drawn in the document panel's _viewport_ within the area inside the scroll bars on the bottom/right edges and the _rulers_ on the top/left edges. The canvas can be panned and zoomed in order to display all or part of the artwork in any _frames_. A canvas has a coordinate system spanning infinitely in all directions with an origin always located at the top left of the primary _artboard_. The purpose of an infinite canvas is to offer a convenient editing experience when there is no logical edge to the artwork, for example a loosely-arranged board of logo design concepts, a mood board, or whiteboard-style notes.
- ## Artboard
An area inside a _canvas_ that provides rectangular bounds to the artwork contained within, as well as default bounds for an exported image. The _Artboard tool_ adjusts the bounds and placement of frames in the _document_ and each artboard is stored in a "artboard list" property of the _root layer_. When there is at least one artboard, the infinite _canvas_ area outside any artboard displays a configurable background color. Artwork can be placed outside of a artboard but it will appear mostly transparent. The purpose of using one artboard is to provide convenient cropping to the edges of the artwork, such as a single digital painting or photograph. The purpose of using multiple frames is to work on related artwork with separate bounds, such as the layout for a book.
- ## Layer graph
A (directed acyclic) graph structure composed of _layers_ with _connections_ between their input and output _ports_. This is commonly referred to as a "node graph" in other software, but Graphite's layer graph is more suited towards layer-based compositing compared to traditional compositor node graphs.
- ## Node
A definition of a _layer_. A node is a graph "operation" or "function" that receives input and generates deterministic output.
- ## Layer
Any instance of a _node_ that lives in the _layer graph_. Layers (usually) take input data, then they transform it or synthesize new data, then they provide it as output. Layers have _properties_ as well as exposed input and output _ports_ for sending and receiving data.
- ## Root layer
- ## Group
- ## Raster
@ -63,7 +63,7 @@ TODO: Add more to make a comprehensive list, finish writing definitions, separat
- ## Core Libraries
- ## Graphite Editor (Frontend)
- ## Graphite Editor (Backend)
- ## Graphene (Document Graph Engine)
- ## Graphene (Node Graph Engine)
- ## Trace
- ## Path
- ## Shape

View file

@ -1,5 +1,5 @@
[package]
name = "graphite-graphene"
name = "graphite-document-legacy"
publish = false
version = "0.0.0"
rust-version = "1.65.0"

View file

@ -31,7 +31,7 @@ impl Color {
///
/// # Examples
/// ```
/// use graphite_graphene::color::Color;
/// use graphite_document_legacy::color::Color;
/// let color = Color::from_rgbaf32(0.3, 0.14, 0.15, 0.92).unwrap();
/// assert!(color.components() == (0.3, 0.14, 0.15, 0.92));
///
@ -54,7 +54,7 @@ impl Color {
///
/// # Examples
/// ```
/// use graphite_graphene::color::Color;
/// use graphite_document_legacy::color::Color;
/// let color = Color::from_rgb8(0x72, 0x67, 0x62);
/// let color2 = Color::from_rgba8(0x72, 0x67, 0x62, 0xFF);
/// assert!(color == color2)
@ -67,7 +67,7 @@ impl Color {
///
/// # Examples
/// ```
/// use graphite_graphene::color::Color;
/// use graphite_document_legacy::color::Color;
/// let color = Color::from_rgba8(0x72, 0x67, 0x62, 0x61);
/// assert!("72676261" == color.rgba_hex())
/// ```
@ -85,7 +85,7 @@ impl Color {
///
/// # Examples
/// ```
/// use graphite_graphene::color::Color;
/// use graphite_document_legacy::color::Color;
/// let color = Color::from_rgbaf32(0.114, 0.103, 0.98, 0.97).unwrap();
/// assert!(color.r() == 0.114);
/// ```
@ -97,7 +97,7 @@ impl Color {
///
/// # Examples
/// ```
/// use graphite_graphene::color::Color;
/// use graphite_document_legacy::color::Color;
/// let color = Color::from_rgbaf32(0.114, 0.103, 0.98, 0.97).unwrap();
/// assert!(color.g() == 0.103);
/// ```
@ -109,7 +109,7 @@ impl Color {
///
/// # Examples
/// ```
/// use graphite_graphene::color::Color;
/// use graphite_document_legacy::color::Color;
/// let color = Color::from_rgbaf32(0.114, 0.103, 0.98, 0.97).unwrap();
/// assert!(color.b() == 0.98);
/// ```
@ -121,7 +121,7 @@ impl Color {
///
/// # Examples
/// ```
/// use graphite_graphene::color::Color;
/// use graphite_document_legacy::color::Color;
/// let color = Color::from_rgbaf32(0.114, 0.103, 0.98, 0.97).unwrap();
/// assert!(color.a() == 0.97);
/// ```
@ -133,7 +133,7 @@ impl Color {
///
/// # Examples
/// ```
/// use graphite_graphene::color::Color;
/// use graphite_document_legacy::color::Color;
/// let color = Color::from_rgbaf32(0.114, 0.103, 0.98, 0.97).unwrap();
/// assert!(color.components() == (0.114, 0.103, 0.98, 0.97));
/// ```
@ -145,7 +145,7 @@ impl Color {
///
/// # Examples
/// ```
/// use graphite_graphene::color::Color;
/// use graphite_document_legacy::color::Color;
/// let color = Color::from_rgba8(0x7C, 0x67, 0xFA, 0x61);
/// assert!("7C67FA61" == color.rgba_hex())
/// ```
@ -161,7 +161,7 @@ impl Color {
/// Return a 6-character RGB hex string (without a # prefix).
/// ```
/// use graphite_graphene::color::Color;
/// use graphite_document_legacy::color::Color;
/// let color = Color::from_rgba8(0x7C, 0x67, 0xFA, 0x61);
/// assert!("7C67FA" == color.rgb_hex())
/// ```
@ -173,7 +173,7 @@ impl Color {
///
/// # Examples
/// ```
/// use graphite_graphene::color::Color;
/// use graphite_document_legacy::color::Color;
/// let color = Color::from_rgba_str("7C67FA61").unwrap();
/// assert!("7C67FA61" == color.rgba_hex())
/// ```
@ -191,7 +191,7 @@ impl Color {
/// Creates a color from a 6-character RGB hex string (without a # prefix).
/// ```
/// use graphite_graphene::color::Color;
/// use graphite_document_legacy::color::Color;
/// let color = Color::from_rgb_str("7C67FA").unwrap();
/// assert!("7C67FA" == color.rgb_hex())
/// ```

View file

@ -60,7 +60,7 @@ impl Document {
// Split the path into the layer ID and its parent folder
let (layer_id_to_render_below, parent_folder_path) = below_layer_path.split_last()?;
// Note: it is bad practice to directly clone and modify the Graphene document structure, this is a temporary hack until this whole system is replaced by the node graph
// Note: it is bad practice to directly clone and modify the document structure, this is a temporary hack until this whole system is replaced by the node graph
let mut temp_subset_folder = self.layer_mut(parent_folder_path).ok()?.clone();
if let LayerDataType::Folder(ref mut folder) = temp_subset_folder.data {
// Remove the upper layers to leave behind the lower subset for rendering
@ -84,7 +84,7 @@ impl Document {
/// Renders a layer and its children
pub fn render_layer(&mut self, layer_path: &[LayerId], render_data: RenderData) -> Option<String> {
// Note: it is bad practice to directly clone and modify the Graphene document structure, this is a temporary hack until this whole system is replaced by the node graph
// Note: it is bad practice to directly clone and modify the document structure, this is a temporary hack until this whole system is replaced by the node graph
let mut temp_clone = self.layer_mut(layer_path).ok()?.clone();
// Render and append to the defs section

View file

@ -1,7 +1,7 @@
use super::LayerId;
use crate::boolean_ops::BooleanOperationError;
/// A set of different errors that can occur when using Graphene.
/// A set of different errors that can occur when using this crate.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum DocumentError {
LayerNotFound(Vec<LayerId>),

View file

@ -52,10 +52,10 @@ impl FolderLayer {
///
/// # Example
/// ```
/// # use graphite_graphene::layers::shape_layer::ShapeLayer;
/// # use graphite_graphene::layers::folder_layer::FolderLayer;
/// # use graphite_graphene::layers::style::PathStyle;
/// # use graphite_graphene::layers::layer_info::LayerDataType;
/// # use graphite_document_legacy::layers::shape_layer::ShapeLayer;
/// # use graphite_document_legacy::layers::folder_layer::FolderLayer;
/// # use graphite_document_legacy::layers::style::PathStyle;
/// # use graphite_document_legacy::layers::layer_info::LayerDataType;
/// let mut folder = FolderLayer::default();
///
/// // Create two layers to be added to the folder
@ -100,7 +100,7 @@ impl FolderLayer {
///
/// # Example
/// ```
/// # use graphite_graphene::layers::folder_layer::FolderLayer;
/// # use graphite_document_legacy::layers::folder_layer::FolderLayer;
/// let mut folder = FolderLayer::default();
///
/// // Try to remove a layer that does not exist
@ -149,7 +149,7 @@ impl FolderLayer {
///
/// # Example
/// ```
/// # use graphite_graphene::layers::folder_layer::FolderLayer;
/// # use graphite_document_legacy::layers::folder_layer::FolderLayer;
/// let mut folder = FolderLayer::default();
///
/// // Search for an id that does not exist
@ -170,7 +170,7 @@ impl FolderLayer {
///
/// # Example
/// ```
/// # use graphite_graphene::layers::folder_layer::FolderLayer;
/// # use graphite_document_legacy::layers::folder_layer::FolderLayer;
/// let mut folder = FolderLayer::default();
///
/// // Search for an id that does not exist
@ -193,9 +193,9 @@ impl FolderLayer {
///
/// # Example
/// ```
/// # use graphite_graphene::layers::folder_layer::FolderLayer;
/// # use graphite_graphene::layers::shape_layer::ShapeLayer;
/// # use graphite_graphene::layers::style::PathStyle;
/// # use graphite_document_legacy::layers::folder_layer::FolderLayer;
/// # use graphite_document_legacy::layers::shape_layer::ShapeLayer;
/// # use graphite_document_legacy::layers::style::PathStyle;
/// let mut folder = FolderLayer::default();
///
/// // Search for an id that does not exist

View file

@ -123,9 +123,9 @@ pub trait LayerData {
///
/// # Example
/// ```
/// # use graphite_graphene::layers::shape_layer::ShapeLayer;
/// # use graphite_graphene::layers::style::{Fill, PathStyle, ViewMode, RenderData};
/// # use graphite_graphene::layers::layer_info::LayerData;
/// # use graphite_document_legacy::layers::shape_layer::ShapeLayer;
/// # use graphite_document_legacy::layers::style::{Fill, PathStyle, ViewMode, RenderData};
/// # use graphite_document_legacy::layers::layer_info::LayerData;
/// # use std::collections::HashMap;
///
/// let mut shape = ShapeLayer::rectangle(PathStyle::new(None, Fill::None));
@ -148,10 +148,10 @@ pub trait LayerData {
/// Determine the layers within this layer that intersect a given quad.
/// # Example
/// ```
/// # use graphite_graphene::layers::shape_layer::ShapeLayer;
/// # use graphite_graphene::layers::style::{Fill, PathStyle, ViewMode};
/// # use graphite_graphene::layers::layer_info::LayerData;
/// # use graphite_graphene::intersection::Quad;
/// # use graphite_document_legacy::layers::shape_layer::ShapeLayer;
/// # use graphite_document_legacy::layers::style::{Fill, PathStyle, ViewMode};
/// # use graphite_document_legacy::layers::layer_info::LayerData;
/// # use graphite_document_legacy::intersection::Quad;
/// # use glam::f64::{DAffine2, DVec2};
/// # use std::collections::HashMap;
///
@ -172,9 +172,9 @@ pub trait LayerData {
/// Calculate the bounding box for the layer's contents after applying a given transform.
/// # Example
/// ```no_run
/// # use graphite_graphene::layers::shape_layer::ShapeLayer;
/// # use graphite_graphene::layers::style::{Fill, PathStyle};
/// # use graphite_graphene::layers::layer_info::LayerData;
/// # use graphite_document_legacy::layers::shape_layer::ShapeLayer;
/// # use graphite_document_legacy::layers::style::{Fill, PathStyle};
/// # use graphite_document_legacy::layers::layer_info::LayerData;
/// # use glam::f64::{DAffine2, DVec2};
/// # use std::collections::HashMap;
/// let shape = ShapeLayer::ellipse(PathStyle::new(None, Fill::None));
@ -271,10 +271,10 @@ impl Layer {
///
/// # Example
/// ```
/// # use graphite_graphene::layers::shape_layer::ShapeLayer;
/// # use graphite_graphene::layers::layer_info::Layer;
/// # use graphite_graphene::layers::style::PathStyle;
/// # use graphite_graphene::layers::folder_layer::FolderLayer;
/// # use graphite_document_legacy::layers::shape_layer::ShapeLayer;
/// # use graphite_document_legacy::layers::layer_info::Layer;
/// # use graphite_document_legacy::layers::style::PathStyle;
/// # use graphite_document_legacy::layers::folder_layer::FolderLayer;
/// let mut root_folder = FolderLayer::default();
///
/// // Add a shape to the root folder
@ -361,9 +361,9 @@ impl Layer {
///
/// # Example
/// ```
/// # use graphite_graphene::layers::shape_layer::ShapeLayer;
/// # use graphite_graphene::layers::layer_info::Layer;
/// # use graphite_graphene::layers::style::PathStyle;
/// # use graphite_document_legacy::layers::shape_layer::ShapeLayer;
/// # use graphite_document_legacy::layers::layer_info::Layer;
/// # use graphite_document_legacy::layers::style::PathStyle;
/// # use glam::DVec2;
/// # use glam::f64::DAffine2;
/// # use std::collections::HashMap;

View file

@ -1,12 +1,12 @@
//! # Layers
//! A document consists of a set of [Layers](layer_info::Layer).
//! Layers allow the user to mutate part of the document while leaving the rest unchanged.
//! Graphene currently includes these different types of layers:
//! There are currently these different types of 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
//! * [Text layers](text_layer::TextLayer), which contain a description of laid out text
//! * [Image layers](image_layer::ImageLayer), which contain a bitmap image
//! * [Imaginate layers](imaginate_layer::ImaginateLayer), which contain a bitmap image generated based on a prompt and optionally the layers beneath it
//! * [Nodegraph layers](nodegraph_layer::NodegraphLayer), which contain a node graph frame
//!
//! Refer to the module-level documentation for detailed information on each layer.
//!

View file

@ -376,8 +376,8 @@ impl PathStyle {
///
/// # Example
/// ```
/// # use graphite_graphene::layers::style::{Fill, PathStyle};
/// # use graphite_graphene::color::Color;
/// # use graphite_document_legacy::layers::style::{Fill, PathStyle};
/// # use graphite_document_legacy::color::Color;
/// let fill = Fill::solid(Color::RED);
/// let style = PathStyle::new(None, fill.clone());
///
@ -391,8 +391,8 @@ impl PathStyle {
///
/// # Example
/// ```
/// # use graphite_graphene::layers::style::{Fill, Stroke, PathStyle};
/// # use graphite_graphene::color::Color;
/// # use graphite_document_legacy::layers::style::{Fill, Stroke, PathStyle};
/// # use graphite_document_legacy::color::Color;
/// let stroke = Stroke::new(Color::GREEN, 42.);
/// let style = PathStyle::new(Some(stroke.clone()), Fill::None);
///
@ -406,8 +406,8 @@ impl PathStyle {
///
/// # Example
/// ```
/// # use graphite_graphene::layers::style::{Fill, PathStyle};
/// # use graphite_graphene::color::Color;
/// # use graphite_document_legacy::layers::style::{Fill, PathStyle};
/// # use graphite_document_legacy::color::Color;
/// let mut style = PathStyle::default();
///
/// assert_eq!(*style.fill(), Fill::None);
@ -425,8 +425,8 @@ impl PathStyle {
///
/// # Example
/// ```
/// # use graphite_graphene::layers::style::{Stroke, PathStyle};
/// # use graphite_graphene::color::Color;
/// # use graphite_document_legacy::layers::style::{Stroke, PathStyle};
/// # use graphite_document_legacy::color::Color;
/// let mut style = PathStyle::default();
///
/// assert_eq!(style.stroke(), None);
@ -444,8 +444,8 @@ impl PathStyle {
///
/// # Example
/// ```
/// # use graphite_graphene::layers::style::{Fill, PathStyle};
/// # use graphite_graphene::color::Color;
/// # use graphite_document_legacy::layers::style::{Fill, PathStyle};
/// # use graphite_document_legacy::color::Color;
/// let mut style = PathStyle::new(None, Fill::Solid(Color::RED));
///
/// assert!(style.fill().is_some());
@ -462,8 +462,8 @@ impl PathStyle {
///
/// # Example
/// ```
/// # use graphite_graphene::layers::style::{Fill, Stroke, PathStyle};
/// # use graphite_graphene::color::Color;
/// # use graphite_document_legacy::layers::style::{Fill, Stroke, PathStyle};
/// # use graphite_document_legacy::color::Color;
/// let mut style = PathStyle::new(Some(Stroke::new(Color::GREEN, 42.)), Fill::None);
///
/// assert!(style.stroke().is_some());

View file

@ -5,10 +5,10 @@ extern crate log;
pub mod boolean_ops;
/// Contains the [Color](color::Color) type.
pub mod color;
/// Contains constant values used by Graphene.
/// Contains constant values used by this crate.
pub mod consts;
pub mod document;
/// Defines errors that can occur when using Graphene.
/// Defines errors that can occur when using this crate.
pub mod error;
/// Utilities for computing intersections.
pub mod intersection;

View file

@ -40,9 +40,9 @@ dyn-any = { path = "../libraries/dyn-any" }
graphene-core = { path = "../node-graph/gcore" }
graphene-std = { path = "../node-graph/gstd" }
[dependencies.graphene]
path = "../graphene"
package = "graphite-graphene"
[dependencies.document-legacy]
path = "../document-legacy"
package = "graphite-document-legacy"
[dev-dependencies]
env_logger = "0.8.4"

File diff suppressed because one or more lines are too long

View file

@ -1,4 +1,4 @@
use graphene::color::Color;
use document_legacy::color::Color;
// Viewport
pub const VIEWPORT_ZOOM_WHEEL_RATE: f64 = (1. / 600.) * 3.;
@ -74,7 +74,7 @@ pub const DEFAULT_FONT_FAMILY: &str = "Merriweather";
pub const DEFAULT_FONT_STYLE: &str = "Normal (400)";
// Document
pub const GRAPHITE_DOCUMENT_VERSION: &str = "0.0.15"; // Remember to save a simple document and replace the test file `graphite-test-document.graphite`
pub const GRAPHITE_DOCUMENT_VERSION: &str = "0.0.16"; // Remember to save a simple document and replace the test file `graphite-test-document.graphite`
pub const DEFAULT_DOCUMENT_NAME: &str = "Untitled Document";
pub const FILE_SAVE_SUFFIX: &str = ".graphite";
pub const MAX_UNDO_HISTORY_LEN: usize = 100; // TODO: Add this to user preferences

View file

@ -2,7 +2,7 @@ use crate::consts::{DEFAULT_FONT_FAMILY, DEFAULT_FONT_STYLE};
use crate::messages::debug::utility_types::MessageLoggingVerbosity;
use crate::messages::prelude::*;
use graphene::layers::text_layer::Font;
use document_legacy::layers::text_layer::Font;
#[derive(Debug, Default)]
pub struct Dispatcher {
@ -256,9 +256,9 @@ mod test {
use crate::messages::prelude::*;
use crate::test_utils::EditorTestUtils;
use graphene::color::Color;
use graphene::LayerId;
use graphene::Operation;
use document_legacy::color::Color;
use document_legacy::LayerId;
use document_legacy::Operation;
fn init_logger() {
let _ = env_logger::builder().is_test(true).try_init();
@ -294,14 +294,14 @@ mod test {
fn copy_paste_single_layer() {
let mut editor = create_editor_with_three_layers();
let document_before_copy = editor.dispatcher.message_handlers.portfolio_message_handler.active_document().unwrap().graphene_document.clone();
let document_before_copy = editor.dispatcher.message_handlers.portfolio_message_handler.active_document().unwrap().document_legacy.clone();
editor.handle_message(PortfolioMessage::Copy { clipboard: Clipboard::Internal });
editor.handle_message(PortfolioMessage::PasteIntoFolder {
clipboard: Clipboard::Internal,
folder_path: vec![],
insert_index: -1,
});
let document_after_copy = editor.dispatcher.message_handlers.portfolio_message_handler.active_document().unwrap().graphene_document.clone();
let document_after_copy = editor.dispatcher.message_handlers.portfolio_message_handler.active_document().unwrap().document_legacy.clone();
let layers_before_copy = document_before_copy.root.as_folder().unwrap().layers();
let layers_after_copy = document_after_copy.root.as_folder().unwrap().layers();
@ -327,7 +327,7 @@ mod test {
fn copy_paste_single_layer_from_middle() {
let mut editor = create_editor_with_three_layers();
let document_before_copy = editor.dispatcher.message_handlers.portfolio_message_handler.active_document().unwrap().graphene_document.clone();
let document_before_copy = editor.dispatcher.message_handlers.portfolio_message_handler.active_document().unwrap().document_legacy.clone();
let shape_id = document_before_copy.root.as_folder().unwrap().layer_ids[1];
editor.handle_message(DocumentMessage::SetSelectedLayers {
@ -340,7 +340,7 @@ mod test {
insert_index: -1,
});
let document_after_copy = editor.dispatcher.message_handlers.portfolio_message_handler.active_document().unwrap().graphene_document.clone();
let document_after_copy = editor.dispatcher.message_handlers.portfolio_message_handler.active_document().unwrap().document_legacy.clone();
let layers_before_copy = document_before_copy.root.as_folder().unwrap().layers();
let layers_after_copy = document_after_copy.root.as_folder().unwrap().layers();
@ -371,7 +371,7 @@ mod test {
editor.handle_message(DocumentMessage::CreateEmptyFolder { container_path: vec![] });
let document_before_added_shapes = editor.dispatcher.message_handlers.portfolio_message_handler.active_document().unwrap().graphene_document.clone();
let document_before_added_shapes = editor.dispatcher.message_handlers.portfolio_message_handler.active_document().unwrap().document_legacy.clone();
let folder_id = document_before_added_shapes.root.as_folder().unwrap().layer_ids[FOLDER_INDEX];
// TODO: This adding of a Line and Pen should be rewritten using the corresponding functions in EditorTestUtils.
@ -395,7 +395,7 @@ mod test {
replacement_selected_layers: vec![vec![folder_id]],
});
let document_before_copy = editor.dispatcher.message_handlers.portfolio_message_handler.active_document().unwrap().graphene_document.clone();
let document_before_copy = editor.dispatcher.message_handlers.portfolio_message_handler.active_document().unwrap().document_legacy.clone();
editor.handle_message(PortfolioMessage::Copy { clipboard: Clipboard::Internal });
editor.handle_message(DocumentMessage::DeleteSelectedLayers);
@ -410,7 +410,7 @@ mod test {
insert_index: -1,
});
let document_after_copy = editor.dispatcher.message_handlers.portfolio_message_handler.active_document().unwrap().graphene_document.clone();
let document_after_copy = editor.dispatcher.message_handlers.portfolio_message_handler.active_document().unwrap().document_legacy.clone();
let layers_before_copy = document_before_copy.root.as_folder().unwrap().layers();
let layers_after_copy = document_after_copy.root.as_folder().unwrap().layers();
@ -460,7 +460,7 @@ mod test {
const SHAPE_INDEX: usize = 1;
const RECT_INDEX: usize = 0;
let document_before_copy = editor.dispatcher.message_handlers.portfolio_message_handler.active_document().unwrap().graphene_document.clone();
let document_before_copy = editor.dispatcher.message_handlers.portfolio_message_handler.active_document().unwrap().document_legacy.clone();
let rect_id = document_before_copy.root.as_folder().unwrap().layer_ids[RECT_INDEX];
let ellipse_id = document_before_copy.root.as_folder().unwrap().layer_ids[ELLIPSE_INDEX];
@ -481,7 +481,7 @@ mod test {
insert_index: -1,
});
let document_after_copy = editor.dispatcher.message_handlers.portfolio_message_handler.active_document().unwrap().graphene_document.clone();
let document_after_copy = editor.dispatcher.message_handlers.portfolio_message_handler.active_document().unwrap().document_legacy.clone();
let layers_before_copy = document_before_copy.root.as_folder().unwrap().layers();
let layers_after_copy = document_after_copy.root.as_folder().unwrap().layers();

View file

@ -65,7 +65,7 @@ impl MessageHandler<DialogMessage, (&PortfolioMessageHandler, &PreferencesMessag
.artboard_ids
.iter()
.rev()
.filter_map(|&artboard| artboard_handler.artboards_graphene_document.layer(&[artboard]).ok().map(|layer| (artboard, layer)))
.filter_map(|&artboard| artboard_handler.artboards_document.layer(&[artboard]).ok().map(|layer| (artboard, layer)))
.map(|(artboard, layer)| {
(
artboard,

View file

@ -6,7 +6,7 @@ use crate::messages::layout::utility_types::widgets::input_widgets::{DropdownEnt
use crate::messages::layout::utility_types::widgets::label_widgets::{Separator, SeparatorDirection, SeparatorType, TextLabel};
use crate::messages::prelude::*;
use graphene::LayerId;
use document_legacy::LayerId;
/// A dialog to allow users to customize their file export.
#[derive(Debug, Clone, Default)]

View file

@ -7,11 +7,11 @@ use crate::messages::portfolio::document::utility_types::layer_panel::{JsRawBuff
use crate::messages::prelude::*;
use crate::messages::tool::utility_types::HintData;
use document_legacy::color::Color;
use document_legacy::layers::text_layer::Font;
use document_legacy::LayerId;
use graph_craft::document::NodeId;
use graph_craft::imaginate_input::*;
use graphene::color::Color;
use graphene::layers::text_layer::Font;
use graphene::LayerId;
use serde::{Deserialize, Serialize};

View file

@ -1,4 +1,4 @@
use graphene::LayerId;
use document_legacy::LayerId;
use serde::{Deserialize, Serialize};
#[derive(PartialEq, Eq, Clone, Debug, Serialize, Deserialize)]

View file

@ -1,7 +1,7 @@
use crate::messages::portfolio::utility_types::KeyboardPlatformLayout;
use crate::messages::prelude::*;
pub use graphene::DocumentResponse;
pub use document_legacy::DocumentResponse;
use bitflags::bitflags;
use serde::{Deserialize, Serialize};

View file

@ -2,7 +2,7 @@ use crate::messages::input_mapper::utility_types::input_keyboard::{Key, Modifier
use crate::messages::input_mapper::utility_types::input_mouse::{EditorMouseState, ViewportBounds};
use crate::messages::prelude::*;
pub use graphene::DocumentResponse;
pub use document_legacy::DocumentResponse;
use serde::{Deserialize, Serialize};

View file

@ -3,7 +3,8 @@ use crate::messages::input_mapper::utility_types::input_mouse::{MouseKeys, Mouse
use crate::messages::portfolio::utility_types::KeyboardPlatformLayout;
use crate::messages::prelude::*;
pub use graphene::DocumentResponse;
pub use document_legacy::DocumentResponse;
pub use document_legacy::Operation;
use glam::DVec2;
@ -34,7 +35,7 @@ impl MessageHandler<InputPreprocessorMessage, KeyboardPlatformLayout> for InputP
self.viewport_bounds = bounds;
responses.push_back(
graphene::Operation::TransformLayer {
Operation::TransformLayer {
path: vec![],
transform: glam::DAffine2::from_translation(translation).to_cols_array(),
}
@ -42,7 +43,7 @@ impl MessageHandler<InputPreprocessorMessage, KeyboardPlatformLayout> for InputP
);
responses.push_back(
DocumentMessage::Artboard(
graphene::Operation::TransformLayer {
Operation::TransformLayer {
path: vec![],
transform: glam::DAffine2::from_translation(translation).to_cols_array(),
}

View file

@ -4,9 +4,9 @@ use crate::messages::layout::utility_types::layout_widget::Layout;
use crate::messages::layout::utility_types::layout_widget::Widget;
use crate::messages::prelude::*;
use graphene::color::Color;
use graphene::layers::text_layer::Font;
use graphene::LayerId;
use document_legacy::color::Color;
use document_legacy::layers::text_layer::Font;
use document_legacy::LayerId;
use serde_json::Value;
use std::ops::Not;

View file

@ -1,7 +1,7 @@
use crate::messages::input_mapper::utility_types::misc::ActionKeys;
use crate::messages::layout::utility_types::layout_widget::WidgetCallback;
use graphene::{color::Color, layers::layer_info::LayerDataTypeDiscriminant, LayerId};
use document_legacy::{color::Color, layers::layer_info::LayerDataTypeDiscriminant, LayerId};
use derivative::*;
use serde::{Deserialize, Serialize};

View file

@ -1,7 +1,7 @@
use crate::messages::prelude::*;
use graphene::LayerId;
use graphene::Operation as DocumentOperation;
use document_legacy::LayerId;
use document_legacy::Operation as DocumentOperation;
use serde::{Deserialize, Serialize};

View file

@ -1,20 +1,20 @@
use crate::application::generate_uuid;
use crate::messages::prelude::*;
use graphene::color::Color;
use graphene::document::Document as GrapheneDocument;
use graphene::layers::style::{self, Fill, RenderData, ViewMode};
use graphene::layers::text_layer::FontCache;
use graphene::DocumentResponse;
use graphene::LayerId;
use graphene::Operation as DocumentOperation;
use document_legacy::color::Color;
use document_legacy::document::Document as DocumentLegacy;
use document_legacy::layers::style::{self, Fill, RenderData, ViewMode};
use document_legacy::layers::text_layer::FontCache;
use document_legacy::DocumentResponse;
use document_legacy::LayerId;
use document_legacy::Operation as DocumentOperation;
use glam::DAffine2;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ArtboardMessageHandler {
pub artboards_graphene_document: GrapheneDocument,
pub artboards_document: DocumentLegacy,
pub artboard_ids: Vec<LayerId>,
}
@ -27,7 +27,7 @@ impl MessageHandler<ArtboardMessage, &FontCache> for ArtboardMessageHandler {
match message {
// Sub-messages
#[remain::unsorted]
DispatchOperation(operation) => match self.artboards_graphene_document.handle_operation(*operation, font_cache) {
DispatchOperation(operation) => match self.artboards_document.handle_operation(*operation, font_cache) {
Ok(Some(document_responses)) => {
for response in document_responses {
match &response {
@ -88,7 +88,7 @@ impl MessageHandler<ArtboardMessage, &FontCache> for ArtboardMessageHandler {
let render_data = RenderData::new(ViewMode::Normal, font_cache, None);
responses.push_back(
FrontendMessage::UpdateDocumentArtboards {
svg: self.artboards_graphene_document.render_root(render_data),
svg: self.artboards_document.render_root(render_data),
}
.into(),
);

View file

@ -3,12 +3,12 @@ use crate::messages::portfolio::document::utility_types::layer_panel::LayerMetad
use crate::messages::portfolio::document::utility_types::misc::{AlignAggregate, AlignAxis, FlipAxis};
use crate::messages::prelude::*;
use document_legacy::boolean_ops::BooleanOperation as BooleanOperationType;
use document_legacy::layers::blend_mode::BlendMode;
use document_legacy::layers::style::ViewMode;
use document_legacy::LayerId;
use document_legacy::Operation as DocumentOperation;
use graph_craft::document::NodeId;
use graphene::boolean_ops::BooleanOperation as BooleanOperationType;
use graphene::layers::blend_mode::BlendMode;
use graphene::layers::style::ViewMode;
use graphene::LayerId;
use graphene::Operation as DocumentOperation;
use serde::{Deserialize, Serialize};
#[remain::sorted]

View file

@ -21,15 +21,15 @@ use crate::messages::portfolio::document::utility_types::vectorize_layer_metadat
use crate::messages::portfolio::utility_types::PersistentData;
use crate::messages::prelude::*;
use document_legacy::color::Color;
use document_legacy::document::Document as DocumentLegacy;
use document_legacy::layers::blend_mode::BlendMode;
use document_legacy::layers::folder_layer::FolderLayer;
use document_legacy::layers::layer_info::{LayerDataType, LayerDataTypeDiscriminant};
use document_legacy::layers::style::{Fill, RenderData, ViewMode};
use document_legacy::layers::text_layer::{Font, FontCache};
use document_legacy::{DocumentError, DocumentResponse, LayerId, Operation as DocumentOperation};
use graph_craft::document::NodeId;
use graphene::color::Color;
use graphene::document::Document as GrapheneDocument;
use graphene::layers::blend_mode::BlendMode;
use graphene::layers::folder_layer::FolderLayer;
use graphene::layers::layer_info::{LayerDataType, LayerDataTypeDiscriminant};
use graphene::layers::style::{Fill, RenderData, ViewMode};
use graphene::layers::text_layer::{Font, FontCache};
use graphene::{DocumentError, DocumentResponse, LayerId, Operation as DocumentOperation};
use graphene_std::vector::subpath::Subpath;
use glam::{DAffine2, DVec2};
@ -37,7 +37,7 @@ use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct DocumentMessageHandler {
pub graphene_document: GrapheneDocument,
pub document_legacy: DocumentLegacy,
pub saved_document_identifier: u64,
pub auto_saved_document_identifier: u64,
pub name: String,
@ -71,7 +71,7 @@ pub struct DocumentMessageHandler {
impl Default for DocumentMessageHandler {
fn default() -> Self {
Self {
graphene_document: GrapheneDocument::default(),
document_legacy: DocumentLegacy::default(),
saved_document_identifier: 0,
auto_saved_document_identifier: 0,
name: String::from("Untitled Document"),
@ -112,7 +112,7 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
match message {
// Sub-messages
#[remain::unsorted]
DispatchOperation(op) => match self.graphene_document.handle_operation(*op, &persistent_data.font_cache) {
DispatchOperation(op) => match self.document_legacy.handle_operation(*op, &persistent_data.font_cache) {
Ok(Some(document_responses)) => {
for response in document_responses {
match &response {
@ -150,7 +150,7 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
}
#[remain::unsorted]
Navigation(message) => {
self.navigation_handler.process_message(message, (&self.graphene_document, ipp), responses);
self.navigation_handler.process_message(message, (&self.document_legacy, ipp), responses);
}
#[remain::unsorted]
Overlays(message) => {
@ -160,13 +160,13 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
#[remain::unsorted]
TransformLayer(message) => {
self.transform_layer_handler
.process_message(message, (&mut self.layer_metadata, &mut self.graphene_document, ipp, &persistent_data.font_cache), responses);
.process_message(message, (&mut self.layer_metadata, &mut self.document_legacy, ipp, &persistent_data.font_cache), responses);
}
#[remain::unsorted]
PropertiesPanel(message) => {
let properties_panel_message_handler_data = PropertiesPanelMessageHandlerData {
artwork_document: &self.graphene_document,
artboard_document: &self.artboard_message_handler.artboards_graphene_document,
artwork_document: &self.document_legacy,
artboard_document: &self.artboard_message_handler.artboards_document,
selected_layers: &mut self.layer_metadata.iter().filter_map(|(path, data)| data.selected.then_some(path.as_slice())),
node_graph_message_handler: &self.node_graph_handler,
};
@ -175,7 +175,7 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
}
#[remain::unsorted]
NodeGraph(message) => {
self.node_graph_handler.process_message(message, (&mut self.graphene_document, ipp), responses);
self.node_graph_handler.process_message(message, (&mut self.document_legacy, ipp), responses);
}
// Messages
@ -198,7 +198,7 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
self.backup(responses);
let (paths, boxes): (Vec<_>, Vec<_>) = self
.selected_layers()
.filter_map(|path| self.graphene_document.viewport_bounding_box(path, &persistent_data.font_cache).ok()?.map(|b| (path, b)))
.filter_map(|path| self.document_legacy.viewport_bounding_box(path, &persistent_data.font_cache).ok()?.map(|b| (path, b)))
.unzip();
let axis = match axis {
@ -206,7 +206,7 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
AlignAxis::Y => DVec2::Y,
};
let lerp = |bbox: &[DVec2; 2]| bbox[0].lerp(bbox[1], 0.5);
if let Some(combined_box) = self.graphene_document.combined_viewport_bounding_box(self.selected_layers(), &persistent_data.font_cache) {
if let Some(combined_box) = self.document_legacy.combined_viewport_bounding_box(self.selected_layers(), &persistent_data.font_cache) {
let aggregated = match aggregate {
AlignAggregate::Min => combined_box[0],
AlignAggregate::Max => combined_box[1],
@ -261,7 +261,7 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
let initial_level = log::max_level();
log::set_max_level(log::LevelFilter::Trace);
trace!("{:#?}\n{:#?}", self.graphene_document, self.layer_metadata);
trace!("{:#?}\n{:#?}", self.document_legacy, self.layer_metadata);
log::set_max_level(initial_level);
}
@ -301,7 +301,7 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
}
DirtyRenderDocument => {
// Mark all non-overlay caches as dirty
GrapheneDocument::mark_children_as_dirty(&mut self.graphene_document.root);
DocumentLegacy::mark_children_as_dirty(&mut self.document_legacy.root);
responses.push_back(DocumentMessage::RenderDocument.into());
}
DirtyRenderDocumentInOutlineView => {
@ -335,7 +335,7 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
ExportBounds::Selection => self.selected_visible_layers_bounding_box(&persistent_data.font_cache),
ExportBounds::Artboard(id) => self
.artboard_message_handler
.artboards_graphene_document
.artboards_document
.layer(&[id])
.ok()
.and_then(|layer| layer.aabb(&persistent_data.font_cache)),
@ -367,7 +367,7 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
FlipAxis::X => DVec2::new(-1., 1.),
FlipAxis::Y => DVec2::new(1., -1.),
};
if let Some([min, max]) = self.graphene_document.combined_viewport_bounding_box(self.selected_layers(), &persistent_data.font_cache) {
if let Some([min, max]) = self.document_legacy.combined_viewport_bounding_box(self.selected_layers(), &persistent_data.font_cache) {
let center = (max + min) / 2.;
let bbox_trans = DAffine2::from_translation(-center);
for path in self.selected_layers() {
@ -397,7 +397,7 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
}
let layer_path = layer_path.unwrap();
let layer = self.graphene_document.layer(layer_path).expect("Clearing NodeGraphFrame image for invalid layer");
let layer = self.document_legacy.layer(layer_path).expect("Clearing NodeGraphFrame image for invalid layer");
let previous_blob_url = match &layer.data {
LayerDataType::NodeGraphFrame(node_graph_frame) => &node_graph_frame.blob_url,
x => panic!("Cannot find blob url for layer type {}", LayerDataTypeDiscriminant::from(x)),
@ -409,7 +409,7 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
responses.push_back(DocumentOperation::ClearBlobURL { path: layer_path.into() }.into());
}
GroupSelectedLayers => {
let mut new_folder_path = self.graphene_document.shallowest_common_folder(self.selected_layers()).unwrap_or(&[]).to_vec();
let mut new_folder_path = self.document_legacy.shallowest_common_folder(self.selected_layers()).unwrap_or(&[]).to_vec();
// Required for grouping parent folders with their own children
if !new_folder_path.is_empty() && self.selected_layers_contains(&new_folder_path) {
@ -470,7 +470,7 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
);
}
MoveSelectedManipulatorPoints { layer_path, delta } => {
if let Ok(_layer) = self.graphene_document.layer(&layer_path) {
if let Ok(_layer) = self.document_legacy.layer(&layer_path) {
responses.push_back(DocumentOperation::MoveSelectedManipulatorPoints { layer_path, delta }.into());
}
}
@ -562,7 +562,7 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
let render_data = RenderData::new(self.view_mode, &persistent_data.font_cache, Some(ipp.document_bounds()));
responses.push_back(
FrontendMessage::UpdateDocumentArtwork {
svg: self.graphene_document.render_root(render_data),
svg: self.document_legacy.render_root(render_data),
}
.into(),
);
@ -584,7 +584,7 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
let ruler_interval = if log < 0. { 100. * 2_f64.powf(-log.ceil()) } else { 100. / 2_f64.powf(log.ceil()) };
let ruler_spacing = ruler_interval * document_transform_scale;
let ruler_origin = self.graphene_document.root.transform.transform_point2(DVec2::ZERO);
let ruler_origin = self.document_legacy.root.transform.transform_point2(DVec2::ZERO);
responses.push_back(
FrontendMessage::UpdateDocumentScrollbars {
@ -654,7 +654,7 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
// Fill the selection range
self.layer_metadata
.iter()
.filter(|(target, _)| self.graphene_document.layer_is_between(target, &layer_path, &self.layer_range_selection_reference))
.filter(|(target, _)| self.document_legacy.layer_is_between(target, &layer_path, &self.layer_range_selection_reference))
.for_each(|(layer_path, _)| {
paths.push(layer_path.clone());
});
@ -700,7 +700,7 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
resolution,
document_id,
} => {
let layer = self.graphene_document.layer(&layer_path).expect("Setting blob URL for invalid layer");
let layer = self.document_legacy.layer(&layer_path).expect("Setting blob URL for invalid layer");
// Revoke the old blob URL
match &layer.data {
@ -764,7 +764,7 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
self.snapping_enabled = snap;
}
SetTextboxEditability { path, editable } => {
let text = self.graphene_document.layer(&path).unwrap().as_text().unwrap();
let text = self.document_legacy.layer(&path).unwrap().as_text().unwrap();
responses.push_back(DocumentOperation::SetTextEditability { path, editable }.into());
if editable {
let color = if let Fill::Solid(solid_color) = text.path_style.fill() { *solid_color } else { Color::BLACK };
@ -818,7 +818,7 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
}
UngroupLayers { folder_path } => {
// Select all the children of the folder
let select = self.graphene_document.folder_children_paths(&folder_path);
let select = self.document_legacy.folder_children_paths(&folder_path);
let message_buffer = [
// Select them
@ -843,7 +843,7 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
}
UngroupSelectedLayers => {
responses.push_back(DocumentMessage::StartTransaction.into());
let folder_paths = self.graphene_document.sorted_folders_by_depth(self.selected_layers());
let folder_paths = self.document_legacy.sorted_folders_by_depth(self.selected_layers());
for folder_path in folder_paths {
responses.push_back(DocumentMessage::UngroupLayers { folder_path: folder_path.to_vec() }.into());
}
@ -929,7 +929,7 @@ impl DocumentMessageHandler {
// Calculate the size of the region to be exported
let old_transforms = self.remove_document_transform();
let transform = self.graphene_document.multiply_transforms(&layer_path).unwrap();
let transform = self.document_legacy.multiply_transforms(&layer_path).unwrap();
let size = DVec2::new(transform.transform_vector2(DVec2::new(1., 0.)).length(), transform.transform_vector2(DVec2::new(0., 1.)).length());
let svg = self.render_document(size, transform.inverse(), persistent_data, DocumentRenderMode::OnlyBelowLayerInFolder(&layer_path));
@ -949,24 +949,24 @@ impl DocumentMessageHandler {
/// Remove the artwork and artboard pan/tilt/zoom to render it without the user's viewport navigation, and save it to be restored at the end
pub(crate) fn remove_document_transform(&mut self) -> [DAffine2; 2] {
let old_artwork_transform = self.graphene_document.root.transform;
self.graphene_document.root.transform = DAffine2::IDENTITY;
GrapheneDocument::mark_children_as_dirty(&mut self.graphene_document.root);
let old_artwork_transform = self.document_legacy.root.transform;
self.document_legacy.root.transform = DAffine2::IDENTITY;
DocumentLegacy::mark_children_as_dirty(&mut self.document_legacy.root);
let old_artboard_transform = self.artboard_message_handler.artboards_graphene_document.root.transform;
self.artboard_message_handler.artboards_graphene_document.root.transform = DAffine2::IDENTITY;
GrapheneDocument::mark_children_as_dirty(&mut self.artboard_message_handler.artboards_graphene_document.root);
let old_artboard_transform = self.artboard_message_handler.artboards_document.root.transform;
self.artboard_message_handler.artboards_document.root.transform = DAffine2::IDENTITY;
DocumentLegacy::mark_children_as_dirty(&mut self.artboard_message_handler.artboards_document.root);
[old_artwork_transform, old_artboard_transform]
}
/// Transform the artwork and artboard back to their original scales
pub(crate) fn restore_document_transform(&mut self, [old_artwork_transform, old_artboard_transform]: [DAffine2; 2]) {
self.graphene_document.root.transform = old_artwork_transform;
GrapheneDocument::mark_children_as_dirty(&mut self.graphene_document.root);
self.document_legacy.root.transform = old_artwork_transform;
DocumentLegacy::mark_children_as_dirty(&mut self.document_legacy.root);
self.artboard_message_handler.artboards_graphene_document.root.transform = old_artboard_transform;
GrapheneDocument::mark_children_as_dirty(&mut self.artboard_message_handler.artboards_graphene_document.root);
self.artboard_message_handler.artboards_document.root.transform = old_artboard_transform;
DocumentLegacy::mark_children_as_dirty(&mut self.artboard_message_handler.artboards_document.root);
}
pub fn render_document(&mut self, size: DVec2, transform: DAffine2, persistent_data: &PersistentData, render_mode: DocumentRenderMode) -> String {
@ -975,11 +975,11 @@ impl DocumentMessageHandler {
let render_data = RenderData::new(ViewMode::Normal, &persistent_data.font_cache, None);
let (artwork, outside) = match render_mode {
DocumentRenderMode::Root => (self.graphene_document.render_root(render_data), None),
DocumentRenderMode::OnlyBelowLayerInFolder(below_layer_path) => (self.graphene_document.render_layers_below(below_layer_path, render_data).unwrap(), None),
DocumentRenderMode::LayerCutout(layer_path, background) => (self.graphene_document.render_layer(layer_path, render_data).unwrap(), Some(background)),
DocumentRenderMode::Root => (self.document_legacy.render_root(render_data), None),
DocumentRenderMode::OnlyBelowLayerInFolder(below_layer_path) => (self.document_legacy.render_layers_below(below_layer_path, render_data).unwrap(), None),
DocumentRenderMode::LayerCutout(layer_path, background) => (self.document_legacy.render_layer(layer_path, render_data).unwrap(), Some(background)),
};
let artboards = self.artboard_message_handler.artboards_graphene_document.render_root(render_data);
let artboards = self.artboard_message_handler.artboards_document.render_root(render_data);
let outside_artboards_color = outside.map_or_else(
|| if self.artboard_message_handler.artboard_ids.is_empty() { "ffffff" } else { "222222" }.to_string(),
|col| col.rgba_hex(),
@ -1021,8 +1021,8 @@ impl DocumentMessageHandler {
pub fn with_name(name: String, ipp: &InputPreprocessorMessageHandler) -> Self {
let mut document = Self { name, ..Self::default() };
let starting_root_transform = document.navigation_handler.calculate_offset_transform(ipp.viewport_bounds.size() / 2.);
document.graphene_document.root.transform = starting_root_transform;
document.artboard_message_handler.artboards_graphene_document.root.transform = starting_root_transform;
document.document_legacy.root.transform = starting_root_transform;
document.artboard_message_handler.artboards_document.root.transform = starting_root_transform;
document
}
@ -1059,11 +1059,11 @@ impl DocumentMessageHandler {
pub fn selected_visible_layers_bounding_box(&self, font_cache: &FontCache) -> Option<[DVec2; 2]> {
let paths = self.selected_visible_layers();
self.graphene_document.combined_viewport_bounding_box(paths, font_cache)
self.document_legacy.combined_viewport_bounding_box(paths, font_cache)
}
pub fn artboard_bounding_box_and_transform(&self, path: &[LayerId], font_cache: &FontCache) -> Option<([DVec2; 2], DAffine2)> {
self.artboard_message_handler.artboards_graphene_document.bounding_box_and_transform(path, font_cache).unwrap_or(None)
self.artboard_message_handler.artboards_document.bounding_box_and_transform(path, font_cache).unwrap_or(None)
}
pub fn selected_layers(&self) -> impl Iterator<Item = &[LayerId]> {
@ -1072,7 +1072,7 @@ impl DocumentMessageHandler {
pub fn selected_layers_with_type(&self, discriminant: LayerDataTypeDiscriminant) -> impl Iterator<Item = &[LayerId]> {
self.selected_layers().filter(move |path| {
self.graphene_document
self.document_legacy
.layer(path)
.map(|layer| LayerDataTypeDiscriminant::from(&layer.data) == discriminant)
.unwrap_or(false)
@ -1084,7 +1084,7 @@ impl DocumentMessageHandler {
}
pub fn selected_layers_without_children(&self) -> Vec<&[LayerId]> {
let unique_layers = GrapheneDocument::shallowest_unique_layers(self.selected_layers());
let unique_layers = DocumentLegacy::shallowest_unique_layers(self.selected_layers());
// We need to maintain layer ordering
self.sort_layers(unique_layers.iter().copied())
@ -1095,14 +1095,14 @@ impl DocumentMessageHandler {
}
pub fn selected_visible_layers(&self) -> impl Iterator<Item = &[LayerId]> {
self.selected_layers().filter(|path| match self.graphene_document.layer(path) {
self.selected_layers().filter(|path| match self.document_legacy.layer(path) {
Ok(layer) => layer.visible,
Err(_) => false,
})
}
pub fn selected_visible_text_layers(&self) -> impl Iterator<Item = &[LayerId]> {
self.selected_layers().filter(|path| match self.graphene_document.layer(path) {
self.selected_layers().filter(|path| match self.document_legacy.layer(path) {
Ok(layer) => {
let discriminant: LayerDataTypeDiscriminant = (&layer.data).into();
layer.visible && discriminant == LayerDataTypeDiscriminant::Text
@ -1112,7 +1112,7 @@ impl DocumentMessageHandler {
}
pub fn visible_layers(&self) -> impl Iterator<Item = &[LayerId]> {
self.all_layers().filter(|path| match self.graphene_document.layer(path) {
self.all_layers().filter(|path| match self.document_legacy.layer(path) {
Ok(layer) => layer.visible,
Err(_) => false,
})
@ -1121,7 +1121,7 @@ impl DocumentMessageHandler {
/// Returns a copy of all the currently selected [Subpath]s.
pub fn selected_subpaths(&self) -> Vec<Subpath> {
self.selected_visible_layers()
.flat_map(|layer| self.graphene_document.layer(layer))
.flat_map(|layer| self.document_legacy.layer(layer))
.flat_map(|layer| layer.as_subpath_copy())
.collect::<Vec<Subpath>>()
}
@ -1129,7 +1129,7 @@ impl DocumentMessageHandler {
/// Returns references to all the currently selected [Subpath]s.
pub fn selected_subpaths_ref(&self) -> Vec<&Subpath> {
self.selected_visible_layers()
.flat_map(|layer| self.graphene_document.layer(layer))
.flat_map(|layer| self.document_legacy.layer(layer))
.flat_map(|layer| layer.as_subpath())
.collect::<Vec<&Subpath>>()
}
@ -1138,13 +1138,13 @@ impl DocumentMessageHandler {
pub fn bounding_boxes<'a>(&'a self, ignore_document: Option<&'a Vec<Vec<LayerId>>>, ignore_artboard: Option<LayerId>, font_cache: &'a FontCache) -> impl Iterator<Item = [DVec2; 2]> + 'a {
self.visible_layers()
.filter(move |path| ignore_document.map_or(true, |ignore_document| !ignore_document.iter().any(|ig| ig.as_slice() == *path)))
.filter_map(|path| self.graphene_document.viewport_bounding_box(path, font_cache).ok()?)
.filter_map(|path| self.document_legacy.viewport_bounding_box(path, font_cache).ok()?)
.chain(
self.artboard_message_handler
.artboard_ids
.iter()
.filter(move |&&id| Some(id) != ignore_artboard)
.filter_map(|&path| self.artboard_message_handler.artboards_graphene_document.viewport_bounding_box(&[path], font_cache).ok()?),
.filter_map(|&path| self.artboard_message_handler.artboards_document.viewport_bounding_box(&[path], font_cache).ok()?),
)
}
@ -1200,7 +1200,7 @@ impl DocumentMessageHandler {
/// ```
pub fn serialize_root(&self) -> Vec<u64> {
let (mut structure, mut data) = (vec![0], Vec::new());
self.serialize_structure(self.graphene_document.root.as_folder().unwrap(), &mut structure, &mut data, &mut vec![]);
self.serialize_structure(self.document_legacy.root.as_folder().unwrap(), &mut structure, &mut data, &mut vec![]);
structure[0] = structure.len() as u64 - 1;
structure.extend(data);
@ -1220,7 +1220,7 @@ impl DocumentMessageHandler {
.filter_map(|path| (!path.is_empty()).then_some(path))
.filter_map(|path| {
// TODO: `indices_for_path` can return an error. We currently skip these layers and log a warning. Once this problem is solved this code can be simplified.
match self.graphene_document.indices_for_path(path) {
match self.document_legacy.indices_for_path(path) {
Err(err) => {
warn!("layers_sorted: Could not get indices for the layer {:?}: {:?}", path, err);
None
@ -1266,7 +1266,7 @@ impl DocumentMessageHandler {
pub fn backup(&mut self, responses: &mut VecDeque<Message>) {
self.document_redo_history.clear();
self.document_undo_history.push_back((self.graphene_document.clone(), self.layer_metadata.clone()));
self.document_undo_history.push_back((self.document_legacy.clone(), self.layer_metadata.clone()));
if self.document_undo_history.len() > crate::consts::MAX_UNDO_HISTORY_LEN {
self.document_undo_history.pop_front();
}
@ -1298,10 +1298,10 @@ impl DocumentMessageHandler {
}
// Keeping the root is required if the bounds of the viewport have changed during the operation
let old_root = self.graphene_document.root.transform;
let document = std::mem::replace(&mut self.graphene_document, document);
self.graphene_document.root.transform = old_root;
self.graphene_document.root.cache_dirty = true;
let old_root = self.document_legacy.root.transform;
let document = std::mem::replace(&mut self.document_legacy, document);
self.document_legacy.root.transform = old_root;
self.document_legacy.root.cache_dirty = true;
let layer_metadata = std::mem::replace(&mut self.layer_metadata, layer_metadata);
self.document_redo_history.push_back((document, layer_metadata));
@ -1336,10 +1336,10 @@ impl DocumentMessageHandler {
}
// Keeping the root is required if the bounds of the viewport have changed during the operation
let old_root = self.graphene_document.root.transform;
let document = std::mem::replace(&mut self.graphene_document, document);
self.graphene_document.root.transform = old_root;
self.graphene_document.root.cache_dirty = true;
let old_root = self.document_legacy.root.transform;
let document = std::mem::replace(&mut self.document_legacy, document);
self.document_legacy.root.transform = old_root;
self.document_legacy.root.cache_dirty = true;
let layer_metadata = std::mem::replace(&mut self.layer_metadata, layer_metadata);
self.document_undo_history.push_back((document, layer_metadata));
@ -1363,7 +1363,7 @@ impl DocumentMessageHandler {
self.document_undo_history
.iter()
.last()
.map(|(graphene_document, _)| graphene_document.current_state_identifier())
.map(|(document_legacy, _)| document_legacy.current_state_identifier())
.unwrap_or(0)
}
@ -1397,15 +1397,15 @@ impl DocumentMessageHandler {
.layer_metadata
.get_mut(&path)
.ok_or_else(|| EditorError::Document(format!("Could not get layer metadata for {:?}", path)))?;
let layer = self.graphene_document.layer(&path)?;
let entry = LayerPanelEntry::new(&data, self.graphene_document.multiply_transforms(&path)?, layer, path, font_cache);
let layer = self.document_legacy.layer(&path)?;
let entry = LayerPanelEntry::new(&data, self.document_legacy.multiply_transforms(&path)?, layer, path, font_cache);
Ok(entry)
}
/// Returns a list of `LayerPanelEntry`s intended for display purposes. These don't contain
/// any actual data, but rather attributes such as visibility and names of the layers.
pub fn layer_panel(&mut self, path: &[LayerId], font_cache: &FontCache) -> Result<Vec<LayerPanelEntry>, EditorError> {
let folder = self.graphene_document.folder(path)?;
let folder = self.document_legacy.folder(path)?;
let paths: Vec<Vec<LayerId>> = folder.layer_ids.iter().map(|id| [path, &[*id]].concat()).collect();
let entries = paths.iter().rev().filter_map(|path| self.layer_panel_entry_from_path(path, font_cache)).collect();
Ok(entries)
@ -1413,11 +1413,8 @@ impl DocumentMessageHandler {
pub fn layer_panel_entry_from_path(&self, path: &[LayerId], font_cache: &FontCache) -> Option<LayerPanelEntry> {
let layer_metadata = self.layer_metadata(path);
let transform = self
.graphene_document
.generate_transform_across_scope(path, Some(self.graphene_document.root.transform.inverse()))
.ok()?;
let layer = self.graphene_document.layer(path).ok()?;
let transform = self.document_legacy.generate_transform_across_scope(path, Some(self.document_legacy.root.transform.inverse())).ok()?;
let layer = self.document_legacy.layer(path).ok()?;
Some(LayerPanelEntry::new(layer_metadata, transform, layer, path.to_vec(), font_cache))
}
@ -1426,7 +1423,7 @@ impl DocumentMessageHandler {
///
/// This function updates the insert index so that it points to the same place after the specified `layers` are deleted.
fn update_insert_index<'a>(&self, layers: &[&'a [LayerId]], path: &[LayerId], insert_index: isize, reverse_index: bool) -> Result<isize, DocumentError> {
let folder = self.graphene_document.folder(path)?;
let folder = self.document_legacy.folder(path)?;
let insert_index = if reverse_index { folder.layer_ids.len() as isize - insert_index } else { insert_index };
let layer_ids_above = if insert_index < 0 { &folder.layer_ids } else { &folder.layer_ids[..(insert_index as usize)] };
@ -1435,7 +1432,7 @@ impl DocumentMessageHandler {
/// Calculates the bounding box of all layers in the document
pub fn all_layer_bounds(&self, font_cache: &FontCache) -> Option<[DVec2; 2]> {
self.graphene_document.viewport_bounding_box(&[], font_cache).ok().flatten()
self.document_legacy.viewport_bounding_box(&[], font_cache).ok().flatten()
}
/// Calculates the document bounds used for scrolling and centring (the layer bounds or the artboard (if applicable))
@ -1443,7 +1440,7 @@ impl DocumentMessageHandler {
if self.artboard_message_handler.is_infinite_canvas() {
self.all_layer_bounds(font_cache)
} else {
self.artboard_message_handler.artboards_graphene_document.viewport_bounding_box(&[], font_cache).ok().flatten()
self.artboard_message_handler.artboards_document.viewport_bounding_box(&[], font_cache).ok().flatten()
}
}
@ -1452,7 +1449,7 @@ impl DocumentMessageHandler {
pub fn get_path_for_new_layer(&self) -> Vec<u64> {
// If the selected layers don't actually exist, a new uuid for the
// root folder will be returned
let mut path = self.graphene_document.shallowest_common_folder(self.selected_layers()).map_or(vec![], |v| v.to_vec());
let mut path = self.document_legacy.shallowest_common_folder(self.selected_layers()).map_or(vec![], |v| v.to_vec());
path.push(generate_uuid());
path
}
@ -1727,7 +1724,7 @@ impl DocumentMessageHandler {
.keys()
.filter_map(|path| self.layer_panel_entry_from_path(path, font_cache))
.filter(|layer_panel_entry| layer_panel_entry.layer_metadata.selected)
.flat_map(|layer_panel_entry| self.graphene_document.layer(layer_panel_entry.path.as_slice()))
.flat_map(|layer_panel_entry| self.document_legacy.layer(layer_panel_entry.path.as_slice()))
.for_each(|layer| {
match opacity {
None => opacity = Some(layer.opacity),
@ -1871,7 +1868,7 @@ impl DocumentMessageHandler {
if let Some(neighbor_path) = existing_layer_to_insert_beside {
let (neighbor_id, folder_path) = neighbor_path.split_last().expect("Can't move the root folder");
if let Some(folder) = self.graphene_document.layer(folder_path).ok().and_then(|layer| layer.as_folder().ok()) {
if let Some(folder) = self.document_legacy.layer(folder_path).ok().and_then(|layer| layer.as_folder().ok()) {
let neighbor_layer_index = folder.layer_ids.iter().position(|id| id == neighbor_id).unwrap() as isize;
// If moving down, insert below this layer. If moving up, insert above this layer.

View file

@ -5,8 +5,8 @@ use crate::messages::input_mapper::utility_types::input_mouse::{ViewportBounds,
use crate::messages::prelude::*;
use crate::messages::tool::utility_types::{HintData, HintGroup, HintInfo};
use graphene::document::Document;
use graphene::Operation as DocumentOperation;
use document_legacy::document::Document;
use document_legacy::Operation as DocumentOperation;
use glam::{DAffine2, DVec2};
use serde::{Deserialize, Serialize};

View file

@ -1,7 +1,7 @@
use crate::messages::prelude::*;
use document_legacy::LayerId;
use graph_craft::document::{value::TaggedValue, NodeId};
use graphene::LayerId;
#[remain::sorted]
#[impl_message(Message, DocumentMessage, NodeGraph)]
@ -45,7 +45,7 @@ pub enum NodeGraphMessage {
displacement_y: i32,
},
OpenNodeGraph {
layer_path: Vec<graphene::LayerId>,
layer_path: Vec<document_legacy::LayerId>,
},
SelectNodes {
nodes: Vec<NodeId>,

View file

@ -2,11 +2,11 @@ use crate::messages::layout::utility_types::layout_widget::{Layout, LayoutGroup,
use crate::messages::layout::utility_types::widgets::button_widgets::BreadcrumbTrailButtons;
use crate::messages::prelude::*;
use document_legacy::document::Document;
use document_legacy::layers::layer_info::LayerDataType;
use document_legacy::layers::nodegraph_layer::NodeGraphFrameLayer;
use graph_craft::document::value::TaggedValue;
use graph_craft::document::{DocumentNode, DocumentNodeImplementation, DocumentNodeMetadata, NodeId, NodeInput, NodeNetwork};
use graphene::document::Document;
use graphene::layers::layer_info::LayerDataType;
use graphene::layers::nodegraph_layer::NodeGraphFrameLayer;
mod document_node_types;
mod node_properties;
@ -94,7 +94,7 @@ impl FrontendNodeType {
#[derive(Debug, Clone, Eq, PartialEq, Default, serde::Serialize, serde::Deserialize)]
pub struct NodeGraphMessageHandler {
pub layer_path: Option<Vec<graphene::LayerId>>,
pub layer_path: Option<Vec<document_legacy::LayerId>>,
pub nested_path: Vec<graph_craft::document::NodeId>,
pub selected_nodes: Vec<graph_craft::document::NodeId>,
}

View file

@ -34,9 +34,9 @@ impl DocumentInputType {
pub struct NodePropertiesContext<'a> {
pub persistent_data: &'a crate::messages::portfolio::utility_types::PersistentData,
pub document: &'a graphene::document::Document,
pub document: &'a document_legacy::document::Document,
pub responses: &'a mut VecDeque<crate::messages::prelude::Message>,
pub layer_path: &'a [graphene::LayerId],
pub layer_path: &'a [document_legacy::LayerId],
pub nested_path: &'a [NodeId],
}

View file

@ -3,12 +3,12 @@ use crate::messages::layout::utility_types::widgets::{button_widgets::*, input_w
use crate::messages::portfolio::utility_types::ImaginateServerStatus;
use crate::messages::prelude::*;
use document_legacy::layers::layer_info::LayerDataTypeDiscriminant;
use document_legacy::Operation;
use glam::DVec2;
use graph_craft::document::value::TaggedValue;
use graph_craft::document::{generate_uuid, DocumentNode, NodeId, NodeInput};
use graph_craft::imaginate_input::*;
use graphene::layers::layer_info::LayerDataTypeDiscriminant;
use graphene::Operation;
use super::document_node_types::NodePropertiesContext;
use super::{FrontendGraphDataType, IMAGINATE_NODE};
@ -521,7 +521,7 @@ pub fn imaginate_properties(document_node: &DocumentNode, node_id: NodeId, conte
};
let resolution = {
use graphene::document::pick_safe_imaginate_resolution;
use document_legacy::document::pick_safe_imaginate_resolution;
let mut widgets = start_widgets(document_node, node_id, resolution_index, "Resolution", FrontendGraphDataType::Vector, false);

View file

@ -1,6 +1,6 @@
use crate::messages::prelude::*;
use graphene::Operation as DocumentOperation;
use document_legacy::Operation as DocumentOperation;
use serde::{Deserialize, Serialize};

View file

@ -1,12 +1,12 @@
use crate::messages::prelude::*;
use graphene::document::Document as GrapheneDocument;
use graphene::layers::style::{RenderData, ViewMode};
use graphene::layers::text_layer::FontCache;
use document_legacy::document::Document as DocumentLegacy;
use document_legacy::layers::style::{RenderData, ViewMode};
use document_legacy::layers::text_layer::FontCache;
#[derive(Debug, Clone, Default)]
pub struct OverlaysMessageHandler {
pub overlays_graphene_document: GrapheneDocument,
pub overlays_document: DocumentLegacy,
}
impl MessageHandler<OverlaysMessage, (bool, &FontCache, &InputPreprocessorMessageHandler)> for OverlaysMessageHandler {
@ -18,7 +18,7 @@ impl MessageHandler<OverlaysMessage, (bool, &FontCache, &InputPreprocessorMessag
match message {
// Sub-messages
#[remain::unsorted]
DispatchOperation(operation) => match self.overlays_graphene_document.handle_operation(*operation, font_cache) {
DispatchOperation(operation) => match self.overlays_document.handle_operation(*operation, font_cache) {
Ok(_) => responses.push_back(OverlaysMessage::Rerender.into()),
Err(e) => error!("OverlaysError: {:?}", e),
},
@ -32,7 +32,7 @@ impl MessageHandler<OverlaysMessage, (bool, &FontCache, &InputPreprocessorMessag
FrontendMessage::UpdateDocumentOverlays {
svg: if overlays_visible {
let render_data = RenderData::new(ViewMode::Normal, font_cache, Some(ipp.document_bounds()));
self.overlays_graphene_document.render_root(render_data)
self.overlays_document.render_root(render_data)
} else {
String::from("")
},

View file

@ -3,8 +3,8 @@ use crate::messages::layout::utility_types::widgets::assist_widgets::PivotPositi
use crate::messages::portfolio::document::utility_types::misc::TargetDocument;
use crate::messages::prelude::*;
use graphene::layers::style::{Fill, Stroke};
use graphene::LayerId;
use document_legacy::layers::style::{Fill, Stroke};
use document_legacy::LayerId;
use serde::{Deserialize, Serialize};

View file

@ -7,8 +7,8 @@ use crate::messages::portfolio::document::utility_types::misc::TargetDocument;
use crate::messages::portfolio::utility_types::PersistentData;
use crate::messages::prelude::*;
use graphene::layers::layer_info::LayerDataTypeDiscriminant;
use graphene::{LayerId, Operation};
use document_legacy::layers::layer_info::LayerDataTypeDiscriminant;
use document_legacy::{LayerId, Operation};
use serde::{Deserialize, Serialize};

View file

@ -9,11 +9,11 @@ use crate::messages::layout::utility_types::widgets::label_widgets::{IconLabel,
use crate::messages::portfolio::utility_types::PersistentData;
use crate::messages::prelude::*;
use graphene::color::Color;
use graphene::document::Document;
use graphene::layers::layer_info::{Layer, LayerDataType, LayerDataTypeDiscriminant};
use graphene::layers::style::{Fill, Gradient, GradientType, LineCap, LineJoin, Stroke};
use graphene::layers::text_layer::{FontCache, TextLayer};
use document_legacy::color::Color;
use document_legacy::document::Document;
use document_legacy::layers::layer_info::{Layer, LayerDataType, LayerDataTypeDiscriminant};
use document_legacy::layers::style::{Fill, Gradient, GradientType, LineCap, LineJoin, Stroke};
use document_legacy::layers::text_layer::{FontCache, TextLayer};
use glam::{DAffine2, DVec2};
use std::f64::consts::PI;
@ -209,7 +209,7 @@ pub fn register_artboard_layer_properties(layer: &Layer, responses: &mut VecDequ
pub fn register_artwork_layer_properties(
document: &Document,
layer_path: Vec<graphene::LayerId>,
layer_path: Vec<document_legacy::LayerId>,
layer: &Layer,
responses: &mut VecDeque<Message>,
persistent_data: &PersistentData,

View file

@ -1,13 +1,13 @@
use graphene::document::Document as GrapheneDocument;
use graphene::LayerId;
use document_legacy::document::Document as DocumentLegacy;
use document_legacy::LayerId;
use serde::{Deserialize, Serialize};
use crate::messages::prelude::NodeGraphMessageHandler;
pub struct PropertiesPanelMessageHandlerData<'a> {
pub artwork_document: &'a GrapheneDocument,
pub artboard_document: &'a GrapheneDocument,
pub artwork_document: &'a DocumentLegacy,
pub artboard_document: &'a DocumentLegacy,
pub selected_layers: &'a mut dyn Iterator<Item = &'a [LayerId]>,
pub node_graph_message_handler: &'a NodeGraphMessageHandler,
}

View file

@ -4,11 +4,11 @@ use crate::messages::portfolio::document::utility_types::layer_panel::LayerMetad
use crate::messages::portfolio::document::utility_types::transformation::{Axis, OriginalTransforms, Selected, TransformOperation, Typing};
use crate::messages::prelude::*;
use graphene::document::Document;
use graphene::LayerId;
use document_legacy::document::Document;
use document_legacy::LayerId;
use document_legacy::layers::text_layer::FontCache;
use glam::DVec2;
use graphene::layers::text_layer::FontCache;
#[derive(Debug, Clone, Default, PartialEq)]
pub struct TransformLayerMessageHandler {

View file

@ -1,6 +1,6 @@
use super::layer_panel::LayerMetadata;
use graphene::layers::layer_info::Layer;
use document_legacy::layers::layer_info::Layer;
use serde::{Deserialize, Serialize};

View file

@ -1,5 +1,5 @@
use graphene::color::Color;
use graphene::DocumentError;
use document_legacy::color::Color;
use document_legacy::DocumentError;
use thiserror::Error;

View file

@ -1,7 +1,7 @@
use graphene::layers::layer_info::{Layer, LayerData, LayerDataTypeDiscriminant};
use graphene::layers::style::{RenderData, ViewMode};
use graphene::layers::text_layer::FontCache;
use graphene::LayerId;
use document_legacy::layers::layer_info::{Layer, LayerData, LayerDataTypeDiscriminant};
use document_legacy::layers::style::{RenderData, ViewMode};
use document_legacy::layers::text_layer::FontCache;
use document_legacy::LayerId;
use glam::{DAffine2, DVec2};
use serde::ser::SerializeStruct;

View file

@ -1,14 +1,14 @@
pub use super::layer_panel::{LayerMetadata, LayerPanelEntry};
use graphene::color::Color;
use graphene::document::Document as GrapheneDocument;
use graphene::LayerId;
use document_legacy::color::Color;
use document_legacy::document::Document as DocumentLegacy;
use document_legacy::LayerId;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::fmt;
pub type DocumentSave = (GrapheneDocument, HashMap<Vec<LayerId>, LayerMetadata>);
pub type DocumentSave = (DocumentLegacy, HashMap<Vec<LayerId>, LayerMetadata>);
#[derive(PartialEq, Eq, Clone, Debug, Serialize, Deserialize, Hash)]
pub enum FlipAxis {

View file

@ -1,10 +1,10 @@
use crate::consts::{ROTATE_SNAP_ANGLE, SCALE_SNAP_INTERVAL};
use crate::messages::prelude::*;
use graphene::document::Document;
use graphene::layers::text_layer::FontCache;
use graphene::LayerId;
use graphene::Operation as DocumentOperation;
use document_legacy::document::Document;
use document_legacy::layers::text_layer::FontCache;
use document_legacy::LayerId;
use document_legacy::Operation as DocumentOperation;
use glam::{DAffine2, DVec2};
use std::collections::{HashMap, VecDeque};

View file

@ -2,10 +2,10 @@ use super::utility_types::ImaginateServerStatus;
use crate::messages::portfolio::document::utility_types::clipboards::Clipboard;
use crate::messages::prelude::*;
use document_legacy::layers::text_layer::Font;
use document_legacy::LayerId;
use graph_craft::document::NodeId;
use graph_craft::imaginate_input::ImaginateStatus;
use graphene::layers::text_layer::Font;
use graphene::LayerId;
use serde::{Deserialize, Serialize};

View file

@ -11,13 +11,13 @@ use crate::messages::portfolio::document::utility_types::misc::DocumentRenderMod
use crate::messages::portfolio::utility_types::ImaginateServerStatus;
use crate::messages::prelude::*;
use document_legacy::document::pick_safe_imaginate_resolution;
use document_legacy::layers::layer_info::{LayerDataType, LayerDataTypeDiscriminant};
use document_legacy::layers::text_layer::Font;
use document_legacy::{LayerId, Operation as DocumentOperation};
use graph_craft::document::value::TaggedValue;
use graph_craft::document::NodeId;
use graph_craft::document::{NodeInput, NodeNetwork};
use graphene::document::pick_safe_imaginate_resolution;
use graphene::layers::layer_info::{LayerDataType, LayerDataTypeDiscriminant};
use graphene::layers::text_layer::Font;
use graphene::{LayerId, Operation as DocumentOperation};
use graphene_core::raster::Image;
use glam::DVec2;
@ -151,7 +151,7 @@ impl MessageHandler<PortfolioMessage, (&InputPreprocessorMessageHandler, &Prefer
if let Some(active_document) = self.active_document_id.and_then(|id| self.documents.get(&id)) {
let copy_val = |buffer: &mut Vec<CopyBufferEntry>| {
for layer_path in active_document.selected_layers_without_children() {
match (active_document.graphene_document.layer(layer_path).map(|t| t.clone()), *active_document.layer_metadata(layer_path)) {
match (active_document.document_legacy.layer(layer_path).map(|t| t.clone()), *active_document.layer_metadata(layer_path)) {
(Ok(layer), layer_metadata) => {
buffer.push(CopyBufferEntry { layer, layer_metadata });
}
@ -194,7 +194,7 @@ impl MessageHandler<PortfolioMessage, (&InputPreprocessorMessageHandler, &Prefer
self.persistent_data.font_cache.insert(Font::new(font_family, font_style), preview_url, data, is_default);
if let Some(document) = self.active_document_mut() {
document.graphene_document.mark_all_layers_of_type_as_dirty(LayerDataTypeDiscriminant::Text);
document.document_legacy.mark_all_layers_of_type_as_dirty(LayerDataTypeDiscriminant::Text);
responses.push_back(DocumentMessage::RenderDocument.into());
responses.push_back(BroadcastEvent::DocumentIsDirty.into());
}
@ -285,7 +285,7 @@ impl MessageHandler<PortfolioMessage, (&InputPreprocessorMessageHandler, &Prefer
}
PortfolioMessage::LoadDocumentResources { document_id } => {
if let Some(document) = self.document_mut(document_id) {
document.load_layer_resources(responses, &document.graphene_document.root.data, Vec::new(), document_id);
document.load_layer_resources(responses, &document.document_legacy.root.data, Vec::new(), document_id);
}
}
PortfolioMessage::LoadFont { font, is_default } => {
@ -358,7 +358,7 @@ impl MessageHandler<PortfolioMessage, (&InputPreprocessorMessageHandler, &Prefer
PortfolioMessage::Paste { clipboard } => {
let shallowest_common_folder = self.active_document().map(|document| {
document
.graphene_document
.document_legacy
.shallowest_common_folder(document.selected_layers())
.expect("While pasting, the selected layers did not exist while attempting to find the appropriate folder path for insertion")
});
@ -420,7 +420,7 @@ impl MessageHandler<PortfolioMessage, (&InputPreprocessorMessageHandler, &Prefer
if let Some(document) = self.active_document() {
if let Ok(data) = serde_json::from_str::<Vec<CopyBufferEntry>>(&data) {
let shallowest_common_folder = document
.graphene_document
.document_legacy
.shallowest_common_folder(document.selected_layers())
.expect("While pasting from serialized, the selected layers did not exist while attempting to find the appropriate folder path for insertion");
responses.push_back(DocumentMessage::DeselectAllLayers.into());
@ -756,7 +756,7 @@ impl PortfolioMessageHandler {
// Get the node graph layer
let document = self.documents.get_mut(&document_id).ok_or_else(|| "Invalid document".to_string())?;
let layer = document.graphene_document.layer(&layer_path).map_err(|e| format!("No layer: {e:?}"))?;
let layer = document.document_legacy.layer(&layer_path).map_err(|e| format!("No layer: {e:?}"))?;
let node_graph_frame = match &layer.data {
LayerDataType::NodeGraphFrame(frame) => Ok(frame),
_ => Err("Invalid layer type".to_string()),
@ -771,12 +771,12 @@ impl PortfolioMessageHandler {
let resolution: Option<glam::DVec2> = Self::compute_input(&network, &imaginate_node, get("Resolution"), Cow::Borrowed(&image))?;
let resolution = resolution.unwrap_or_else(|| {
let transform = document.graphene_document.root.transform.inverse() * document.graphene_document.multiply_transforms(&layer_path).unwrap();
let transform = document.document_legacy.root.transform.inverse() * document.document_legacy.multiply_transforms(&layer_path).unwrap();
let (x, y) = pick_safe_imaginate_resolution((transform.transform_vector2(DVec2::new(1., 0.)).length(), transform.transform_vector2(DVec2::new(0., 1.)).length()));
DVec2::new(x as f64, y as f64)
});
let transform = document.graphene_document.root.transform.inverse() * document.graphene_document.multiply_transforms(&layer_path).unwrap();
let transform = document.document_legacy.root.transform.inverse() * document.document_legacy.multiply_transforms(&layer_path).unwrap();
let parameters = ImaginateGenerationParameters {
seed: Self::compute_input::<f64>(&network, &imaginate_node, get("Seed"), Cow::Borrowed(&image))? as u64,
resolution: resolution.as_uvec2().into(),
@ -818,8 +818,8 @@ impl PortfolioMessageHandler {
// Render the masking layer within the node graph frame
let old_transforms = document.remove_document_transform();
let mask_is_some = mask_path.is_some();
let mask_image = mask_path.filter(|mask_layer_path| document.graphene_document.layer(mask_layer_path).is_ok()).map(|mask_layer_path| {
let render_mode = DocumentRenderMode::LayerCutout(&mask_layer_path, graphene::color::Color::WHITE);
let mask_image = mask_path.filter(|mask_layer_path| document.document_legacy.layer(mask_layer_path).is_ok()).map(|mask_layer_path| {
let render_mode = DocumentRenderMode::LayerCutout(&mask_layer_path, document_legacy::color::Color::WHITE);
let svg = document.render_document(size, transform.inverse(), &self.persistent_data, render_mode);
ImaginateMaskImage { svg, size }

View file

@ -1,4 +1,4 @@
use graphene::layers::text_layer::FontCache;
use document_legacy::layers::text_layer::FontCache;
use serde::{Deserialize, Serialize};

View file

@ -3,10 +3,10 @@ use crate::consts::VIEWPORT_GRID_ROUNDING_BIAS;
use crate::consts::{COLOR_ACCENT, MANIPULATOR_GROUP_MARKER_SIZE, PATH_OUTLINE_WEIGHT};
use crate::messages::prelude::*;
use graphene::color::Color;
use graphene::document::Document;
use graphene::layers::style::{self, Fill, Stroke};
use graphene::{LayerId, Operation};
use document_legacy::color::Color;
use document_legacy::document::Document;
use document_legacy::layers::style::{self, Fill, Stroke};
use document_legacy::{LayerId, Operation};
use graphene_std::vector::consts::ManipulatorType;
use graphene_std::vector::manipulator_group::ManipulatorGroup;
use graphene_std::vector::manipulator_point::ManipulatorPoint;

View file

@ -2,11 +2,11 @@ use crate::application::generate_uuid;
use crate::consts::{COLOR_ACCENT, PATH_OUTLINE_WEIGHT, SELECTION_TOLERANCE};
use crate::messages::prelude::*;
use graphene::intersection::Quad;
use graphene::layers::layer_info::LayerDataType;
use graphene::layers::style::{self, Fill, Stroke};
use graphene::layers::text_layer::FontCache;
use graphene::{LayerId, Operation};
use document_legacy::intersection::Quad;
use document_legacy::layers::layer_info::LayerDataType;
use document_legacy::layers::style::{self, Fill, Stroke};
use document_legacy::layers::text_layer::FontCache;
use document_legacy::{LayerId, Operation};
use graphene_std::vector::subpath::Subpath;
use glam::{DAffine2, DVec2};
@ -29,7 +29,7 @@ impl PathOutline {
font_cache: &FontCache,
) -> Option<Vec<LayerId>> {
// Get layer data
let document_layer = document.graphene_document.layer(&document_layer_path).ok()?;
let document_layer = document.document_legacy.layer(&document_layer_path).ok()?;
// TODO Purge this area of BezPath and Kurbo
// Get the bezpath from the shape or text
@ -65,7 +65,7 @@ impl PathOutline {
// Update the transform to match the document
let operation = Operation::SetLayerTransform {
path: overlay.clone(),
transform: document.graphene_document.multiply_transforms(&document_layer_path).unwrap().to_cols_array(),
transform: document.document_legacy.multiply_transforms(&document_layer_path).unwrap().to_cols_array(),
};
responses.push_back(DocumentMessage::Overlays(operation.into()).into());
@ -86,7 +86,7 @@ impl PathOutline {
// Get the layer the user is hovering over
let tolerance = DVec2::splat(SELECTION_TOLERANCE);
let quad = Quad::from_box([input.mouse.position - tolerance, input.mouse.position + tolerance]);
let mut intersection = document.graphene_document.intersects_quad_root(quad, font_cache);
let mut intersection = document.document_legacy.intersects_quad_root(quad, font_cache);
// If the user is hovering over a layer they have not already selected, then update outline
if let Some(path) = intersection.pop() {

View file

@ -5,9 +5,9 @@ use crate::consts::{COLOR_ACCENT, PIVOT_INNER, PIVOT_OUTER, PIVOT_OUTER_OUTLINE_
use crate::messages::layout::utility_types::widgets::assist_widgets::PivotPosition;
use crate::messages::prelude::*;
use graphene::layers::style;
use graphene::layers::text_layer::FontCache;
use graphene::{LayerId, Operation};
use document_legacy::layers::style;
use document_legacy::layers::text_layer::FontCache;
use document_legacy::{LayerId, Operation};
use glam::{DAffine2, DVec2};
use std::collections::VecDeque;
@ -40,7 +40,7 @@ impl Default for Pivot {
impl Pivot {
/// Calculates the transform that gets from normalized pivot to viewspace.
fn get_layer_pivot_transform(layer_path: &[LayerId], layer: &graphene::layers::layer_info::Layer, document: &DocumentMessageHandler, font_cache: &FontCache) -> DAffine2 {
fn get_layer_pivot_transform(layer_path: &[LayerId], layer: &document_legacy::layers::layer_info::Layer, document: &DocumentMessageHandler, font_cache: &FontCache) -> DAffine2 {
let [mut min, max] = layer.aabb_for_transform(DAffine2::IDENTITY, font_cache).unwrap_or([DVec2::ZERO, DVec2::ONE]);
// If the layer bounds are 0 in either axis then set them to one (to avoid div 0)
@ -51,7 +51,7 @@ impl Pivot {
min.y = max.y - 1.;
}
let bounds_transform = DAffine2::from_translation(min) * DAffine2::from_scale(max - min);
let layer_transform = document.graphene_document.multiply_transforms(layer_path).unwrap_or(DAffine2::IDENTITY);
let layer_transform = document.document_legacy.multiply_transforms(layer_path).unwrap_or(DAffine2::IDENTITY);
layer_transform * bounds_transform
}
@ -64,7 +64,7 @@ impl Pivot {
// If just one layer is selected we can use its inner transform
if selected_layers_count == 1 {
if let Ok(layer) = document.graphene_document.layer(first) {
if let Ok(layer) = document.document_legacy.layer(first) {
self.normalized_pivot = layer.pivot;
self.transform_from_normalized = Self::get_layer_pivot_transform(first, layer, document, font_cache);
self.pivot = Some(self.transform_from_normalized.transform_point2(layer.pivot));
@ -73,7 +73,7 @@ impl Pivot {
// If more than one layer is selected we use the AABB with the mean of the pivots
let xy_summation = document
.selected_visible_layers()
.filter_map(|path| document.graphene_document.pivot(path, font_cache))
.filter_map(|path| document.document_legacy.pivot(path, font_cache))
.reduce(|a, b| a + b)
.unwrap_or_default();
@ -113,7 +113,10 @@ impl Pivot {
Operation::AddEllipse {
path: layer_paths[0].clone(),
transform: DAffine2::IDENTITY.to_cols_array(),
style: style::PathStyle::new(Some(style::Stroke::new(COLOR_ACCENT, PIVOT_OUTER_OUTLINE_THICKNESS)), style::Fill::Solid(graphene::color::Color::WHITE)),
style: style::PathStyle::new(
Some(style::Stroke::new(COLOR_ACCENT, PIVOT_OUTER_OUTLINE_THICKNESS)),
style::Fill::Solid(document_legacy::color::Color::WHITE),
),
insert_index: -1,
}
.into(),
@ -164,7 +167,7 @@ impl Pivot {
/// Sets the viewport position of the pivot for all selected layers.
pub fn set_viewport_position(&self, position: DVec2, document: &DocumentMessageHandler, font_cache: &FontCache, responses: &mut VecDeque<Message>) {
for layer_path in document.selected_visible_layers() {
if let Ok(layer) = document.graphene_document.layer(layer_path) {
if let Ok(layer) = document.document_legacy.layer(layer_path) {
let transform = Self::get_layer_pivot_transform(layer_path, layer, document, font_cache);
let pivot = transform.inverse().transform_point2(position);
// Only update the pivot when computed position is finite. Infinite can happen when scale is 0.

View file

@ -3,9 +3,9 @@ use crate::messages::input_mapper::utility_types::input_mouse::ViewportPosition;
use crate::messages::prelude::*;
use crate::messages::tool::common_functionality::snapping::SnapManager;
use graphene::layers::text_layer::FontCache;
use graphene::LayerId;
use graphene::Operation;
use document_legacy::layers::text_layer::FontCache;
use document_legacy::LayerId;
use document_legacy::Operation;
use glam::{DAffine2, DVec2, Vec2Swizzles};

View file

@ -1,14 +1,14 @@
use crate::messages::prelude::*;
use bezier_rs::ComputeType;
use graphene::{LayerId, Operation};
use document_legacy::{LayerId, Operation};
use graphene_std::vector::consts::ManipulatorType;
use graphene_std::vector::manipulator_group::ManipulatorGroup;
use graphene_std::vector::manipulator_point::ManipulatorPoint;
use graphene_std::vector::subpath::{BezierId, Subpath};
use document_legacy::document::Document;
use glam::DVec2;
use graphene::document::Document;
/// ShapeEditor is the container for all of the layer paths that are represented as [Subpath]s and provides
/// functionality required to query and create the [Subpath] / [ManipulatorGroup]s / [ManipulatorPoint]s.

View file

@ -5,9 +5,9 @@ use crate::consts::{
};
use crate::messages::prelude::*;
use graphene::layers::layer_info::{Layer, LayerDataType};
use graphene::layers::style::{self, Stroke};
use graphene::{LayerId, Operation};
use document_legacy::layers::layer_info::{Layer, LayerDataType};
use document_legacy::layers::style::{self, Stroke};
use document_legacy::{LayerId, Operation};
use graphene_std::vector::consts::ManipulatorType;
use glam::{DAffine2, DVec2};
@ -239,7 +239,7 @@ impl SnapManager {
/// This should be called after start_snap
pub fn add_snap_path(&mut self, document_message_handler: &DocumentMessageHandler, layer: &Layer, path: &[LayerId], include_handles: bool, ignore_points: &[(&[LayerId], u64, ManipulatorType)]) {
if let LayerDataType::Shape(shape_layer) = &layer.data {
let transform = document_message_handler.graphene_document.multiply_transforms(path).unwrap();
let transform = document_message_handler.document_legacy.multiply_transforms(path).unwrap();
let snap_points = shape_layer
.shape
.manipulator_groups()
@ -273,7 +273,7 @@ impl SnapManager {
) {
for path in document_message_handler.all_layers() {
if !exclude.contains(&path) {
let layer = document_message_handler.graphene_document.layer(path).expect("Could not get layer for snapping");
let layer = document_message_handler.document_legacy.layer(path).expect("Could not get layer for snapping");
self.add_snap_path(document_message_handler, layer, path, include_handles.contains(&path), ignore_points);
}
}

View file

@ -4,10 +4,10 @@ use crate::messages::frontend::utility_types::MouseCursorIcon;
use crate::messages::portfolio::document::utility_types::transformation::OriginalTransforms;
use crate::messages::prelude::*;
use graphene::color::Color;
use graphene::layers::style::{self, Fill, Stroke};
use graphene::LayerId;
use graphene::Operation;
use document_legacy::color::Color;
use document_legacy::layers::style::{self, Fill, Stroke};
use document_legacy::LayerId;
use document_legacy::Operation;
use glam::{DAffine2, DVec2};

View file

@ -1,7 +1,7 @@
use super::utility_types::ToolType;
use crate::messages::prelude::*;
use graphene::color::Color;
use document_legacy::color::Color;
use serde::{Deserialize, Serialize};

View file

@ -6,7 +6,7 @@ use crate::messages::portfolio::utility_types::PersistentData;
use crate::messages::prelude::*;
use crate::messages::tool::utility_types::ToolType;
use graphene::color::Color;
use document_legacy::color::Color;
#[derive(Debug, Default)]
pub struct ToolMessageHandler {

View file

@ -10,8 +10,8 @@ use crate::messages::tool::common_functionality::transformation_cage::*;
use crate::messages::tool::utility_types::{EventToMessageMap, Fsm, ToolActionHandlerData, ToolMetadata, ToolTransition, ToolType};
use crate::messages::tool::utility_types::{HintData, HintGroup, HintInfo};
use graphene::intersection::Quad;
use graphene::LayerId;
use document_legacy::intersection::Quad;
use document_legacy::LayerId;
use glam::{DVec2, Vec2Swizzles};
use serde::{Deserialize, Serialize};
@ -198,8 +198,8 @@ impl Fsm for ArtboardToolFsmState {
tool_data.snap_manager.add_all_document_handles(document, &[], &[], &[]);
if let Some(bounds) = &mut tool_data.bounding_box_overlays {
let pivot = document.artboard_message_handler.artboards_graphene_document.pivot(&[artboard], font_cache).unwrap_or_default();
let root = document.graphene_document.root.transform;
let pivot = document.artboard_message_handler.artboards_document.pivot(&[artboard], font_cache).unwrap_or_default();
let root = document.document_legacy.root.transform;
let pivot = root.inverse().transform_point2(pivot);
bounds.center_of_transformation = pivot;
}
@ -208,7 +208,7 @@ impl Fsm for ArtboardToolFsmState {
} else {
let tolerance = DVec2::splat(SELECTION_TOLERANCE);
let quad = Quad::from_box([input.mouse.position - tolerance, input.mouse.position + tolerance]);
let intersection = document.artboard_message_handler.artboards_graphene_document.intersects_quad_root(quad, font_cache);
let intersection = document.artboard_message_handler.artboards_document.intersects_quad_root(quad, font_cache);
responses.push_back(BroadcastEvent::DocumentIsDirty.into());
if let Some(intersection) = intersection.last() {
@ -294,7 +294,7 @@ impl Fsm for ArtboardToolFsmState {
let mouse_position = input.mouse.position;
let snapped_mouse_position = tool_data.snap_manager.snap_position(responses, document, mouse_position);
let root_transform = document.graphene_document.root.transform.inverse();
let root_transform = document.document_legacy.root.transform.inverse();
let mut start = tool_data.drag_start;
let mut size = snapped_mouse_position - start;

View file

@ -7,8 +7,8 @@ use crate::messages::tool::common_functionality::resize::Resize;
use crate::messages::tool::utility_types::{EventToMessageMap, Fsm, ToolActionHandlerData, ToolMetadata, ToolTransition, ToolType};
use crate::messages::tool::utility_types::{HintData, HintGroup, HintInfo};
use graphene::layers::style;
use graphene::Operation;
use document_legacy::layers::style;
use document_legacy::Operation;
use glam::DAffine2;
use serde::{Deserialize, Serialize};

View file

@ -6,9 +6,9 @@ use crate::messages::prelude::*;
use crate::messages::tool::utility_types::{EventToMessageMap, Fsm, ToolActionHandlerData, ToolMetadata, ToolTransition, ToolType};
use crate::messages::tool::utility_types::{HintData, HintGroup, HintInfo};
use graphene::intersection::Quad;
use graphene::layers::style::Fill;
use graphene::Operation;
use document_legacy::intersection::Quad;
use document_legacy::layers::style::Fill;
use document_legacy::Operation;
use glam::DVec2;
use serde::{Deserialize, Serialize};
@ -119,7 +119,7 @@ impl Fsm for FillToolFsmState {
let tolerance = DVec2::splat(SELECTION_TOLERANCE);
let quad = Quad::from_box([mouse_pos - tolerance, mouse_pos + tolerance]);
if let Some(path) = document.graphene_document.intersects_quad_root(quad, font_cache).last() {
if let Some(path) = document.document_legacy.intersects_quad_root(quad, font_cache).last() {
let color = match lmb_or_rmb {
LeftPointerDown => global_tool_data.primary_color,
RightPointerDown => global_tool_data.secondary_color,

View file

@ -6,9 +6,9 @@ use crate::messages::prelude::*;
use crate::messages::tool::utility_types::{DocumentToolData, EventToMessageMap, Fsm, ToolActionHandlerData, ToolMetadata, ToolTransition, ToolType};
use crate::messages::tool::utility_types::{HintData, HintGroup, HintInfo};
use graphene::layers::style;
use graphene::LayerId;
use graphene::Operation;
use document_legacy::layers::style;
use document_legacy::LayerId;
use document_legacy::Operation;
use glam::{DAffine2, DVec2};
use serde::{Deserialize, Serialize};
@ -168,7 +168,7 @@ impl Fsm for FreehandToolFsmState {
use FreehandToolFsmState::*;
use FreehandToolMessage::*;
let transform = document.graphene_document.root.transform;
let transform = document.document_legacy.root.transform;
if let ToolMessage::Freehand(event) = event {
match (self, event) {

View file

@ -9,15 +9,15 @@ use crate::messages::tool::common_functionality::snapping::SnapManager;
use crate::messages::tool::utility_types::{EventToMessageMap, Fsm, ToolActionHandlerData, ToolMetadata, ToolTransition, ToolType};
use crate::messages::tool::utility_types::{HintData, HintGroup, HintInfo};
use graphene::color::Color;
use graphene::intersection::Quad;
use graphene::layers::layer_info::Layer;
use graphene::layers::style::{Fill, Gradient, GradientType, PathStyle, Stroke};
use graphene::LayerId;
use graphene::Operation;
use document_legacy::color::Color;
use document_legacy::intersection::Quad;
use document_legacy::layers::layer_info::Layer;
use document_legacy::layers::style::{Fill, Gradient, GradientType, PathStyle, Stroke};
use document_legacy::LayerId;
use document_legacy::Operation;
use document_legacy::layers::text_layer::FontCache;
use glam::{DAffine2, DVec2};
use graphene::layers::text_layer::FontCache;
use serde::{Deserialize, Serialize};
#[derive(Default)]
@ -152,7 +152,7 @@ fn gradient_space_transform(path: &[LayerId], layer: &Layer, document: &Document
let bounds = layer.aabb_for_transform(DAffine2::IDENTITY, font_cache).unwrap();
let bound_transform = DAffine2::from_scale_angle_translation(bounds[1] - bounds[0], 0., bounds[0]);
let multiplied = document.graphene_document.multiply_transforms(path).unwrap();
let multiplied = document.document_legacy.multiply_transforms(path).unwrap();
multiplied * bound_transform
}
@ -385,10 +385,10 @@ impl Fsm for GradientToolFsmState {
}
for path in document.selected_visible_layers() {
if !document.graphene_document.multiply_transforms(path).unwrap().inverse().is_finite() {
if !document.document_legacy.multiply_transforms(path).unwrap().inverse().is_finite() {
continue;
}
let layer = document.graphene_document.layer(path).unwrap();
let layer = document.document_legacy.layer(path).unwrap();
if let Ok(Fill::Gradient(gradient)) = layer.style().map(|style| style.fill()) {
let dragging = tool_data
@ -445,7 +445,7 @@ impl Fsm for GradientToolFsmState {
} else {
let tolerance = DVec2::splat(SELECTION_TOLERANCE);
let quad = Quad::from_box([input.mouse.position - tolerance, input.mouse.position + tolerance]);
let intersection = document.graphene_document.intersects_quad_root(quad, font_cache).pop();
let intersection = document.document_legacy.intersects_quad_root(quad, font_cache).pop();
if let Some(intersection) = intersection {
if !document.selected_layers_contains(&intersection) {
@ -454,7 +454,7 @@ impl Fsm for GradientToolFsmState {
responses.push_back(DocumentMessage::SetSelectedLayers { replacement_selected_layers }.into());
}
let layer = document.graphene_document.layer(&intersection).unwrap();
let layer = document.document_legacy.layer(&intersection).unwrap();
let gradient = Gradient::new(
DVec2::ZERO,

View file

@ -8,7 +8,7 @@ use crate::messages::tool::common_functionality::resize::Resize;
use crate::messages::tool::utility_types::{EventToMessageMap, Fsm, ToolActionHandlerData, ToolMetadata, ToolTransition, ToolType};
use crate::messages::tool::utility_types::{HintData, HintGroup, HintInfo};
use graphene::Operation;
use document_legacy::Operation;
use glam::DAffine2;
use serde::{Deserialize, Serialize};

View file

@ -9,9 +9,9 @@ use crate::messages::tool::common_functionality::snapping::SnapManager;
use crate::messages::tool::utility_types::{EventToMessageMap, Fsm, ToolActionHandlerData, ToolMetadata, ToolTransition, ToolType};
use crate::messages::tool::utility_types::{HintData, HintGroup, HintInfo};
use graphene::layers::style;
use graphene::LayerId;
use graphene::Operation;
use document_legacy::layers::style;
use document_legacy::LayerId;
use document_legacy::Operation;
use glam::{DAffine2, DVec2};
use serde::{Deserialize, Serialize};

View file

@ -7,7 +7,7 @@ use crate::messages::tool::common_functionality::resize::Resize;
use crate::messages::tool::utility_types::{EventToMessageMap, Fsm, ToolActionHandlerData, ToolMetadata, ToolTransition, ToolType};
use crate::messages::tool::utility_types::{HintData, HintGroup, HintInfo};
use graphene::Operation;
use document_legacy::Operation;
use glam::DAffine2;
use serde::{Deserialize, Serialize};

View file

@ -9,7 +9,7 @@ use crate::messages::tool::common_functionality::snapping::SnapManager;
use crate::messages::tool::utility_types::{EventToMessageMap, Fsm, ToolActionHandlerData, ToolMetadata, ToolTransition, ToolType};
use crate::messages::tool::utility_types::{HintData, HintGroup, HintInfo};
use graphene::intersection::Quad;
use document_legacy::intersection::Quad;
use graphene_std::vector::consts::ManipulatorType;
use glam::DVec2;
@ -151,7 +151,7 @@ impl Fsm for PathToolFsmState {
(_, PathToolMessage::SelectionChanged) => {
// Set the previously selected layers to invisible
for layer_path in document.all_layers() {
tool_data.overlay_renderer.layer_overlay_visibility(&document.graphene_document, layer_path.to_vec(), false, responses);
tool_data.overlay_renderer.layer_overlay_visibility(&document.document_legacy, layer_path.to_vec(), false, responses);
}
// Set the newly targeted layers to visible
@ -159,7 +159,7 @@ impl Fsm for PathToolFsmState {
tool_data.shape_editor.set_selected_layers(layer_paths);
// Render the new overlays
for layer_path in tool_data.shape_editor.selected_layers() {
tool_data.overlay_renderer.render_subpath_overlays(&document.graphene_document, layer_path.to_vec(), responses);
tool_data.overlay_renderer.render_subpath_overlays(&document.document_legacy, layer_path.to_vec(), responses);
}
// This can happen in any state (which is why we return self)
@ -169,7 +169,7 @@ impl Fsm for PathToolFsmState {
// When the document has moved / needs to be redraw, re-render the overlays
// TODO the overlay system should probably receive this message instead of the tool
for layer_path in document.selected_visible_layers() {
tool_data.overlay_renderer.render_subpath_overlays(&document.graphene_document, layer_path.to_vec(), responses);
tool_data.overlay_renderer.render_subpath_overlays(&document.document_legacy, layer_path.to_vec(), responses);
}
self
@ -182,7 +182,7 @@ impl Fsm for PathToolFsmState {
if let Some((mut new_selected, offset)) =
tool_data
.shape_editor
.select_point(&document.graphene_document, input.mouse.position, SELECTION_THRESHOLD, toggle_add_to_selection, responses)
.select_point(&document.document_legacy, input.mouse.position, SELECTION_THRESHOLD, toggle_add_to_selection, responses)
{
responses.push_back(DocumentMessage::StartTransaction.into());
@ -212,7 +212,7 @@ impl Fsm for PathToolFsmState {
let selection_size = DVec2::new(2.0, 2.0);
// Select shapes directly under our mouse
let intersection = document
.graphene_document
.document_legacy
.intersects_quad_root(Quad::from_box([input.mouse.position - selection_size, input.mouse.position + selection_size]), font_cache);
if !intersection.is_empty() {
if toggle_add_to_selection {
@ -277,15 +277,15 @@ impl Fsm for PathToolFsmState {
tool_data.shape_editor.delete_selected_points(responses);
responses.push_back(PathToolMessage::SelectionChanged.into());
for layer_path in document.all_layers() {
tool_data.overlay_renderer.clear_subpath_overlays(&document.graphene_document, layer_path.to_vec(), responses);
tool_data.overlay_renderer.clear_subpath_overlays(&document.document_legacy, layer_path.to_vec(), responses);
}
PathToolFsmState::Ready
}
(_, PathToolMessage::InsertPoint) => {
// First we try and flip the sharpness (if they have clicked on an anchor)
if !tool_data.shape_editor.flip_sharp(&document.graphene_document, input.mouse.position, SELECTION_TOLERANCE, responses) {
if !tool_data.shape_editor.flip_sharp(&document.document_legacy, input.mouse.position, SELECTION_TOLERANCE, responses) {
// If not, then we try and split the path that may have been clicked upon
tool_data.shape_editor.split(&document.graphene_document, input.mouse.position, SELECTION_TOLERANCE, responses);
tool_data.shape_editor.split(&document.document_legacy, input.mouse.position, SELECTION_TOLERANCE, responses);
}
self
@ -293,7 +293,7 @@ impl Fsm for PathToolFsmState {
(_, PathToolMessage::Abort) => {
// TODO Tell overlay manager to remove the overlays
for layer_path in document.all_layers() {
tool_data.overlay_renderer.clear_subpath_overlays(&document.graphene_document, layer_path.to_vec(), responses);
tool_data.overlay_renderer.clear_subpath_overlays(&document.document_legacy, layer_path.to_vec(), responses);
}
PathToolFsmState::Ready
}

View file

@ -9,9 +9,9 @@ use crate::messages::tool::common_functionality::snapping::SnapManager;
use crate::messages::tool::utility_types::{EventToMessageMap, Fsm, ToolActionHandlerData, ToolMetadata, ToolTransition, ToolType};
use crate::messages::tool::utility_types::{HintData, HintGroup, HintInfo};
use graphene::layers::style;
use graphene::LayerId;
use graphene::Operation;
use document_legacy::layers::style;
use document_legacy::LayerId;
use document_legacy::Operation;
use graphene_std::vector::consts::ManipulatorType;
use graphene_std::vector::manipulator_group::ManipulatorGroup;
@ -186,7 +186,7 @@ impl Fsm for PenToolFsmState {
tool_options: &Self::ToolOptions,
responses: &mut VecDeque<Message>,
) -> Self {
let transform = tool_data.path.as_ref().and_then(|path| document.graphene_document.multiply_transforms(path).ok()).unwrap_or_default();
let transform = tool_data.path.as_ref().and_then(|path| document.document_legacy.multiply_transforms(path).ok()).unwrap_or_default();
if let ToolMessage::Pen(event) = event {
match (self, event) {
@ -194,14 +194,14 @@ impl Fsm for PenToolFsmState {
// When the document has moved / needs to be redraw, re-render the overlays
// TODO the overlay system should probably receive this message instead of the tool
for layer_path in document.selected_visible_layers() {
tool_data.overlay_renderer.render_subpath_overlays(&document.graphene_document, layer_path.to_vec(), responses);
tool_data.overlay_renderer.render_subpath_overlays(&document.document_legacy, layer_path.to_vec(), responses);
}
self
}
(_, PenToolMessage::SelectionChanged) => {
// Set the previously selected layers to invisible
for layer_path in document.all_layers() {
tool_data.overlay_renderer.layer_overlay_visibility(&document.graphene_document, layer_path.to_vec(), false, responses);
tool_data.overlay_renderer.layer_overlay_visibility(&document.document_legacy, layer_path.to_vec(), false, responses);
}
self
}
@ -222,7 +222,7 @@ impl Fsm for PenToolFsmState {
// Stop the handles on the first point from mirroring
let mut stop_mirror = || {
let subpath = document.graphene_document.layer(layer).ok().and_then(|layer| layer.as_subpath())?;
let subpath = document.document_legacy.layer(layer).ok().and_then(|layer| layer.as_subpath())?;
let mut manipulator_groups = subpath.manipulator_groups().enumerate();
let (&id, _) = if from_start { manipulator_groups.next()? } else { manipulator_groups.next_back()? };
@ -251,7 +251,7 @@ impl Fsm for PenToolFsmState {
let transform = tool_data
.path
.as_ref()
.and_then(|path| document.graphene_document.multiply_transforms(&path[..path.len() - 1]).ok())
.and_then(|path| document.document_legacy.multiply_transforms(&path[..path.len() - 1]).ok())
.unwrap_or_default();
let snapped_position = tool_data.snap_manager.snap_position(responses, document, input.mouse.position);
let start_position = transform.inverse().transform_point2(snapped_position);
@ -284,7 +284,7 @@ impl Fsm for PenToolFsmState {
let mut check_break = || {
// Get subpath
let layer_path = tool_data.path.as_ref()?;
let subpath = document.graphene_document.layer(layer_path).ok().and_then(|layer| layer.as_subpath())?;
let subpath = document.document_legacy.layer(layer_path).ok().and_then(|layer| layer.as_subpath())?;
// Get the last manipulator group and the one previous to that
let mut manipulator_groups = subpath.manipulator_groups().enumerate();
@ -330,7 +330,7 @@ impl Fsm for PenToolFsmState {
// The overlay system cannot detect deleted points so we must just delete all the overlays
for layer_path in document.all_layers() {
tool_data.overlay_renderer.clear_subpath_overlays(&document.graphene_document, layer_path.to_vec(), responses);
tool_data.overlay_renderer.clear_subpath_overlays(&document.document_legacy, layer_path.to_vec(), responses);
}
tool_data.should_mirror = false;
@ -344,7 +344,7 @@ impl Fsm for PenToolFsmState {
let mut process = || {
// Get subpath
let layer_path = tool_data.path.as_ref()?;
let subpath = document.graphene_document.layer(layer_path).ok().and_then(|layer| layer.as_subpath())?;
let subpath = document.document_legacy.layer(layer_path).ok().and_then(|layer| layer.as_subpath())?;
// Get the last manipulator group and the one previous to that
let mut manipulator_groups = subpath.manipulator_groups().enumerate();
@ -400,7 +400,7 @@ impl Fsm for PenToolFsmState {
// Clean up overlays
for layer_path in document.all_layers() {
tool_data.overlay_renderer.clear_subpath_overlays(&document.graphene_document, layer_path.to_vec(), responses);
tool_data.overlay_renderer.clear_subpath_overlays(&document.document_legacy, layer_path.to_vec(), responses);
}
// Clean up tool data
@ -425,7 +425,7 @@ impl Fsm for PenToolFsmState {
let mut process = || {
// Get subpath
let layer_path = tool_data.path.as_ref()?;
let subpath = document.graphene_document.layer(layer_path).ok().and_then(|layer| layer.as_subpath())?;
let subpath = document.document_legacy.layer(layer_path).ok().and_then(|layer| layer.as_subpath())?;
// Get the last manipulator group
let mut manipulator_groups = subpath.manipulator_groups().enumerate();
@ -487,7 +487,7 @@ impl Fsm for PenToolFsmState {
let mut process = || {
// Get subpath
let layer_path = tool_data.path.as_ref()?;
let subpath = document.graphene_document.layer(layer_path).ok().and_then(|layer| layer.as_subpath())?;
let subpath = document.document_legacy.layer(layer_path).ok().and_then(|layer| layer.as_subpath())?;
// Get the last manipulator group and the one previous to that
let mut manipulator_groups = subpath.manipulator_groups().enumerate();
@ -541,7 +541,7 @@ impl Fsm for PenToolFsmState {
let mut commit = || {
// Get subpath
let layer_path = tool_data.path.as_ref()?;
let subpath = document.graphene_document.layer(layer_path).ok().and_then(|layer| layer.as_subpath())?;
let subpath = document.document_legacy.layer(layer_path).ok().and_then(|layer| layer.as_subpath())?;
// If placing anchor we should abort if there are less than three manipulators (as the last one gets deleted)
if self == PenToolFsmState::PlacingAnchor && subpath.manipulator_groups().len() < 3 {
@ -590,7 +590,7 @@ impl Fsm for PenToolFsmState {
// Clean up overlays
for layer_path in document.all_layers() {
tool_data.overlay_renderer.clear_subpath_overlays(&document.graphene_document, layer_path.to_vec(), responses);
tool_data.overlay_renderer.clear_subpath_overlays(&document.document_legacy, layer_path.to_vec(), responses);
}
tool_data.path = None;
tool_data.snap_manager.cleanup(responses);
@ -600,7 +600,7 @@ impl Fsm for PenToolFsmState {
(_, PenToolMessage::Abort) => {
// Clean up overlays
for layer_path in document.all_layers() {
tool_data.overlay_renderer.clear_subpath_overlays(&document.graphene_document, layer_path.to_vec(), responses);
tool_data.overlay_renderer.clear_subpath_overlays(&document.document_legacy, layer_path.to_vec(), responses);
}
self
}
@ -710,9 +710,9 @@ fn should_extend(document: &DocumentMessageHandler, pos: DVec2, tolerance: f64)
for layer_path in document.selected_layers() {
(|| {
let viewspace = document.graphene_document.generate_transform_relative_to_viewport(layer_path).ok()?;
let viewspace = document.document_legacy.generate_transform_relative_to_viewport(layer_path).ok()?;
let subpath = document.graphene_document.layer(layer_path).ok().and_then(|layer| layer.as_subpath())?;
let subpath = document.document_legacy.layer(layer_path).ok().and_then(|layer| layer.as_subpath())?;
let (_first_id, first) = subpath.manipulator_groups().enumerate().next()?;
let (_last_id, last) = subpath.manipulator_groups().enumerate().next_back()?;

View file

@ -7,8 +7,8 @@ use crate::messages::tool::common_functionality::resize::Resize;
use crate::messages::tool::utility_types::{EventToMessageMap, Fsm, ToolActionHandlerData, ToolMetadata, ToolTransition, ToolType};
use crate::messages::tool::utility_types::{HintData, HintGroup, HintInfo};
use graphene::layers::style;
use graphene::Operation;
use document_legacy::layers::style;
use document_legacy::Operation;
use glam::DAffine2;
use serde::{Deserialize, Serialize};

View file

@ -18,12 +18,12 @@ use crate::messages::tool::common_functionality::transformation_cage::*;
use crate::messages::tool::utility_types::{EventToMessageMap, Fsm, ToolActionHandlerData, ToolMetadata, ToolTransition, ToolType};
use crate::messages::tool::utility_types::{HintData, HintGroup, HintInfo};
use graphene::boolean_ops::BooleanOperation;
use graphene::document::Document;
use graphene::intersection::Quad;
use graphene::layers::layer_info::LayerDataType;
use graphene::LayerId;
use graphene::Operation;
use document_legacy::boolean_ops::BooleanOperation;
use document_legacy::document::Document;
use document_legacy::intersection::Quad;
use document_legacy::layers::layer_info::LayerDataType;
use document_legacy::LayerId;
use document_legacy::Operation;
use glam::{DAffine2, DVec2};
use serde::{Deserialize, Serialize};
@ -415,8 +415,8 @@ impl Fsm for SelectToolFsmState {
let quad = Quad::from_box([mouse_pos - tolerance, mouse_pos + tolerance]);
// Check the last (top most) intersection layer.
if let Some(intersect_layer_path) = document.graphene_document.intersects_quad_root(quad, font_cache).last() {
if let Ok(intersect) = document.graphene_document.layer(intersect_layer_path) {
if let Some(intersect_layer_path) = document.document_legacy.intersects_quad_root(quad, font_cache).last() {
if let Ok(intersect) = document.document_legacy.layer(intersect_layer_path) {
match intersect.data {
LayerDataType::Text(_) => {
responses.push_front(ToolMessage::ActivateTool { tool_type: ToolType::Text }.into());
@ -466,7 +466,7 @@ impl Fsm for SelectToolFsmState {
let mut selected: Vec<_> = document.selected_visible_layers().map(|path| path.to_vec()).collect();
let quad = tool_data.selection_quad();
let mut intersection = document.graphene_document.intersects_quad_root(quad, font_cache);
let mut intersection = document.document_legacy.intersects_quad_root(quad, font_cache);
// If the user is dragging the bounding box bounds, go into ResizingBounds mode.
// If the user is dragging the rotate trigger, go into RotatingBounds mode.
// If the user clicks on a layer that is in their current selection, go into the dragging mode.
@ -489,7 +489,7 @@ impl Fsm for SelectToolFsmState {
tool_data.layers_dragging = selected;
if let Some(bounds) = &mut tool_data.bounding_box_overlays {
let document = &document.graphene_document;
let document = &document.document_legacy;
let selected = &tool_data.layers_dragging.iter().collect::<Vec<_>>();
let mut selected = Selected::new(&mut bounds.original_transforms, &mut bounds.center_of_transformation, selected, responses, document);
@ -500,7 +500,7 @@ impl Fsm for SelectToolFsmState {
} else if rotating_bounds {
if let Some(bounds) = &mut tool_data.bounding_box_overlays {
let selected = selected.iter().collect::<Vec<_>>();
let mut selected = Selected::new(&mut bounds.original_transforms, &mut bounds.center_of_transformation, &selected, responses, &document.graphene_document);
let mut selected = Selected::new(&mut bounds.original_transforms, &mut bounds.center_of_transformation, &selected, responses, &document.document_legacy);
bounds.center_of_transformation = selected.mean_average_of_pivots(font_cache);
}
@ -554,7 +554,7 @@ impl Fsm for SelectToolFsmState {
let snap = tool_data
.layers_dragging
.iter()
.filter_map(|path| document.graphene_document.viewport_bounding_box(path, font_cache).ok()?)
.filter_map(|path| document.document_legacy.viewport_bounding_box(path, font_cache).ok()?)
.flat_map(snapping::expand_bounds)
.collect();
@ -592,7 +592,7 @@ impl Fsm for SelectToolFsmState {
let (delta, mut pivot) = movement.bounds_to_scale_transform(position, size);
let selected = &tool_data.layers_dragging.iter().collect::<Vec<_>>();
let mut selected = Selected::new(&mut bounds.original_transforms, &mut pivot, selected, responses, &document.graphene_document);
let mut selected = Selected::new(&mut bounds.original_transforms, &mut pivot, selected, responses, &document.document_legacy);
selected.update_transforms(delta);
}
@ -618,7 +618,7 @@ impl Fsm for SelectToolFsmState {
let delta = DAffine2::from_angle(snapped_angle);
let selected = tool_data.layers_dragging.iter().collect::<Vec<_>>();
let mut selected = Selected::new(&mut bounds.original_transforms, &mut bounds.center_of_transformation, &selected, responses, &document.graphene_document);
let mut selected = Selected::new(&mut bounds.original_transforms, &mut bounds.center_of_transformation, &selected, responses, &document.document_legacy);
selected.update_transforms(delta);
}
@ -703,7 +703,7 @@ impl Fsm for SelectToolFsmState {
let quad = tool_data.selection_quad();
responses.push_front(
DocumentMessage::AddSelectedLayers {
additional_layers: document.graphene_document.intersects_quad_root(quad, font_cache),
additional_layers: document.document_legacy.intersects_quad_root(quad, font_cache),
}
.into(),
);
@ -738,7 +738,7 @@ impl Fsm for SelectToolFsmState {
&mut bounding_box_overlays.opposite_pivot,
&selected,
responses,
&document.graphene_document,
&document.document_legacy,
);
selected.revert_operation();
@ -947,7 +947,7 @@ impl SelectToolData {
// Copy the layers.
// Not using the Copy message allows us to retrieve the ids of the new layers to initialize the drag.
let layer = match document.graphene_document.layer(layer_path) {
let layer = match document.document_legacy.layer(layer_path) {
Ok(layer) => layer.clone(),
Err(e) => {
warn!("Could not access selected layer {:?}: {:?}", layer_path, e);

View file

@ -8,8 +8,8 @@ use crate::messages::tool::common_functionality::resize::Resize;
use crate::messages::tool::utility_types::{EventToMessageMap, Fsm, ToolActionHandlerData, ToolMetadata, ToolTransition, ToolType};
use crate::messages::tool::utility_types::{HintData, HintGroup, HintInfo};
use graphene::layers::style;
use graphene::Operation;
use document_legacy::layers::style;
use document_legacy::Operation;
use glam::DAffine2;
use serde::{Deserialize, Serialize};

View file

@ -8,9 +8,9 @@ use crate::messages::tool::common_functionality::snapping::SnapManager;
use crate::messages::tool::utility_types::{DocumentToolData, EventToMessageMap, Fsm, ToolActionHandlerData, ToolMetadata, ToolTransition, ToolType};
use crate::messages::tool::utility_types::{HintData, HintGroup, HintInfo};
use graphene::layers::style;
use graphene::LayerId;
use graphene::Operation;
use document_legacy::layers::style;
use document_legacy::LayerId;
use document_legacy::Operation;
use glam::{DAffine2, DVec2};
use serde::{Deserialize, Serialize};
@ -177,7 +177,7 @@ impl Fsm for SplineToolFsmState {
use SplineToolFsmState::*;
use SplineToolMessage::*;
let transform = document.graphene_document.root.transform;
let transform = document.document_legacy.root.transform;
if let ToolMessage::Spline(event) = event {
match (self, event) {

View file

@ -10,11 +10,11 @@ use crate::messages::prelude::*;
use crate::messages::tool::utility_types::{EventToMessageMap, Fsm, ToolActionHandlerData, ToolMetadata, ToolTransition, ToolType};
use crate::messages::tool::utility_types::{HintData, HintGroup, HintInfo};
use graphene::intersection::Quad;
use graphene::layers::style::{self, Fill, Stroke};
use graphene::layers::text_layer::FontCache;
use graphene::LayerId;
use graphene::Operation;
use document_legacy::intersection::Quad;
use document_legacy::layers::style::{self, Fill, Stroke};
use document_legacy::layers::text_layer::FontCache;
use document_legacy::LayerId;
use document_legacy::Operation;
use glam::{DAffine2, DVec2};
use serde::{Deserialize, Serialize};
@ -246,10 +246,10 @@ fn update_overlays(document: &DocumentMessageHandler, tool_data: &mut TextToolDa
.zip(&tool_data.overlays)
.filter_map(|(layer_path, overlay_path)| {
document
.graphene_document
.document_legacy
.layer(layer_path)
.unwrap()
.aabb_for_transform(document.graphene_document.multiply_transforms(layer_path).unwrap(), font_cache)
.aabb_for_transform(document.document_legacy.multiply_transforms(layer_path).unwrap(), font_cache)
.map(|bounds| (bounds, overlay_path))
})
.collect::<Vec<_>>();
@ -294,10 +294,10 @@ impl Fsm for TextToolFsmState {
let quad = Quad::from_box([mouse_pos - tolerance, mouse_pos + tolerance]);
let new_state = if let Some(l) = document
.graphene_document
.document_legacy
.intersects_quad_root(quad, font_cache)
.last()
.filter(|l| document.graphene_document.layer(l).map(|l| l.as_text().is_ok()).unwrap_or(false))
.filter(|l| document.document_legacy.layer(l).map(|l| l.as_text().is_ok()).unwrap_or(false))
// Editing existing text
{
if state == TextToolFsmState::Editing {
@ -433,10 +433,10 @@ impl Fsm for TextToolFsmState {
}
(Editing, UpdateBounds { new_text }) => {
resize_overlays(&mut tool_data.overlays, responses, 1);
let text = document.graphene_document.layer(&tool_data.path).unwrap().as_text().unwrap();
let text = document.document_legacy.layer(&tool_data.path).unwrap().as_text().unwrap();
let quad = text.bounding_box(&new_text, text.load_face(font_cache));
let transformed_quad = document.graphene_document.multiply_transforms(&tool_data.path).unwrap() * quad;
let transformed_quad = document.document_legacy.multiply_transforms(&tool_data.path).unwrap() * quad;
let bounds = transformed_quad.bounding_box();
let operation = Operation::SetLayerTransformInViewport {

View file

@ -10,8 +10,8 @@ use crate::messages::layout::utility_types::widgets::input_widgets::SwatchPairIn
use crate::messages::layout::utility_types::widgets::label_widgets::{Separator, SeparatorDirection, SeparatorType};
use crate::messages::prelude::*;
use graphene::color::Color;
use graphene::layers::text_layer::FontCache;
use document_legacy::color::Color;
use document_legacy::layers::text_layer::FontCache;
use serde::{Deserialize, Serialize};
use std::fmt::{self, Debug};

View file

@ -6,7 +6,7 @@ use crate::messages::portfolio::utility_types::Platform;
use crate::messages::prelude::*;
use crate::messages::tool::utility_types::ToolType;
use graphene::color::Color;
use document_legacy::color::Color;
/// A set of utility functions to make the writing of editor test more declarative
pub trait EditorTestUtils {

View file

@ -0,0 +1 @@
This file exists just so Git keeps this directory.

View file

@ -3,7 +3,7 @@
"build": {
"beforeBuildCommand": "npm run build",
"beforeDevCommand": "npm start",
"distDir": "../dist",
"distDir": "../dist-tauri",
"devPath": "http://127.0.0.1:8080"
},
"package": {

View file

@ -23,7 +23,7 @@ module.exports = {
crateDirectory: path.resolve(__dirname, "wasm"),
// Remove when this issue is resolved: https://github.com/wasm-tool/wasm-pack-plugin/issues/93
outDir: path.resolve(__dirname, "wasm/pkg"),
watchDirectories: ["../editor", "../graphene", "../proc-macros", "../node-graph"].map((folder) => path.resolve(__dirname, folder)),
watchDirectories: ["../editor", "../document-legacy", "../proc-macros", "../node-graph"].map((folder) => path.resolve(__dirname, folder)),
})
)
.end();

View file

@ -19,7 +19,7 @@ crate-type = ["cdylib", "rlib"]
[dependencies]
editor = { path = "../../editor", package = "graphite-editor" }
graphene = { path = "../../graphene", package = "graphite-graphene" }
document-legacy = { path = "../../document-legacy", package = "graphite-document-legacy" }
graph-craft = { path = "../../node-graph/graph-craft" }
log = "0.4"
serde = { version = "1.0", features = ["derive"] }

View file

@ -5,6 +5,8 @@
use crate::helpers::{translate_key, Error};
use crate::{EDITOR_HAS_CRASHED, EDITOR_INSTANCES, JS_EDITOR_HANDLES};
use document_legacy::color::Color;
use document_legacy::LayerId;
use editor::application::generate_uuid;
use editor::application::Editor;
use editor::consts::{FILE_SAVE_SUFFIX, GRAPHITE_DOCUMENT_VERSION};
@ -13,8 +15,6 @@ use editor::messages::input_mapper::utility_types::input_mouse::{EditorMouseStat
use editor::messages::portfolio::utility_types::{ImaginateServerStatus, Platform};
use editor::messages::prelude::*;
use graph_craft::document::NodeId;
use graphene::color::Color;
use graphene::LayerId;
use serde::Serialize;
use serde_wasm_bindgen::{self, from_value};
@ -159,7 +159,7 @@ impl JsEditorHandle {
}
#[wasm_bindgen(js_name = tauriResponse)]
pub fn tauri_response(&self, message: JsValue) {
pub fn tauri_response(&self, _message: JsValue) {
#[cfg(feature = "tauri")]
match ron::from_str::<Vec<FrontendMessage>>(&message.as_string().unwrap()) {
Ok(response) => {

View file

@ -11,8 +11,6 @@ use std::{
};
use storage_map::{StorageMap, StorageMapGuard};
use graphene_api::{DynamicInput, Node};
/// Caches the output of a given Node and acts as a proxy
/// Automatically resets if it receives different input
pub struct SmartCacheNode<'n, 'c, NODE: Node + 'c> {
@ -30,9 +28,10 @@ where
input.borrow().hash(&mut hasher);
let hash = hasher.finish();
self.map.get_or_create_with(&hash, ||{
self.map.get_or_create_with(&hash, || {
trace!("Creating new cache node");
CacheNode::new(self.node)})
CacheNode::new(self.node)
})
}
}

View file

@ -66,19 +66,19 @@ The Graphite Editor is built as a web app powered by Vue.js in the frontend and
The Editor's frontend web code lives in `/frontend/src` and the backend Rust code lives in `/editor`. The web-based frontend is intended to be semi-temporary and eventually replaceable with a pure-Rust GUI frontend. Therefore, all backend code should be unaware of JavaScript or web concepts and all Editor application logic should be written in Rust not JS.
### Frontend/backend communication
### Frontend/backend communication.
Frontend (JS) -> backend (Rust/wasm) communication is achieved through a thin Rust translation layer in `/frontend/wasm/editor_api.rs` which wraps the Editor backend's complex Rust data type API and provides the JS with a simpler API of callable functions. These wrapper functions are compiled by wasm-bindgen into autogenerated JS functions that serve as an entry point into the wasm.
Backend (Rust) -> frontend (JS) communication happens by sending a queue of messages to the frontend message dispatcher. After the JS calls any wrapper API function to get into backend (Rust) code execution, the Editor's business logic runs and queues up `FrontendMessage`s (defined in `editor/src/frontend/frontend_message_handler.rs`) which get mapped from Rust to JS-friendly data types in `frontend/src/dispatcher/js-messages.ts`. Various JS code subscribes to these messages by calling `subscribeJsMessage(MessageName, (messageData) => { /* callback code */ });`.
### Editor backend and Graphene modules
### The Editor backend and Legacy Document modules.
The Graphite Editor backend handles all the day-to-day logic and responsibilities of a user-facing interactive application. Some duties include: user input, GUI state management, viewport tool behavior, layer management and selection, and handling of multiple document tabs.
The actual document (the artwork data and layers included in a saved `.graphite` file) is part of another core module located in `/graphene`. Graphene manages a document and will grow into the codebase for the full node graph system in the future. While it's OK for the Editor to read data from, or make immutable function calls upon, the Graphene document, it should never be directly mutated. Instead, messages (called Operations) should be sent to the Graphene document to request changes occur. Graphene is designed to be used by the Editor or by third-party Rust or C/C++ code directly so a careful separation of concerns between the Editor and Graphene should be considered.
The actual document (the artwork data and layers included in a saved `.graphite` file) is part of another core module located in `/document-legacy`. The (soon-to-be-replaced) Legacy Document codebase manages a user's document. Once it is replaced, the new Document module (that will be located in `/document`) will store a document's node graph and change history. While it's OK for the Editor to read data from—or make immutable function calls upon—the user's document controlled by the Legacy Document module, it should never be directly mutated. Instead, messages (called Operations) should be sent to the document to request changes occur. The Legacy Document code is designed to be used by the Editor or by third-party Rust or C/C++ code directly so a careful separation of concerns between the Editor and Legacy Document modules should be considered.
### The message bus
### The message bus.
Every part of the Graphite stack works based on the concept of message passing. Messages are pushed to the front or back of a queue and each one is processed by the module's dispatcher in the order encountered. Only the dispatcher owns a mutable reference to update its module's state.
@ -92,7 +92,7 @@ Because this is cumbersome, we have a proc macro `#[child]` that automatically i
</details>
## Debugging
## Debugging.
Use the browser console (<kbd>F12</kbd>) to check for warnings and errors. Use the Rust macro `debug!("A debug message")` to print to the browser console. These statements should be for temporary debugging. Remove them before committing to master. Print-based debugging is necessary because breakpoints are not supported in WebAssembly.
@ -108,7 +108,7 @@ To also view logs of the messages dispatched by the message bus system, activate
## Contributing guide.
### Code style
### Code style.
The Graphite project highly values code quality and accessibility to new contributors. Therefore, please make an effort to make your code readable and well-documented.
@ -121,7 +121,7 @@ The Graphite project highly values code quality and accessibility to new contrib
- **Imports:**
At the top of Rust files, please follow the convention of separating imports into three blocks, in this order:
1. Local (`use super::` and `use crate::`)
2. First-party crates (e.g. `use graphene::`)
2. First-party crates (e.g. `use editor::`)
3. Third-party libraries (e.g. `use std::` or `use serde::`)
Combine related imports with common paths at the same depth. For example, the lines `use crate::A::B::C;`, `use crate::A::B::C::Foo;`, and `use crate::A::B::C::Bar;` should be combined into `use crate::A::B::C::{self, Foo, Bar};`. But do not combine imports at mixed path depths. For example, `use crate::A::{B::C::Foo, X::Hello};` should be split into two separate import lines. In simpler terms, avoid putting a `::` inside `{}`.
@ -131,7 +131,7 @@ The Graphite project highly values code quality and accessibility to new contrib
Additional best practices will be added here soon. Please ask @Keavon in the mean time.
### Draft pull requests
### Draft pull requests.
Once you begin writing code, please open a pull request immediately and mark it as a **Draft**. Please push to this on a frequent basis, even if things don't compile or work fully yet. It's very helpful to have your work-in-progress code up on GitHub so the status of your feature is less of a mystery.