iced-yoda/wgpu/src/renderer/button.rs

41 lines
1.2 KiB
Rust
Raw Normal View History

2019-10-06 19:22:25 +02:00
use crate::{Background, Primitive, Renderer};
use iced_native::{button, Button, Color, Layout, Length, Node, Point, Style};
2019-10-05 19:22:51 +02:00
impl button::Renderer for Renderer {
2019-10-06 19:22:25 +02:00
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)
2019-10-05 19:22:51 +02:00
}
fn draw<Message>(
&mut self,
2019-10-06 19:22:25 +02:00
button: &Button<Message>,
layout: Layout<'_>,
2019-10-05 19:22:51 +02:00
_cursor_position: Point,
) -> Self::Primitive {
2019-10-06 19:22:25 +02:00
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(),
},
],
}
2019-10-05 19:22:51 +02:00
}
}