pub enum MotionExpr {
Show 21 variants
Value(MotionValue),
IntrinsicWidth,
IntrinsicHeight,
LayoutX(WidgetId),
LayoutY(WidgetId),
LayoutWidth(WidgetId),
LayoutHeight(WidgetId),
PointerLocalX,
PointerLocalY,
If {
predicate: MotionPredicate,
then_expr: Box<MotionExpr>,
else_expr: Box<MotionExpr>,
},
Add(Box<MotionExpr>, Box<MotionExpr>),
Sub(Box<MotionExpr>, Box<MotionExpr>),
Mul(Box<MotionExpr>, Box<MotionExpr>),
Div(Box<MotionExpr>, Box<MotionExpr>),
Neg(Box<MotionExpr>),
Abs(Box<MotionExpr>),
Min(Box<MotionExpr>, Box<MotionExpr>),
Max(Box<MotionExpr>, Box<MotionExpr>),
Clamp {
value: Box<MotionExpr>,
min: Box<MotionExpr>,
max: Box<MotionExpr>,
},
Lerp {
from: Box<MotionExpr>,
to: Box<MotionExpr>,
t: Box<MotionExpr>,
},
MapRange {
value: Box<MotionExpr>,
from_start: f32,
from_end: f32,
to_start: f32,
to_end: f32,
clamp: bool,
},
}Expand description
Declarative expression evaluated by the motion runtime.
Expressions are the closed IR for motion targets. They can reference layout snapshots, pointer position, interaction predicates, and numeric operators without requiring arbitrary per-frame callbacks.
use fission::motion::{
scalar, MotionExpr, MotionPredicate, MotionPropertyId, MotionStartValue, MotionTrack,
};
use fission::WidgetId;
let button_id = WidgetId::explicit("save_button");
let scale = MotionTrack::composite(
MotionPropertyId::Scale,
MotionStartValue::Current,
MotionExpr::If {
predicate: MotionPredicate::Pressed(button_id),
then_expr: Box::new(scalar(0.96)),
else_expr: Box::new(scalar(1.0)),
},
);Variants§
Value(MotionValue)
Literal typed value.
IntrinsicWidth
Current widget intrinsic width.
IntrinsicHeight
Current widget intrinsic height.
LayoutX(WidgetId)
X position of another widget from the latest layout snapshot.
LayoutY(WidgetId)
Y position of another widget from the latest layout snapshot.
LayoutWidth(WidgetId)
Width of another widget from the latest layout snapshot.
LayoutHeight(WidgetId)
Height of another widget from the latest layout snapshot.
PointerLocalX
Pointer x-position local to the tracked widget.
PointerLocalY
Pointer y-position local to the tracked widget.
If
Conditional expression selected by a runtime predicate.
Fields
predicate: MotionPredicateRuntime predicate to test.
then_expr: Box<MotionExpr>Expression evaluated when the predicate is true.
else_expr: Box<MotionExpr>Expression evaluated when the predicate is false.
Add(Box<MotionExpr>, Box<MotionExpr>)
Numeric addition.
Sub(Box<MotionExpr>, Box<MotionExpr>)
Numeric subtraction.
Mul(Box<MotionExpr>, Box<MotionExpr>)
Numeric multiplication.
Div(Box<MotionExpr>, Box<MotionExpr>)
Numeric division. Division by zero leaves the left value unchanged.
Neg(Box<MotionExpr>)
Numeric negation.
Abs(Box<MotionExpr>)
Absolute value.
Min(Box<MotionExpr>, Box<MotionExpr>)
Minimum of two scalar-like expressions.
Max(Box<MotionExpr>, Box<MotionExpr>)
Maximum of two scalar-like expressions.
Clamp
Clamps a scalar-like expression between min and max.
Fields
value: Box<MotionExpr>Value to clamp.
min: Box<MotionExpr>Minimum allowed value.
max: Box<MotionExpr>Maximum allowed value.
Lerp
Interpolates between two values using scalar-like t.
Fields
from: Box<MotionExpr>Start expression.
to: Box<MotionExpr>End expression.
t: Box<MotionExpr>Interpolation progress, normally 0.0..=1.0.
MapRange
Maps a scalar-like expression from one range to another.
Implementations§
Source§impl MotionExpr
impl MotionExpr
Sourcepub fn eval(&self, input: &MotionEvalInput<'_>) -> MotionValue
pub fn eval(&self, input: &MotionEvalInput<'_>) -> MotionValue
Evaluates the expression against runtime and layout inputs.
Application code usually does not call this directly; shells and tests
use it to turn declarative targets into concrete MotionValues.
Trait Implementations§
Source§impl Clone for MotionExpr
impl Clone for MotionExpr
Source§fn clone(&self) -> MotionExpr
fn clone(&self) -> MotionExpr
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MotionExpr
impl Debug for MotionExpr
Source§impl<'de> Deserialize<'de> for MotionExpr
impl<'de> Deserialize<'de> for MotionExpr
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl From<MotionValue> for MotionExpr
impl From<MotionValue> for MotionExpr
Source§fn from(value: MotionValue) -> Self
fn from(value: MotionValue) -> Self
Source§impl PartialEq for MotionExpr
impl PartialEq for MotionExpr
Source§fn eq(&self, other: &MotionExpr) -> bool
fn eq(&self, other: &MotionExpr) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for MotionExpr
impl Serialize for MotionExpr
impl StructuralPartialEq for MotionExpr
Auto Trait Implementations§
impl Freeze for MotionExpr
impl RefUnwindSafe for MotionExpr
impl Send for MotionExpr
impl Sync for MotionExpr
impl Unpin for MotionExpr
impl UnsafeUnpin for MotionExpr
impl UnwindSafe for MotionExpr
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.