Skip to content

Commit f3242c8

Browse files
committed
Rename MarkdownText to StyledText
1 parent 3c72c1c commit f3242c8

File tree

10 files changed

+27
-27
lines changed

10 files changed

+27
-27
lines changed

api/cpp/cbindgen.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ fn gen_corelib(
305305
"Flickable",
306306
"SimpleText",
307307
"ComplexText",
308-
"MarkdownText",
308+
"StyledText",
309309
"Path",
310310
"WindowItem",
311311
"TextInput",

internal/compiler/builtins.slint

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@ component ComplexText inherits SimpleText {
120120

121121
export { ComplexText as Text }
122122

123-
export component MarkdownText inherits Empty {
123+
export component StyledText inherits Empty {
124124
in property <length> width;
125125
in property <length> height;
126-
in property <string> text;
126+
in property <styled-text> text;
127127
in property <length> font-size;
128128
in property <int> font-weight;
129129
in property <brush> color;
@@ -142,10 +142,6 @@ export component MarkdownText inherits Empty {
142142
//-default_size_binding:implicit_size
143143
}
144144

145-
export component StyledText inherits Empty {
146-
in property <styled-text> text;
147-
}
148-
149145
export component TouchArea {
150146
in property <bool> enabled: true;
151147
out property <bool> pressed;

internal/compiler/passes/apply_default_properties_from_style.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub fn apply_default_properties_from_style(
6262
}
6363
});
6464
}
65-
"Text" | "MarkdownText" => {
65+
"Text" | "StyledText" => {
6666
elem.set_binding_if_not_set("color".into(), || Expression::Cast {
6767
from: Expression::PropertyReference(NamedReference::new(
6868
&palette.root_element,

internal/compiler/passes/embed_glyphs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ pub fn collect_font_sizes_used(
546546
.to_string()
547547
.as_str()
548548
{
549-
"TextInput" | "Text" | "SimpleText" | "ComplexText" | "MarkdownText" => {
549+
"TextInput" | "Text" | "SimpleText" | "ComplexText" | "StyledText" => {
550550
if let Some(font_size) = try_extract_font_size_from_element(elem, "font-size") {
551551
add_font_size(font_size)
552552
}

internal/compiler/typeregister.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ impl TypeRegister {
587587
register.elements.remove("DropArea").unwrap();
588588
register.types.remove("DropEvent").unwrap(); // Also removed in xtask/src/slintdocs.rs
589589

590-
register.elements.remove("MarkdownText").unwrap();
590+
register.elements.remove("StyledText").unwrap();
591591

592592
Rc::new(RefCell::new(register))
593593
}

internal/core/items.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1729,7 +1729,7 @@ declare_item_vtable! {
17291729
}
17301730

17311731
declare_item_vtable! {
1732-
fn slint_get_MarkdownTextVTable() -> MarkdownTextVTable for MarkdownText
1732+
fn slint_get_StyledTextVTable() -> StyledTextVTable for StyledText
17331733
}
17341734

17351735
declare_item_vtable! {

internal/core/items/text.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use super::{
1313
TextHorizontalAlignment, TextOverflow, TextStrokeStyle, TextVerticalAlignment, TextWrap,
1414
VoidArg, WindowItem,
1515
};
16+
use crate::api;
1617
use crate::graphics::{Brush, Color, FontRequest};
1718
use crate::input::{
1819
FocusEvent, FocusEventResult, FocusReason, InputEventFilterResult, InputEventResult, KeyEvent,
@@ -225,10 +226,10 @@ impl ComplexText {
225226
#[repr(C)]
226227
#[derive(FieldOffsets, Default, SlintElement)]
227228
#[pin]
228-
pub struct MarkdownText {
229+
pub struct StyledText {
229230
pub width: Property<LogicalLength>,
230231
pub height: Property<LogicalLength>,
231-
pub text: Property<SharedString>,
232+
pub text: Property<api::StyledText>,
232233
pub font_size: Property<LogicalLength>,
233234
pub font_weight: Property<i32>,
234235
pub color: Property<Brush>,
@@ -248,7 +249,7 @@ pub struct MarkdownText {
248249
pub cached_rendering_data: CachedRenderingData,
249250
}
250251

251-
impl Item for MarkdownText {
252+
impl Item for StyledText {
252253
fn init(self: Pin<&Self>, _self_rc: &ItemRc) {}
253254

254255
fn layout_info(
@@ -368,14 +369,14 @@ impl Item for MarkdownText {
368369
}
369370
}
370371

371-
impl ItemConsts for MarkdownText {
372+
impl ItemConsts for StyledText {
372373
const cached_rendering_data_offset: const_field_offset::FieldOffset<
373-
MarkdownText,
374+
StyledText,
374375
CachedRenderingData,
375-
> = MarkdownText::FIELD_OFFSETS.cached_rendering_data.as_unpinned_projection();
376+
> = StyledText::FIELD_OFFSETS.cached_rendering_data.as_unpinned_projection();
376377
}
377378

378-
impl HasFont for MarkdownText {
379+
impl HasFont for StyledText {
379380
fn font_request(self: Pin<&Self>, self_rc: &crate::items::ItemRc) -> FontRequest {
380381
crate::items::WindowItem::resolved_font_request(
381382
self_rc,
@@ -388,13 +389,13 @@ impl HasFont for MarkdownText {
388389
}
389390
}
390391

391-
impl RenderString for MarkdownText {
392+
impl RenderString for StyledText {
392393
fn text(self: Pin<&Self>) -> SharedString {
393-
self.text()
394+
panic!()
394395
}
395396
}
396397

397-
impl RenderText for MarkdownText {
398+
impl RenderText for StyledText {
398399
fn target_size(self: Pin<&Self>) -> LogicalSize {
399400
LogicalSize::from_lengths(self.width(), self.height())
400401
}
@@ -430,7 +431,7 @@ impl RenderText for MarkdownText {
430431
}
431432
}
432433

433-
impl MarkdownText {
434+
impl StyledText {
434435
pub fn font_metrics(
435436
self: Pin<&Self>,
436437
window_adapter: &Rc<dyn WindowAdapter>,

internal/core/rtti.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ macro_rules! declare_ValueType_2 {
5454
crate::items::MenuEntry,
5555
crate::items::DropEvent,
5656
crate::model::ModelRc<crate::items::MenuEntry>,
57+
crate::api::StyledText,
5758
$(crate::items::$Name,)*
5859
];
5960
};

internal/interpreter/api.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ use std::rc::Rc;
1818

1919
#[doc(inline)]
2020
pub use i_slint_compiler::diagnostics::{Diagnostic, DiagnosticLevel};
21-
22-
pub use i_slint_core::api::*;
21+
pub use i_slint_core::api::{
22+
self, ComponentHandle, EventLoopError, Global, JoinHandle, PlatformError, SharedString, Weak,
23+
Window,
24+
};
2325
// keep in sync with api/rs/slint/lib.rs
2426
pub use i_slint_backend_selector::api::*;
2527
pub use i_slint_core::graphics::{
@@ -129,7 +131,7 @@ pub enum Value {
129131
#[doc(hidden)]
130132
/// Correspond to the `component-factory` type in .slint
131133
ComponentFactory(ComponentFactory) = 12,
132-
StyledText(StyledText) = 13,
134+
StyledText(api::StyledText) = 13,
133135
}
134136

135137
impl Value {
@@ -245,7 +247,7 @@ declare_value_conversion!(PathData => [PathData]);
245247
declare_value_conversion!(EasingCurve => [i_slint_core::animations::EasingCurve]);
246248
declare_value_conversion!(LayoutCache => [SharedVector<f32>] );
247249
declare_value_conversion!(ComponentFactory => [ComponentFactory] );
248-
declare_value_conversion!(StyledText => [StyledText] );
250+
declare_value_conversion!(StyledText => [api::StyledText] );
249251

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

internal/interpreter/dynamic_item_tree.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ fn generate_rtti() -> HashMap<&'static str, Rc<ItemRTTI>> {
982982
rtti_for::<ImageItem>(),
983983
rtti_for::<ClippedImage>(),
984984
rtti_for::<ComplexText>(),
985-
rtti_for::<MarkdownText>(),
985+
rtti_for::<StyledText>(),
986986
rtti_for::<SimpleText>(),
987987
rtti_for::<Rectangle>(),
988988
rtti_for::<BasicBorderRectangle>(),

0 commit comments

Comments
 (0)