mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-23 19:08:11 +08:00
Make it easier to resize short/narrow edges of the transform cage without corners taking precedence (#2320)
* Add threshold beyond which the corner point is valid Fixes https://discord.com/channels/731730685944922173/931942323644928040/1344594798404964364 * Add missing delimeters * Code review * Widen the constant --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
co-authored by
Keavon Chambers
parent
1b59a9414a
commit
37b4e3d410
@@ -1,6 +1,6 @@
|
||||
use crate::consts::{
|
||||
BOUNDS_ROTATE_THRESHOLD, BOUNDS_SELECT_THRESHOLD, COLOR_OVERLAY_WHITE, MAXIMUM_ALT_SCALE_FACTOR, MIN_LENGTH_FOR_CORNERS_VISIBILITY, MIN_LENGTH_FOR_MIDPOINT_VISIBILITY,
|
||||
MIN_LENGTH_FOR_RESIZE_TO_INCLUDE_INTERIOR, RESIZE_HANDLE_SIZE, SELECTION_DRAG_ANGLE,
|
||||
BOUNDS_ROTATE_THRESHOLD, BOUNDS_SELECT_THRESHOLD, COLOR_OVERLAY_WHITE, MAXIMUM_ALT_SCALE_FACTOR, MIN_LENGTH_FOR_CORNERS_VISIBILITY, MIN_LENGTH_FOR_EDGE_RESIZE_PRIORITY_OVER_CORNERS,
|
||||
MIN_LENGTH_FOR_MIDPOINT_VISIBILITY, MIN_LENGTH_FOR_RESIZE_TO_INCLUDE_INTERIOR, RESIZE_HANDLE_SIZE, SELECTION_DRAG_ANGLE,
|
||||
};
|
||||
use crate::messages::frontend::utility_types::MouseCursorIcon;
|
||||
use crate::messages::portfolio::document::overlays::utility_types::OverlayContext;
|
||||
@@ -491,6 +491,7 @@ impl BoundingBoxManager {
|
||||
let [threshold_x, threshold_y] = self.compute_viewport_threshold(BOUNDS_SELECT_THRESHOLD);
|
||||
let [corner_min_x, corner_min_y] = self.compute_viewport_threshold(MIN_LENGTH_FOR_CORNERS_VISIBILITY);
|
||||
let [edge_min_x, edge_min_y] = self.compute_viewport_threshold(MIN_LENGTH_FOR_RESIZE_TO_INCLUDE_INTERIOR);
|
||||
let [midpoint_threshold_x, midpoint_threshold_y] = self.compute_viewport_threshold(MIN_LENGTH_FOR_EDGE_RESIZE_PRIORITY_OVER_CORNERS);
|
||||
|
||||
if min.x - cursor.x < threshold_x && min.y - cursor.y < threshold_y && cursor.x - max.x < threshold_x && cursor.y - max.y < threshold_y {
|
||||
let mut top = (cursor.y - min.y).abs() < threshold_y;
|
||||
@@ -501,6 +502,19 @@ impl BoundingBoxManager {
|
||||
let width = max.x - min.x;
|
||||
let height = max.y - min.y;
|
||||
|
||||
if (left || right) && (top || bottom) {
|
||||
let horizontal_midpoint_x = (min.x + max.x) / 2.;
|
||||
let vertical_midpoint_y = (min.y + max.y) / 2.;
|
||||
|
||||
if (cursor.x - horizontal_midpoint_x).abs() < midpoint_threshold_x {
|
||||
left = false;
|
||||
right = false;
|
||||
} else if (cursor.y - vertical_midpoint_y).abs() < midpoint_threshold_y {
|
||||
top = false;
|
||||
bottom = false;
|
||||
}
|
||||
}
|
||||
|
||||
if width < edge_min_x || height <= edge_min_y {
|
||||
if self.transform_tampered {
|
||||
return None;
|
||||
|
||||
Reference in New Issue
Block a user