mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-22 08:48:11 +08:00
Restore select tool functionality and shallow select mode (#1583)
* Restore select tool functionality * UI tweak * Change all of the things --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
co-authored by
Keavon Chambers
parent
5c9d3c5d75
commit
208e907fa4
@@ -86,33 +86,20 @@ impl SelectedEdges {
|
||||
|
||||
let mut pivot = self.pivot_from_bounds(min, max);
|
||||
if let Some(center_around) = center_around {
|
||||
// The below ratio is: `dragging edge / being centered`.
|
||||
// The `is_finite()` checks are in case the user is dragging the edge where the pivot is located (in which case the centering mode is ignored).
|
||||
let center_around = transform.inverse().transform_point2(center_around);
|
||||
if self.top {
|
||||
let ratio = (center_around.y - min.y) / (center_around.y - self.bounds[0].y);
|
||||
if ratio.is_finite() {
|
||||
max.y = center_around.y + ratio * (self.bounds[1].y - center_around.y);
|
||||
pivot.y = center_around.y;
|
||||
}
|
||||
pivot.y = center_around.y;
|
||||
max.y = center_around.y * 2. - min.y;
|
||||
} else if self.bottom {
|
||||
let ratio = (max.y - center_around.y) / (self.bounds[1].y - center_around.y);
|
||||
if ratio.is_finite() {
|
||||
min.y = center_around.y - ratio * (center_around.y - self.bounds[0].y);
|
||||
pivot.y = center_around.y;
|
||||
}
|
||||
pivot.y = center_around.y;
|
||||
min.y = center_around.y * 2. - max.y;
|
||||
}
|
||||
if self.left {
|
||||
let ratio = (center_around.x - min.x) / (center_around.x - self.bounds[0].x);
|
||||
if ratio.is_finite() {
|
||||
max.x = center_around.x + ratio * (self.bounds[1].x - center_around.x);
|
||||
pivot.x = center_around.x;
|
||||
}
|
||||
pivot.x = center_around.x;
|
||||
max.x = center_around.x * 2. - min.x;
|
||||
} else if self.right {
|
||||
let ratio = (max.x - center_around.x) / (self.bounds[1].x - center_around.x);
|
||||
if ratio.is_finite() {
|
||||
min.x = center_around.x - ratio * (center_around.x - self.bounds[0].x);
|
||||
pivot.x = center_around.x;
|
||||
}
|
||||
pivot.x = center_around.x;
|
||||
min.x = center_around.x * 2. - max.x;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,7 +115,9 @@ impl SelectedEdges {
|
||||
let delta_size = new_size - size;
|
||||
min -= delta_size * min_pivot;
|
||||
max = min + new_size;
|
||||
} else if let Some(SizeSnapData { manager, points, snap_data }) = snap {
|
||||
}
|
||||
|
||||
if let Some(SizeSnapData { manager, points, snap_data }) = snap {
|
||||
let view_to_doc = snap_data.document.metadata.document_to_viewport.inverse();
|
||||
let bounds_to_doc = view_to_doc * transform;
|
||||
let mut best_snap = SnappedPoint::infinite_snap(pivot);
|
||||
@@ -140,7 +129,13 @@ impl SelectedEdges {
|
||||
let normalised = (bounds_space - self.bounds[0]) / (self.bounds[1] - self.bounds[0]);
|
||||
let updated = normalised * (max - min) + min;
|
||||
point.document_point = bounds_to_doc.transform_point2(updated);
|
||||
let mut snapped = if !(self.top || self.bottom) || !(self.left || self.right) {
|
||||
let mut snapped = if constrain {
|
||||
let constraint = SnapConstraint::Line {
|
||||
origin: point.document_point,
|
||||
direction: (point.document_point - bounds_to_doc.transform_point2(pivot)).normalize_or_zero(),
|
||||
};
|
||||
manager.constrained_snap(&snap_data, point, constraint, None)
|
||||
} else if !(self.top || self.bottom) || !(self.left || self.right) {
|
||||
let axis = if !(self.top || self.bottom) { DVec2::X } else { DVec2::Y };
|
||||
let constraint = SnapConstraint::Line {
|
||||
origin: point.document_point,
|
||||
@@ -158,10 +153,10 @@ impl SelectedEdges {
|
||||
let snapped_bounds = bounds_to_doc.inverse().transform_point2(snapped.snapped_point_document);
|
||||
|
||||
let mut scale_factor = (snapped_bounds - pivot) / (updated - pivot);
|
||||
if !(self.left || self.right) {
|
||||
if !(self.left || self.right) && !constrain {
|
||||
scale_factor.x = 1.
|
||||
}
|
||||
if !(self.top || self.bottom) {
|
||||
if !(self.top || self.bottom) && !constrain {
|
||||
scale_factor.y = 1.
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user