mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-08-31 02:07:21 +00:00
Auto-generate enum type widget boilerplate for radio buttons and dropdown menus (#2589)
* First draft of factoring out the dropdown boilerplate * Add proc macro for enum boilerplate * Detect whether to say `crate` or the name * Clean up the input and naming of the enum macro * Rename a file * Do the rename of code too * Use the attribute-driven selection of radio vs dropdown * Add a metadata struct and tooltips * Move the new traits to a better place. * Use ChoiceType, part 1 * Use ChoiceType, part 2 * Introduce a builder API for choice widgets * Start using the new new API * DomainWarpType should be a dropdown still * Handle the case where a node property can never have a socket * Rustfmt * Code review * Update stable node IDs in test --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
parent
9303953cf8
commit
9ef9b205d9
18 changed files with 713 additions and 990 deletions
|
@ -157,56 +157,75 @@ macro_rules! tagged_value {
|
|||
}
|
||||
|
||||
tagged_value! {
|
||||
// TODO: Eventually remove this migration document upgrade code
|
||||
#[cfg_attr(all(feature = "serde", target_arch = "wasm32"), serde(deserialize_with = "graphene_core::raster::image::migrate_image_frame"))]
|
||||
ImageFrame(graphene_core::raster::image::ImageFrameTable<Color>),
|
||||
// TODO: Eventually remove this migration document upgrade code
|
||||
#[cfg_attr(all(feature = "serde", target_arch = "wasm32"), serde(deserialize_with = "graphene_core::vector::migrate_vector_data"))]
|
||||
VectorData(graphene_core::vector::VectorDataTable),
|
||||
// TODO: Eventually remove this migration document upgrade code
|
||||
#[cfg_attr(all(feature = "serde", target_arch = "wasm32"), serde(deserialize_with = "graphene_core::migrate_graphic_group"))]
|
||||
GraphicGroup(graphene_core::GraphicGroupTable),
|
||||
// TODO: Eventually remove this migration document upgrade code
|
||||
#[cfg_attr(all(feature = "serde", target_arch = "wasm32"), serde(deserialize_with = "graphene_core::migrate_artboard_group"))]
|
||||
ArtboardGroup(graphene_core::ArtboardGroupTable),
|
||||
GraphicElement(graphene_core::GraphicElement),
|
||||
Artboard(graphene_core::Artboard),
|
||||
String(String),
|
||||
// ===============
|
||||
// PRIMITIVE TYPES
|
||||
// ===============
|
||||
#[cfg_attr(feature = "serde", serde(alias = "F32"))] // TODO: Eventually remove this alias document upgrade code
|
||||
F64(f64),
|
||||
U32(u32),
|
||||
U64(u64),
|
||||
// TODO: Eventually remove this alias document upgrade code
|
||||
#[cfg_attr(feature = "serde", serde(alias = "F32"))]
|
||||
F64(f64),
|
||||
OptionalF64(Option<f64>),
|
||||
Bool(bool),
|
||||
String(String),
|
||||
UVec2(UVec2),
|
||||
IVec2(IVec2),
|
||||
DVec2(DVec2),
|
||||
OptionalDVec2(Option<DVec2>),
|
||||
DAffine2(DAffine2),
|
||||
OptionalF64(Option<f64>),
|
||||
OptionalDVec2(Option<DVec2>),
|
||||
// ==========================
|
||||
// PRIMITIVE COLLECTION TYPES
|
||||
// ==========================
|
||||
#[cfg_attr(feature = "serde", serde(alias = "VecF32"))] // TODO: Eventually remove this alias document upgrade code
|
||||
VecF64(Vec<f64>),
|
||||
VecU64(Vec<u64>),
|
||||
VecDVec2(Vec<DVec2>),
|
||||
F64Array4([f64; 4]),
|
||||
NodePath(Vec<NodeId>),
|
||||
#[cfg_attr(feature = "serde", serde(alias = "ManipulatorGroupIds"))] // TODO: Eventually remove this alias document upgrade code
|
||||
PointIds(Vec<graphene_core::vector::PointId>),
|
||||
// ====================
|
||||
// GRAPHICAL DATA TYPES
|
||||
// ====================
|
||||
GraphicElement(graphene_core::GraphicElement),
|
||||
#[cfg_attr(all(feature = "serde", target_arch = "wasm32"), serde(deserialize_with = "graphene_core::vector::migrate_vector_data"))] // TODO: Eventually remove this migration document upgrade code
|
||||
VectorData(graphene_core::vector::VectorDataTable),
|
||||
#[cfg_attr(all(feature = "serde", target_arch = "wasm32"), serde(deserialize_with = "graphene_core::raster::image::migrate_image_frame"))] // TODO: Eventually remove this migration document upgrade code
|
||||
ImageFrame(graphene_core::raster::image::ImageFrameTable<Color>),
|
||||
#[cfg_attr(all(feature = "serde", target_arch = "wasm32"), serde(deserialize_with = "graphene_core::migrate_graphic_group"))] // TODO: Eventually remove this migration document upgrade code
|
||||
GraphicGroup(graphene_core::GraphicGroupTable),
|
||||
#[cfg_attr(all(feature = "serde", target_arch = "wasm32"), serde(deserialize_with = "graphene_core::migrate_artboard_group"))] // TODO: Eventually remove this migration document upgrade code
|
||||
ArtboardGroup(graphene_core::ArtboardGroupTable),
|
||||
// ============
|
||||
// STRUCT TYPES
|
||||
// ============
|
||||
Artboard(graphene_core::Artboard),
|
||||
Image(graphene_core::raster::Image<Color>),
|
||||
Color(graphene_core::raster::color::Color),
|
||||
OptionalColor(Option<graphene_core::raster::color::Color>),
|
||||
Palette(Vec<Color>),
|
||||
Subpaths(Vec<bezier_rs::Subpath<graphene_core::vector::PointId>>),
|
||||
BlendMode(BlendMode),
|
||||
LuminanceCalculation(LuminanceCalculation),
|
||||
// ImaginateCache(ImaginateCache),
|
||||
// ImaginateSamplingMethod(ImaginateSamplingMethod),
|
||||
// ImaginateMaskStartingFill(ImaginateMaskStartingFill),
|
||||
// ImaginateController(ImaginateController),
|
||||
Fill(graphene_core::vector::style::Fill),
|
||||
Stroke(graphene_core::vector::style::Stroke),
|
||||
F64Array4([f64; 4]),
|
||||
// TODO: Eventually remove this alias document upgrade code
|
||||
#[cfg_attr(feature = "serde", serde(alias = "VecF32"))]
|
||||
VecF64(Vec<f64>),
|
||||
VecU64(Vec<u64>),
|
||||
NodePath(Vec<NodeId>),
|
||||
VecDVec2(Vec<DVec2>),
|
||||
Gradient(graphene_core::vector::style::Gradient),
|
||||
#[cfg_attr(feature = "serde", serde(alias = "GradientPositions"))] // TODO: Eventually remove this alias document upgrade code
|
||||
GradientStops(graphene_core::vector::style::GradientStops),
|
||||
Font(graphene_core::text::Font),
|
||||
BrushStrokes(Vec<graphene_core::vector::brush_stroke::BrushStroke>),
|
||||
BrushCache(BrushCache),
|
||||
DocumentNode(DocumentNode),
|
||||
Curve(graphene_core::raster::curve::Curve),
|
||||
Footprint(graphene_core::transform::Footprint),
|
||||
VectorModification(Box<graphene_core::vector::VectorModification>),
|
||||
FontCache(Arc<graphene_core::text::FontCache>),
|
||||
// ==========
|
||||
// ENUM TYPES
|
||||
// ==========
|
||||
BlendMode(BlendMode),
|
||||
LuminanceCalculation(LuminanceCalculation),
|
||||
XY(graphene_core::ops::XY),
|
||||
RedGreenBlue(graphene_core::raster::RedGreenBlue),
|
||||
RealTimeMode(graphene_core::animation::RealTimeMode),
|
||||
RedGreenBlueAlpha(graphene_core::raster::RedGreenBlueAlpha),
|
||||
RealTimeMode(graphene_core::animation::RealTimeMode),
|
||||
NoiseType(graphene_core::raster::NoiseType),
|
||||
FractalType(graphene_core::raster::FractalType),
|
||||
CellularDistanceFunction(graphene_core::raster::CellularDistanceFunction),
|
||||
|
@ -220,26 +239,15 @@ tagged_value! {
|
|||
LineJoin(graphene_core::vector::style::LineJoin),
|
||||
FillType(graphene_core::vector::style::FillType),
|
||||
FillChoice(graphene_core::vector::style::FillChoice),
|
||||
Gradient(graphene_core::vector::style::Gradient),
|
||||
GradientType(graphene_core::vector::style::GradientType),
|
||||
// TODO: Eventually remove this alias document upgrade code
|
||||
#[cfg_attr(feature = "serde", serde(alias = "GradientPositions"))]
|
||||
GradientStops(graphene_core::vector::style::GradientStops),
|
||||
// TODO: Eventually remove this alias document upgrade code
|
||||
#[cfg_attr(feature = "serde", serde(alias = "ManipulatorGroupIds"))]
|
||||
PointIds(Vec<graphene_core::vector::PointId>),
|
||||
Font(graphene_core::text::Font),
|
||||
BrushStrokes(Vec<graphene_core::vector::brush_stroke::BrushStroke>),
|
||||
BrushCache(BrushCache),
|
||||
DocumentNode(DocumentNode),
|
||||
Curve(graphene_core::raster::curve::Curve),
|
||||
Footprint(graphene_core::transform::Footprint),
|
||||
ReferencePoint(graphene_core::transform::ReferencePoint),
|
||||
Palette(Vec<Color>),
|
||||
VectorModification(Box<graphene_core::vector::VectorModification>),
|
||||
CentroidType(graphene_core::vector::misc::CentroidType),
|
||||
BooleanOperation(graphene_core::vector::misc::BooleanOperation),
|
||||
FontCache(Arc<graphene_core::text::FontCache>),
|
||||
|
||||
// ImaginateCache(ImaginateCache),
|
||||
// ImaginateSamplingMethod(ImaginateSamplingMethod),
|
||||
// ImaginateMaskStartingFill(ImaginateMaskStartingFill),
|
||||
// ImaginateController(ImaginateController),
|
||||
}
|
||||
|
||||
impl TaggedValue {
|
||||
|
|
|
@ -938,12 +938,12 @@ mod test {
|
|||
assert_eq!(
|
||||
ids,
|
||||
vec![
|
||||
NodeId(8409339180888025381),
|
||||
NodeId(210279231591542793),
|
||||
NodeId(11043024792989571946),
|
||||
NodeId(16261870568621497283),
|
||||
NodeId(6520148642810552409),
|
||||
NodeId(8779776256867305756)
|
||||
NodeId(16997244687192517417),
|
||||
NodeId(12226224850522777131),
|
||||
NodeId(9162113827627229771),
|
||||
NodeId(12793582657066318419),
|
||||
NodeId(16945623684036608820),
|
||||
NodeId(2640415155091892458)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue