summaryrefslogtreecommitdiffstats
path: root/widget/src/shader
diff options
context:
space:
mode:
authorLibravatar Héctor <hector@hecrj.dev>2024-11-13 17:08:26 +0100
committerLibravatar GitHub <noreply@github.com>2024-11-13 17:08:26 +0100
commita11fcf8f2dde551335c6f34788393fa2e8f8a362 (patch)
tree1e423c847a6505a2582bec19908866dba94c436d /widget/src/shader
parent42a2cb6d4f78343f43d6a68a28e5502d9426ed2c (diff)
parent28ec6df8f0ebf96966bee61caf5a325695314b7a (diff)
downloadiced-a11fcf8f2dde551335c6f34788393fa2e8f8a362.tar.gz
iced-a11fcf8f2dde551335c6f34788393fa2e8f8a362.tar.bz2
iced-a11fcf8f2dde551335c6f34788393fa2e8f8a362.zip
Merge pull request #2662 from iced-rs/reactive-rendering
Reactive Rendering
Diffstat (limited to 'widget/src/shader')
-rw-r--r--widget/src/shader/event.rs25
-rw-r--r--widget/src/shader/program.rs16
2 files changed, 7 insertions, 34 deletions
diff --git a/widget/src/shader/event.rs b/widget/src/shader/event.rs
deleted file mode 100644
index 005c8725..00000000
--- a/widget/src/shader/event.rs
+++ /dev/null
@@ -1,25 +0,0 @@
-//! Handle events of a custom shader widget.
-use crate::core::keyboard;
-use crate::core::mouse;
-use crate::core::time::Instant;
-use crate::core::touch;
-
-pub use crate::core::event::Status;
-
-/// A [`Shader`] event.
-///
-/// [`Shader`]: crate::Shader
-#[derive(Debug, Clone, PartialEq)]
-pub enum Event {
- /// A mouse event.
- Mouse(mouse::Event),
-
- /// A touch event.
- Touch(touch::Event),
-
- /// A keyboard event.
- Keyboard(keyboard::Event),
-
- /// A window requested a redraw.
- RedrawRequested(Instant),
-}
diff --git a/widget/src/shader/program.rs b/widget/src/shader/program.rs
index 902c7c3b..0fc110af 100644
--- a/widget/src/shader/program.rs
+++ b/widget/src/shader/program.rs
@@ -1,8 +1,7 @@
-use crate::core::event;
use crate::core::mouse;
-use crate::core::{Rectangle, Shell};
+use crate::core::Rectangle;
use crate::renderer::wgpu::Primitive;
-use crate::shader;
+use crate::shader::{self, Action};
/// The state and logic of a [`Shader`] widget.
///
@@ -18,10 +17,10 @@ pub trait Program<Message> {
type Primitive: Primitive + 'static;
/// Update the internal [`State`] of the [`Program`]. This can be used to reflect state changes
- /// based on mouse & other events. You can use the [`Shell`] to publish messages, request a
- /// redraw for the window, etc.
+ /// based on mouse & other events. You can return an [`Action`] to publish a message, request a
+ /// redraw, or capture the event.
///
- /// By default, this method does and returns nothing.
+ /// By default, this method returns `None`.
///
/// [`State`]: Self::State
fn update(
@@ -30,9 +29,8 @@ pub trait Program<Message> {
_event: shader::Event,
_bounds: Rectangle,
_cursor: mouse::Cursor,
- _shell: &mut Shell<'_, Message>,
- ) -> (event::Status, Option<Message>) {
- (event::Status::Ignored, None)
+ ) -> Option<Action<Message>> {
+ None
}
/// Draws the [`Primitive`].