mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-12-23 10:11:54 +00:00
Merge a73582c851 into 9d26c040e9
This commit is contained in:
commit
c792e02abb
3 changed files with 11 additions and 4 deletions
|
|
@ -1024,7 +1024,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
|
|||
let viewport_size = viewport.size().into_dvec2();
|
||||
let viewport_mid = viewport.center_in_viewport_space().into_dvec2();
|
||||
let [bounds1, bounds2] = if !self.graph_view_overlay_open {
|
||||
self.metadata().document_bounds_viewport_space().unwrap_or([viewport_mid; 2])
|
||||
self.network_interface.document_bounds_viewport_space(true).unwrap_or([viewport_mid; 2])
|
||||
} else {
|
||||
self.network_interface.graph_bounds_viewport_space(&self.breadcrumb_network_path).unwrap_or([viewport_mid; 2])
|
||||
};
|
||||
|
|
|
|||
|
|
@ -241,7 +241,7 @@ impl MessageHandler<NavigationMessage, NavigationMessageContext<'_>> for Navigat
|
|||
}
|
||||
let document_bounds = if !graph_view_overlay_open {
|
||||
// TODO: Cache this in node graph coordinates and apply the transform to the rectangle to get viewport coordinates
|
||||
network_interface.document_metadata().document_bounds_viewport_space()
|
||||
network_interface.document_bounds_viewport_space(true)
|
||||
} else {
|
||||
network_interface.graph_bounds_viewport_space(breadcrumb_network_path)
|
||||
};
|
||||
|
|
@ -259,7 +259,7 @@ impl MessageHandler<NavigationMessage, NavigationMessageContext<'_>> for Navigat
|
|||
NavigationMessage::CanvasZoomSet { zoom_factor } => {
|
||||
let document_bounds = if !graph_view_overlay_open {
|
||||
// TODO: Cache this in node graph coordinates and apply the transform to the rectangle to get viewport coordinates
|
||||
network_interface.document_metadata().document_bounds_viewport_space()
|
||||
network_interface.document_bounds_viewport_space(true)
|
||||
} else {
|
||||
network_interface.graph_bounds_viewport_space(breadcrumb_network_path)
|
||||
};
|
||||
|
|
@ -456,7 +456,7 @@ impl MessageHandler<NavigationMessage, NavigationMessageContext<'_>> for Navigat
|
|||
|
||||
let document_bounds = if !graph_view_overlay_open {
|
||||
// TODO: Cache this in node graph coordinates and apply the transform to the rectangle to get viewport coordinates
|
||||
network_interface.document_metadata().document_bounds_viewport_space()
|
||||
network_interface.document_bounds_viewport_space(true)
|
||||
} else {
|
||||
network_interface.graph_bounds_viewport_space(breadcrumb_network_path)
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1193,6 +1193,13 @@ impl NodeNetworkInterface {
|
|||
.reduce(Quad::combine_bounds)
|
||||
}
|
||||
|
||||
pub fn document_bounds_viewport_space(&self, include_artboards: bool) -> Option<[DVec2; 2]> {
|
||||
let [min, max] = self.document_bounds_document_space(include_artboards)?;
|
||||
let quad = Quad::from_box([min, max]);
|
||||
let transformed = self.document_metadata.document_to_viewport * quad;
|
||||
Some(transformed.bounding_box())
|
||||
}
|
||||
|
||||
/// Calculates the selected layer bounds in document space
|
||||
pub fn selected_bounds_document_space(&self, include_artboards: bool, network_path: &[NodeId]) -> Option<[DVec2; 2]> {
|
||||
let Some(selected_nodes) = self.selected_nodes_in_nested_network(network_path) else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue