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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
use iced::widget::{button, column, container, horizontal_rule, row, text, vertical_rule};
use iced::window::Settings;
use iced::{Element, Fill, FillPortion, Theme};
fn main() -> iced::Result {
let mut settings = Settings::default();
settings.size = [640.0, 480.0].into();
settings.min_size = Some([320.0, 200.0].into());
iced::application("Title", update, view)
.window(settings)
.theme(|s: &State| {
Theme::ALL[(s.count as usize) % Theme::ALL.len()].clone()
})
.run()
}
#[derive(Debug, Clone, Default)]
struct State {
count: u64
}
#[derive(Debug, Clone, Copy)]
enum Message {
Increment,
Decrement
}
fn update(counter: &mut State, message: Message) {
match message {
Message::Increment => counter.count = counter.count.wrapping_add(1),
Message::Decrement => counter.count = counter.count.wrapping_sub(1),
}
}
fn view(counter: &State) -> Element<Message> {
container(column([
container(row([
button("amogus")
.style(button::text)
.on_press(Message::Decrement).into()
]))
.style(container::bordered_box)
.width(Fill)
.into(),
row([
container("this is where a sane person might choose a profile to play.")
.width(FillPortion(3))
.height(Fill).into(),
vertical_rule(1).into(),
container("the goddamn user interface.")
.width(Fill).into()
]).height(Fill).into(),
horizontal_rule(1).into(),
container(row([
text("yippee!!").height(Fill).width(Fill).into(),
container(button(text("Play").height(Fill).width(Fill).center()).style(button::primary).on_press(Message::Increment)).max_width(150.0).into(),
text("you're logged in or something").height(Fill).width(Fill).into(),
])
.padding(10)
.spacing(10))
.height(75).into(),
container(text(format!("Counter: {}", counter.count))).padding(5).width(Fill).style(container::bordered_box).into()
]))
.center_x(Fill)
.center_y(Fill)
.into()
}
|