summaryrefslogtreecommitdiffstats
path: root/graphics/src
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/src')
-rw-r--r--graphics/src/lib.rs3
-rw-r--r--graphics/src/renderer.rs2
-rw-r--r--graphics/src/widget.rs3
-rw-r--r--graphics/src/widget/canvas.rs61
-rw-r--r--graphics/src/widget/canvas/cache.rs6
-rw-r--r--graphics/src/widget/canvas/frame.rs9
-rw-r--r--graphics/src/widget/canvas/path.rs2
-rw-r--r--graphics/src/widget/canvas/path/builder.rs2
-rw-r--r--graphics/src/widget/canvas/program.rs34
-rw-r--r--graphics/src/widget/pure.rs12
-rw-r--r--graphics/src/widget/pure/canvas.rs246
-rw-r--r--graphics/src/widget/pure/canvas/program.rs102
-rw-r--r--graphics/src/widget/pure/qr_code.rs64
-rw-r--r--graphics/src/widget/qr_code.rs4
14 files changed, 67 insertions, 483 deletions
diff --git a/graphics/src/lib.rs b/graphics/src/lib.rs
index a7a1cabb..11082472 100644
--- a/graphics/src/lib.rs
+++ b/graphics/src/lib.rs
@@ -36,9 +36,6 @@ pub mod triangle;
pub mod widget;
pub mod window;
-#[doc(no_inline)]
-pub use widget::*;
-
pub use antialiasing::Antialiasing;
pub use backend::Backend;
pub use error::Error;
diff --git a/graphics/src/renderer.rs b/graphics/src/renderer.rs
index 3c19fbfb..cdbc4f40 100644
--- a/graphics/src/renderer.rs
+++ b/graphics/src/renderer.rs
@@ -58,7 +58,7 @@ where
element: &Element<'a, Message, Self>,
limits: &layout::Limits,
) -> layout::Node {
- let layout = element.layout(self, limits);
+ let layout = element.as_widget().layout(self, limits);
self.backend.trim_measurements();
diff --git a/graphics/src/widget.rs b/graphics/src/widget.rs
index cf500a69..e7fab97c 100644
--- a/graphics/src/widget.rs
+++ b/graphics/src/widget.rs
@@ -14,6 +14,3 @@ pub mod qr_code;
#[cfg(feature = "qr_code")]
#[doc(no_inline)]
pub use qr_code::QRCode;
-
-#[cfg(feature = "pure")]
-pub mod pure;
diff --git a/graphics/src/widget/canvas.rs b/graphics/src/widget/canvas.rs
index c3e28e8c..88403fd7 100644
--- a/graphics/src/widget/canvas.rs
+++ b/graphics/src/widget/canvas.rs
@@ -3,8 +3,6 @@
//! A [`Canvas`] widget can be used to draw different kinds of 2D shapes in a
//! [`Frame`]. It can be used for animation, data visualization, game graphics,
//! and more!
-use crate::renderer::{self, Renderer};
-use crate::{Backend, Primitive};
pub mod event;
pub mod path;
@@ -29,42 +27,31 @@ pub use program::Program;
pub use stroke::{LineCap, LineDash, LineJoin, Stroke};
pub use text::Text;
-use iced_native::layout;
+use crate::{Backend, Primitive, Renderer};
+
+use iced_native::layout::{self, Layout};
use iced_native::mouse;
+use iced_native::renderer;
+use iced_native::widget::tree::{self, Tree};
use iced_native::{
- Clipboard, Element, Layout, Length, Point, Rectangle, Shell, Size, Vector,
- Widget,
+ Clipboard, Element, Length, Point, Rectangle, Shell, Size, Vector, Widget,
};
use std::marker::PhantomData;
/// A widget capable of drawing 2D graphics.
///
-/// # Examples
-/// The repository has a couple of [examples] showcasing how to use a
-/// [`Canvas`]:
-///
-/// - [`clock`], an application that uses the [`Canvas`] widget to draw a clock
-/// and its hands to display the current time.
-/// - [`game_of_life`], an interactive version of the Game of Life, invented by
-/// John Conway.
-/// - [`solar_system`], an animated solar system drawn using the [`Canvas`] widget
-/// and showcasing how to compose different transforms.
-///
-/// [examples]: https://github.com/iced-rs/iced/tree/0.4/examples
-/// [`clock`]: https://github.com/iced-rs/iced/tree/0.4/examples/clock
-/// [`game_of_life`]: https://github.com/iced-rs/iced/tree/0.4/examples/game_of_life
-/// [`solar_system`]: https://github.com/iced-rs/iced/tree/0.4/examples/solar_system
-///
/// ## Drawing a simple circle
/// If you want to get a quick overview, here's how we can draw a simple circle:
///
/// ```no_run
/// # mod iced {
-/// # pub use iced_graphics::canvas;
+/// # pub mod widget {
+/// # pub use iced_graphics::widget::canvas;
+/// # }
/// # pub use iced_native::{Color, Rectangle, Theme};
/// # }
-/// use iced::canvas::{self, Canvas, Cursor, Fill, Frame, Geometry, Path, Program};
+/// use iced::widget::canvas::{self, Canvas, Cursor, Fill, Frame, Geometry, Path, Program};
/// use iced::{Color, Rectangle, Theme};
///
/// // First, we define the data we need for drawing
@@ -75,7 +62,9 @@ use std::marker::PhantomData;
///
/// // Then, we implement the `Program` trait
/// impl Program<()> for Circle {
-/// fn draw(&self, _theme: &Theme, bounds: Rectangle, _cursor: Cursor) -> Vec<Geometry>{
+/// type State = ();
+///
+/// fn draw(&self, _state: &(), _theme: &Theme, bounds: Rectangle, _cursor: Cursor) -> Vec<Geometry>{
/// // We prepare a new `Frame`
/// let mut frame = Frame::new(bounds.size());
///
@@ -140,6 +129,15 @@ where
P: Program<Message, T>,
B: Backend,
{
+ fn tag(&self) -> tree::Tag {
+ struct Tag<T>(T);
+ tree::Tag::of::<Tag<P::State>>()
+ }
+
+ fn state(&self) -> tree::State {
+ tree::State::new(P::State::default())
+ }
+
fn width(&self) -> Length {
self.width
}
@@ -161,6 +159,7 @@ where
fn on_event(
&mut self,
+ tree: &mut Tree,
event: iced_native::Event,
layout: Layout<'_>,
cursor_position: Point,
@@ -183,8 +182,10 @@ where
let cursor = Cursor::from_window_position(cursor_position);
if let Some(canvas_event) = canvas_event {
+ let state = tree.state.downcast_mut::<P::State>();
+
let (event_status, message) =
- self.program.update(canvas_event, bounds, cursor);
+ self.program.update(state, canvas_event, bounds, cursor);
if let Some(message) = message {
shell.publish(message);
@@ -198,6 +199,7 @@ where
fn mouse_interaction(
&self,
+ tree: &Tree,
layout: Layout<'_>,
cursor_position: Point,
_viewport: &Rectangle,
@@ -205,12 +207,14 @@ where
) -> mouse::Interaction {
let bounds = layout.bounds();
let cursor = Cursor::from_window_position(cursor_position);
+ let state = tree.state.downcast_ref::<P::State>();
- self.program.mouse_interaction(bounds, cursor)
+ self.program.mouse_interaction(state, bounds, cursor)
}
fn draw(
&self,
+ tree: &Tree,
renderer: &mut Renderer<B, T>,
theme: &T,
_style: &renderer::Style,
@@ -228,12 +232,13 @@ where
let translation = Vector::new(bounds.x, bounds.y);
let cursor = Cursor::from_window_position(cursor_position);
+ let state = tree.state.downcast_ref::<P::State>();
renderer.with_translation(translation, |renderer| {
renderer.draw_primitive(Primitive::Group {
primitives: self
.program
- .draw(theme, bounds, cursor)
+ .draw(state, theme, bounds, cursor)
.into_iter()
.map(Geometry::into_primitive)
.collect(),
@@ -245,7 +250,7 @@ where
impl<'a, Message, P, B, T> From<Canvas<Message, T, P>>
for Element<'a, Message, Renderer<B, T>>
where
- Message: 'static,
+ Message: 'a,
P: Program<Message, T> + 'a,
B: Backend,
T: 'a,
diff --git a/graphics/src/widget/canvas/cache.rs b/graphics/src/widget/canvas/cache.rs
index a469417d..5af694e9 100644
--- a/graphics/src/widget/canvas/cache.rs
+++ b/graphics/src/widget/canvas/cache.rs
@@ -1,7 +1,5 @@
-use crate::{
- canvas::{Frame, Geometry},
- Primitive,
-};
+use crate::widget::canvas::{Frame, Geometry};
+use crate::Primitive;
use iced_native::Size;
use std::{cell::RefCell, sync::Arc};
diff --git a/graphics/src/widget/canvas/frame.rs b/graphics/src/widget/canvas/frame.rs
index 2f46079c..417412b2 100644
--- a/graphics/src/widget/canvas/frame.rs
+++ b/graphics/src/widget/canvas/frame.rs
@@ -2,11 +2,10 @@ use std::borrow::Cow;
use iced_native::{Point, Rectangle, Size, Vector};
-use crate::{
- canvas::path,
- canvas::{Fill, Geometry, Path, Stroke, Text},
- triangle, Primitive,
-};
+use crate::triangle;
+use crate::widget::canvas::path;
+use crate::widget::canvas::{Fill, Geometry, Path, Stroke, Text};
+use crate::Primitive;
use lyon::tessellation;
diff --git a/graphics/src/widget/canvas/path.rs b/graphics/src/widget/canvas/path.rs
index 608507ad..aeb2589e 100644
--- a/graphics/src/widget/canvas/path.rs
+++ b/graphics/src/widget/canvas/path.rs
@@ -7,7 +7,7 @@ mod builder;
pub use arc::Arc;
pub use builder::Builder;
-use crate::canvas::LineDash;
+use crate::widget::canvas::LineDash;
use iced_native::{Point, Size};
use lyon::algorithms::walk::{walk_along_path, RepeatedPattern, WalkerEvent};
diff --git a/graphics/src/widget/canvas/path/builder.rs b/graphics/src/widget/canvas/path/builder.rs
index c49ccdc3..5121aa68 100644
--- a/graphics/src/widget/canvas/path/builder.rs
+++ b/graphics/src/widget/canvas/path/builder.rs
@@ -1,4 +1,4 @@
-use crate::canvas::path::{arc, Arc, Path};
+use crate::widget::canvas::path::{arc, Arc, Path};
use iced_native::{Point, Size};
use lyon::path::builder::SvgPathBuilder;
diff --git a/graphics/src/widget/canvas/program.rs b/graphics/src/widget/canvas/program.rs
index dddc387d..656dbfa6 100644
--- a/graphics/src/widget/canvas/program.rs
+++ b/graphics/src/widget/canvas/program.rs
@@ -1,8 +1,7 @@
-use crate::canvas::event::{self, Event};
-use crate::canvas::{Cursor, Geometry};
-
-use iced_native::mouse;
-use iced_native::Rectangle;
+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`].
///
@@ -11,7 +10,10 @@ use iced_native::Rectangle;
///
/// [`Canvas`]: crate::widget::Canvas
pub trait Program<Message, Theme = iced_native::Theme> {
- /// Updates the state of the [`Program`].
+ /// 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`].
@@ -23,7 +25,8 @@ pub trait Program<Message, Theme = iced_native::Theme> {
///
/// [`Canvas`]: crate::widget::Canvas
fn update(
- &mut self,
+ &self,
+ _state: &mut Self::State,
_event: Event,
_bounds: Rectangle,
_cursor: Cursor,
@@ -40,6 +43,7 @@ pub trait Program<Message, Theme = iced_native::Theme> {
/// [`Cache`]: crate::widget::canvas::Cache
fn draw(
&self,
+ state: &Self::State,
theme: &Theme,
bounds: Rectangle,
cursor: Cursor,
@@ -53,6 +57,7 @@ pub trait Program<Message, Theme = iced_native::Theme> {
/// [`Canvas`]: crate::widget::Canvas
fn mouse_interaction(
&self,
+ _state: &Self::State,
_bounds: Rectangle,
_cursor: Cursor,
) -> mouse::Interaction {
@@ -60,33 +65,38 @@ pub trait Program<Message, Theme = iced_native::Theme> {
}
}
-impl<T, Message, Theme> Program<Message, Theme> for &mut T
+impl<Message, Theme, T> Program<Message, Theme> for &T
where
T: Program<Message, Theme>,
{
+ type State = T::State;
+
fn update(
- &mut self,
+ &self,
+ state: &mut Self::State,
event: Event,
bounds: Rectangle,
cursor: Cursor,
) -> (event::Status, Option<Message>) {
- T::update(self, event, bounds, cursor)
+ T::update(self, state, event, bounds, cursor)
}
fn draw(
&self,
+ state: &Self::State,
theme: &Theme,
bounds: Rectangle,
cursor: Cursor,
) -> Vec<Geometry> {
- T::draw(self, theme, bounds, cursor)
+ T::draw(self, state, theme, bounds, cursor)
}
fn mouse_interaction(
&self,
+ state: &Self::State,
bounds: Rectangle,
cursor: Cursor,
) -> mouse::Interaction {
- T::mouse_interaction(self, bounds, cursor)
+ T::mouse_interaction(self, state, bounds, cursor)
}
}
diff --git a/graphics/src/widget/pure.rs b/graphics/src/widget/pure.rs
deleted file mode 100644
index ee530379..00000000
--- a/graphics/src/widget/pure.rs
+++ /dev/null
@@ -1,12 +0,0 @@
-//! Leverage pure, virtual widgets in your application.
-#[cfg(feature = "canvas")]
-pub mod canvas;
-
-#[cfg(feature = "canvas")]
-pub use canvas::Canvas;
-
-#[cfg(feature = "qr_code")]
-pub mod qr_code;
-
-#[cfg(feature = "qr_code")]
-pub use qr_code::QRCode;
diff --git a/graphics/src/widget/pure/canvas.rs b/graphics/src/widget/pure/canvas.rs
deleted file mode 100644
index 19bcb0de..00000000
--- a/graphics/src/widget/pure/canvas.rs
+++ /dev/null
@@ -1,246 +0,0 @@
-//! Draw 2D graphics for your users.
-//!
-//! A [`Canvas`] widget can be used to draw different kinds of 2D shapes in a
-//! [`Frame`]. It can be used for animation, data visualization, game graphics,
-//! and more!
-mod program;
-
-pub use crate::widget::canvas::{Canvas as _, Program as _, *};
-
-pub use program::Program;
-
-use crate::{Backend, Primitive, Renderer};
-
-use iced_native::layout::{self, Layout};
-use iced_native::mouse;
-use iced_native::renderer;
-use iced_native::{Clipboard, Length, Point, Rectangle, Shell, Size, Vector};
-use iced_pure::widget::tree::{self, Tree};
-use iced_pure::{Element, Widget};
-
-use std::marker::PhantomData;
-
-/// A widget capable of drawing 2D graphics.
-///
-/// ## Drawing a simple circle
-/// If you want to get a quick overview, here's how we can draw a simple circle:
-///
-/// ```no_run
-/// # mod iced {
-/// # pub mod pure {
-/// # pub mod widget {
-/// # pub use iced_graphics::pure::canvas;
-/// # }
-/// # }
-/// # pub use iced_native::{Color, Rectangle, Theme};
-/// # }
-/// use iced::pure::widget::canvas::{self, Canvas, Cursor, Fill, Frame, Geometry, Path, Program};
-/// use iced::{Color, Rectangle, Theme};
-///
-/// // First, we define the data we need for drawing
-/// #[derive(Debug)]
-/// struct Circle {
-/// radius: f32,
-/// }
-///
-/// // Then, we implement the `Program` trait
-/// impl Program<()> for Circle {
-/// type State = ();
-///
-/// fn draw(&self, _state: &(), _theme: &Theme, bounds: Rectangle, _cursor: Cursor) -> Vec<Geometry>{
-/// // We prepare a new `Frame`
-/// let mut frame = Frame::new(bounds.size());
-///
-/// // We create a `Path` representing a simple circle
-/// let circle = Path::circle(frame.center(), self.radius);
-///
-/// // And fill it with some color
-/// frame.fill(&circle, Color::BLACK);
-///
-/// // Finally, we produce the geometry
-/// vec![frame.into_geometry()]
-/// }
-/// }
-///
-/// // Finally, we simply use our `Circle` to create the `Canvas`!
-/// let canvas = Canvas::new(Circle { radius: 50.0 });
-/// ```
-#[derive(Debug)]
-pub struct Canvas<Message, Theme, P>
-where
- P: Program<Message, Theme>,
-{
- width: Length,
- height: Length,
- program: P,
- message_: PhantomData<Message>,
- theme_: PhantomData<Theme>,
-}
-
-impl<Message, Theme, P> Canvas<Message, Theme, P>
-where
- P: Program<Message, Theme>,
-{
- const DEFAULT_SIZE: u16 = 100;
-
- /// Creates a new [`Canvas`].
- pub fn new(program: P) -> Self {
- Canvas {
- width: Length::Units(Self::DEFAULT_SIZE),
- height: Length::Units(Self::DEFAULT_SIZE),
- program,
- message_: PhantomData,
- theme_: PhantomData,
- }
- }
-
- /// Sets the width of the [`Canvas`].
- pub fn width(mut self, width: Length) -> Self {
- self.width = width;
- self
- }
-
- /// Sets the height of the [`Canvas`].
- pub fn height(mut self, height: Length) -> Self {
- self.height = height;
- self
- }
-}
-
-impl<Message, P, B, T> Widget<Message, Renderer<B, T>> for Canvas<Message, T, P>
-where
- P: Program<Message, T>,
- B: Backend,
-{
- fn tag(&self) -> tree::Tag {
- struct Tag<T>(T);
- tree::Tag::of::<Tag<P::State>>()
- }
-
- fn state(&self) -> tree::State {
- tree::State::new(P::State::default())
- }
-
- fn width(&self) -> Length {
- self.width
- }
-
- fn height(&self) -> Length {
- self.height
- }
-
- fn layout(
- &self,
- _renderer: &Renderer<B, T>,
- limits: &layout::Limits,
- ) -> layout::Node {
- let limits = limits.width(self.width).height(self.height);
- let size = limits.resolve(Size::ZERO);
-
- layout::Node::new(size)
- }
-
- fn on_event(
- &mut self,
- tree: &mut Tree,
- event: iced_native::Event,
- layout: Layout<'_>,
- cursor_position: Point,
- _renderer: &Renderer<B, T>,
- _clipboard: &mut dyn Clipboard,
- shell: &mut Shell<'_, Message>,
- ) -> event::Status {
- let bounds = layout.bounds();
-
- let canvas_event = match event {
- iced_native::Event::Mouse(mouse_event) => {
- Some(Event::Mouse(mouse_event))
- }
- iced_native::Event::Keyboard(keyboard_event) => {
- Some(Event::Keyboard(keyboard_event))
- }
- _ => None,
- };
-
- let cursor = Cursor::from_window_position(cursor_position);
-
- if let Some(canvas_event) = canvas_event {
- let state = tree.state.downcast_mut::<P::State>();
-
- let (event_status, message) =
- self.program.update(state, canvas_event, bounds, cursor);
-
- if let Some(message) = message {
- shell.publish(message);
- }
-
- return event_status;
- }
-
- event::Status::Ignored
- }
-
- fn mouse_interaction(
- &self,
- tree: &Tree,
- layout: Layout<'_>,
- cursor_position: Point,
- _viewport: &Rectangle,
- _renderer: &Renderer<B, T>,
- ) -> mouse::Interaction {
- let bounds = layout.bounds();
- let cursor = Cursor::from_window_position(cursor_position);
- let state = tree.state.downcast_ref::<P::State>();
-
- self.program.mouse_interaction(state, bounds, cursor)
- }
-
- fn draw(
- &self,
- tree: &Tree,
- renderer: &mut Renderer<B, T>,
- theme: &T,
- _style: &renderer::Style,
- layout: Layout<'_>,
- cursor_position: Point,
- _viewport: &Rectangle,
- ) {
- use iced_native::Renderer as _;
-
- let bounds = layout.bounds();
-
- if bounds.width < 1.0 || bounds.height < 1.0 {
- return;
- }
-
- let translation = Vector::new(bounds.x, bounds.y);
- let cursor = Cursor::from_window_position(cursor_position);
- let state = tree.state.downcast_ref::<P::State>();
-
- renderer.with_translation(translation, |renderer| {
- renderer.draw_primitive(Primitive::Group {
- primitives: self
- .program
- .draw(state, theme, bounds, cursor)
- .into_iter()
- .map(Geometry::into_primitive)
- .collect(),
- });
- });
- }
-}
-
-impl<'a, Message, P, B, T> From<Canvas<Message, T, P>>
- for Element<'a, Message, Renderer<B, T>>
-where
- Message: 'a,
- P: Program<Message, T> + 'a,
- B: Backend,
- T: 'a,
-{
- fn from(
- canvas: Canvas<Message, T, P>,
- ) -> Element<'a, Message, Renderer<B, T>> {
- Element::new(canvas)
- }
-}
diff --git a/graphics/src/widget/pure/canvas/program.rs b/graphics/src/widget/pure/canvas/program.rs
deleted file mode 100644
index 20c6406e..00000000
--- a/graphics/src/widget/pure/canvas/program.rs
+++ /dev/null
@@ -1,102 +0,0 @@
-use crate::widget::pure::canvas::event::{self, Event};
-use crate::widget::pure::canvas::mouse;
-use crate::widget::pure::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)
- }
-}
diff --git a/graphics/src/widget/pure/qr_code.rs b/graphics/src/widget/pure/qr_code.rs
deleted file mode 100644
index bff391fe..00000000
--- a/graphics/src/widget/pure/qr_code.rs
+++ /dev/null
@@ -1,64 +0,0 @@
-//! Encode and display information in a QR code.
-pub use crate::qr_code::*;
-
-use crate::{Backend, Renderer};
-
-use iced_native::layout::{self, Layout};
-use iced_native::renderer;
-use iced_native::{Length, Point, Rectangle};
-use iced_pure::widget::tree::Tree;
-use iced_pure::{Element, Widget};
-
-impl<'a, Message, B, T> Widget<Message, Renderer<B, T>> for QRCode<'a>
-where
- B: Backend,
-{
- fn width(&self) -> Length {
- <Self as iced_native::Widget<Message, Renderer<B, T>>>::width(self)
- }
-
- fn height(&self) -> Length {
- <Self as iced_native::Widget<Message, Renderer<B, T>>>::height(self)
- }
-
- fn layout(
- &self,
- renderer: &Renderer<B, T>,
- limits: &layout::Limits,
- ) -> layout::Node {
- <Self as iced_native::Widget<Message, Renderer<B, T>>>::layout(
- self, renderer, limits,
- )
- }
-
- fn draw(
- &self,
- _tree: &Tree,
- renderer: &mut Renderer<B, T>,
- theme: &T,
- style: &renderer::Style,
- layout: Layout<'_>,
- cursor_position: Point,
- viewport: &Rectangle,
- ) {
- <Self as iced_native::Widget<Message, Renderer<B, T>>>::draw(
- self,
- renderer,
- theme,
- style,
- layout,
- cursor_position,
- viewport,
- )
- }
-}
-
-impl<'a, Message, B, T> From<QRCode<'a>>
- for Element<'a, Message, Renderer<B, T>>
-where
- B: Backend,
-{
- fn from(qr_code: QRCode<'a>) -> Self {
- Self::new(qr_code)
- }
-}
diff --git a/graphics/src/widget/qr_code.rs b/graphics/src/widget/qr_code.rs
index 1a5c0b0a..12ce5b1f 100644
--- a/graphics/src/widget/qr_code.rs
+++ b/graphics/src/widget/qr_code.rs
@@ -1,9 +1,10 @@
//! Encode and display information in a QR code.
-use crate::canvas;
use crate::renderer::{self, Renderer};
+use crate::widget::canvas;
use crate::Backend;
use iced_native::layout;
+use iced_native::widget::Tree;
use iced_native::{
Color, Element, Layout, Length, Point, Rectangle, Size, Vector, Widget,
};
@@ -72,6 +73,7 @@ where
fn draw(
&self,
+ _state: &Tree,
renderer: &mut Renderer<B, T>,
_theme: &T,
_style: &renderer::Style,