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:
kythyria
2025-05-01 12:14:26 +01:00
committed by GitHub
parent 9303953cf8
commit 9ef9b205d9
18 changed files with 713 additions and 990 deletions

View File

@@ -2,9 +2,10 @@ use crate::{Ctx, ExtractAnimationTime, ExtractTime};
const DAY: f64 = 1000. * 3600. * 24.;
#[derive(Debug, Clone, Copy, PartialEq, Eq, dyn_any::DynAny, Default, Hash)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, dyn_any::DynAny, Default, Hash, node_macro::ChoiceType)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum RealTimeMode {
#[label("UTC")]
Utc,
Year,
Hour,
@@ -13,18 +14,6 @@ pub enum RealTimeMode {
Second,
Millisecond,
}
impl core::fmt::Display for RealTimeMode {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
RealTimeMode::Utc => write!(f, "UTC"),
RealTimeMode::Year => write!(f, "Year"),
RealTimeMode::Hour => write!(f, "Hour"),
RealTimeMode::Minute => write!(f, "Minute"),
RealTimeMode::Second => write!(f, "Second"),
RealTimeMode::Millisecond => write!(f, "Millisecond"),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum AnimationTimeMode {