mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-27 12:38:12 +08:00
Fix artboard thumbnails (#1342)
* Fix artboard thumbnails * Use GraphIdentifier instead of option * Fix warnings introduced by artboard nodes
This commit is contained in:
@@ -24,11 +24,6 @@ impl MessageHandler<InputPreprocessorMessage, KeyboardPlatformLayout> for InputP
|
||||
assert_eq!(bounds_of_viewports.len(), 1, "Only one viewport is currently supported");
|
||||
|
||||
for bounds in bounds_of_viewports {
|
||||
let new_size = bounds.size();
|
||||
let existing_size = self.viewport_bounds.size();
|
||||
|
||||
let translation = ((new_size - existing_size) / 2.).round();
|
||||
|
||||
// TODO: Extend this to multiple viewports instead of setting it to the value of this last loop iteration
|
||||
self.viewport_bounds = bounds;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ use crate::messages::portfolio::utility_types::PersistentData;
|
||||
use crate::messages::prelude::*;
|
||||
|
||||
use document_legacy::document::Document as DocumentLegacy;
|
||||
use document_legacy::layers::style::{self, Fill, RenderData, ViewMode};
|
||||
use document_legacy::layers::style::{self, Fill};
|
||||
use document_legacy::DocumentResponse;
|
||||
use document_legacy::LayerId;
|
||||
use document_legacy::Operation as DocumentOperation;
|
||||
@@ -20,7 +20,7 @@ pub struct ArtboardMessageHandler {
|
||||
|
||||
impl MessageHandler<ArtboardMessage, &PersistentData> for ArtboardMessageHandler {
|
||||
#[remain::check]
|
||||
fn process_message(&mut self, message: ArtboardMessage, responses: &mut VecDeque<Message>, persistent_data: &PersistentData) {
|
||||
fn process_message(&mut self, message: ArtboardMessage, responses: &mut VecDeque<Message>, _persistent_data: &PersistentData) {
|
||||
use ArtboardMessage::*;
|
||||
|
||||
#[remain::sorted]
|
||||
|
||||
@@ -201,7 +201,7 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
|
||||
#[remain::unsorted]
|
||||
PropertiesPanel(message) => {
|
||||
let properties_panel_message_handler_data = PropertiesPanelMessageHandlerData {
|
||||
document_name: &self.name.as_str(),
|
||||
document_name: self.name.as_str(),
|
||||
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())),
|
||||
|
||||
+3
-18
@@ -80,19 +80,6 @@ impl<'a> ModifyInputsContext<'a> {
|
||||
Some(id)
|
||||
}
|
||||
|
||||
pub fn insert_layer_below(&mut self, node_id: NodeId, input_index: usize) -> Option<NodeId> {
|
||||
let layer_node = resolve_document_node_type("Layer").expect("Layer node");
|
||||
|
||||
let new_id = generate_uuid();
|
||||
let post_node = self.network.nodes.get_mut(&node_id)?;
|
||||
post_node.inputs[input_index] = NodeInput::node(new_id, 0);
|
||||
let document_node = layer_node.to_document_node_default_inputs([], DocumentNodeMetadata::position(post_node.metadata.position + IVec2::new(0, 2)));
|
||||
|
||||
self.network.nodes.insert(new_id, document_node);
|
||||
|
||||
Some(new_id)
|
||||
}
|
||||
|
||||
pub fn insert_node_before(&mut self, new_id: NodeId, node_id: NodeId, input_index: usize, mut document_node: DocumentNode, offset: IVec2) -> Option<NodeId> {
|
||||
let post_node = self.network.nodes.get_mut(&node_id)?;
|
||||
|
||||
@@ -109,7 +96,7 @@ impl<'a> ModifyInputsContext<'a> {
|
||||
let mut current_input = &self.network.nodes.get(¤t_node)?.inputs[input_index];
|
||||
|
||||
while let NodeInput::Node { node_id, output_index, .. } = current_input {
|
||||
let mut sibling_node = &self.network.nodes.get(node_id)?;
|
||||
let sibling_node = &self.network.nodes.get(node_id)?;
|
||||
if sibling_node.name == "Layer" {
|
||||
current_node = *node_id;
|
||||
input_index = 7;
|
||||
@@ -148,7 +135,7 @@ impl<'a> ModifyInputsContext<'a> {
|
||||
fn shift_upstream(&mut self, node_id: NodeId, shift: IVec2) {
|
||||
let mut shift_nodes = HashSet::new();
|
||||
let mut stack = vec![node_id];
|
||||
while let Some(node) = stack.pop() {
|
||||
while let Some(node_id) = stack.pop() {
|
||||
let Some(node) = self.network.nodes.get(&node_id) else { continue };
|
||||
for input in &node.inputs {
|
||||
let NodeInput::Node { node_id, .. } = input else { continue };
|
||||
@@ -477,12 +464,10 @@ impl MessageHandler<GraphOperationMessage, (&mut Document, &mut NodeGraphMessage
|
||||
if let Some(layer) = modify_inputs.create_layer(id, modify_inputs.network.outputs[0].node_id) {
|
||||
modify_inputs.insert_artboard(artboard, layer);
|
||||
}
|
||||
|
||||
//modify_inputs.brush_modify(strokes);
|
||||
}
|
||||
GraphOperationMessage::ResizeArtboard { id, location, dimensions } => {
|
||||
let mut modify_inputs = ModifyInputsContext::new_doc(document, node_graph, responses);
|
||||
if let Some(layer) = modify_inputs.locate_layer(id) {
|
||||
if modify_inputs.locate_layer(id).is_some() {
|
||||
modify_inputs.resize_artboard(location, dimensions);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ pub use self::document_node_types::*;
|
||||
use crate::messages::input_mapper::utility_types::macros::action_keys;
|
||||
use crate::messages::layout::utility_types::widget_prelude::*;
|
||||
use crate::messages::prelude::*;
|
||||
use crate::node_graph_executor::NodeGraphExecutor;
|
||||
use crate::node_graph_executor::{GraphIdentifier, NodeGraphExecutor};
|
||||
|
||||
use document_legacy::document::Document;
|
||||
use document_legacy::LayerId;
|
||||
@@ -347,10 +347,8 @@ impl NodeGraphMessageHandler {
|
||||
})
|
||||
.collect();
|
||||
|
||||
let thumbnail_svg = layer_id
|
||||
.and_then(|layer_id| executor.thumbnails.get(&layer_id))
|
||||
.and_then(|layer| layer.get(id))
|
||||
.map(|svg| svg.to_string());
|
||||
let graph_identifier = GraphIdentifier::new(layer_id);
|
||||
let thumbnail_svg = executor.thumbnails.get(&graph_identifier).and_then(|thumbnails| thumbnails.get(id)).map(|svg| svg.to_string());
|
||||
|
||||
nodes.push(FrontendNode {
|
||||
id: *id,
|
||||
|
||||
@@ -12,7 +12,7 @@ use crate::messages::prelude::*;
|
||||
use crate::node_graph_executor::NodeGraphExecutor;
|
||||
|
||||
use document_legacy::document::Document;
|
||||
use document_legacy::layers::layer_info::{Layer, LayerDataType, LayerDataTypeDiscriminant};
|
||||
use document_legacy::layers::layer_info::{Layer, LayerDataType};
|
||||
use document_legacy::layers::style::{Fill, Gradient, GradientType, LineCap, LineJoin, RenderData, Stroke, ViewMode};
|
||||
use graphene_core::raster::color::Color;
|
||||
|
||||
|
||||
@@ -482,8 +482,8 @@ impl MessageHandler<PortfolioMessage, (&InputPreprocessorMessageHandler, &Prefer
|
||||
blob_url,
|
||||
resolution,
|
||||
} => {
|
||||
if let (Some(layer_id), Some(node_id)) = (layer_path.last().copied(), node_id) {
|
||||
self.executor.insert_thumbnail_blob_url(blob_url, layer_id, node_id, responses);
|
||||
if let Some(node_id) = node_id {
|
||||
self.executor.insert_thumbnail_blob_url(blob_url, layer_path.last().copied(), node_id, responses);
|
||||
return;
|
||||
}
|
||||
let message = DocumentMessage::SetImageBlobUrl {
|
||||
|
||||
Reference in New Issue
Block a user