Skip to content
Merged
5 changes: 4 additions & 1 deletion api/node/rust/interpreter/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub enum JsValueType {
Struct,
Brush,
Image,
StyledText,
}

impl From<slint_interpreter::ValueType> for JsValueType {
Expand All @@ -37,6 +38,7 @@ impl From<slint_interpreter::ValueType> for JsValueType {
slint_interpreter::ValueType::Struct => JsValueType::Struct,
slint_interpreter::ValueType::Brush => JsValueType::Brush,
slint_interpreter::ValueType::Image => JsValueType::Image,
slint_interpreter::ValueType::StyledText => JsValueType::StyledText,
_ => JsValueType::Void,
}
}
Expand Down Expand Up @@ -290,7 +292,8 @@ pub fn to_value(env: &Env, unknown: JsUnknown, typ: &Type) -> Result<Value> {
| Type::Easing
| Type::PathData
| Type::LayoutCache
| Type::ElementReference => Err(napi::Error::from_reason("reason")),
| Type::ElementReference
| Type::StyledText => Err(napi::Error::from_reason("reason")),
}
}

Expand Down
7 changes: 6 additions & 1 deletion internal/compiler/builtin_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,12 @@ fn to_debug_string(
Type::Float32 | Type::Int32 => expr.maybe_convert_to(Type::String, node, diag),
Type::String => expr,
// TODO
Type::Color | Type::Brush | Type::Image | Type::Easing | Type::Array(_) => {
Type::Color
| Type::Brush
| Type::Image
| Type::Easing
| Type::StyledText
| Type::Array(_) => {
Expression::StringLiteral("<debug-of-this-type-not-yet-implemented>".into())
}
Type::Duration
Expand Down
1 change: 1 addition & 0 deletions internal/compiler/expression_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1427,6 +1427,7 @@ impl Expression {
Expression::EnumerationValue(enumeration.clone().default_value())
}
Type::ComponentFactory => Expression::EmptyComponentFactory,
Type::StyledText => Expression::Invalid,
}
}

Expand Down
1 change: 1 addition & 0 deletions internal/compiler/generator/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ pub fn rust_primitive_type(ty: &Type) -> Option<proc_macro2::TokenStream> {
Type::Percent => Some(quote!(f32)),
Type::Bool => Some(quote!(bool)),
Type::Image => Some(quote!(sp::Image)),
Type::StyledText => Some(quote!(sp::StyledText)),
Type::Struct(s) => {
struct_name_to_tokens(&s.name).or_else(|| {
let elem =
Expand Down
6 changes: 6 additions & 0 deletions internal/compiler/langtype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ pub enum Type {

/// This is a `SharedArray<f32>`
LayoutCache,

StyledText,
}

impl core::cmp::PartialEq for Type {
Expand Down Expand Up @@ -104,6 +106,7 @@ impl core::cmp::PartialEq for Type {
Type::UnitProduct(a) => matches!(other, Type::UnitProduct(b) if a == b),
Type::ElementReference => matches!(other, Type::ElementReference),
Type::LayoutCache => matches!(other, Type::LayoutCache),
Type::StyledText => matches!(other, Type::StyledText),
}
}
}
Expand Down Expand Up @@ -178,6 +181,7 @@ impl Display for Type {
}
Type::ElementReference => write!(f, "element ref"),
Type::LayoutCache => write!(f, "layout cache"),
Type::StyledText => write!(f, "styled-text"),
}
}
}
Expand Down Expand Up @@ -213,6 +217,7 @@ impl Type {
| Self::Array(_)
| Self::Brush
| Self::InferredProperty
| Self::StyledText
)
}

Expand Down Expand Up @@ -314,6 +319,7 @@ impl Type {
Type::UnitProduct(_) => None,
Type::ElementReference => None,
Type::LayoutCache => None,
Type::StyledText => None,
}
}

Expand Down
1 change: 1 addition & 0 deletions internal/compiler/llr/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ impl Expression {
Expression::EnumerationValue(enumeration.clone().default_value())
}
Type::ComponentFactory => Expression::EmptyComponentFactory,
Type::StyledText => return None,
})
}

Expand Down
1 change: 1 addition & 0 deletions internal/compiler/typeregister.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ impl TypeRegister {
register.insert_type(Type::Angle);
register.insert_type(Type::Brush);
register.insert_type(Type::Rem);
register.insert_type(Type::StyledText);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we keep it experimental by removing it from the builtin() function (like we do for Type::ComponentFactory) (or not adding it in the first place by adding a parametter to this function to only add it if experimental)

register.types.insert("Point".into(), logical_point_type().into());

BUILTIN.with(|e| e.enums.fill_register(&mut register));
Expand Down
6 changes: 5 additions & 1 deletion internal/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ std = [
"dep:sys-locale",
"dep:webbrowser",
"shared-fontique",
"dep:pulldown-cmark",
"dep:thiserror",
"dep:htmlparser",
"i-slint-common/color-parsing",
]
# Unsafe feature meaning that there is only one core running and all thread_local are static.
# You can only enable this feature if you are sure that any API of this crate is only called
Expand All @@ -68,7 +72,7 @@ raw-window-handle-06 = ["dep:raw-window-handle-06"]

experimental = []

experimental-rich-text = ["dep:pulldown-cmark", "dep:htmlparser", "dep:thiserror", "i-slint-common/color-parsing"]
experimental-rich-text = []

unstable-wgpu-26 = ["dep:wgpu-26"]
unstable-wgpu-27 = ["dep:wgpu-27"]
Expand Down
3 changes: 3 additions & 0 deletions internal/core/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ use crate::window::{WindowAdapter, WindowInner};
use alloc::boxed::Box;
use alloc::string::String;

mod styled_text;
pub use styled_text::*;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole module can be gated on #[cfg(feature = "experimental-rich-text")]


/// A position represented in the coordinate space of logical pixels. That is the space before applying
/// a display device specific scale factor.
#[derive(Debug, Default, Copy, Clone, PartialEq)]
Expand Down
Loading
Loading