summaryrefslogtreecommitdiffstats
path: root/wgpu
diff options
context:
space:
mode:
Diffstat (limited to 'wgpu')
-rw-r--r--wgpu/src/renderer/widget.rs1
-rw-r--r--wgpu/src/renderer/widget/panes.rs34
-rw-r--r--wgpu/src/widget/canvas/layer/cache.rs15
3 files changed, 49 insertions, 1 deletions
diff --git a/wgpu/src/renderer/widget.rs b/wgpu/src/renderer/widget.rs
index 84f908e7..9a46552e 100644
--- a/wgpu/src/renderer/widget.rs
+++ b/wgpu/src/renderer/widget.rs
@@ -2,6 +2,7 @@ mod button;
mod checkbox;
mod column;
mod container;
+mod panes;
mod progress_bar;
mod radio;
mod row;
diff --git a/wgpu/src/renderer/widget/panes.rs b/wgpu/src/renderer/widget/panes.rs
new file mode 100644
index 00000000..74e58895
--- /dev/null
+++ b/wgpu/src/renderer/widget/panes.rs
@@ -0,0 +1,34 @@
+use crate::{Primitive, Renderer};
+use iced_native::{panes, Element, Layout, MouseCursor, Point};
+
+impl panes::Renderer for Renderer {
+ fn draw<Message>(
+ &mut self,
+ defaults: &Self::Defaults,
+ content: &[(panes::Pane, Element<'_, Message, Self>)],
+ layout: Layout<'_>,
+ cursor_position: Point,
+ ) -> Self::Output {
+ let mut mouse_cursor = MouseCursor::OutOfBounds;
+
+ (
+ Primitive::Group {
+ primitives: content
+ .iter()
+ .zip(layout.children())
+ .map(|((_, pane), layout)| {
+ let (primitive, new_mouse_cursor) =
+ pane.draw(self, defaults, layout, cursor_position);
+
+ if new_mouse_cursor > mouse_cursor {
+ mouse_cursor = new_mouse_cursor;
+ }
+
+ primitive
+ })
+ .collect(),
+ },
+ mouse_cursor,
+ )
+ }
+}
diff --git a/wgpu/src/widget/canvas/layer/cache.rs b/wgpu/src/widget/canvas/layer/cache.rs
index 3071cce0..8f265142 100644
--- a/wgpu/src/widget/canvas/layer/cache.rs
+++ b/wgpu/src/widget/canvas/layer/cache.rs
@@ -21,7 +21,6 @@ pub struct Cache<T: Drawable> {
state: RefCell<State>,
}
-#[derive(Debug)]
enum State {
Empty,
Filled {
@@ -99,3 +98,17 @@ where
mesh
}
}
+
+impl std::fmt::Debug for State {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ match self {
+ State::Empty => write!(f, "Empty"),
+ State::Filled { mesh, bounds } => f
+ .debug_struct("Filled")
+ .field("vertices", &mesh.vertices.len())
+ .field("indices", &mesh.indices.len())
+ .field("bounds", bounds)
+ .finish(),
+ }
+ }
+}