-
// ......
export component Path {
in property <brush> fill;
in property <FillRule> fill-rule;
in property <brush> stroke;
in property <length> stroke-width;
in property <LineCap> stroke-line-cap;
in property <LineJoin> stroke-line-join;
in property <[length]> stroke-dash-array; // <- Add
in property <length> stroke-dash-offset; // <- Add
in property <string> commands; // 'fake' hardcoded in typeregister.rs
in property <float> viewbox-x;
in property <float> viewbox-y;
in property <float> viewbox-width;
in property <float> viewbox-height;
in property <ImageFit> fit-style: contain;
in property <bool> clip;
in property <bool> anti-alias: true;
//-disallow_global_types_as_child_elements
MoveTo { }
LineTo { }
ArcTo { }
CubicTo { }
QuadraticTo { }
Close { }
//-default_size_binding:expands_to_parent_geometry
}
// ......
// ......
/// The implementation of the `Path` element
#[repr(C)]
#[derive(FieldOffsets, Default, SlintElement)]
#[pin]
pub struct Path {
pub elements: Property<PathData>,
pub fill: Property<Brush>,
pub fill_rule: Property<FillRule>,
pub stroke: Property<Brush>,
pub stroke_width: Property<LogicalLength>,
pub stroke_line_cap: Property<LineCap>,
pub stroke_line_join: Property<LineJoin>,
pub stroke_dash_array: Property<ModelRc<LogicalLength>>, // <- Add
pub stroke_dash_offset: Property<LogicalLength>, // <- Add
pub viewbox_x: Property<f32>,
pub viewbox_y: Property<f32>,
pub viewbox_width: Property<f32>,
pub viewbox_height: Property<f32>,
pub fit_style: Property<ImageFit>,
pub clip: Property<bool>,
pub anti_alias: Property<bool>,
pub cached_rendering_data: CachedRenderingData,
}
// ......
error[E0277]: the trait bound `ModelRc<Length<f32, LogicalPx>>: From<Value>` is not satisfied
--> internal/core/items/path.rs:39:33
|
39 | #[derive(FieldOffsets, Default, SlintElement)]
| ^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `From<Value>` is not implemented for `ModelRc<Length<f32, LogicalPx>>`
--> internal/core/model.rs:702:1
|
702 | pub struct ModelRc<T>(Option<Rc<dyn Model<Data = T>>>);
| ^^^^^^^^^^^^^^^^^^^^^
= note: required for `Value` to implement `Into<ModelRc<Length<f32, LogicalPx>>>`
= note: required for `ModelRc<Length<f32, LogicalPx>>` to implement `TryFrom<Value>`
= note: required for `Value` to implement `TryInto<ModelRc<Length<f32, LogicalPx>>>`
note: required for `vtable::FieldOffset<items::path::Path, properties::Property<ModelRc<Length<f32, LogicalPx>>>, AllowPin>` to implement `rtti::PropertyInfo<items::path::Path, Value>`
--> internal/core/rtti.rs:156:31
|
156 | impl<Item: 'static, T, Value> PropertyInfo<Item, Value> for FieldOffset<Item, Property<T>>
| ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
157 | where
158 | Value: TryInto<T> + Clone + PartialEq + Default + 'static,
| ---------- unsatisfied trait bound introduced here
= note: this error originates in the derive macro `SlintElement` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `Value: From<ModelRc<Length<f32, LogicalPx>>>` is not satisfied
--> internal/core/items/path.rs:39:33
|
39 | #[derive(FieldOffsets, Default, SlintElement)]
| ^^^^^^^^^^^^ the trait `From<ModelRc<Length<f32, LogicalPx>>>` is not implemented for `Value`
|
= note: required for `ModelRc<Length<f32, LogicalPx>>` to implement `Into<Value>`
= note: required for `Value` to implement `TryFrom<ModelRc<Length<f32, LogicalPx>>>`
= note: required for `ModelRc<Length<f32, LogicalPx>>` to implement `TryInto<Value>`
note: required for `vtable::FieldOffset<items::path::Path, properties::Property<ModelRc<Length<f32, LogicalPx>>>, AllowPin>` to implement `rtti::PropertyInfo<items::path::Path, Value>`
--> internal/core/rtti.rs:156:31
|
156 | impl<Item: 'static, T, Value> PropertyInfo<Item, Value> for FieldOffset<Item, Property<T>>
| ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
159 | T: TryInto<Value> + Clone + PartialEq + Default + 'static,
| -------------- unsatisfied trait bound introduced here
= note: this error originates in the derive macro `SlintElement` (in Nightly builds, run with -Z macro-backtrace for more info)Hello everyone! I encountered the error above while adding dashed line support to |
Beta Was this translation helpful? Give feedback.
Answered by
ogoffart
Mar 24, 2026
Replies: 1 comment 3 replies
-
|
Thanks for trying to contribute. Indeed, we currently can't have builtin properties with a "model" type. So to move forward i can see the following solution:
|
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
lzm-build
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for trying to contribute.
Indeed, we currently can't have builtin properties with a "model" type.
That's because
ModelRcalso can't be shared in C++ as is (where it is ashared_ptr)So to move forward i can see the following solution:
stroke-dash-arrayproperty, but anstroke-styleproperty that would be an enum (Solid, Dashed, Dotted) or something like that.Property<SharedVector<f32>>but that comes with its own challenge (it is still not supported out of the box and there will be need to have compiler support to generate it)