mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-28 11:28:11 +08:00
Make the transform cage show/hide resize grips as space allows (#2209)
* Changes rotation handles to be around overlay squares Fixes https://discord.com/channels/731730685944922173/931942323644928040/1330785941786329209 * Fix zero width objects not being selected by slightly nudging the transform * Follow the categorical limits to render overlay quads As discussed here: https://discord.com/channels/731730685944922173/931942323644928040/1331166336923074600 * Replace area based calculations with edge based calculations * Fix 3rd category vis * Code review * Add missing powi(2) * Fixes to handle logic * Remove single axis prioritisation * Explicitly check for distance to find nearest handle * Replace threshold check based on corner vis bounds * Fix discrepancy at h=12px * Allow grab when box is too small by disabling resizing within bounds * Replace inside resize pixel limit * Code review --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
co-authored by
Keavon Chambers
parent
c5a3c32114
commit
a0f8f89e71
+29
-22
@@ -1,11 +1,11 @@
|
||||
// Graph
|
||||
// GRAPH
|
||||
pub const GRID_SIZE: u32 = 24;
|
||||
pub const EXPORTS_TO_TOP_EDGE_PIXEL_GAP: u32 = 72;
|
||||
pub const EXPORTS_TO_RIGHT_EDGE_PIXEL_GAP: u32 = 120;
|
||||
pub const IMPORTS_TO_TOP_EDGE_PIXEL_GAP: u32 = 72;
|
||||
pub const IMPORTS_TO_LEFT_EDGE_PIXEL_GAP: u32 = 120;
|
||||
|
||||
// Viewport
|
||||
// VIEWPORT
|
||||
pub const VIEWPORT_ZOOM_WHEEL_RATE: f64 = (1. / 600.) * 3.;
|
||||
pub const VIEWPORT_ZOOM_MOUSE_RATE: f64 = 1. / 400.;
|
||||
pub const VIEWPORT_ZOOM_SCALE_MIN: f64 = 0.000_000_1;
|
||||
@@ -17,7 +17,8 @@ pub const VIEWPORT_ZOOM_LEVELS: [f64; 74] = [
|
||||
128., 160., 200., 256., 320., 400., 512., 640., 800., 1024., 1280., 1600., 2048., 2560.,
|
||||
];
|
||||
|
||||
pub const VIEWPORT_GRID_ROUNDING_BIAS: f64 = 0.002; // Helps push values that end in approximately half, plus or minus some floating point imprecision, towards the same side of the round() function
|
||||
/// Helps push values that end in approximately half, plus or minus some floating point imprecision, towards the same side of the round() function.
|
||||
pub const VIEWPORT_GRID_ROUNDING_BIAS: f64 = 0.002;
|
||||
|
||||
pub const VIEWPORT_SCROLL_RATE: f64 = 0.6;
|
||||
|
||||
@@ -28,76 +29,82 @@ pub const VIEWPORT_ZOOM_TO_FIT_PADDING_SCALE_FACTOR: f64 = 0.95;
|
||||
pub const DRAG_BEYOND_VIEWPORT_MAX_OVEREXTENSION_PIXELS: f64 = 50.;
|
||||
pub const DRAG_BEYOND_VIEWPORT_SPEED_FACTOR: f64 = 20.;
|
||||
|
||||
// Snapping point
|
||||
// SNAPPING POINT
|
||||
pub const SNAP_POINT_TOLERANCE: f64 = 5.;
|
||||
pub const MAX_ALIGNMENT_CANDIDATES: usize = 100; // These are layers whose bounding boxes are used for alignment.
|
||||
pub const MAX_SNAP_CANDIDATES: usize = 10; // These are layers that are used for the layer snapper
|
||||
pub const MAX_LAYER_SNAP_POINTS: usize = 100; // These are points (anchors and bounding box corners etc.) in the layer snapper
|
||||
/// These are layers whose bounding boxes are used for alignment.
|
||||
pub const MAX_ALIGNMENT_CANDIDATES: usize = 100;
|
||||
/// These are layers that are used for the layer snapper.
|
||||
pub const MAX_SNAP_CANDIDATES: usize = 10;
|
||||
/// These are points (anchors and bounding box corners etc.) in the layer snapper.
|
||||
pub const MAX_LAYER_SNAP_POINTS: usize = 100;
|
||||
|
||||
pub const DRAG_THRESHOLD: f64 = 1.;
|
||||
|
||||
// Transforming layer
|
||||
// TRANSFORMING LAYER
|
||||
pub const ROTATE_SNAP_ANGLE: f64 = 15.;
|
||||
pub const SCALE_SNAP_INTERVAL: f64 = 0.1;
|
||||
pub const SLOWING_DIVISOR: f64 = 10.;
|
||||
pub const NUDGE_AMOUNT: f64 = 1.;
|
||||
pub const BIG_NUDGE_AMOUNT: f64 = 10.;
|
||||
|
||||
// Tools
|
||||
// TOOLS
|
||||
pub const DEFAULT_STROKE_WIDTH: f64 = 2.;
|
||||
|
||||
// Select tool
|
||||
// SELECT TOOL
|
||||
pub const SELECTION_TOLERANCE: f64 = 5.;
|
||||
pub const SELECTION_DRAG_ANGLE: f64 = 90.;
|
||||
pub const PIVOT_CROSSHAIR_THICKNESS: f64 = 1.;
|
||||
pub const PIVOT_CROSSHAIR_LENGTH: f64 = 9.;
|
||||
pub const PIVOT_DIAMETER: f64 = 5.;
|
||||
|
||||
// Transform overlay
|
||||
// TRANSFORM OVERLAY
|
||||
pub const ANGLE_MEASURE_RADIUS_FACTOR: f64 = 0.04;
|
||||
pub const ARC_MEASURE_RADIUS_FACTOR_RANGE: (f64, f64) = (0.05, 0.15);
|
||||
|
||||
// Transformation cage
|
||||
// TRANSFORM CAGE
|
||||
pub const BOUNDS_SELECT_THRESHOLD: f64 = 10.;
|
||||
pub const BOUNDS_ROTATE_THRESHOLD: f64 = 20.;
|
||||
pub const MIN_LENGTH_FOR_MIDPOINT_VISIBILITY: f64 = 20.;
|
||||
pub const MIN_LENGTH_FOR_CORNERS_VISIBILITY: f64 = 12.;
|
||||
/// When the width or height of the transform cage is less than this value, only the exterior of the bounding box will act as a click target for resizing.
|
||||
pub const MIN_LENGTH_FOR_RESIZE_TO_INCLUDE_INTERIOR: f64 = 40.;
|
||||
|
||||
// Path tool
|
||||
// PATH TOOL
|
||||
pub const MANIPULATOR_GROUP_MARKER_SIZE: f64 = 6.;
|
||||
pub const SELECTION_THRESHOLD: f64 = 10.;
|
||||
pub const HIDE_HANDLE_DISTANCE: f64 = 3.;
|
||||
pub const INSERT_POINT_ON_SEGMENT_TOO_FAR_DISTANCE: f64 = 50.;
|
||||
pub const HANDLE_ROTATE_SNAP_ANGLE: f64 = 15.;
|
||||
|
||||
// Pen tool
|
||||
// PEN TOOL
|
||||
pub const CREATE_CURVE_THRESHOLD: f64 = 5.;
|
||||
|
||||
// Spline tool
|
||||
// SPLINE TOOL
|
||||
pub const PATH_JOIN_THRESHOLD: f64 = 5.;
|
||||
|
||||
// Line tool
|
||||
// LINE TOOL
|
||||
pub const LINE_ROTATE_SNAP_ANGLE: f64 = 15.;
|
||||
|
||||
// Brush tool
|
||||
// BRUSH TOOL
|
||||
pub const BRUSH_SIZE_CHANGE_KEYBOARD: f64 = 5.;
|
||||
pub const DEFAULT_BRUSH_SIZE: f64 = 20.;
|
||||
|
||||
// Scrollbars
|
||||
// SCROLLBARS
|
||||
pub const SCROLLBAR_SPACING: f64 = 0.1;
|
||||
pub const ASYMPTOTIC_EFFECT: f64 = 0.5;
|
||||
pub const SCALE_EFFECT: f64 = 0.5;
|
||||
|
||||
// Colors
|
||||
// Keep changes to these colors updated with `Editor.svelte`
|
||||
// COLORS
|
||||
pub const COLOR_OVERLAY_BLUE: &str = "#00a8ff";
|
||||
pub const COLOR_OVERLAY_YELLOW: &str = "#ffc848";
|
||||
pub const COLOR_OVERLAY_GREEN: &str = "#63ce63";
|
||||
pub const COLOR_OVERLAY_RED: &str = "#ef5454";
|
||||
pub const COLOR_OVERLAY_GRAY: &str = "#cccccc";
|
||||
pub const COLOR_OVERLAY_WHITE: &str = "#ffffff";
|
||||
pub const COLOR_OVERLAY_SNAP_BACKGROUND: &str = "#000000cc";
|
||||
pub const COLOR_OVERLAY_LABEL_BACKGROUND: &str = "#000000cc";
|
||||
pub const COLOR_OVERLAY_TRANSPARENT: &str = "#ffffff00";
|
||||
|
||||
// Document
|
||||
// DOCUMENT
|
||||
pub const DEFAULT_DOCUMENT_NAME: &str = "Untitled Document";
|
||||
pub const FILE_SAVE_SUFFIX: &str = ".graphite";
|
||||
pub const MAX_UNDO_HISTORY_LEN: usize = 100; // TODO: Add this to user preferences
|
||||
|
||||
Reference in New Issue
Block a user