From fc13bb3d65c85cfad9f231c0776d3a45f4fbf480 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 7 Jun 2022 05:24:43 +0200 Subject: Implement theme styling for `Canvas` --- graphics/src/widget/canvas/program.rs | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'graphics/src/widget/canvas/program.rs') 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 { +pub trait Program { /// 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 { /// /// [`Frame`]: crate::widget::canvas::Frame /// [`Cache`]: crate::widget::canvas::Cache - fn draw(&self, bounds: Rectangle, cursor: Cursor) -> Vec; + fn draw( + &self, + theme: &Theme, + bounds: Rectangle, + cursor: Cursor, + ) -> Vec; /// Returns the current mouse interaction of the [`Program`]. /// @@ -53,9 +60,9 @@ pub trait Program { } } -impl Program for &mut T +impl Program for &mut T where - T: Program, + T: Program, { fn update( &mut self, @@ -66,8 +73,13 @@ where T::update(self, event, bounds, cursor) } - fn draw(&self, bounds: Rectangle, cursor: Cursor) -> Vec { - T::draw(self, bounds, cursor) + fn draw( + &self, + theme: &Theme, + bounds: Rectangle, + cursor: Cursor, + ) -> Vec { + T::draw(self, theme, bounds, cursor) } fn mouse_interaction( -- cgit