From fab522cd4b3480d38fb259995e85ddd8a7f91a65 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 11 Dec 2025 10:18:43 +0100 Subject: [PATCH] core: Move style_text module outside of API ... just re-export the `StyledText` type from public API That way we can access StyledText internals from the renderer --- api/cpp/cbindgen.rs | 2 +- internal/core/api.rs | 6 +----- internal/core/lib.rs | 1 + internal/core/{api => }/styled_text.rs | 0 internal/core/textlayout/sharedparley.rs | 6 +++--- 5 files changed, 6 insertions(+), 9 deletions(-) rename internal/core/{api => }/styled_text.rs (100%) diff --git a/api/cpp/cbindgen.rs b/api/cpp/cbindgen.rs index 64109f3b5d..2731624797 100644 --- a/api/cpp/cbindgen.rs +++ b/api/cpp/cbindgen.rs @@ -420,7 +420,7 @@ fn gen_corelib( cbindgen::Builder::new() .with_config(string_config) .with_src(crate_dir.join("string.rs")) - .with_src(crate_dir.join("api/styled_text.rs")) + .with_src(crate_dir.join("styled_text.rs")) .with_src(crate_dir.join("slice.rs")) .with_after_include("namespace slint { struct SharedString; struct StyledText; }") .generate() diff --git a/internal/core/api.rs b/internal/core/api.rs index 7bba803d80..d3310ec04b 100644 --- a/internal/core/api.rs +++ b/internal/core/api.rs @@ -11,15 +11,11 @@ This module contains types that are public and re-exported in the slint-rs as we pub use crate::future::*; use crate::graphics::{Rgba8Pixel, SharedPixelBuffer}; use crate::input::{KeyEventType, MouseEvent}; +pub use crate::styled_text::StyledText; use crate::window::{WindowAdapter, WindowInner}; use alloc::boxed::Box; use alloc::string::String; -mod styled_text; -pub use styled_text::StyledText; -#[cfg(any(feature = "shared-parley"))] -pub(crate) use styled_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)] diff --git a/internal/core/lib.rs b/internal/core/lib.rs index f048dca311..9ce7527487 100644 --- a/internal/core/lib.rs +++ b/internal/core/lib.rs @@ -55,6 +55,7 @@ pub mod rtti; pub mod sharedvector; pub mod slice; pub mod string; +pub mod styled_text; pub mod tests; pub mod textlayout; pub mod timers; diff --git a/internal/core/api/styled_text.rs b/internal/core/styled_text.rs similarity index 100% rename from internal/core/api/styled_text.rs rename to internal/core/styled_text.rs diff --git a/internal/core/textlayout/sharedparley.rs b/internal/core/textlayout/sharedparley.rs index fa0f28d8f5..cbb7f971e1 100644 --- a/internal/core/textlayout/sharedparley.rs +++ b/internal/core/textlayout/sharedparley.rs @@ -226,10 +226,10 @@ impl LayoutWithoutLineBreaksBuilder { &self, text: &str, selection: Option<(Range, Color)>, - formatting: impl IntoIterator, + formatting: impl IntoIterator, link_color: Option, ) -> parley::Layout { - use crate::api::Style; + use crate::styled_text::Style; CONTEXTS.with_borrow_mut(|contexts| { let mut builder = self.ranged_builder(contexts.as_mut(), text); @@ -315,7 +315,7 @@ fn create_text_paragraphs( let paragraph_from_text = |text: &str, range: std::ops::Range, - formatting: Vec, + formatting: Vec, links: Vec<(std::ops::Range, std::string::String)>| { let selection = selection.clone().and_then(|(selection, selection_color)| { let sel_start = selection.start.max(range.start);