mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-16 23:08:05 +08:00
Retire layer paths used throughout the code (#1531)
* Part 1 * Part 2 * Part 3 * Part 4 * Part 5 * Part 6 * Part 7 * Part 8
This commit is contained in:
@@ -16,7 +16,8 @@ use alloc::vec::Vec;
|
||||
/// This data structure is somewhat similar to a linked list in terms of invariants.
|
||||
/// The downside is that currently it requires a lot of iteration.
|
||||
|
||||
type ElementId = u64;
|
||||
// TODO: Convert from a type alias to a newtype
|
||||
pub type ElementId = u64;
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize, specta::Type, Hash)]
|
||||
pub struct IdBackedVec<T> {
|
||||
/// Contained elements
|
||||
@@ -124,7 +125,7 @@ impl<T> IdBackedVec<T> {
|
||||
}
|
||||
|
||||
/// Enumerate the ids and elements in this container `(&ElementId, &T)`
|
||||
pub fn enumerate(&self) -> core::iter::Zip<core::slice::Iter<u64>, core::slice::Iter<T>> {
|
||||
pub fn enumerate(&self) -> core::iter::Zip<core::slice::Iter<ElementId>, core::slice::Iter<T>> {
|
||||
self.element_ids.iter().zip(self.elements.iter())
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ impl core::hash::Hash for Gradient {
|
||||
}
|
||||
impl Gradient {
|
||||
/// Constructs a new gradient with the colors at 0 and 1 specified.
|
||||
pub fn new(start: DVec2, start_color: Color, end: DVec2, end_color: Color, transform: DAffine2, _uuid: u64, gradient_type: GradientType) -> Self {
|
||||
pub fn new(start: DVec2, start_color: Color, end: DVec2, end_color: Color, transform: DAffine2, gradient_type: GradientType) -> Self {
|
||||
Gradient {
|
||||
start,
|
||||
end,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use super::consts::ManipulatorType;
|
||||
use super::id_vec::IdBackedVec;
|
||||
use super::manipulator_group::ManipulatorGroup;
|
||||
use super::manipulator_point::ManipulatorPoint;
|
||||
use super::{consts::ManipulatorType, id_vec::ElementId};
|
||||
use crate::uuid::ManipulatorGroupId;
|
||||
|
||||
use alloc::string::String;
|
||||
@@ -204,7 +204,7 @@ impl Subpath {
|
||||
|
||||
/// Delete the selected points from the [Subpath]
|
||||
pub fn delete_selected(&mut self) {
|
||||
let mut ids_to_delete: Vec<u64> = vec![];
|
||||
let mut ids_to_delete: Vec<ElementId> = vec![];
|
||||
for (id, manipulator_group) in self.manipulator_groups_mut().enumerate_mut() {
|
||||
if manipulator_group.is_anchor_selected() {
|
||||
ids_to_delete.push(*id);
|
||||
@@ -228,7 +228,7 @@ impl Subpath {
|
||||
// ** SELECTION OF POINTS **
|
||||
|
||||
/// Set a single point to a chosen selection state by providing `(manipulator group ID, manipulator type)`.
|
||||
pub fn select_point(&mut self, point: (u64, ManipulatorType), selected: bool) -> Option<&mut ManipulatorGroup> {
|
||||
pub fn select_point(&mut self, point: (ElementId, ManipulatorType), selected: bool) -> Option<&mut ManipulatorGroup> {
|
||||
let (manipulator_group_id, point_id) = point;
|
||||
if let Some(manipulator_group) = self.manipulator_groups_mut().by_id_mut(manipulator_group_id) {
|
||||
manipulator_group.select_point(point_id as usize, selected);
|
||||
@@ -240,7 +240,7 @@ impl Subpath {
|
||||
}
|
||||
|
||||
/// Set points in the [Subpath] to a chosen selection state, given by `(manipulator group ID, manipulator type)`.
|
||||
pub fn select_points(&mut self, points: &[(u64, ManipulatorType)], selected: bool) {
|
||||
pub fn select_points(&mut self, points: &[(ElementId, ManipulatorType)], selected: bool) {
|
||||
points.iter().for_each(|point| {
|
||||
self.select_point(*point, selected);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user