summaryrefslogtreecommitdiffstats
path: root/graphics/src/widget/canvas/program.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-03-18 22:13:52 +0700
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-03-18 22:13:52 +0700
commit32fd8dadda6636b11d4a1d9f59b467e57b3706a8 (patch)
tree6acb0c0d0a14c032939412f8d177dc08c5fd75aa /graphics/src/widget/canvas/program.rs
parentd7100fd2597da82d97eaf196d50573ea64f3f8ff (diff)
downloadiced-32fd8dadda6636b11d4a1d9f59b467e57b3706a8.tar.gz
iced-32fd8dadda6636b11d4a1d9f59b467e57b3706a8.tar.bz2
iced-32fd8dadda6636b11d4a1d9f59b467e57b3706a8.zip
Reintroduce generic `Message` type for `canvas::Program`
As it is useful to make the `Message` completely free in many implementations.
Diffstat (limited to 'graphics/src/widget/canvas/program.rs')
-rw-r--r--graphics/src/widget/canvas/program.rs15
1 files changed, 5 insertions, 10 deletions
diff --git a/graphics/src/widget/canvas/program.rs b/graphics/src/widget/canvas/program.rs
index f8b9ff2b..85a2f67b 100644
--- a/graphics/src/widget/canvas/program.rs
+++ b/graphics/src/widget/canvas/program.rs
@@ -8,10 +8,7 @@ use iced_native::{mouse, Rectangle};
/// application.
///
/// [`Canvas`]: crate::widget::Canvas
-pub trait Program {
- /// The [`Message`] produced by the [`Program`].
- type Message;
-
+pub trait Program<Message> {
/// Updates the state of the [`Program`].
///
/// When a [`Program`] is used in a [`Canvas`], the runtime will call this
@@ -28,7 +25,7 @@ pub trait Program {
_event: Event,
_bounds: Rectangle,
_cursor: Cursor,
- ) -> (event::Status, Option<Self::Message>) {
+ ) -> (event::Status, Option<Message>) {
(event::Status::Ignored, None)
}
@@ -56,18 +53,16 @@ pub trait Program {
}
}
-impl<T> Program for &mut T
+impl<T, Message> Program<Message> for &mut T
where
- T: Program,
+ T: Program<Message>,
{
- type Message = T::Message;
-
fn update(
&mut self,
event: Event,
bounds: Rectangle,
cursor: Cursor,
- ) -> (event::Status, Option<Self::Message>) {
+ ) -> (event::Status, Option<Message>) {
T::update(self, event, bounds, cursor)
}