mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-12-23 10:11:54 +00:00
Restore the zoom to fit behaviour in new bounded documents (#641)
* Restore the zoom to fit behaviour * cargo fmt Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
parent
3673490990
commit
eb43f0b0a5
1 changed files with 12 additions and 2 deletions
|
|
@ -460,10 +460,20 @@ impl DocumentMessageHandler {
|
|||
Ok(insert_index - layer_ids_above.iter().filter(|layer_id| layers.iter().any(|x| *x == [path, &[**layer_id]].concat())).count() as isize)
|
||||
}
|
||||
|
||||
pub fn document_bounds(&self) -> Option<[DVec2; 2]> {
|
||||
/// Calculates the bounding box of all layers in the document
|
||||
pub fn all_layer_bounds(&self) -> Option<[DVec2; 2]> {
|
||||
self.graphene_document.viewport_bounding_box(&[]).ok().flatten()
|
||||
}
|
||||
|
||||
/// Calculates the document bounds used for scrolling and centring (the layer bounds or the artboard (if applicable))
|
||||
pub fn document_bounds(&self) -> Option<[DVec2; 2]> {
|
||||
if self.artboard_message_handler.is_infinite_canvas() {
|
||||
self.all_layer_bounds()
|
||||
} else {
|
||||
self.artboard_message_handler.artboards_graphene_document.viewport_bounding_box(&[]).ok().flatten()
|
||||
}
|
||||
}
|
||||
|
||||
/// Calculate the path that new layers should be inserted to.
|
||||
/// Depends on the selected layers as well as their types (Folder/Non-Folder)
|
||||
pub fn get_path_for_new_layer(&self) -> Vec<u64> {
|
||||
|
|
@ -868,7 +878,7 @@ impl MessageHandler<DocumentMessage, &InputPreprocessorMessageHandler> for Docum
|
|||
|
||||
// Calculates the bounding box of the region to be exported
|
||||
let bbox = match bounds {
|
||||
crate::frontend::utility_types::ExportBounds::AllArtwork => self.document_bounds(),
|
||||
crate::frontend::utility_types::ExportBounds::AllArtwork => self.all_layer_bounds(),
|
||||
crate::frontend::utility_types::ExportBounds::Artboard(id) => self
|
||||
.artboard_message_handler
|
||||
.artboards_graphene_document
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue