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
This commit is contained in:
Olivier Goffart 2025-12-11 10:18:43 +01:00
parent 2109a2e494
commit fab522cd4b
5 changed files with 6 additions and 9 deletions

View file

@ -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()

View file

@ -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)]

View file

@ -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;

View file

@ -226,10 +226,10 @@ impl LayoutWithoutLineBreaksBuilder {
&self,
text: &str,
selection: Option<(Range<usize>, Color)>,
formatting: impl IntoIterator<Item = crate::api::FormattedSpan>,
formatting: impl IntoIterator<Item = crate::styled_text::FormattedSpan>,
link_color: Option<Color>,
) -> parley::Layout<Brush> {
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<usize>,
formatting: Vec<crate::api::FormattedSpan>,
formatting: Vec<crate::styled_text::FormattedSpan>,
links: Vec<(std::ops::Range<usize>, std::string::String)>| {
let selection = selection.clone().and_then(|(selection, selection_color)| {
let sel_start = selection.start.max(range.start);