mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-23 07:18:12 +08:00
Rename the legacy Graphene crate to document-legacy (#899)
* Rename /graphene to /document-legacy * Update names in code
This commit is contained in:
@@ -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
|
||||
|
||||
+13
-13
@@ -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();
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)]
|
||||
|
||||
@@ -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};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use graphene::LayerId;
|
||||
use document_legacy::LayerId;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(PartialEq, Eq, Clone, Debug, Serialize, Deserialize)]
|
||||
|
||||
@@ -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};
|
||||
|
||||
@@ -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};
|
||||
|
||||
|
||||
@@ -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(),
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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};
|
||||
|
||||
@@ -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};
|
||||
|
||||
|
||||
@@ -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(),
|
||||
);
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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};
|
||||
|
||||
@@ -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>,
|
||||
|
||||
@@ -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>,
|
||||
}
|
||||
|
||||
+2
-2
@@ -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],
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -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);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::messages::prelude::*;
|
||||
|
||||
use graphene::Operation as DocumentOperation;
|
||||
use document_legacy::Operation as DocumentOperation;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
|
||||
@@ -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("")
|
||||
},
|
||||
|
||||
@@ -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};
|
||||
|
||||
|
||||
+2
-2
@@ -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};
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
+3
-3
@@ -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 {
|
||||
|
||||
@@ -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};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use graphene::color::Color;
|
||||
use graphene::DocumentError;
|
||||
use document_legacy::color::Color;
|
||||
use document_legacy::DocumentError;
|
||||
|
||||
use thiserror::Error;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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};
|
||||
|
||||
@@ -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};
|
||||
|
||||
|
||||
@@ -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 }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use graphene::layers::text_layer::FontCache;
|
||||
use document_legacy::layers::text_layer::FontCache;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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};
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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};
|
||||
|
||||
|
||||
@@ -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};
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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};
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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};
|
||||
|
||||
@@ -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};
|
||||
|
||||
@@ -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};
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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()?;
|
||||
|
||||
|
||||
@@ -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};
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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};
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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};
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user