mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-01 22:58:11 +08:00
Move graph breadcrumb trail button into the top bar
This commit is contained in:
@@ -248,10 +248,6 @@ pub enum FrontendMessage {
|
|||||||
layout_target: LayoutTarget,
|
layout_target: LayoutTarget,
|
||||||
diff: Vec<WidgetDiff>,
|
diff: Vec<WidgetDiff>,
|
||||||
},
|
},
|
||||||
UpdateSubgraphPath {
|
|
||||||
#[serde(rename = "subgraphPath")]
|
|
||||||
subgraph_path: Vec<String>,
|
|
||||||
},
|
|
||||||
UpdateToolOptionsLayout {
|
UpdateToolOptionsLayout {
|
||||||
#[serde(rename = "layoutTarget")]
|
#[serde(rename = "layoutTarget")]
|
||||||
layout_target: LayoutTarget,
|
layout_target: LayoutTarget,
|
||||||
|
|||||||
@@ -1316,14 +1316,8 @@ impl DocumentMessageHandler {
|
|||||||
self.selected_nodes
|
self.selected_nodes
|
||||||
.selected_nodes(network)
|
.selected_nodes(network)
|
||||||
.filter_map(|node| {
|
.filter_map(|node| {
|
||||||
let Some(node_metadata) = self.node_graph_handler.node_metadata.get(node) else {
|
let node_metadata = self.node_graph_handler.node_metadata.get(node)?;
|
||||||
log::debug!("Could not get click target for node {node}");
|
let node_graph_to_viewport = self.node_graph_to_viewport.get(&self.node_graph_handler.network)?;
|
||||||
return None;
|
|
||||||
};
|
|
||||||
let Some(node_graph_to_viewport) = self.node_graph_to_viewport.get(&self.node_graph_handler.network) else {
|
|
||||||
log::debug!("Could not get node_graph_to_viewport for network: {:?}", self.node_graph_handler.network);
|
|
||||||
return None;
|
|
||||||
};
|
|
||||||
node_metadata.node_click_target.subpath.bounding_box_with_transform(*node_graph_to_viewport)
|
node_metadata.node_click_target.subpath.bounding_box_with_transform(*node_graph_to_viewport)
|
||||||
})
|
})
|
||||||
.reduce(graphene_core::renderer::Quad::combine_bounds)
|
.reduce(graphene_core::renderer::Quad::combine_bounds)
|
||||||
|
|||||||
@@ -1947,7 +1947,24 @@ impl NodeGraphMessageHandler {
|
|||||||
warn!("No network in update_selection_action_buttons");
|
warn!("No network in update_selection_action_buttons");
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
let mut widgets = Vec::new();
|
|
||||||
|
let subgraph_path_names = Self::collect_subgraph_names(&mut self.network, document_network);
|
||||||
|
let breadcrumb_trail = subgraph_path_names.and_then(|subgraph_path_names| {
|
||||||
|
let subgraph_path_names_length = subgraph_path_names.len();
|
||||||
|
if subgraph_path_names_length < 2 {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
|
Some(BreadcrumbTrailButtons::new(subgraph_path_names).on_update(move |index| {
|
||||||
|
NodeGraphMessage::ExitNestedNetwork {
|
||||||
|
steps_back: subgraph_path_names_length - (*index as usize) - 1,
|
||||||
|
}
|
||||||
|
.into()
|
||||||
|
}))
|
||||||
|
});
|
||||||
|
let mut widgets = breadcrumb_trail
|
||||||
|
.map(|breadcrumb_trail| vec![breadcrumb_trail.widget_holder(), Separator::new(SeparatorType::Unrelated).widget_holder()])
|
||||||
|
.unwrap_or_default();
|
||||||
|
|
||||||
// Don't allow disabling input or output nodes
|
// Don't allow disabling input or output nodes
|
||||||
let mut selection = selected_nodes
|
let mut selection = selected_nodes
|
||||||
@@ -2458,7 +2475,7 @@ impl NodeGraphMessageHandler {
|
|||||||
|
|
||||||
fn collect_subgraph_names(subgraph_path: &mut Vec<NodeId>, network: &NodeNetwork) -> Option<Vec<String>> {
|
fn collect_subgraph_names(subgraph_path: &mut Vec<NodeId>, network: &NodeNetwork) -> Option<Vec<String>> {
|
||||||
let mut current_network = network;
|
let mut current_network = network;
|
||||||
let mut subraph_names = Vec::new();
|
let mut subgraph_path_names = vec!["Document".to_string()];
|
||||||
for node_id in subgraph_path.iter() {
|
for node_id in subgraph_path.iter() {
|
||||||
let Some(node) = current_network.nodes.get(node_id) else {
|
let Some(node) = current_network.nodes.get(node_id) else {
|
||||||
// If node cannot be found and we are in a nested network, set subgraph_path to document network and return None, which runs send_graph again on the document network
|
// If node cannot be found and we are in a nested network, set subgraph_path to document network and return None, which runs send_graph again on the document network
|
||||||
@@ -2474,9 +2491,9 @@ impl NodeGraphMessageHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Maybe replace with alias and default to name if it does not exist
|
// TODO: Maybe replace with alias and default to name if it does not exist
|
||||||
subraph_names.push(node.name.clone());
|
subgraph_path_names.push(node.name.clone());
|
||||||
}
|
}
|
||||||
Some(subraph_names)
|
Some(subgraph_path_names)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_layer_panel(document_network: &NodeNetwork, metadata: &DocumentMetadata, collapsed: &CollapsedLayers, responses: &mut VecDeque<Message>) {
|
fn update_layer_panel(document_network: &NodeNetwork, metadata: &DocumentMetadata, collapsed: &CollapsedLayers, responses: &mut VecDeque<Message>) {
|
||||||
@@ -2529,12 +2546,6 @@ impl NodeGraphMessageHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn send_graph(&mut self, document_network: &NodeNetwork, metadata: &mut DocumentMetadata, collapsed: &CollapsedLayers, graph_open: bool, responses: &mut VecDeque<Message>) {
|
fn send_graph(&mut self, document_network: &NodeNetwork, metadata: &mut DocumentMetadata, collapsed: &CollapsedLayers, graph_open: bool, responses: &mut VecDeque<Message>) {
|
||||||
// If a node cannot be found in collect_subgraph_names, for example when the nested node is deleted while it is entered, and we are in a nested network, set self.network to empty (document network), and call send_graph again to send the document network
|
|
||||||
let Some(nested_path) = Self::collect_subgraph_names(&mut self.network, document_network) else {
|
|
||||||
self.send_graph(document_network, metadata, collapsed, graph_open, responses);
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
|
|
||||||
let Some(network) = document_network.nested_network(&self.network) else {
|
let Some(network) = document_network.nested_network(&self.network) else {
|
||||||
log::error!("Could not send graph since nested network does not exist");
|
log::error!("Could not send graph since nested network does not exist");
|
||||||
return;
|
return;
|
||||||
@@ -2553,7 +2564,6 @@ impl NodeGraphMessageHandler {
|
|||||||
let nodes = self.collect_nodes(document_network, network, &wires);
|
let nodes = self.collect_nodes(document_network, network, &wires);
|
||||||
|
|
||||||
responses.add(FrontendMessage::UpdateNodeGraph { nodes, wires });
|
responses.add(FrontendMessage::UpdateNodeGraph { nodes, wires });
|
||||||
responses.add(FrontendMessage::UpdateSubgraphPath { subgraph_path: nested_path });
|
|
||||||
let layer_widths = self
|
let layer_widths = self
|
||||||
.node_metadata
|
.node_metadata
|
||||||
.iter()
|
.iter()
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
|
|
||||||
import LayoutCol from "@graphite/components/layout/LayoutCol.svelte";
|
import LayoutCol from "@graphite/components/layout/LayoutCol.svelte";
|
||||||
import LayoutRow from "@graphite/components/layout/LayoutRow.svelte";
|
import LayoutRow from "@graphite/components/layout/LayoutRow.svelte";
|
||||||
import BreadcrumbTrailButtons from "@graphite/components/widgets/buttons/BreadcrumbTrailButtons.svelte";
|
|
||||||
import IconButton from "@graphite/components/widgets/buttons/IconButton.svelte";
|
import IconButton from "@graphite/components/widgets/buttons/IconButton.svelte";
|
||||||
import TextButton from "@graphite/components/widgets/buttons/TextButton.svelte";
|
import TextButton from "@graphite/components/widgets/buttons/TextButton.svelte";
|
||||||
import RadioInput from "@graphite/components/widgets/inputs/RadioInput.svelte";
|
import RadioInput from "@graphite/components/widgets/inputs/RadioInput.svelte";
|
||||||
@@ -95,7 +94,7 @@
|
|||||||
category.nodes.push(node);
|
category.nodes.push(node);
|
||||||
} else
|
} else
|
||||||
categories.set(node.category, {
|
categories.set(node.category, {
|
||||||
open: open,
|
open,
|
||||||
nodes: [node],
|
nodes: [node],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -315,7 +314,6 @@
|
|||||||
style:--dot-radius={`${dotRadius}px`}
|
style:--dot-radius={`${dotRadius}px`}
|
||||||
data-node-graph
|
data-node-graph
|
||||||
>
|
>
|
||||||
<BreadcrumbTrailButtons labels={["Document"].concat($nodeGraph.subgraphPath)} action={(index) => editor.handle.exitNestedNetwork($nodeGraph.subgraphPath?.length - index)} />
|
|
||||||
<!-- Right click menu for adding nodes -->
|
<!-- Right click menu for adding nodes -->
|
||||||
{#if $nodeGraph.contextMenuInformation}
|
{#if $nodeGraph.contextMenuInformation}
|
||||||
<LayoutCol
|
<LayoutCol
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import {
|
|||||||
UpdateNodeGraphTransform,
|
UpdateNodeGraphTransform,
|
||||||
UpdateNodeTypes,
|
UpdateNodeTypes,
|
||||||
UpdateNodeThumbnail,
|
UpdateNodeThumbnail,
|
||||||
UpdateSubgraphPath,
|
|
||||||
UpdateWirePathInProgress,
|
UpdateWirePathInProgress,
|
||||||
UpdateZoomWithScroll,
|
UpdateZoomWithScroll,
|
||||||
} from "@graphite/wasm-communication/messages";
|
} from "@graphite/wasm-communication/messages";
|
||||||
@@ -34,7 +33,6 @@ export function createNodeGraphState(editor: Editor) {
|
|||||||
zoomWithScroll: false as boolean,
|
zoomWithScroll: false as boolean,
|
||||||
thumbnails: new Map<bigint, string>(),
|
thumbnails: new Map<bigint, string>(),
|
||||||
selected: [] as bigint[],
|
selected: [] as bigint[],
|
||||||
subgraphPath: [] as string[],
|
|
||||||
transform: { scale: 1, x: 0, y: 0 },
|
transform: { scale: 1, x: 0, y: 0 },
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -89,12 +87,6 @@ export function createNodeGraphState(editor: Editor) {
|
|||||||
return state;
|
return state;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
editor.subscriptions.subscribeJsMessage(UpdateSubgraphPath, (UpdateSubgraphPath) => {
|
|
||||||
update((state) => {
|
|
||||||
state.subgraphPath = UpdateSubgraphPath.subgraphPath;
|
|
||||||
return state;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
editor.subscriptions.subscribeJsMessage(UpdateWirePathInProgress, (updateWirePathInProgress) => {
|
editor.subscriptions.subscribeJsMessage(UpdateWirePathInProgress, (updateWirePathInProgress) => {
|
||||||
update((state) => {
|
update((state) => {
|
||||||
state.wirePathInProgress = updateWirePathInProgress.wirePath;
|
state.wirePathInProgress = updateWirePathInProgress.wirePath;
|
||||||
|
|||||||
@@ -83,10 +83,6 @@ export class UpdateOpenDocumentsList extends JsMessage {
|
|||||||
readonly openDocuments!: FrontendDocumentDetails[];
|
readonly openDocuments!: FrontendDocumentDetails[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class UpdateSubgraphPath extends JsMessage {
|
|
||||||
readonly subgraphPath!: string[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export class UpdateWirePathInProgress extends JsMessage {
|
export class UpdateWirePathInProgress extends JsMessage {
|
||||||
readonly wirePath!: WirePath | undefined;
|
readonly wirePath!: WirePath | undefined;
|
||||||
}
|
}
|
||||||
@@ -1479,7 +1475,6 @@ export const messageMakers: Record<string, MessageMaker> = {
|
|||||||
UpdateOpenDocumentsList,
|
UpdateOpenDocumentsList,
|
||||||
UpdatePropertyPanelOptionsLayout,
|
UpdatePropertyPanelOptionsLayout,
|
||||||
UpdatePropertyPanelSectionsLayout,
|
UpdatePropertyPanelSectionsLayout,
|
||||||
UpdateSubgraphPath,
|
|
||||||
UpdateToolOptionsLayout,
|
UpdateToolOptionsLayout,
|
||||||
UpdateToolShelfLayout,
|
UpdateToolShelfLayout,
|
||||||
UpdateWorkingColorsLayout,
|
UpdateWorkingColorsLayout,
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ pub enum GraphicElement {
|
|||||||
VectorData(Box<VectorData>),
|
VectorData(Box<VectorData>),
|
||||||
/// A bitmap image with a finite position and extent, equivalent to the SVG <image> tag: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/image
|
/// A bitmap image with a finite position and extent, equivalent to the SVG <image> tag: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/image
|
||||||
ImageFrame(ImageFrame<Color>),
|
ImageFrame(ImageFrame<Color>),
|
||||||
/// A Canvas evement
|
/// A Canvas element
|
||||||
Surface(SurfaceFrame),
|
Surface(SurfaceFrame),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1280,7 +1280,6 @@ impl NodeNetwork {
|
|||||||
NodeInput::Value { .. } => unreachable!("Value inputs should have been replaced with value nodes"),
|
NodeInput::Value { .. } => unreachable!("Value inputs should have been replaced with value nodes"),
|
||||||
NodeInput::Inline(_) => (),
|
NodeInput::Inline(_) => (),
|
||||||
NodeInput::Scope(ref key) => {
|
NodeInput::Scope(ref key) => {
|
||||||
log::debug!("flattening scope: {}", key);
|
|
||||||
let (import_id, _ty) = self.scope_injections.get(key.as_ref()).expect("Tried to import a non existent key from scope");
|
let (import_id, _ty) = self.scope_injections.get(key.as_ref()).expect("Tried to import a non existent key from scope");
|
||||||
// TODO use correct output index
|
// TODO use correct output index
|
||||||
nested_node.inputs[nested_input_index] = NodeInput::node(*import_id, 0);
|
nested_node.inputs[nested_input_index] = NodeInput::node(*import_id, 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user