mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-12-23 10:11:54 +00:00
Transform nudge coordinates to viewport space (#264)
* Transform nudge coordinates to viewport space * Refactor nudge transform for clarity
This commit is contained in:
parent
eab498f795
commit
e7699bbcbd
1 changed files with 8 additions and 2 deletions
|
|
@ -5,7 +5,7 @@ use crate::{
|
|||
};
|
||||
use document_core::layers::Layer;
|
||||
use document_core::{DocumentResponse, LayerId, Operation as DocumentOperation};
|
||||
use glam::{DAffine2, DVec2};
|
||||
use glam::DAffine2;
|
||||
use log::warn;
|
||||
|
||||
use crate::document::Document;
|
||||
|
|
@ -534,10 +534,16 @@ impl MessageHandler<DocumentMessage, &InputPreprocessor> for DocumentMessageHand
|
|||
}
|
||||
NudgeSelectedLayers(x, y) => {
|
||||
let paths: Vec<Vec<LayerId>> = self.selected_layers_sorted();
|
||||
|
||||
let delta = {
|
||||
let root_layer_rotation = self.layerdata_mut(&vec![]).rotation;
|
||||
let rotate_to_viewport_space = DAffine2::from_angle(root_layer_rotation).inverse();
|
||||
rotate_to_viewport_space.transform_point2((x, y).into())
|
||||
};
|
||||
for path in paths {
|
||||
let operation = DocumentOperation::TransformLayer {
|
||||
path,
|
||||
transform: DAffine2::from_translation(DVec2::new(x, y)).to_cols_array(),
|
||||
transform: DAffine2::from_translation(delta).to_cols_array(),
|
||||
};
|
||||
responses.push_back(operation.into());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue