|
1 | 1 | use super::tool_prelude::*; |
| 2 | +use crate::messages::portfolio::document::graph_operation::utility_types::TransformIn; |
2 | 3 | use crate::messages::portfolio::document::overlays::utility_types::OverlayContext; |
3 | 4 | use crate::messages::portfolio::document::utility_types::document_metadata::LayerNodeIdentifier; |
4 | 5 | use crate::messages::tool::common_functionality::auto_panning::AutoPanning; |
@@ -111,6 +112,7 @@ struct ArtboardToolData { |
111 | 112 | drag_current: DVec2, |
112 | 113 | auto_panning: AutoPanning, |
113 | 114 | snap_candidates: Vec<SnapCandidatePoint>, |
| 115 | + dragging_current_artboad_location: IVec2, |
114 | 116 | } |
115 | 117 |
|
116 | 118 | impl ArtboardToolData { |
@@ -138,6 +140,7 @@ impl ArtboardToolData { |
138 | 140 | fn start_resizing(&mut self, _selected_edges: (bool, bool, bool, bool), _document: &DocumentMessageHandler, _input: &InputPreprocessorMessageHandler) { |
139 | 141 | if let Some(bounds) = &mut self.bounding_box_manager { |
140 | 142 | bounds.center_of_transformation = bounds.transform.transform_point2((bounds.bounds[0] + bounds.bounds[1]) / 2.); |
| 143 | + self.dragging_current_artboad_location = bounds.bounds[0].round().as_ivec2(); |
141 | 144 | } |
142 | 145 | } |
143 | 146 |
|
@@ -197,18 +200,17 @@ impl ArtboardToolData { |
197 | 200 | dimensions: size.round().as_ivec2(), |
198 | 201 | }); |
199 | 202 |
|
200 | | - // TODO: Resize artboard children when resizing left/top edges so that they stay in the same viewport space |
201 | | - // let old_top_left = bounds.bounds[0].round().as_ivec2(); |
202 | | - // let new_top_left = position.round().as_ivec2(); |
203 | | - // let top_left_delta = new_top_left - old_top_left; |
204 | | - // if top_left_delta != IVec2::ZERO { |
205 | | - // responses.add(GraphOperationMessage::TransformChange { |
206 | | - // layer: self.selected_artboard.unwrap(), |
207 | | - // transform: DAffine2::from_translation((-top_left_delta).into()), |
208 | | - // transform_in: TransformIn::Local, |
209 | | - // skip_rerender: false, |
210 | | - // }); |
211 | | - // } |
| 203 | + let translation = position.round().as_ivec2() - self.dragging_current_artboad_location; |
| 204 | + self.dragging_current_artboad_location = position.round().as_ivec2(); |
| 205 | + for child in self.selected_artboard.unwrap().children(&document.metadata()) { |
| 206 | + let local_translation = document.metadata().downstream_transform_to_document(child).inverse().transform_vector2(-translation.as_dvec2()); |
| 207 | + responses.add(GraphOperationMessage::TransformChange { |
| 208 | + layer: child, |
| 209 | + transform: DAffine2::from_translation(local_translation), |
| 210 | + transform_in: TransformIn::Local, |
| 211 | + skip_rerender: false, |
| 212 | + }); |
| 213 | + } |
212 | 214 | } |
213 | 215 | } |
214 | 216 |
|
|
0 commit comments