Skip to content

Commit

Permalink
fix: use grid (but it doesn't change anything)
Browse files Browse the repository at this point in the history
  • Loading branch information
albx79 committed Jan 17, 2022
1 parent 30be1ec commit a788301
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions gui/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,25 @@ fn filter_color(filter: &Filter) -> egui::Color32 {
}
}

fn wordler_button(c: char) -> egui::Button {
egui::Button::new(RichText::new(String::from(c))
.color(egui::Color32::WHITE)
.monospace()
.heading())
}

impl epi::App for Wordler {
fn update(&mut self, ctx: &CtxRef, frame: &Frame) {
egui::CentralPanel::default().show(ctx, |ui| {
ui.vertical_centered_justified(|ui| {
egui::Grid::new("main grid")
.show(ui, |ui| {
let num_attempts = self.attempts.len();
let mut next_word = false;
for (row, word) in self.attempts.iter_mut().enumerate() {
ui.add_enabled_ui(row == num_attempts - 1, |ui| ui.horizontal(|ui| {
let is_last_row = row == num_attempts - 1;
ui.add_enabled_ui(is_last_row, |ui| ui.horizontal(|ui| {
for (position, filter) in word.enumerate() {
let button = egui::Button::new(RichText::new(String::from(filter.letter()))
.color(egui::Color32::WHITE)
.monospace()
.heading())
.fill(filter_color(filter));
let button = wordler_button(filter.letter()).fill(filter_color(filter));
if ui.add(button).clicked() {
*filter = filter.cycle(position);
}
Expand All @@ -76,6 +81,7 @@ impl epi::App for Wordler {
next_word = true;
}
}));
ui.end_row();
}
if next_word {
let last_word = self.attempts.last().unwrap();
Expand All @@ -86,10 +92,12 @@ impl epi::App for Wordler {
}
}
ui.separator();
ui.end_row();
if ui.button("Reset").clicked() {
let new_wordler = Wordler::default();
*self = new_wordler;
}
ui.end_row();
});
});

Expand Down

0 comments on commit a788301

Please sign in to comment.