Derive Default for Rainbow in geometry example
This commit is contained in:
parent
324d60db63
commit
bb2bf063b4
1 changed files with 5 additions and 6 deletions
|
|
@ -20,12 +20,11 @@ mod rainbow {
|
||||||
Element, Layout, Length, Point, Rectangle, Size, Vector,
|
Element, Layout, Length, Point, Rectangle, Size, Vector,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, Default)]
|
||||||
pub struct Rainbow;
|
pub struct Rainbow;
|
||||||
|
|
||||||
impl Rainbow {
|
pub fn rainbow() -> Rainbow {
|
||||||
pub fn new() -> Self {
|
Rainbow
|
||||||
Self
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Message, B, T> Widget<Message, Renderer<B, T>> for Rainbow
|
impl<Message, B, T> Widget<Message, Renderer<B, T>> for Rainbow
|
||||||
|
|
@ -164,7 +163,7 @@ mod rainbow {
|
||||||
|
|
||||||
use iced::widget::{column, container, scrollable};
|
use iced::widget::{column, container, scrollable};
|
||||||
use iced::{Element, Length, Sandbox, Settings};
|
use iced::{Element, Length, Sandbox, Settings};
|
||||||
use rainbow::Rainbow;
|
use rainbow::rainbow;
|
||||||
|
|
||||||
pub fn main() -> iced::Result {
|
pub fn main() -> iced::Result {
|
||||||
Example::run(Settings::default())
|
Example::run(Settings::default())
|
||||||
|
|
@ -187,7 +186,7 @@ impl Sandbox for Example {
|
||||||
|
|
||||||
fn view(&self) -> Element<()> {
|
fn view(&self) -> Element<()> {
|
||||||
let content = column![
|
let content = column![
|
||||||
Rainbow::new(),
|
rainbow(),
|
||||||
"In this example we draw a custom widget Rainbow, using \
|
"In this example we draw a custom widget Rainbow, using \
|
||||||
the Mesh2D primitive. This primitive supplies a list of \
|
the Mesh2D primitive. This primitive supplies a list of \
|
||||||
triangles, expressed as vertices and indices.",
|
triangles, expressed as vertices and indices.",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue