diff options
| author | 2022-07-09 02:28:52 +0200 | |
|---|---|---|
| committer | 2022-07-09 02:28:52 +0200 | |
| commit | e053e25d2ccb17f7a162685a106a8bbd915a873f (patch) | |
| tree | 5304f3ea2712e8889c7278ec5e57418f484d8f6c /graphics/src/widget/canvas/program.rs | |
| parent | 66eb6263003c1bbedd1fd14d6b12f172d20a6211 (diff) | |
| parent | 7105db97a53d90adf429091298f31c90974d8f08 (diff) | |
| download | iced-e053e25d2ccb17f7a162685a106a8bbd915a873f.tar.gz iced-e053e25d2ccb17f7a162685a106a8bbd915a873f.tar.bz2 iced-e053e25d2ccb17f7a162685a106a8bbd915a873f.zip  | |
Merge pull request #1362 from iced-rs/theming
Theming
Diffstat (limited to 'graphics/src/widget/canvas/program.rs')
| -rw-r--r-- | graphics/src/widget/canvas/program.rs | 26 | 
1 files changed, 19 insertions, 7 deletions
diff --git a/graphics/src/widget/canvas/program.rs b/graphics/src/widget/canvas/program.rs index 85a2f67b..dddc387d 100644 --- a/graphics/src/widget/canvas/program.rs +++ b/graphics/src/widget/canvas/program.rs @@ -1,6 +1,8 @@  use crate::canvas::event::{self, Event};  use crate::canvas::{Cursor, Geometry}; -use iced_native::{mouse, Rectangle}; + +use iced_native::mouse; +use iced_native::Rectangle;  /// The state and logic of a [`Canvas`].  /// @@ -8,7 +10,7 @@ use iced_native::{mouse, Rectangle};  /// application.  ///  /// [`Canvas`]: crate::widget::Canvas -pub trait Program<Message> { +pub trait Program<Message, Theme = iced_native::Theme> {      /// Updates the state of the [`Program`].      ///      /// When a [`Program`] is used in a [`Canvas`], the runtime will call this @@ -36,7 +38,12 @@ pub trait Program<Message> {      ///      /// [`Frame`]: crate::widget::canvas::Frame      /// [`Cache`]: crate::widget::canvas::Cache -    fn draw(&self, bounds: Rectangle, cursor: Cursor) -> Vec<Geometry>; +    fn draw( +        &self, +        theme: &Theme, +        bounds: Rectangle, +        cursor: Cursor, +    ) -> Vec<Geometry>;      /// Returns the current mouse interaction of the [`Program`].      /// @@ -53,9 +60,9 @@ pub trait Program<Message> {      }  } -impl<T, Message> Program<Message> for &mut T +impl<T, Message, Theme> Program<Message, Theme> for &mut T  where -    T: Program<Message>, +    T: Program<Message, Theme>,  {      fn update(          &mut self, @@ -66,8 +73,13 @@ where          T::update(self, event, bounds, cursor)      } -    fn draw(&self, bounds: Rectangle, cursor: Cursor) -> Vec<Geometry> { -        T::draw(self, bounds, cursor) +    fn draw( +        &self, +        theme: &Theme, +        bounds: Rectangle, +        cursor: Cursor, +    ) -> Vec<Geometry> { +        T::draw(self, theme, bounds, cursor)      }      fn mouse_interaction(  | 
