Draft Box primitive

This commit is contained in:
Héctor Ramón Jiménez 2019-10-06 19:22:25 +02:00
parent 5a5ca34b5f
commit 7765e6da50
4 changed files with 44 additions and 10 deletions

View file

@ -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(),
},
],
}
}
}