-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathmaterial_icons.rs
37 lines (32 loc) · 1.21 KB
/
material_icons.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright 2022 the Druid Authors
// SPDX-License-Identifier: Apache-2.0 OR MIT
use druid::{widget::Flex, AppLauncher, Color, LocalizedString, Widget, WidgetExt, WindowDesc};
use druid_widget_nursery::material_icons::{
normal::action::{ABC, ADD_CARD, ADD_TASK, ADD_TO_DRIVE},
Icon,
};
use qu::ick_use::*;
// Helps to make the icons visible.
fn show_icon(icon: impl Widget<()> + 'static) -> impl Widget<()> {
icon.padding(10.)
}
fn ui_builder() -> impl Widget<()> {
Flex::row()
.with_child(show_icon(Icon::new(ABC)))
// if we make it bigger it will preserve aspect ratio if possible
.with_child(show_icon(Icon::new(ADD_TASK).fix_width(100.)))
// demo non-uniform scale
.with_child(show_icon(Icon::new(ADD_CARD).fix_size(24., 100.)))
// different color
.with_child(show_icon(Icon::new(ADD_TO_DRIVE).with_color(Color::MAROON)))
.center()
}
#[qu::ick]
pub fn main() -> Result {
// Create the main window
let main_window = WindowDesc::new(ui_builder())
.title(LocalizedString::new("material-icons").with_placeholder("Material Icons demo"));
// start the application
AppLauncher::with_window(main_window).launch(())?;
Ok(())
}