mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-16 23:08:05 +08:00
Groundwork for integrating Specta (#949)
* add derive(specta::Type) * use specta from git * introduce Uuid type * remove unnecessary specta::Type * document export_types test * upgrade Specta The previous Specta branch had some hacks that were just for this project. They have all been converted into proper features so they can be merged into main. * remove some unnecessary specta::Type uses * add MessageDiscriminantDef explanation * manually export types with specta * rename 'specta.rs' to 'export_types.rs' * rename 'export_types' to 'generate_ts_types' --------- Co-authored-by: Oscar Beaumont <oscar@otbeaumont.me>
This commit is contained in:
committed by
Keavon Chambers
parent
e0146d57f7
commit
5388b59e97
@@ -3,7 +3,7 @@ use core::ops::{Index, IndexMut};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[repr(usize)]
|
||||
#[derive(PartialEq, Eq, Clone, Debug, Copy, Serialize, Deserialize)]
|
||||
#[derive(PartialEq, Eq, Clone, Debug, Copy, Serialize, Deserialize, specta::Type)]
|
||||
pub enum ManipulatorType {
|
||||
Anchor,
|
||||
InHandle,
|
||||
|
||||
@@ -17,7 +17,7 @@ use alloc::vec::Vec;
|
||||
/// The downside is that currently it requires a lot of iteration.
|
||||
|
||||
type ElementId = u64;
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize, specta::Type)]
|
||||
pub struct IdBackedVec<T> {
|
||||
/// Contained elements
|
||||
elements: Vec<T>,
|
||||
|
||||
@@ -16,7 +16,7 @@ use serde::{Deserialize, Serialize};
|
||||
/// / | \
|
||||
/// "Anchor" "InHandle" "OutHandle" <- These are ManipulatorPoints and the only editable "primitive"
|
||||
/// ```
|
||||
#[derive(PartialEq, Clone, Debug, Serialize, Deserialize, Default)]
|
||||
#[derive(PartialEq, Clone, Debug, Serialize, Deserialize, Default, specta::Type)]
|
||||
pub struct ManipulatorGroup {
|
||||
/// Editable points for the anchor and handles.
|
||||
pub points: [Option<ManipulatorPoint>; 3],
|
||||
|
||||
@@ -3,7 +3,7 @@ use glam::{DAffine2, DVec2};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// [ManipulatorPoint] represents any editable Bezier point, either an anchor or handle
|
||||
#[derive(PartialEq, Clone, Debug, Serialize, Deserialize)]
|
||||
#[derive(PartialEq, Clone, Debug, Serialize, Deserialize, specta::Type)]
|
||||
pub struct ManipulatorPoint {
|
||||
/// The sibling element if this is a handle
|
||||
pub position: glam::DVec2,
|
||||
@@ -60,7 +60,7 @@ impl ManipulatorPoint {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Clone, Debug)]
|
||||
#[derive(PartialEq, Eq, Clone, Debug, specta::Type)]
|
||||
pub struct ManipulatorPointEditorState {
|
||||
/// Whether or not this manipulator point can be selected.
|
||||
pub can_be_selected: bool,
|
||||
|
||||
@@ -14,7 +14,7 @@ use serde::{Deserialize, Serialize};
|
||||
/// [Subpath] represents a single vector path, containing many [ManipulatorGroups].
|
||||
/// For each closed shape we keep a [Subpath] which contains the [ManipulatorGroup]s (handles and anchors) that define that shape.
|
||||
// TODO Add "closed" bool to subpath
|
||||
#[derive(PartialEq, Clone, Debug, Default, Serialize, Deserialize, DynAny)]
|
||||
#[derive(PartialEq, Clone, Debug, Default, Serialize, Deserialize, DynAny, specta::Type)]
|
||||
pub struct Subpath(IdBackedVec<ManipulatorGroup>);
|
||||
|
||||
impl Subpath {
|
||||
|
||||
Reference in New Issue
Block a user