Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions internal/compiler/builtins.slint
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export component MarkdownText inherits Empty {
in property <TextHorizontalAlignment> horizontal-alignment;
in property <TextVerticalAlignment> vertical-alignment;
callback link-clicked(link: string);
in property <color> link-color: #00f;

in property <string> font-family;
in property <bool> font-italic;
Expand Down
7 changes: 6 additions & 1 deletion internal/core/item_rendering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! module for rendering the tree of items

use super::items::*;
use crate::graphics::{FontRequest, Image, IntRect};
use crate::graphics::{Color, FontRequest, Image, IntRect};
use crate::item_tree::ItemTreeRc;
use crate::item_tree::{ItemVisitor, ItemVisitorVTable, VisitChildrenResult};
use crate::lengths::{
Expand Down Expand Up @@ -299,6 +299,7 @@ pub trait RenderText {
fn letter_spacing(self: Pin<&Self>) -> LogicalLength;
fn stroke(self: Pin<&Self>) -> (Brush, LogicalLength, TextStrokeStyle);
fn is_markdown(self: Pin<&Self>) -> bool;
fn link_color(self: Pin<&Self>) -> Color;
}

impl RenderText for (SharedString, Brush) {
Expand All @@ -318,6 +319,10 @@ impl RenderText for (SharedString, Brush) {
self.1.clone()
}

fn link_color(self: Pin<&Self>) -> Color {
Default::default()
}

fn alignment(
self: Pin<&Self>,
) -> (crate::items::TextHorizontalAlignment, crate::items::TextVerticalAlignment) {
Expand Down
13 changes: 13 additions & 0 deletions internal/core/items/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ impl RenderText for ComplexText {
self.color()
}

fn link_color(self: Pin<&Self>) -> Color {
Default::default()
}

fn alignment(
self: Pin<&Self>,
) -> (super::TextHorizontalAlignment, super::TextVerticalAlignment) {
Expand Down Expand Up @@ -242,6 +246,7 @@ pub struct MarkdownText {
pub stroke: Property<Brush>,
pub stroke_width: Property<LogicalLength>,
pub stroke_style: Property<TextStrokeStyle>,
pub link_color: Property<Color>,
pub cached_rendering_data: CachedRenderingData,
}

Expand Down Expand Up @@ -396,6 +401,10 @@ impl RenderText for MarkdownText {
self.color()
}

fn link_color(self: Pin<&Self>) -> Color {
self.link_color()
}

fn alignment(
self: Pin<&Self>,
) -> (super::TextHorizontalAlignment, super::TextVerticalAlignment) {
Expand Down Expand Up @@ -571,6 +580,10 @@ impl RenderText for SimpleText {
self.color()
}

fn link_color(self: Pin<&Self>) -> Color {
Default::default()
}

fn alignment(
self: Pin<&Self>,
) -> (super::TextHorizontalAlignment, super::TextVerticalAlignment) {
Expand Down
6 changes: 3 additions & 3 deletions internal/core/textlayout/sharedparley.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl LayoutOptions {
stroke: None,
text_wrap: text_input.wrap(),
text_overflow: TextOverflow::Clip,
link_color: crate::Color::from_rgb_u8(64, 64, 255),
link_color: Default::default(),
}
}
}
Expand Down Expand Up @@ -1188,7 +1188,7 @@ pub fn draw_text(
text_overflow,
selection: None,
selection_foreground_color: None,
link_color: crate::Color::from_rgb_u8(64, 64, 255),
link_color: text.link_color(),
},
);

Expand Down Expand Up @@ -1372,7 +1372,7 @@ pub fn text_size(
text_overflow: TextOverflow::Clip,
selection: None,
selection_foreground_color: None,
link_color: crate::Color::from_rgb_u8(64, 64, 255),
link_color: Default::default(),
},
);
PhysicalSize::from_lengths(layout.max_width, layout.height) / scale_factor
Expand Down
Loading