Skip to content

Commit b6d9215

Browse files
committed
Add StyledText type
1 parent 65fb303 commit b6d9215

File tree

12 files changed

+566
-4
lines changed

12 files changed

+566
-4
lines changed

api/node/rust/interpreter/value.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub enum JsValueType {
2525
Struct,
2626
Brush,
2727
Image,
28+
StyledText,
2829
}
2930

3031
impl From<slint_interpreter::ValueType> for JsValueType {
@@ -37,6 +38,7 @@ impl From<slint_interpreter::ValueType> for JsValueType {
3738
slint_interpreter::ValueType::Struct => JsValueType::Struct,
3839
slint_interpreter::ValueType::Brush => JsValueType::Brush,
3940
slint_interpreter::ValueType::Image => JsValueType::Image,
41+
slint_interpreter::ValueType::StyledText => JsValueType::StyledText,
4042
_ => JsValueType::Void,
4143
}
4244
}
@@ -290,7 +292,8 @@ pub fn to_value(env: &Env, unknown: JsUnknown, typ: &Type) -> Result<Value> {
290292
| Type::Easing
291293
| Type::PathData
292294
| Type::LayoutCache
293-
| Type::ElementReference => Err(napi::Error::from_reason("reason")),
295+
| Type::ElementReference
296+
| Type::StyledText => Err(napi::Error::from_reason("reason")),
294297
}
295298
}
296299

internal/compiler/builtin_macros.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,12 @@ fn to_debug_string(
343343
Type::Float32 | Type::Int32 => expr.maybe_convert_to(Type::String, node, diag),
344344
Type::String => expr,
345345
// TODO
346-
Type::Color | Type::Brush | Type::Image | Type::Easing | Type::Array(_) => {
346+
Type::Color
347+
| Type::Brush
348+
| Type::Image
349+
| Type::Easing
350+
| Type::StyledText
351+
| Type::Array(_) => {
347352
Expression::StringLiteral("<debug-of-this-type-not-yet-implemented>".into())
348353
}
349354
Type::Duration

internal/compiler/expression_tree.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,6 +1427,7 @@ impl Expression {
14271427
Expression::EnumerationValue(enumeration.clone().default_value())
14281428
}
14291429
Type::ComponentFactory => Expression::EmptyComponentFactory,
1430+
Type::StyledText => Expression::Invalid,
14301431
}
14311432
}
14321433

internal/compiler/generator/rust.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ pub fn rust_primitive_type(ty: &Type) -> Option<proc_macro2::TokenStream> {
9191
Type::Percent => Some(quote!(f32)),
9292
Type::Bool => Some(quote!(bool)),
9393
Type::Image => Some(quote!(sp::Image)),
94+
Type::StyledText => Some(quote!(sp::StyledText)),
9495
Type::Struct(s) => {
9596
struct_name_to_tokens(&s.name).or_else(|| {
9697
let elem =

internal/compiler/langtype.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ pub enum Type {
6464

6565
/// This is a `SharedArray<f32>`
6666
LayoutCache,
67+
68+
StyledText,
6769
}
6870

6971
impl core::cmp::PartialEq for Type {
@@ -104,6 +106,7 @@ impl core::cmp::PartialEq for Type {
104106
Type::UnitProduct(a) => matches!(other, Type::UnitProduct(b) if a == b),
105107
Type::ElementReference => matches!(other, Type::ElementReference),
106108
Type::LayoutCache => matches!(other, Type::LayoutCache),
109+
Type::StyledText => matches!(other, Type::StyledText),
107110
}
108111
}
109112
}
@@ -178,6 +181,7 @@ impl Display for Type {
178181
}
179182
Type::ElementReference => write!(f, "element ref"),
180183
Type::LayoutCache => write!(f, "layout cache"),
184+
Type::StyledText => write!(f, "styled-text"),
181185
}
182186
}
183187
}
@@ -213,6 +217,7 @@ impl Type {
213217
| Self::Array(_)
214218
| Self::Brush
215219
| Self::InferredProperty
220+
| Self::StyledText
216221
)
217222
}
218223

@@ -314,6 +319,7 @@ impl Type {
314319
Type::UnitProduct(_) => None,
315320
Type::ElementReference => None,
316321
Type::LayoutCache => None,
322+
Type::StyledText => None,
317323
}
318324
}
319325

internal/compiler/llr/expression.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ impl Expression {
267267
Expression::EnumerationValue(enumeration.clone().default_value())
268268
}
269269
Type::ComponentFactory => Expression::EmptyComponentFactory,
270+
Type::StyledText => return None,
270271
})
271272
}
272273

internal/compiler/typeregister.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,7 @@ impl TypeRegister {
397397
register.insert_type(Type::Angle);
398398
register.insert_type(Type::Brush);
399399
register.insert_type(Type::Rem);
400+
register.insert_type(Type::StyledText);
400401
register.types.insert("Point".into(), logical_point_type().into());
401402

402403
BUILTIN.with(|e| e.enums.fill_register(&mut register));

0 commit comments

Comments
 (0)