mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-22 10:28:11 +08:00
Rename vector components to match new terminology (#719)
* Renamed VectorAnchor, VectorShape and VectorControlPoint. Also fixed other naming inconsistencies. * Renamed messages relating to vector and updated naming in several tools * Renamed comments + caught a few areas I had missed. * Caught a few more incorrect names * Code review pass * Review changes * Fixed warning * Additional review feedback Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
committed by
Keavon Chambers
co-authored by
Keavon Chambers
parent
5d1d93917d
commit
03633bf313
@@ -1,4 +1,4 @@
|
||||
use crate::consts::{COLOR_ACCENT, LINE_ROTATE_SNAP_ANGLE, SELECTION_TOLERANCE, VECTOR_MANIPULATOR_ANCHOR_MARKER_SIZE};
|
||||
use crate::consts::{COLOR_ACCENT, LINE_ROTATE_SNAP_ANGLE, MANIPULATOR_GROUP_MARKER_SIZE, SELECTION_TOLERANCE};
|
||||
use crate::document::DocumentMessageHandler;
|
||||
use crate::frontend::utility_types::MouseCursorIcon;
|
||||
use crate::input::keyboard::{Key, MouseMotion};
|
||||
@@ -141,7 +141,7 @@ impl Default for GradientToolFsmState {
|
||||
|
||||
/// Computes the transform from gradient space to layer space (where gradient space is 0..1 in layer space)
|
||||
fn gradient_space_transform(path: &[LayerId], layer: &Layer, document: &DocumentMessageHandler, font_cache: &FontCache) -> DAffine2 {
|
||||
let bounds = layer.aabounding_box_for_transform(DAffine2::IDENTITY, font_cache).unwrap();
|
||||
let bounds = layer.aabb_for_transform(DAffine2::IDENTITY, font_cache).unwrap();
|
||||
let bound_transform = DAffine2::from_scale_angle_translation(bounds[1] - bounds[0], 0., bounds[0]);
|
||||
|
||||
let multiplied = document.graphene_document.multiply_transforms(path).unwrap();
|
||||
@@ -163,7 +163,7 @@ impl GradientOverlay {
|
||||
fn generate_overlay_handle(translation: DVec2, responses: &mut VecDeque<Message>, selected: bool) -> Vec<LayerId> {
|
||||
let path = vec![generate_uuid()];
|
||||
|
||||
let size = DVec2::splat(VECTOR_MANIPULATOR_ANCHOR_MARKER_SIZE);
|
||||
let size = DVec2::splat(MANIPULATOR_GROUP_MARKER_SIZE);
|
||||
|
||||
let fill = if selected { Fill::solid(COLOR_ACCENT) } else { Fill::solid(Color::WHITE) };
|
||||
|
||||
@@ -359,7 +359,7 @@ impl Fsm for GradientToolFsmState {
|
||||
responses.push_back(BroadcastSignal::DocumentIsDirty.into());
|
||||
|
||||
let mouse = input.mouse.position;
|
||||
let tolerance = VECTOR_MANIPULATOR_ANCHOR_MARKER_SIZE.powi(2);
|
||||
let tolerance = MANIPULATOR_GROUP_MARKER_SIZE.powi(2);
|
||||
|
||||
let mut dragging = false;
|
||||
for overlay in &tool_data.gradient_overlays {
|
||||
|
||||
@@ -10,7 +10,7 @@ use crate::viewport_tools::vector_editor::overlay_renderer::OverlayRenderer;
|
||||
use crate::viewport_tools::vector_editor::shape_editor::ShapeEditor;
|
||||
|
||||
use graphene::intersection::Quad;
|
||||
use graphene::layers::vector::constants::ControlPointType;
|
||||
use graphene::layers::vector::constants::ManipulatorType;
|
||||
|
||||
use glam::DVec2;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -152,7 +152,7 @@ impl Fsm for PathToolFsmState {
|
||||
tool_data.shape_editor.set_selected_layers(layer_paths);
|
||||
// Render the new overlays
|
||||
for layer_path in tool_data.shape_editor.selected_layers() {
|
||||
tool_data.overlay_renderer.render_vector_shape_overlays(&document.graphene_document, layer_path.to_vec(), responses);
|
||||
tool_data.overlay_renderer.render_subpath_overlays(&document.graphene_document, layer_path.to_vec(), responses);
|
||||
}
|
||||
|
||||
// This can happen in any state (which is why we return self)
|
||||
@@ -162,7 +162,7 @@ impl Fsm for PathToolFsmState {
|
||||
// When the document has moved / needs to be redraw, re-render the overlays
|
||||
// TODO the overlay system should probably receive this message instead of the tool
|
||||
for layer_path in document.selected_visible_layers() {
|
||||
tool_data.overlay_renderer.render_vector_shape_overlays(&document.graphene_document, layer_path.to_vec(), responses);
|
||||
tool_data.overlay_renderer.render_subpath_overlays(&document.graphene_document, layer_path.to_vec(), responses);
|
||||
}
|
||||
|
||||
self
|
||||
@@ -186,9 +186,9 @@ impl Fsm for PathToolFsmState {
|
||||
// Do not snap against handles when anchor is selected
|
||||
let mut extension = Vec::new();
|
||||
for &(path, id, point_type) in new_selected.iter() {
|
||||
if point_type == ControlPointType::Anchor {
|
||||
extension.push((path, id, ControlPointType::InHandle));
|
||||
extension.push((path, id, ControlPointType::OutHandle));
|
||||
if point_type == ManipulatorType::Anchor {
|
||||
extension.push((path, id, ManipulatorType::InHandle));
|
||||
extension.push((path, id, ManipulatorType::OutHandle));
|
||||
}
|
||||
}
|
||||
new_selected.extend(extension);
|
||||
@@ -269,14 +269,14 @@ impl Fsm for PathToolFsmState {
|
||||
tool_data.shape_editor.delete_selected_points(responses);
|
||||
responses.push_back(SelectionChanged.into());
|
||||
for layer_path in document.all_layers() {
|
||||
tool_data.overlay_renderer.clear_vector_shape_overlays(&document.graphene_document, layer_path.to_vec(), responses);
|
||||
tool_data.overlay_renderer.clear_subpath_overlays(&document.graphene_document, layer_path.to_vec(), responses);
|
||||
}
|
||||
Ready
|
||||
}
|
||||
(_, Abort) => {
|
||||
// TODO Tell overlay manager to remove the overlays
|
||||
for layer_path in document.all_layers() {
|
||||
tool_data.overlay_renderer.clear_vector_shape_overlays(&document.graphene_document, layer_path.to_vec(), responses);
|
||||
tool_data.overlay_renderer.clear_subpath_overlays(&document.graphene_document, layer_path.to_vec(), responses);
|
||||
}
|
||||
Ready
|
||||
}
|
||||
|
||||
@@ -11,9 +11,9 @@ use crate::viewport_tools::tool::{Fsm, SignalToMessageMap, ToolActionHandlerData
|
||||
use crate::viewport_tools::vector_editor::overlay_renderer::OverlayRenderer;
|
||||
|
||||
use graphene::layers::style;
|
||||
use graphene::layers::vector::constants::ControlPointType;
|
||||
use graphene::layers::vector::vector_anchor::VectorAnchor;
|
||||
use graphene::layers::vector::vector_shape::VectorShape;
|
||||
use graphene::layers::vector::constants::ManipulatorType;
|
||||
use graphene::layers::vector::manipulator_group::ManipulatorGroup;
|
||||
use graphene::layers::vector::subpath::Subpath;
|
||||
use graphene::Operation;
|
||||
|
||||
use glam::{DAffine2, DVec2};
|
||||
@@ -180,7 +180,7 @@ impl Fsm for PenToolFsmState {
|
||||
// When the document has moved / needs to be redraw, re-render the overlays
|
||||
// TODO the overlay system should probably receive this message instead of the tool
|
||||
for layer_path in document.selected_visible_layers() {
|
||||
tool_data.overlay_renderer.render_vector_shape_overlays(&document.graphene_document, layer_path.to_vec(), responses);
|
||||
tool_data.overlay_renderer.render_subpath_overlays(&document.graphene_document, layer_path.to_vec(), responses);
|
||||
}
|
||||
self
|
||||
}
|
||||
@@ -217,12 +217,15 @@ impl Fsm for PenToolFsmState {
|
||||
path: layer_path.clone(),
|
||||
transform: DAffine2::IDENTITY.to_cols_array(),
|
||||
insert_index: -1,
|
||||
vector_path: Default::default(),
|
||||
subpath: Default::default(),
|
||||
style: style::PathStyle::new(Some(style::Stroke::new(global_tool_data.primary_color, tool_data.weight)), style::Fill::None),
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
responses.push_back(add_anchor(&tool_data.path, VectorAnchor::new_with_handles(start_position, Some(start_position), Some(start_position))));
|
||||
responses.push_back(add_manipulator_group(
|
||||
&tool_data.path,
|
||||
ManipulatorGroup::new_with_handles(start_position, Some(start_position), Some(start_position)),
|
||||
));
|
||||
}
|
||||
|
||||
PenToolFsmState::DraggingHandle
|
||||
@@ -231,9 +234,9 @@ impl Fsm for PenToolFsmState {
|
||||
(PenToolFsmState::DraggingHandle, PenToolMessage::DragStop) => {
|
||||
// Add new point onto path
|
||||
if let Some(layer_path) = &tool_data.path {
|
||||
if let Some(vector_anchor) = get_vector_shape(layer_path, document).and_then(|shape| shape.anchors().last()) {
|
||||
if let Some(anchor) = &vector_anchor.points[ControlPointType::OutHandle] {
|
||||
responses.push_back(add_anchor(&tool_data.path, VectorAnchor::new(anchor.position)));
|
||||
if let Some(manipulator_group) = get_subpath(layer_path, document).and_then(|subpath| subpath.manipulator_groups().last()) {
|
||||
if let Some(out_handle) = &manipulator_group.points[ManipulatorType::OutHandle] {
|
||||
responses.push_back(add_manipulator_group(&tool_data.path, ManipulatorGroup::new_with_anchor(out_handle.position)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -244,29 +247,29 @@ impl Fsm for PenToolFsmState {
|
||||
if let Some(layer_path) = &tool_data.path {
|
||||
let mouse = tool_data.snap_handler.snap_position(responses, document, input.mouse.position);
|
||||
let mut pos = transform.inverse().transform_point2(mouse);
|
||||
if let Some(((&id, anchor), _previous)) = get_vector_shape(layer_path, document).and_then(last_2_anchors) {
|
||||
if let Some(anchor) = anchor.points[ControlPointType::Anchor as usize].as_ref() {
|
||||
if let Some(((&id, manipulator_group), _previous)) = get_subpath(layer_path, document).and_then(last_2_manipulator_groups) {
|
||||
if let Some(anchor) = manipulator_group.points[ManipulatorType::Anchor].as_ref() {
|
||||
pos = compute_snapped_angle(input, snap_angle, pos, anchor.position);
|
||||
}
|
||||
|
||||
// Update points on current segment (to show preview of new handle)
|
||||
let msg = Operation::MoveVectorPoint {
|
||||
let msg = Operation::MoveManipulatorPoint {
|
||||
layer_path: layer_path.clone(),
|
||||
id,
|
||||
control_type: ControlPointType::OutHandle,
|
||||
manipulator_type: ManipulatorType::OutHandle,
|
||||
position: pos.into(),
|
||||
};
|
||||
responses.push_back(msg.into());
|
||||
|
||||
// Mirror handle of last segement
|
||||
if !input.keyboard.get(break_handle as usize) && get_vector_shape(layer_path, document).map(|shape| shape.anchors().len() > 1).unwrap_or_default() {
|
||||
if let Some(anchor) = anchor.points[ControlPointType::Anchor as usize].as_ref() {
|
||||
// Mirror handle of last segment
|
||||
if !input.keyboard.get(break_handle as usize) && get_subpath(layer_path, document).map(|shape| shape.manipulator_groups().len() > 1).unwrap_or_default() {
|
||||
if let Some(anchor) = manipulator_group.points[ManipulatorType::Anchor].as_ref() {
|
||||
pos = anchor.position - (pos - anchor.position);
|
||||
}
|
||||
let msg = Operation::MoveVectorPoint {
|
||||
let msg = Operation::MoveManipulatorPoint {
|
||||
layer_path: layer_path.clone(),
|
||||
id,
|
||||
control_type: ControlPointType::InHandle,
|
||||
manipulator_type: ManipulatorType::InHandle,
|
||||
position: pos.into(),
|
||||
};
|
||||
responses.push_back(msg.into());
|
||||
@@ -281,16 +284,16 @@ impl Fsm for PenToolFsmState {
|
||||
let mouse = tool_data.snap_handler.snap_position(responses, document, input.mouse.position);
|
||||
let mut pos = transform.inverse().transform_point2(mouse);
|
||||
|
||||
if let Some(((&id, _anchor), previous)) = get_vector_shape(layer_path, document).and_then(last_2_anchors) {
|
||||
if let Some(relative) = previous.as_ref().and_then(|(_, anchor)| anchor.points[ControlPointType::Anchor as usize].as_ref()) {
|
||||
if let Some(((&id, _), previous)) = get_subpath(layer_path, document).and_then(last_2_manipulator_groups) {
|
||||
if let Some(relative) = previous.as_ref().and_then(|(_, manipulator_group)| manipulator_group.points[ManipulatorType::Anchor].as_ref()) {
|
||||
pos = compute_snapped_angle(input, snap_angle, pos, relative.position);
|
||||
}
|
||||
|
||||
for control_type in [ControlPointType::Anchor, ControlPointType::InHandle, ControlPointType::OutHandle] {
|
||||
let msg = Operation::MoveVectorPoint {
|
||||
for manipulator_type in [ManipulatorType::Anchor, ManipulatorType::InHandle, ManipulatorType::OutHandle] {
|
||||
let msg = Operation::MoveManipulatorPoint {
|
||||
layer_path: layer_path.clone(),
|
||||
id,
|
||||
control_type,
|
||||
manipulator_type,
|
||||
position: pos.into(),
|
||||
};
|
||||
responses.push_back(msg.into());
|
||||
@@ -303,25 +306,25 @@ impl Fsm for PenToolFsmState {
|
||||
(PenToolFsmState::DraggingHandle | PenToolFsmState::PlacingAnchor, PenToolMessage::Abort | PenToolMessage::Confirm) => {
|
||||
// Abort or commit the transaction to the undo history
|
||||
if let Some(layer_path) = tool_data.path.as_ref() {
|
||||
if let Some(vector_shape) = (get_vector_shape(layer_path, document)).filter(|vector_shape| vector_shape.anchors().len() > 1) {
|
||||
if let Some(((&(mut id), mut anchor), previous)) = last_2_anchors(vector_shape) {
|
||||
if let Some(subpath) = (get_subpath(layer_path, document)).filter(|subpath| subpath.manipulator_groups().len() > 1) {
|
||||
if let Some(((&(mut id), mut manipulator_group), previous)) = last_2_manipulator_groups(subpath) {
|
||||
// Remove the unplaced anchor if in anchor placing mode
|
||||
if self == PenToolFsmState::PlacingAnchor {
|
||||
let layer_path = layer_path.clone();
|
||||
let op = Operation::RemoveVectorAnchor { layer_path, id };
|
||||
let op = Operation::RemoveManipulatorGroup { layer_path, id };
|
||||
responses.push_back(op.into());
|
||||
if let Some((&new_id, new_anchor)) = previous {
|
||||
if let Some((&new_id, new_manipulator_group)) = previous {
|
||||
id = new_id;
|
||||
anchor = new_anchor;
|
||||
manipulator_group = new_manipulator_group;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the out handle if in dragging handle mode
|
||||
let op = Operation::MoveVectorPoint {
|
||||
let op = Operation::MoveManipulatorPoint {
|
||||
layer_path: layer_path.clone(),
|
||||
id,
|
||||
control_type: ControlPointType::OutHandle,
|
||||
position: anchor.points[ControlPointType::Anchor as usize].as_ref().unwrap().position.into(),
|
||||
manipulator_type: ManipulatorType::OutHandle,
|
||||
position: manipulator_group.points[ManipulatorType::Anchor].as_ref().unwrap().position.into(),
|
||||
};
|
||||
responses.push_back(op.into());
|
||||
}
|
||||
@@ -334,7 +337,7 @@ impl Fsm for PenToolFsmState {
|
||||
|
||||
// Clean up overlays
|
||||
for layer_path in document.all_layers() {
|
||||
tool_data.overlay_renderer.clear_vector_shape_overlays(&document.graphene_document, layer_path.to_vec(), responses);
|
||||
tool_data.overlay_renderer.clear_subpath_overlays(&document.graphene_document, layer_path.to_vec(), responses);
|
||||
}
|
||||
tool_data.path = None;
|
||||
tool_data.snap_handler.cleanup(responses);
|
||||
@@ -344,7 +347,7 @@ impl Fsm for PenToolFsmState {
|
||||
(_, PenToolMessage::Abort) => {
|
||||
// Clean up overlays
|
||||
for layer_path in document.all_layers() {
|
||||
tool_data.overlay_renderer.clear_vector_shape_overlays(&document.graphene_document, layer_path.to_vec(), responses);
|
||||
tool_data.overlay_renderer.clear_subpath_overlays(&document.graphene_document, layer_path.to_vec(), responses);
|
||||
}
|
||||
self
|
||||
}
|
||||
@@ -373,7 +376,7 @@ impl Fsm for PenToolFsmState {
|
||||
HintGroup(vec![HintInfo {
|
||||
key_groups: vec![],
|
||||
mouse: Some(MouseMotion::Lmb),
|
||||
label: String::from("Add Control Point"),
|
||||
label: String::from("Add Anchor"),
|
||||
plus: false,
|
||||
}]),
|
||||
HintGroup(vec![HintInfo {
|
||||
@@ -406,7 +409,7 @@ impl Fsm for PenToolFsmState {
|
||||
}
|
||||
|
||||
// TODO: Expand `pos` name below to the full word (position?)
|
||||
/// Snap the angle of the line from relative to pos if the key is pressed
|
||||
/// Snap the angle of the line from relative to pos if the key is pressed.
|
||||
fn compute_snapped_angle(input: &InputPreprocessorMessageHandler, key: Key, pos: DVec2, relative: DVec2) -> DVec2 {
|
||||
if input.keyboard.get(key as usize) {
|
||||
let delta = relative - pos;
|
||||
@@ -424,12 +427,12 @@ fn compute_snapped_angle(input: &InputPreprocessorMessageHandler, key: Key, pos:
|
||||
}
|
||||
}
|
||||
|
||||
/// Pushes an anchor to the current layer via an [Operation]
|
||||
fn add_anchor(layer_path: &Option<Vec<LayerId>>, anchor: VectorAnchor) -> Message {
|
||||
/// Pushes a [ManipulatorGroup] to the current layer via an [Operation].
|
||||
fn add_manipulator_group(layer_path: &Option<Vec<LayerId>>, manipulator_group: ManipulatorGroup) -> Message {
|
||||
if let Some(layer_path) = layer_path {
|
||||
Operation::PushVectorAnchor {
|
||||
Operation::PushManipulatorGroup {
|
||||
layer_path: layer_path.clone(),
|
||||
anchor,
|
||||
manipulator_group,
|
||||
}
|
||||
.into()
|
||||
} else {
|
||||
@@ -437,20 +440,20 @@ fn add_anchor(layer_path: &Option<Vec<LayerId>>, anchor: VectorAnchor) -> Messag
|
||||
}
|
||||
}
|
||||
|
||||
/// Gets the currently editing [VectorShape]
|
||||
fn get_vector_shape<'a>(layer_path: &'a [LayerId], document: &'a DocumentMessageHandler) -> Option<&'a VectorShape> {
|
||||
document.graphene_document.layer(layer_path).ok().and_then(|layer| layer.as_vector_shape())
|
||||
/// Gets the currently editing [Subpath].
|
||||
fn get_subpath<'a>(layer_path: &'a [LayerId], document: &'a DocumentMessageHandler) -> Option<&'a Subpath> {
|
||||
document.graphene_document.layer(layer_path).ok().and_then(|layer| layer.as_subpath())
|
||||
}
|
||||
|
||||
type AnchorRef<'a> = (&'a u64, &'a VectorAnchor);
|
||||
type ManipulatorGroupRef<'a> = (&'a u64, &'a ManipulatorGroup);
|
||||
|
||||
/// Gets the last 2 [VectorAnchor] on the currently editing layer along with its id
|
||||
fn last_2_anchors(vector_shape: &VectorShape) -> Option<(AnchorRef, Option<AnchorRef>)> {
|
||||
vector_shape.anchors().enumerate().last().map(|last| {
|
||||
/// Gets the last 2 [ManipulatorGroup]s on the currently editing layer along with its ID.
|
||||
fn last_2_manipulator_groups(subpath: &Subpath) -> Option<(ManipulatorGroupRef, Option<ManipulatorGroupRef>)> {
|
||||
subpath.manipulator_groups().enumerate().last().map(|last| {
|
||||
(
|
||||
last,
|
||||
(vector_shape.anchors().len() > 1)
|
||||
.then(|| vector_shape.anchors().enumerate().nth(vector_shape.anchors().len() - 2))
|
||||
(subpath.manipulator_groups().len() > 1)
|
||||
.then(|| subpath.manipulator_groups().enumerate().nth(subpath.manipulator_groups().len() - 2))
|
||||
.flatten(),
|
||||
)
|
||||
})
|
||||
|
||||
@@ -7,7 +7,7 @@ use graphene::intersection::Quad;
|
||||
use graphene::layers::layer_info::LayerDataType;
|
||||
use graphene::layers::style::{self, Fill, Stroke};
|
||||
use graphene::layers::text_layer::FontCache;
|
||||
use graphene::layers::vector::vector_shape::VectorShape;
|
||||
use graphene::layers::vector::subpath::Subpath;
|
||||
use graphene::{LayerId, Operation};
|
||||
|
||||
use glam::{DAffine2, DVec2};
|
||||
@@ -35,12 +35,10 @@ impl PathOutline {
|
||||
|
||||
// TODO Purge this area of BezPath and Kurbo
|
||||
// Get the bezpath from the shape or text
|
||||
let vector_path = match &document_layer.data {
|
||||
let subpath = match &document_layer.data {
|
||||
LayerDataType::Shape(layer_shape) => Some(layer_shape.shape.clone()),
|
||||
LayerDataType::Text(text) => Some(text.to_vector_path_nonmut(font_cache)),
|
||||
_ => document_layer
|
||||
.aabounding_box_for_transform(DAffine2::IDENTITY, font_cache)
|
||||
.map(|[p1, p2]| VectorShape::new_rect(p1, p2)),
|
||||
LayerDataType::Text(text) => Some(text.to_subpath_nonmut(font_cache)),
|
||||
_ => document_layer.aabb_for_transform(DAffine2::IDENTITY, font_cache).map(|[p1, p2]| Subpath::new_rect(p1, p2)),
|
||||
}?;
|
||||
|
||||
// Generate a new overlay layer if necessary
|
||||
@@ -50,7 +48,7 @@ impl PathOutline {
|
||||
let overlay_path = vec![generate_uuid()];
|
||||
let operation = Operation::AddShape {
|
||||
path: overlay_path.clone(),
|
||||
vector_path: Default::default(),
|
||||
subpath: Default::default(),
|
||||
style: style::PathStyle::new(Some(Stroke::new(COLOR_ACCENT, PATH_OUTLINE_WEIGHT)), Fill::None),
|
||||
insert_index: -1,
|
||||
transform: DAffine2::IDENTITY.to_cols_array(),
|
||||
@@ -63,7 +61,7 @@ impl PathOutline {
|
||||
};
|
||||
|
||||
// Update the shape bezpath
|
||||
let operation = Operation::SetShapePath { path: overlay.clone(), vector_path };
|
||||
let operation = Operation::SetShapePath { path: overlay.clone(), subpath };
|
||||
responses.push_back(DocumentMessage::Overlays(operation.into()).into());
|
||||
|
||||
// Update the transform to match the document
|
||||
@@ -110,7 +108,7 @@ impl PathOutline {
|
||||
}
|
||||
}
|
||||
|
||||
/// Clears overlays for the seleted paths and removes references
|
||||
/// Clears overlays for the selected paths and removes references
|
||||
pub fn clear_selected(&mut self, responses: &mut VecDeque<Message>) {
|
||||
while let Some(path) = self.selected_overlay_paths.pop() {
|
||||
let operation = Operation::DeleteLayer { path };
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::consts::{BOUNDS_ROTATE_THRESHOLD, BOUNDS_SELECT_THRESHOLD, COLOR_ACCENT, SELECTION_DRAG_ANGLE, VECTOR_MANIPULATOR_ANCHOR_MARKER_SIZE};
|
||||
use crate::consts::{BOUNDS_ROTATE_THRESHOLD, BOUNDS_SELECT_THRESHOLD, COLOR_ACCENT, MANIPULATOR_GROUP_MARKER_SIZE, SELECTION_DRAG_ANGLE};
|
||||
use crate::document::transformation::OriginalTransforms;
|
||||
use crate::frontend::utility_types::MouseCursorIcon;
|
||||
use crate::input::InputPreprocessorMessageHandler;
|
||||
@@ -219,7 +219,7 @@ impl BoundingBoxOverlays {
|
||||
}
|
||||
}
|
||||
|
||||
/// Calculats the transformed handle positions based on the bounding box and the transform
|
||||
/// Calculates the transformed handle positions based on the bounding box and the transform
|
||||
pub fn evaluate_transform_handle_positions(&self) -> [DVec2; 8] {
|
||||
let (left, top): (f64, f64) = self.bounds[0].into();
|
||||
let (right, bottom): (f64, f64) = self.bounds[1].into();
|
||||
@@ -245,7 +245,7 @@ impl BoundingBoxOverlays {
|
||||
const BIAS: f64 = 0.0001;
|
||||
|
||||
for (position, path) in self.evaluate_transform_handle_positions().into_iter().zip(&self.transform_handles) {
|
||||
let scale = DVec2::splat(VECTOR_MANIPULATOR_ANCHOR_MARKER_SIZE);
|
||||
let scale = DVec2::splat(MANIPULATOR_GROUP_MARKER_SIZE);
|
||||
let translation = (position - (scale / 2.) - 0.5 + BIAS).round();
|
||||
let transform = DAffine2::from_scale_angle_translation(scale, 0., translation).to_cols_array();
|
||||
let path = path.clone();
|
||||
|
||||
@@ -238,7 +238,7 @@ fn update_overlays(document: &DocumentMessageHandler, tool_data: &mut TextToolDa
|
||||
.graphene_document
|
||||
.layer(layer_path)
|
||||
.unwrap()
|
||||
.aabounding_box_for_transform(document.graphene_document.multiply_transforms(layer_path).unwrap(), font_cache)
|
||||
.aabb_for_transform(document.graphene_document.multiply_transforms(layer_path).unwrap(), font_cache)
|
||||
.map(|bounds| (bounds, overlay_path))
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
Reference in New Issue
Block a user