diff options
author | 2024-07-28 13:44:08 +0200 | |
---|---|---|
committer | 2024-07-28 13:44:08 +0200 | |
commit | f7fe1edcbbfde71d801379805b4605ff36075b11 (patch) | |
tree | e823f5e1dcc92d83ee32aec00a2bfe64e34aa34e /widget | |
parent | 4dc7b9b9619010b50ec6df837bd945ff0f675781 (diff) | |
download | iced-f7fe1edcbbfde71d801379805b4605ff36075b11.tar.gz iced-f7fe1edcbbfde71d801379805b4605ff36075b11.tar.bz2 iced-f7fe1edcbbfde71d801379805b4605ff36075b11.zip |
Improve ergonomics of `span` background highlighting
Diffstat (limited to 'widget')
-rw-r--r-- | widget/src/markdown.rs | 7 | ||||
-rw-r--r-- | widget/src/text/rich.rs | 6 |
2 files changed, 5 insertions, 8 deletions
diff --git a/widget/src/markdown.rs b/widget/src/markdown.rs index 362aba67..cb3e9cfc 100644 --- a/widget/src/markdown.rs +++ b/widget/src/markdown.rs @@ -7,7 +7,6 @@ use crate::core::border; use crate::core::font::{self, Font}; use crate::core::padding; -use crate::core::text::Background; use crate::core::theme::{self, Theme}; use crate::core::{self, color, Color, Element, Length, Pixels}; use crate::{column, container, rich_text, row, scrollable, span, text}; @@ -262,10 +261,8 @@ pub fn parse<'a>( let span = span(code.into_string()) .font(Font::MONOSPACE) .color(Color::WHITE) - .background(Background { - color: color!(0x111111), - border: border::rounded(2), - }); + .background(color!(0x111111)) + .border(border::rounded(2)); let span = if let Some(link) = link.as_ref() { span.color(palette.primary).link(link.clone()) diff --git a/widget/src/text/rich.rs b/widget/src/text/rich.rs index 832a3ae7..f636b219 100644 --- a/widget/src/text/rich.rs +++ b/widget/src/text/rich.rs @@ -248,17 +248,17 @@ where // Draw backgrounds for (index, span) in self.spans.iter().enumerate() { - if let Some(background) = span.background { + if let Some(highlight) = span.highlight { let translation = layout.position() - Point::ORIGIN; for bounds in state.paragraph.span_bounds(index) { renderer.fill_quad( renderer::Quad { bounds: bounds + translation, - border: background.border, + border: highlight.border, ..Default::default() }, - background.color, + highlight.background, ); } } |