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

43 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-07 03:56:16 +02:00
let bounds = layout.bounds();
2019-10-06 19:22:25 +02:00
Primitive::Group {
primitives: vec![
2019-10-07 02:17:40 +02:00
Primitive::Quad {
2019-10-07 03:56:16 +02:00
bounds,
2019-10-06 19:22:25 +02:00
background: Background::Color(Color {
2019-10-07 03:56:16 +02:00
r: 0.8,
b: 0.8,
g: 0.8,
2019-10-06 19:22:25 +02:00
a: 1.0,
}),
},
Primitive::Text {
content: button.label.clone(),
size: 20.0,
bounds: layout.bounds(),
},
],
}
2019-10-05 19:22:51 +02:00
}
}