mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-23 02:28:13 +08:00
Refactor ViewportPosition from u32 (UVec2) to f64 (DVec2) (#345)
* Refactor ViewportPosition from u32 (UVec2) to f64 (DVec2) * Fix pseudo_hash call * Replace hash function with proper function for uuid generation * Cargo fmt Co-authored-by: Dennis Kobert <dennis@kobert.dev>
This commit is contained in:
co-authored by
Dennis Kobert
parent
91543d530d
commit
790647815b
@@ -79,9 +79,9 @@ impl SelectToolData {
|
||||
fn selection_box(&self) -> [DVec2; 2] {
|
||||
if self.drag_current == self.drag_start {
|
||||
let tolerance = DVec2::splat(SELECTION_TOLERANCE);
|
||||
[self.drag_start.as_f64() - tolerance, self.drag_start.as_f64() + tolerance]
|
||||
[self.drag_start - tolerance, self.drag_start + tolerance]
|
||||
} else {
|
||||
[self.drag_start.as_f64(), self.drag_current.as_f64()]
|
||||
[self.drag_start, self.drag_current]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -122,7 +122,7 @@ impl Fsm for SelectToolFsmState {
|
||||
Dragging
|
||||
} else {
|
||||
responses.push_back(DocumentMessage::DeselectAllLayers.into());
|
||||
data.box_id = Some(vec![generate_hash(&*responses, input, document.document.hash())]);
|
||||
data.box_id = Some(vec![generate_uuid()]);
|
||||
responses.push_back(
|
||||
Operation::AddBoundingBox {
|
||||
path: data.box_id.clone().unwrap(),
|
||||
@@ -139,7 +139,7 @@ impl Fsm for SelectToolFsmState {
|
||||
responses.push_back(
|
||||
Operation::TransformLayerInViewport {
|
||||
path: path.clone(),
|
||||
transform: DAffine2::from_translation(input.mouse.position.as_f64() - data.drag_current.as_f64()).to_cols_array(),
|
||||
transform: DAffine2::from_translation(input.mouse.position - data.drag_current).to_cols_array(),
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
@@ -149,8 +149,8 @@ impl Fsm for SelectToolFsmState {
|
||||
}
|
||||
(DrawingBox, MouseMove) => {
|
||||
data.drag_current = input.mouse.position;
|
||||
let start = data.drag_start.as_f64();
|
||||
let size = data.drag_current.as_f64() - start;
|
||||
let start = data.drag_start;
|
||||
let size = data.drag_current - start;
|
||||
|
||||
responses.push_back(
|
||||
Operation::SetLayerTransformInViewport {
|
||||
|
||||
Reference in New Issue
Block a user