|
|
@@ -42,7 +42,7 @@ use crate::{
|
|
|
},
|
|
|
pubsub::Subscription,
|
|
|
scene::{Pimpl, SceneNode, SceneNodePtr, SceneNodeType},
|
|
|
- ui::{get_ui_object3, get_ui_object_ptr, RedrawTrigger},
|
|
|
+ ui::{get_ui_object3, get_ui_object_ptr, RedrawTrigger, VectorShape},
|
|
|
};
|
|
|
|
|
|
pub mod light;
|
|
|
@@ -64,6 +64,19 @@ fn color_prop(name: &str, val: [f32; 4]) -> Property {
|
|
|
prop
|
|
|
}
|
|
|
|
|
|
+/// Shape token: same as [`color_prop`], but the value is a whole
|
|
|
+/// `VectorShape`.
|
|
|
+fn shape_prop(name: &str, val: VectorShape) -> Property {
|
|
|
+ let prop = Property::new(
|
|
|
+ name,
|
|
|
+ PropertyType::VectorShape,
|
|
|
+ PropertySubType::Null,
|
|
|
+ PropertyPermission { read: Role::ALL, write: Role::Theme },
|
|
|
+ );
|
|
|
+ prop.set_default_shape(0, val).unwrap();
|
|
|
+ prop
|
|
|
+}
|
|
|
+
|
|
|
/// The shared token vocabulary with the `minimal` palette as defaults.
|
|
|
/// Every token here is wired by schema `wire_color` calls — nothing
|
|
|
/// unused ships in the vocabulary. A default must never dangle when
|
|
|
@@ -145,6 +158,20 @@ pub fn wire_color(
|
|
|
Ok(())
|
|
|
}
|
|
|
|
|
|
+/// Shape variant of [`wire_color`].
|
|
|
+pub fn wire_shape(
|
|
|
+ node: &SceneNode,
|
|
|
+ prop_name: &str,
|
|
|
+ theme: &SceneNode,
|
|
|
+ token_name: &str,
|
|
|
+) -> Result<()> {
|
|
|
+ let prop = node.get_property(prop_name).ok_or(Error::PropertyNotFound)?;
|
|
|
+ let token = theme.get_property(token_name).ok_or(Error::PropertyNotFound)?;
|
|
|
+ prop.set_default_expr(0, expr::load_var(token_name))?;
|
|
|
+ prop.add_depend(Role::App, &token, 0, token_name);
|
|
|
+ Ok(())
|
|
|
+}
|
|
|
+
|
|
|
// ============================================================================
|
|
|
// Theme engine (design D8/D9)
|
|
|
// ============================================================================
|
|
|
@@ -353,6 +380,18 @@ impl ThemeCtx {
|
|
|
let prop = theme.get_property(name).ok_or(Error::PropertyNotFound)?;
|
|
|
self.set_touched_color(atom, &prop, val)
|
|
|
}
|
|
|
+
|
|
|
+ /// Shape-token variant of [`ThemeCtx::set_shared_token_color`].
|
|
|
+ pub fn set_shared_token_shape(
|
|
|
+ &self,
|
|
|
+ atom: &mut PropertyAtomicGuard,
|
|
|
+ name: &str,
|
|
|
+ val: VectorShape,
|
|
|
+ ) -> Result<()> {
|
|
|
+ let theme = self.sg_root.lookup_node("/theme").ok_or(Error::NodeNotFound)?;
|
|
|
+ let prop = theme.get_property(name).ok_or(Error::PropertyNotFound)?;
|
|
|
+ self.set_touched(atom, &prop, 0, PropertyValue::VectorShape(Arc::new(val)))
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/// A theme: a name and an apply routine. `minimal` is the registry's
|