mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-12-23 10:11:54 +00:00
Move graph breadcrumb trail button into the top bar
This commit is contained in:
parent
857bc772de
commit
8e774efe9d
8 changed files with 25 additions and 41 deletions
|
|
@ -248,10 +248,6 @@ pub enum FrontendMessage {
|
|||
layout_target: LayoutTarget,
|
||||
diff: Vec<WidgetDiff>,
|
||||
},
|
||||
UpdateSubgraphPath {
|
||||
#[serde(rename = "subgraphPath")]
|
||||
subgraph_path: Vec<String>,
|
||||
},
|
||||
UpdateToolOptionsLayout {
|
||||
#[serde(rename = "layoutTarget")]
|
||||
layout_target: LayoutTarget,
|
||||
|
|
|
|||
|
|
@ -1316,14 +1316,8 @@ impl DocumentMessageHandler {
|
|||
self.selected_nodes
|
||||
.selected_nodes(network)
|
||||
.filter_map(|node| {
|
||||
let Some(node_metadata) = self.node_graph_handler.node_metadata.get(node) else {
|
||||
log::debug!("Could not get click target for node {node}");
|
||||
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;
|
||||
};
|
||||
let node_metadata = self.node_graph_handler.node_metadata.get(node)?;
|
||||
let node_graph_to_viewport = self.node_graph_to_viewport.get(&self.node_graph_handler.network)?;
|
||||
node_metadata.node_click_target.subpath.bounding_box_with_transform(*node_graph_to_viewport)
|
||||
})
|
||||
.reduce(graphene_core::renderer::Quad::combine_bounds)
|
||||
|
|
|
|||
|
|
@ -1947,7 +1947,24 @@ impl NodeGraphMessageHandler {
|
|||
warn!("No network in update_selection_action_buttons");
|
||||
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
|
||||
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>> {
|
||||
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() {
|
||||
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
|
||||
|
|
@ -2474,9 +2491,9 @@ impl NodeGraphMessageHandler {
|
|||
}
|
||||
|
||||
// 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>) {
|
||||
|
|
@ -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>) {
|
||||
// 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 {
|
||||
log::error!("Could not send graph since nested network does not exist");
|
||||
return;
|
||||
|
|
@ -2553,7 +2564,6 @@ impl NodeGraphMessageHandler {
|
|||
let nodes = self.collect_nodes(document_network, network, &wires);
|
||||
|
||||
responses.add(FrontendMessage::UpdateNodeGraph { nodes, wires });
|
||||
responses.add(FrontendMessage::UpdateSubgraphPath { subgraph_path: nested_path });
|
||||
let layer_widths = self
|
||||
.node_metadata
|
||||
.iter()
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
import LayoutCol from "@graphite/components/layout/LayoutCol.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 TextButton from "@graphite/components/widgets/buttons/TextButton.svelte";
|
||||
import RadioInput from "@graphite/components/widgets/inputs/RadioInput.svelte";
|
||||
|
|
@ -95,7 +94,7 @@
|
|||
category.nodes.push(node);
|
||||
} else
|
||||
categories.set(node.category, {
|
||||
open: open,
|
||||
open,
|
||||
nodes: [node],
|
||||
});
|
||||
});
|
||||
|
|
@ -315,7 +314,6 @@
|
|||
style:--dot-radius={`${dotRadius}px`}
|
||||
data-node-graph
|
||||
>
|
||||
<BreadcrumbTrailButtons labels={["Document"].concat($nodeGraph.subgraphPath)} action={(index) => editor.handle.exitNestedNetwork($nodeGraph.subgraphPath?.length - index)} />
|
||||
<!-- Right click menu for adding nodes -->
|
||||
{#if $nodeGraph.contextMenuInformation}
|
||||
<LayoutCol
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ import {
|
|||
UpdateNodeGraphTransform,
|
||||
UpdateNodeTypes,
|
||||
UpdateNodeThumbnail,
|
||||
UpdateSubgraphPath,
|
||||
UpdateWirePathInProgress,
|
||||
UpdateZoomWithScroll,
|
||||
} from "@graphite/wasm-communication/messages";
|
||||
|
|
@ -34,7 +33,6 @@ export function createNodeGraphState(editor: Editor) {
|
|||
zoomWithScroll: false as boolean,
|
||||
thumbnails: new Map<bigint, string>(),
|
||||
selected: [] as bigint[],
|
||||
subgraphPath: [] as string[],
|
||||
transform: { scale: 1, x: 0, y: 0 },
|
||||
});
|
||||
|
||||
|
|
@ -89,12 +87,6 @@ export function createNodeGraphState(editor: Editor) {
|
|||
return state;
|
||||
});
|
||||
});
|
||||
editor.subscriptions.subscribeJsMessage(UpdateSubgraphPath, (UpdateSubgraphPath) => {
|
||||
update((state) => {
|
||||
state.subgraphPath = UpdateSubgraphPath.subgraphPath;
|
||||
return state;
|
||||
});
|
||||
});
|
||||
editor.subscriptions.subscribeJsMessage(UpdateWirePathInProgress, (updateWirePathInProgress) => {
|
||||
update((state) => {
|
||||
state.wirePathInProgress = updateWirePathInProgress.wirePath;
|
||||
|
|
|
|||
|
|
@ -83,10 +83,6 @@ export class UpdateOpenDocumentsList extends JsMessage {
|
|||
readonly openDocuments!: FrontendDocumentDetails[];
|
||||
}
|
||||
|
||||
export class UpdateSubgraphPath extends JsMessage {
|
||||
readonly subgraphPath!: string[];
|
||||
}
|
||||
|
||||
export class UpdateWirePathInProgress extends JsMessage {
|
||||
readonly wirePath!: WirePath | undefined;
|
||||
}
|
||||
|
|
@ -1479,7 +1475,6 @@ export const messageMakers: Record<string, MessageMaker> = {
|
|||
UpdateOpenDocumentsList,
|
||||
UpdatePropertyPanelOptionsLayout,
|
||||
UpdatePropertyPanelSectionsLayout,
|
||||
UpdateSubgraphPath,
|
||||
UpdateToolOptionsLayout,
|
||||
UpdateToolShelfLayout,
|
||||
UpdateWorkingColorsLayout,
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ pub enum GraphicElement {
|
|||
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
|
||||
ImageFrame(ImageFrame<Color>),
|
||||
/// A Canvas evement
|
||||
/// A Canvas element
|
||||
Surface(SurfaceFrame),
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1280,7 +1280,6 @@ impl NodeNetwork {
|
|||
NodeInput::Value { .. } => unreachable!("Value inputs should have been replaced with value nodes"),
|
||||
NodeInput::Inline(_) => (),
|
||||
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");
|
||||
// TODO use correct output index
|
||||
nested_node.inputs[nested_input_index] = NodeInput::node(*import_id, 0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue