summaryrefslogtreecommitdiffstats
path: root/graphics/src/widget/canvas/program.rs
diff options
context:
space:
mode:
authorLibravatar Bingus <shankern@protonmail.com>2023-07-12 12:23:18 -0700
committerLibravatar Bingus <shankern@protonmail.com>2023-07-12 12:23:18 -0700
commit633f405f3f78bc7f82d2b2061491b0e011137451 (patch)
tree5ebfc1f45d216a5c14a90492563599e6969eab4d /graphics/src/widget/canvas/program.rs
parent41836dd80d0534608e7aedfbf2319c540a23de1a (diff)
parent21bd51426d900e271206f314e0c915dd41065521 (diff)
downloadiced-633f405f3f78bc7f82d2b2061491b0e011137451.tar.gz
iced-633f405f3f78bc7f82d2b2061491b0e011137451.tar.bz2
iced-633f405f3f78bc7f82d2b2061491b0e011137451.zip
Merge remote-tracking branch 'origin/master' into feat/multi-window-support
# Conflicts: # Cargo.toml # core/src/window/icon.rs # core/src/window/id.rs # core/src/window/position.rs # core/src/window/settings.rs # examples/integration/src/main.rs # examples/integration_opengl/src/main.rs # glutin/src/application.rs # native/src/subscription.rs # native/src/window.rs # runtime/src/window/action.rs # src/lib.rs # src/window.rs # winit/Cargo.toml # winit/src/application.rs # winit/src/icon.rs # winit/src/settings.rs # winit/src/window.rs
Diffstat (limited to 'graphics/src/widget/canvas/program.rs')
-rw-r--r--graphics/src/widget/canvas/program.rs102
1 files changed, 0 insertions, 102 deletions
diff --git a/graphics/src/widget/canvas/program.rs b/graphics/src/widget/canvas/program.rs
deleted file mode 100644
index 656dbfa6..00000000
--- a/graphics/src/widget/canvas/program.rs
+++ /dev/null
@@ -1,102 +0,0 @@
-use crate::widget::canvas::event::{self, Event};
-use crate::widget::canvas::mouse;
-use crate::widget::canvas::{Cursor, Geometry};
-use crate::Rectangle;
-
-/// The state and logic of a [`Canvas`].
-///
-/// A [`Program`] can mutate internal state and produce messages for an
-/// application.
-///
-/// [`Canvas`]: crate::widget::Canvas
-pub trait Program<Message, Theme = iced_native::Theme> {
- /// The internal state mutated by the [`Program`].
- type State: Default + 'static;
-
- /// Updates the [`State`](Self::State) of the [`Program`].
- ///
- /// When a [`Program`] is used in a [`Canvas`], the runtime will call this
- /// method for each [`Event`].
- ///
- /// This method can optionally return a `Message` to notify an application
- /// of any meaningful interactions.
- ///
- /// By default, this method does and returns nothing.
- ///
- /// [`Canvas`]: crate::widget::Canvas
- fn update(
- &self,
- _state: &mut Self::State,
- _event: Event,
- _bounds: Rectangle,
- _cursor: Cursor,
- ) -> (event::Status, Option<Message>) {
- (event::Status::Ignored, None)
- }
-
- /// Draws the state of the [`Program`], producing a bunch of [`Geometry`].
- ///
- /// [`Geometry`] can be easily generated with a [`Frame`] or stored in a
- /// [`Cache`].
- ///
- /// [`Frame`]: crate::widget::canvas::Frame
- /// [`Cache`]: crate::widget::canvas::Cache
- fn draw(
- &self,
- state: &Self::State,
- theme: &Theme,
- bounds: Rectangle,
- cursor: Cursor,
- ) -> Vec<Geometry>;
-
- /// Returns the current mouse interaction of the [`Program`].
- ///
- /// The interaction returned will be in effect even if the cursor position
- /// is out of bounds of the program's [`Canvas`].
- ///
- /// [`Canvas`]: crate::widget::Canvas
- fn mouse_interaction(
- &self,
- _state: &Self::State,
- _bounds: Rectangle,
- _cursor: Cursor,
- ) -> mouse::Interaction {
- mouse::Interaction::default()
- }
-}
-
-impl<Message, Theme, T> Program<Message, Theme> for &T
-where
- T: Program<Message, Theme>,
-{
- type State = T::State;
-
- fn update(
- &self,
- state: &mut Self::State,
- event: Event,
- bounds: Rectangle,
- cursor: Cursor,
- ) -> (event::Status, Option<Message>) {
- T::update(self, state, event, bounds, cursor)
- }
-
- fn draw(
- &self,
- state: &Self::State,
- theme: &Theme,
- bounds: Rectangle,
- cursor: Cursor,
- ) -> Vec<Geometry> {
- T::draw(self, state, theme, bounds, cursor)
- }
-
- fn mouse_interaction(
- &self,
- state: &Self::State,
- bounds: Rectangle,
- cursor: Cursor,
- ) -> mouse::Interaction {
- T::mouse_interaction(self, state, bounds, cursor)
- }
-}