mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-08-03 21:08:18 +00:00
Automatic graph popup on Node Graph Frame layer (#890)
Automatic Node Graph Frame Popup
This commit is contained in:
parent
2732492307
commit
520c9dfec0
5 changed files with 25 additions and 73 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -905,7 +905,6 @@ dependencies = [
|
|||
name = "dyn-any-derive"
|
||||
version = "0.2.1"
|
||||
dependencies = [
|
||||
"dyn-any",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
|
|
|
@ -1297,7 +1297,12 @@ impl DocumentMessageHandler {
|
|||
responses.push_back(BroadcastEvent::SelectionChanged.into());
|
||||
}
|
||||
|
||||
// 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 layer_metadata = std::mem::replace(&mut self.layer_metadata, layer_metadata);
|
||||
self.document_redo_history.push_back((document, layer_metadata));
|
||||
if self.document_redo_history.len() > crate::consts::MAX_UNDO_HISTORY_LEN {
|
||||
|
@ -1330,7 +1335,12 @@ impl DocumentMessageHandler {
|
|||
responses.push_back(BroadcastEvent::SelectionChanged.into());
|
||||
}
|
||||
|
||||
// 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 layer_metadata = std::mem::replace(&mut self.layer_metadata, layer_metadata);
|
||||
self.document_undo_history.push_back((document, layer_metadata));
|
||||
if self.document_undo_history.len() > crate::consts::MAX_UNDO_HISTORY_LEN {
|
||||
|
|
|
@ -7,6 +7,7 @@ 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 serde::{Deserialize, Serialize};
|
||||
|
@ -39,9 +40,20 @@ impl<'a> MessageHandler<PropertiesPanelMessage, (&PersistentData, PropertiesPane
|
|||
} else {
|
||||
let path = paths.into_iter().next().unwrap();
|
||||
if Some((path.clone(), document)) != self.active_selection {
|
||||
// Update the node graph frame visibility
|
||||
if get_document(document)
|
||||
.layer(&path)
|
||||
.ok()
|
||||
.filter(|layer| LayerDataTypeDiscriminant::from(&layer.data) == LayerDataTypeDiscriminant::NodeGraphFrame)
|
||||
.is_some()
|
||||
{
|
||||
responses.push_back(NodeGraphMessage::OpenNodeGraph { layer_path: path.clone() }.into());
|
||||
} else {
|
||||
responses.push_back(NodeGraphMessage::CloseNodeGraph.into());
|
||||
}
|
||||
|
||||
self.active_selection = Some((path, document));
|
||||
responses.push_back(PropertiesPanelMessage::ResendActiveProperties.into());
|
||||
responses.push_back(NodeGraphMessage::CloseNodeGraph.into());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -60,6 +72,7 @@ impl<'a> MessageHandler<PropertiesPanelMessage, (&PersistentData, PropertiesPane
|
|||
}
|
||||
.into(),
|
||||
);
|
||||
responses.push_back(NodeGraphMessage::CloseNodeGraph.into());
|
||||
self.active_selection = None;
|
||||
}
|
||||
Deactivate => responses.push_back(
|
||||
|
|
|
@ -12,7 +12,6 @@ use crate::messages::prelude::*;
|
|||
use graphene::color::Color;
|
||||
use graphene::document::Document;
|
||||
use graphene::layers::layer_info::{Layer, LayerDataType, LayerDataTypeDiscriminant};
|
||||
use graphene::layers::nodegraph_layer::NodeGraphFrameLayer;
|
||||
use graphene::layers::style::{Fill, Gradient, GradientType, LineCap, LineJoin, Stroke};
|
||||
use graphene::layers::text_layer::{FontCache, TextLayer};
|
||||
|
||||
|
@ -295,10 +294,7 @@ pub fn register_artwork_layer_properties(
|
|||
let is_graph_open = node_graph_message_handler.layer_path.as_ref().filter(|node_graph| *node_graph == &layer_path).is_some();
|
||||
let selected_nodes = &node_graph_message_handler.selected_nodes;
|
||||
|
||||
let mut properties_sections = vec![
|
||||
node_section_transform(layer, persistent_data),
|
||||
node_section_node_graph_frame(layer_path.clone(), node_graph_frame, is_graph_open),
|
||||
];
|
||||
let mut properties_sections = vec![node_section_transform(layer, persistent_data)];
|
||||
if !selected_nodes.is_empty() && is_graph_open {
|
||||
let mut context = crate::messages::portfolio::document::node_graph::NodePropertiesContext {
|
||||
persistent_data,
|
||||
|
@ -492,69 +488,6 @@ fn node_section_transform(layer: &Layer, persistent_data: &PersistentData) -> La
|
|||
}
|
||||
}
|
||||
|
||||
fn node_section_node_graph_frame(layer_path: Vec<graphene::LayerId>, node_graph_frame: &NodeGraphFrameLayer, open_graph: bool) -> LayoutGroup {
|
||||
LayoutGroup::Section {
|
||||
name: "Node Graph Frame".into(),
|
||||
layout: vec![
|
||||
LayoutGroup::Row {
|
||||
widgets: vec![
|
||||
WidgetHolder::new(Widget::TextLabel(TextLabel {
|
||||
value: "Network".into(),
|
||||
tooltip: "Button to edit the node graph network for this layer".into(),
|
||||
..Default::default()
|
||||
})),
|
||||
WidgetHolder::unrelated_separator(),
|
||||
WidgetHolder::unrelated_separator(), // TODO: These three separators add up to 24px,
|
||||
WidgetHolder::unrelated_separator(), // TODO: which is the width of the Assist area.
|
||||
WidgetHolder::unrelated_separator(), // TODO: Remove these when we have proper entry row formatting that includes room for Assists.
|
||||
WidgetHolder::unrelated_separator(),
|
||||
WidgetHolder::new(Widget::TextButton(TextButton {
|
||||
label: if open_graph { "Close Node Graph".into() } else { "Open Node Graph".into() },
|
||||
tooltip: format!("{} the node graph associated with this layer", if open_graph { "Close" } else { "Open" }),
|
||||
on_update: WidgetCallback::new(move |_| {
|
||||
let layer_path = layer_path.clone();
|
||||
if open_graph {
|
||||
NodeGraphMessage::CloseNodeGraph.into()
|
||||
} else {
|
||||
NodeGraphMessage::OpenNodeGraph { layer_path }.into()
|
||||
}
|
||||
}),
|
||||
..Default::default()
|
||||
})),
|
||||
],
|
||||
},
|
||||
LayoutGroup::Row {
|
||||
widgets: vec![
|
||||
WidgetHolder::new(Widget::TextLabel(TextLabel {
|
||||
value: "Image".into(),
|
||||
tooltip: "Buttons to render the node graph and clear the last rendered image".into(),
|
||||
..Default::default()
|
||||
})),
|
||||
WidgetHolder::unrelated_separator(),
|
||||
WidgetHolder::unrelated_separator(), // TODO: These three separators add up to 24px,
|
||||
WidgetHolder::unrelated_separator(), // TODO: which is the width of the Assist area.
|
||||
WidgetHolder::unrelated_separator(), // TODO: Remove these when we have proper entry row formatting that includes room for Assists.
|
||||
WidgetHolder::unrelated_separator(),
|
||||
WidgetHolder::new(Widget::TextButton(TextButton {
|
||||
label: "Render".into(),
|
||||
tooltip: "Fill layer frame by rendering the node graph".into(),
|
||||
on_update: WidgetCallback::new(|_| DocumentMessage::NodeGraphFrameGenerate.into()),
|
||||
..Default::default()
|
||||
})),
|
||||
WidgetHolder::related_separator(),
|
||||
WidgetHolder::new(Widget::TextButton(TextButton {
|
||||
label: "Clear".into(),
|
||||
tooltip: "Remove rendered node graph from the layer frame".into(),
|
||||
disabled: node_graph_frame.blob_url.is_none(),
|
||||
on_update: WidgetCallback::new(|_| DocumentMessage::FrameClear.into()),
|
||||
..Default::default()
|
||||
})),
|
||||
],
|
||||
},
|
||||
],
|
||||
}
|
||||
}
|
||||
|
||||
fn node_section_font(layer: &TextLayer) -> LayoutGroup {
|
||||
let font = layer.font.clone();
|
||||
let size = layer.size;
|
||||
|
|
|
@ -17,6 +17,3 @@ proc-macro = true
|
|||
proc-macro2 = "1"
|
||||
quote = "1"
|
||||
syn = { version = "1", default-features = false, features = ["derive", "parsing", "proc-macro", "printing"] }
|
||||
|
||||
[dev-dependencies]
|
||||
dyn-any = { path = "..", features = ["derive"] }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue