mirror of
https://github.com/danbulant/cushy
synced 2026-06-10 18:13:48 +00:00
Closes #91 There's some details to still figure out, which are in new issues: - #109: When opening a window, no handle is returned that gives access to the window from the opener. Technically this can all be wired up manually, with exception of requeesting the window close. - #107: How can a window close itself? Once we have a handle type, we still need a mechanism to allow a button on a window request that the window closes gracefully. The examples that currently close the window call exit instad.
63 lines
1.9 KiB
Rust
63 lines
1.9 KiB
Rust
use gooey::value::Dynamic;
|
|
use gooey::widget::{MakeWidget, WidgetInstance};
|
|
use gooey::widgets::container::ContainerShadow;
|
|
use gooey::window::ThemeMode;
|
|
use gooey::Run;
|
|
use kludgine::figures::units::Lp;
|
|
use kludgine::figures::Point;
|
|
|
|
fn main() -> gooey::Result {
|
|
let theme_mode = Dynamic::default();
|
|
set_of_containers(3, theme_mode.clone())
|
|
.centered()
|
|
.into_window()
|
|
.themed_mode(theme_mode)
|
|
.run()
|
|
}
|
|
|
|
fn set_of_containers(repeat: usize, theme_mode: Dynamic<ThemeMode>) -> WidgetInstance {
|
|
let inner = if let Some(remaining_iters) = repeat.checked_sub(1) {
|
|
set_of_containers(remaining_iters, theme_mode)
|
|
} else {
|
|
"Toggle Theme Mode"
|
|
.into_button()
|
|
.on_click(move |_| {
|
|
theme_mode.map_mut(|mode| mode.toggle());
|
|
})
|
|
.make_widget()
|
|
};
|
|
"Lowest"
|
|
.and(
|
|
"Low"
|
|
.and(
|
|
"Mid"
|
|
.and(
|
|
"High"
|
|
.and(
|
|
"Highest"
|
|
.and(inner)
|
|
.into_rows()
|
|
.contain()
|
|
.shadow(drop_shadow()),
|
|
)
|
|
.into_rows()
|
|
.contain()
|
|
.shadow(drop_shadow()),
|
|
)
|
|
.into_rows()
|
|
.contain()
|
|
.shadow(drop_shadow()),
|
|
)
|
|
.into_rows()
|
|
.contain()
|
|
.shadow(drop_shadow()),
|
|
)
|
|
.into_rows()
|
|
.contain()
|
|
.shadow(drop_shadow())
|
|
.make_widget()
|
|
}
|
|
|
|
fn drop_shadow() -> ContainerShadow<Lp> {
|
|
ContainerShadow::new(Point::new(Lp::ZERO, Lp::mm(1))).spread(Lp::mm(1))
|
|
}
|