Skip to content

Retire layer paths used throughout the code #1531

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions editor/src/dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ const SIDE_EFFECT_FREE_MESSAGES: &[MessageDiscriminant] = &[
PropertiesPanelMessageDiscriminant::Refresh,
))),
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::Document(DocumentMessageDiscriminant::DocumentStructureChanged)),
MessageDiscriminant::Frontend(FrontendMessageDiscriminant::UpdateDocumentLayerTreeStructure),
MessageDiscriminant::Frontend(FrontendMessageDiscriminant::UpdateDocumentLayerStructure),
MessageDiscriminant::Frontend(FrontendMessageDiscriminant::TriggerFontLoad),
MessageDiscriminant::Broadcast(BroadcastMessageDiscriminant::TriggerEvent(BroadcastEventDiscriminant::DocumentIsDirty)),
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::Document(DocumentMessageDiscriminant::InputFrameRasterizeRegionBelowLayer)),
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::Document(DocumentMessageDiscriminant::Overlays(OverlaysMessageDiscriminant::Draw))),
];

Expand Down Expand Up @@ -262,6 +261,7 @@ mod test {
use crate::messages::tool::tool_messages::tool_prelude::ToolType;
use crate::test_utils::EditorTestUtils;

use graph_craft::document::NodeId;
use graphene_core::raster::color::Color;

fn init_logger() {
Expand Down Expand Up @@ -359,7 +359,7 @@ mod test {
fn copy_paste_folder() {
let mut editor = create_editor_with_three_layers();

const FOLDER_ID: u64 = 3;
const FOLDER_ID: NodeId = 3;

editor.handle_message(GraphOperationMessage::NewCustomLayer {
id: FOLDER_ID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl LayoutHolder for ExportDialogMessageHandler {
NumberInput::new(Some(self.scale_factor))
.unit("")
.min(0.)
.max((1u64 << std::f64::MANTISSA_DIGITS) as f64)
.max((1_u64 << std::f64::MANTISSA_DIGITS) as f64)
.disabled(self.file_type == FileType::Svg)
.on_update(|number_input: &NumberInput| ExportDialogMessage::ScaleFactor(number_input.value.unwrap()).into())
.min_width(200)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl LayoutHolder for NewDocumentDialogMessageHandler {
.label("W")
.unit(" px")
.min(0.)
.max((1u64 << std::f64::MANTISSA_DIGITS) as f64)
.max((1_u64 << std::f64::MANTISSA_DIGITS) as f64)
.is_integer(true)
.disabled(self.infinite)
.min_width(100)
Expand All @@ -106,7 +106,7 @@ impl LayoutHolder for NewDocumentDialogMessageHandler {
.label("H")
.unit(" px")
.min(0.)
.max((1u64 << std::f64::MANTISSA_DIGITS) as f64)
.max((1_u64 << std::f64::MANTISSA_DIGITS) as f64)
.is_integer(true)
.disabled(self.infinite)
.min_width(100)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl PreferencesDialogMessageHandler {
NumberInput::new(Some(preferences.imaginate_refresh_frequency))
.unit(" seconds")
.min(0.)
.max((1u64 << std::f64::MANTISSA_DIGITS) as f64)
.max((1_u64 << std::f64::MANTISSA_DIGITS) as f64)
.min_width(200)
.on_update(|number_input: &NumberInput| PreferencesMessage::ImaginateRefreshFrequency { seconds: number_input.value.unwrap() }.into())
.widget_holder(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::messages::prelude::*;
/// A dialog for confirming the closing a document with unsaved changes.
pub struct CloseDocumentDialog {
pub document_name: String,
pub document_id: u64,
pub document_id: DocumentId,
}

impl DialogLayoutHolder for CloseDocumentDialog {
Expand Down
10 changes: 5 additions & 5 deletions editor/src/messages/frontend/frontend_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ pub enum FrontendMessage {
TriggerImport,
TriggerIndexedDbRemoveDocument {
#[serde(rename = "documentId")]
document_id: u64,
document_id: DocumentId,
},
TriggerIndexedDbWriteDocument {
document: String,
Expand Down Expand Up @@ -111,7 +111,7 @@ pub enum FrontendMessage {
// Update prefix: give the frontend a new value or state for it to use
UpdateActiveDocument {
#[serde(rename = "documentId")]
document_id: u64,
document_id: DocumentId,
},
UpdateDialogButtons {
#[serde(rename = "layoutTarget")]
Expand Down Expand Up @@ -139,11 +139,11 @@ pub enum FrontendMessage {
UpdateDocumentLayerDetails {
data: LayerPanelEntry,
},
UpdateDocumentLayerTreeStructure {
UpdateDocumentLayerStructure {
#[serde(rename = "dataBuffer")]
data_buffer: RawBuffer,
},
UpdateDocumentLayerTreeStructureJs {
UpdateDocumentLayerStructureJs {
#[serde(rename = "dataBuffer")]
data_buffer: JsRawBuffer,
},
Expand Down Expand Up @@ -180,7 +180,7 @@ pub enum FrontendMessage {
},
UpdateImageData {
#[serde(rename = "documentId")]
document_id: u64,
document_id: DocumentId,
#[serde(rename = "imageData")]
image_data: Vec<FrontendImageData>,
},
Expand Down
8 changes: 2 additions & 6 deletions editor/src/messages/frontend/utility_types.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::messages::portfolio::document::utility_types::document_metadata::LayerNodeIdentifier;
use crate::messages::portfolio::document::utility_types::LayerId;
use crate::messages::prelude::*;

use serde::{Deserialize, Serialize};

Expand All @@ -10,18 +10,14 @@ pub struct FrontendDocumentDetails {
#[serde(rename = "isSaved")]
pub is_saved: bool,
pub name: String,
pub id: u64,
pub id: DocumentId,
}

#[derive(PartialEq, Clone, Debug, Serialize, Deserialize, specta::Type)]
pub struct FrontendImageData {
pub path: Vec<LayerId>,
pub mime: String,
#[serde(skip)]
pub image_data: std::sync::Arc<Vec<u8>>,
pub transform: Option<[f64; 6]>,
#[serde(rename = "nodeId")]
pub node_id: Option<graph_craft::document::NodeId>,
}

#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Serialize, Deserialize, specta::Type)]
Expand Down
20 changes: 5 additions & 15 deletions editor/src/messages/portfolio/document/document_message.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::messages::input_mapper::utility_types::input_keyboard::Key;
use crate::messages::portfolio::document::utility_types::document_metadata::LayerNodeIdentifier;
use crate::messages::portfolio::document::utility_types::misc::{AlignAggregate, AlignAxis, FlipAxis};
use crate::messages::portfolio::document::utility_types::LayerId;
use crate::messages::prelude::*;

use graph_craft::document::{NodeId, NodeNetwork};
Expand Down Expand Up @@ -42,14 +41,14 @@ pub enum DocumentMessage {
BackupDocument {
network: NodeNetwork,
},
ClearLayerTree,
ClearLayersPanel,
CommitTransaction,
CreateEmptyFolder {
parent: LayerNodeIdentifier,
},
DebugPrintDocument,
DeleteLayer {
layer_path: Vec<LayerId>,
id: NodeId,
},
DeleteSelectedLayers,
DeselectAllLayers,
Expand All @@ -61,20 +60,11 @@ pub enum DocumentMessage {
flip_axis: FlipAxis,
},
GroupSelectedLayers,
ImaginateClear {
layer_path: Vec<LayerId>,
},
ImaginateGenerate {
layer_path: Vec<LayerId>,
},
ImaginateGenerate,
ImaginateRandom {
layer_path: Vec<LayerId>,
imaginate_node: Vec<NodeId>,
then_generate: bool,
},
InputFrameRasterizeRegionBelowLayer {
layer_path: Vec<LayerId>,
},
MoveSelectedLayersTo {
parent: LayerNodeIdentifier,
insert_index: isize,
Expand Down Expand Up @@ -106,7 +96,7 @@ pub enum DocumentMessage {
relative_index_offset: isize,
},
SelectLayer {
layer_path: Vec<LayerId>,
id: NodeId,
ctrl: bool,
shift: bool,
},
Expand All @@ -132,7 +122,7 @@ pub enum DocumentMessage {
},
StartTransaction,
ToggleLayerExpansion {
layer: NodeId,
id: NodeId,
},
Undo,
UndoFinished,
Expand Down
Loading