Draft Box
primitive
This commit is contained in:
parent
5a5ca34b5f
commit
7765e6da50
@ -3,5 +3,5 @@ mod primitive;
|
||||
mod renderer;
|
||||
|
||||
pub use mouse_cursor::MouseCursor;
|
||||
pub use primitive::Primitive;
|
||||
pub use primitive::{Background, Primitive};
|
||||
pub use renderer::{Renderer, Target};
|
||||
|
@ -1,4 +1,4 @@
|
||||
use iced_native::Rectangle;
|
||||
use iced_native::{Color, Rectangle};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum Primitive {
|
||||
@ -11,4 +11,13 @@ pub enum Primitive {
|
||||
bounds: Rectangle,
|
||||
size: f32,
|
||||
},
|
||||
Box {
|
||||
bounds: Rectangle,
|
||||
background: Background,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub enum Background {
|
||||
Color(Color),
|
||||
}
|
||||
|
@ -144,6 +144,9 @@ impl Renderer {
|
||||
scale: wgpu_glyph::Scale { x: *size, y: *size },
|
||||
..Default::default()
|
||||
}),
|
||||
Primitive::Box { bounds, background } => {
|
||||
// TODO: Batch boxes and draw them all at once
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,40 @@
|
||||
use crate::{Primitive, Renderer};
|
||||
use iced_native::{button, Button, Layout, Node, Point, Style};
|
||||
use crate::{Background, Primitive, Renderer};
|
||||
use iced_native::{button, Button, Color, Layout, Length, Node, Point, Style};
|
||||
|
||||
impl button::Renderer for Renderer {
|
||||
fn node<Message>(&self, _button: &Button<Message>) -> Node {
|
||||
Node::new(Style::default())
|
||||
fn node<Message>(&self, button: &Button<Message>) -> Node {
|
||||
let style = Style::default()
|
||||
.width(button.width)
|
||||
.min_height(Length::Units(30))
|
||||
.min_width(Length::Units(100))
|
||||
.align_self(button.align_self);
|
||||
|
||||
Node::new(style)
|
||||
}
|
||||
|
||||
fn draw<Message>(
|
||||
&mut self,
|
||||
_button: &Button<Message>,
|
||||
_layout: Layout<'_>,
|
||||
button: &Button<Message>,
|
||||
layout: Layout<'_>,
|
||||
_cursor_position: Point,
|
||||
) -> Self::Primitive {
|
||||
// TODO
|
||||
Primitive::None
|
||||
Primitive::Group {
|
||||
primitives: vec![
|
||||
Primitive::Box {
|
||||
bounds: layout.bounds(),
|
||||
background: Background::Color(Color {
|
||||
r: 0.0,
|
||||
b: 1.0,
|
||||
g: 0.0,
|
||||
a: 1.0,
|
||||
}),
|
||||
},
|
||||
Primitive::Text {
|
||||
content: button.label.clone(),
|
||||
size: 20.0,
|
||||
bounds: layout.bounds(),
|
||||
},
|
||||
],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user