Implement Widget::draw for Canvas in iced_graphics

This commit is contained in:
Héctor Ramón Jiménez 2021-10-29 16:45:47 +07:00
parent 0df5b5bb7b
commit de728737fd
No known key found for this signature in database
GPG key ID: 140CC052C94F138E

View file

@ -4,11 +4,12 @@
//! [`Frame`]. It can be used for animation, data visualization, game graphics, //! [`Frame`]. It can be used for animation, data visualization, game graphics,
//! and more! //! and more!
use crate::renderer::{self, Renderer}; use crate::renderer::{self, Renderer};
use crate::Backend; use crate::{Backend, Primitive};
use iced_native::layout; use iced_native::layout;
use iced_native::{ use iced_native::{
Clipboard, Element, Hasher, Layout, Length, Point, Rectangle, Size, Widget, Clipboard, Element, Hasher, Layout, Length, Point, Rectangle, Size, Vector,
Widget,
}; };
use std::hash::Hash; use std::hash::Hash;
use std::marker::PhantomData; use std::marker::PhantomData;
@ -188,31 +189,28 @@ where
fn draw( fn draw(
&self, &self,
_renderer: &mut Renderer<B>, renderer: &mut Renderer<B>,
_style: &renderer::Style, _style: &renderer::Style,
_layout: Layout<'_>, layout: Layout<'_>,
_cursor_position: Point, cursor_position: Point,
_viewport: &Rectangle, _viewport: &Rectangle,
) { ) {
// let bounds = layout.bounds(); use iced_native::Renderer as _;
// let translation = Vector::new(bounds.x, bounds.y);
// let cursor = Cursor::from_window_position(cursor_position);
// ( let bounds = layout.bounds();
// Primitive::Translate { let translation = Vector::new(bounds.x, bounds.y);
// translation, let cursor = Cursor::from_window_position(cursor_position);
// content: Box::new(Primitive::Group {
// primitives: self renderer.with_translation(translation, |renderer| {
// .program renderer.draw_primitive(Primitive::Group {
// .draw(bounds, cursor) primitives: self
// .into_iter() .program
// .map(Geometry::into_primitive) .draw(bounds, cursor)
// .collect(), .into_iter()
// }), .map(Geometry::into_primitive)
// }, .collect(),
// self.program.mouse_interaction(bounds, cursor), });
// ) });
// TODO
} }
fn hash_layout(&self, state: &mut Hasher) { fn hash_layout(&self, state: &mut Hasher) {