Skip to content

Commit bb2a927

Browse files
committed
Implement more things
1 parent 4923354 commit bb2a927

File tree

7 files changed

+21
-6
lines changed

7 files changed

+21
-6
lines changed

internal/compiler/builtin_macros.rs

Lines changed: 6 additions & 2 deletions
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
@@ -420,7 +425,6 @@ fn to_debug_string(
420425
}
421426
}
422427
Type::Enumeration(_) => Expression::Cast { from: Box::new(expr), to: (Type::String) },
423-
Type::StyledText => Expression::Invalid,
424428
}
425429
}
426430

internal/compiler/builtins.slint

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ export component MarkdownText inherits Empty {
131131
in property <TextVerticalAlignment> vertical-alignment;
132132
callback link-clicked(link: string);
133133
in property <color> link-color: #00f;
134-
135134
in property <string> font-family;
136135
in property <bool> font-italic;
137136
in property <TextOverflow> overflow;
@@ -143,6 +142,10 @@ export component MarkdownText inherits Empty {
143142
//-default_size_binding:implicit_size
144143
}
145144

145+
export component StyledText inherits Empty {
146+
in property <styled-text> text;
147+
}
148+
146149
export component TouchArea {
147150
in property <bool> enabled: true;
148151
out property <bool> pressed;

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
if let Some(name) = &s.name {
9697
Some(struct_name_to_tokens(name))

internal/compiler/typeregister.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ impl TypeRegister {
402402
register.insert_type(Type::Angle);
403403
register.insert_type(Type::Brush);
404404
register.insert_type(Type::Rem);
405+
register.insert_type(Type::StyledText);
405406
register.types.insert("Point".into(), logical_point_type().into());
406407

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

internal/core/api.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,3 +1219,8 @@ pub fn set_xdg_app_id(app_id: impl Into<SharedString>) -> Result<(), PlatformErr
12191219
|ctx| ctx.set_xdg_app_id(app_id.into()),
12201220
)
12211221
}
1222+
1223+
#[derive(Debug, PartialEq, Clone, Default)]
1224+
pub struct StyledText {
1225+
inner: (),
1226+
}

internal/interpreter/api.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ pub enum Value {
129129
#[doc(hidden)]
130130
/// Correspond to the `component-factory` type in .slint
131131
ComponentFactory(ComponentFactory) = 12,
132-
StyledText(()) = 13,
132+
StyledText(StyledText) = 13,
133133
}
134134

135135
impl Value {
@@ -245,6 +245,7 @@ declare_value_conversion!(PathData => [PathData]);
245245
declare_value_conversion!(EasingCurve => [i_slint_core::animations::EasingCurve]);
246246
declare_value_conversion!(LayoutCache => [SharedVector<f32>] );
247247
declare_value_conversion!(ComponentFactory => [ComponentFactory] );
248+
declare_value_conversion!(StyledText => [StyledText] );
248249

249250
/// Implement From / TryFrom for Value that convert a `struct` to/from `Value::Struct`
250251
macro_rules! declare_value_struct_conversion {

internal/interpreter/dynamic_item_tree.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use i_slint_compiler::{generator, object_tree, parser, CompilerConfiguration};
1414
use i_slint_core::accessibility::{
1515
AccessibilityAction, AccessibleStringProperty, SupportedAccessibilityAction,
1616
};
17-
use i_slint_core::api::LogicalPosition;
17+
use i_slint_core::api::{LogicalPosition, StyledText};
1818
use i_slint_core::component_factory::ComponentFactory;
1919
use i_slint_core::item_tree::{
2020
IndexRange, ItemRc, ItemTree, ItemTreeNode, ItemTreeRef, ItemTreeRefPin, ItemTreeVTable,
@@ -1254,7 +1254,7 @@ pub(crate) fn generate_item_tree<'id>(
12541254
}
12551255
Type::LayoutCache => property_info::<SharedVector<f32>>(),
12561256
Type::Function { .. } | Type::Callback { .. } => return None,
1257-
Type::StyledText => property_info::<Value>(),
1257+
Type::StyledText => property_info::<StyledText>(),
12581258
// These can't be used in properties
12591259
Type::Invalid
12601260
| Type::Void

0 commit comments

Comments
 (0)