diff options
Diffstat (limited to 'widget/src')
| -rw-r--r-- | widget/src/helpers.rs | 2 | ||||
| -rw-r--r-- | widget/src/themer.rs | 18 | 
2 files changed, 16 insertions, 4 deletions
| diff --git a/widget/src/helpers.rs b/widget/src/helpers.rs index 71b0579d..ed385ea5 100644 --- a/widget/src/helpers.rs +++ b/widget/src/helpers.rs @@ -15,6 +15,7 @@ use crate::rule::{self, Rule};  use crate::runtime::Command;  use crate::scrollable::{self, Scrollable};  use crate::slider::{self, Slider}; +use crate::style::application;  use crate::text::{self, Text};  use crate::text_editor::{self, TextEditor};  use crate::text_input::{self, TextInput}; @@ -445,6 +446,7 @@ pub fn themer<'a, Message, Theme, Renderer>(  ) -> Themer<'a, Message, Theme, Renderer>  where      Renderer: core::Renderer, +    Theme: application::StyleSheet,  {      Themer::new(theme, content)  } diff --git a/widget/src/themer.rs b/widget/src/themer.rs index e6ca6cfe..a27e4813 100644 --- a/widget/src/themer.rs +++ b/widget/src/themer.rs @@ -9,6 +9,7 @@ use crate::core::{      Clipboard, Element, Layout, Length, Point, Rectangle, Shell, Size, Vector,      Widget,  }; +use crate::style::application;  /// A widget that applies any `Theme` to its contents.  /// @@ -18,14 +19,17 @@ use crate::core::{  pub struct Themer<'a, Message, Theme, Renderer>  where      Renderer: crate::core::Renderer, +    Theme: application::StyleSheet,  {      content: Element<'a, Message, Theme, Renderer>,      theme: Theme, +    style: Theme::Style,  }  impl<'a, Message, Theme, Renderer> Themer<'a, Message, Theme, Renderer>  where      Renderer: crate::core::Renderer, +    Theme: application::StyleSheet,  {      /// Creates an empty [`Themer`] that applies the given `Theme`      /// to the provided `content`. @@ -34,8 +38,9 @@ where          T: Into<Element<'a, Message, Theme, Renderer>>,      {          Self { -            theme,              content: content.into(), +            theme, +            style: Theme::Style::default(),          }      }  } @@ -44,6 +49,7 @@ impl<'a, AnyTheme, Message, Theme, Renderer> Widget<Message, AnyTheme, Renderer>      for Themer<'a, Message, Theme, Renderer>  where      Renderer: crate::core::Renderer, +    Theme: application::StyleSheet,  {      fn tag(&self) -> tree::Tag {          self.content.as_widget().tag() @@ -120,16 +126,20 @@ where          tree: &Tree,          renderer: &mut Renderer,          _theme: &AnyTheme, -        renderer_style: &renderer::Style, +        _style: &renderer::Style,          layout: Layout<'_>,          cursor: mouse::Cursor,          viewport: &Rectangle,      ) { +        let appearance = self.theme.appearance(&self.style); +          self.content.as_widget().draw(              tree,              renderer,              &self.theme, -            renderer_style, +            &renderer::Style { +                text_color: appearance.text_color, +            },              layout,              cursor,              viewport, @@ -248,7 +258,7 @@ impl<'a, AnyTheme, Message, Theme, Renderer>      for Element<'a, Message, AnyTheme, Renderer>  where      Message: 'a, -    Theme: 'a, +    Theme: 'a + application::StyleSheet,      Renderer: 'a + crate::core::Renderer,  {      fn from( | 
