Skip to content

Commit

Permalink
feat: new score layout
Browse files Browse the repository at this point in the history
  • Loading branch information
SilenLoc committed May 4, 2023
1 parent e229047 commit fe72c11
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 34 deletions.
16 changes: 11 additions & 5 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,19 @@ impl eframe::App for TypeFastApp {
.id_source("all")
.show(ui, |ui| {
self.settings.set_new_theme(ctx);
self.type_state
.render(ui, &mut self.score, &mut self.settings);
ui.horizontal_wrapped(|ui| {
ui.vertical(|ui| {
self.type_state
.render(ui, &mut self.score, &mut self.settings);
ui.horizontal_top(|ui| {
self.score.render_scoring(ui);

self.score.render_scoring(ui);

self.settings.render(&mut self.services, ui, ctx);
self.settings.render(&mut self.services, ui, ctx);
});
});
});
});

self.services.notifier.show(ctx);
});
}
Expand Down
42 changes: 22 additions & 20 deletions src/scoring/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,28 @@ pub struct Score {

impl Score {
pub fn render_scoring(&mut self, ui: &mut Ui) {
ui.heading(format!("{}", self.score));
ui.horizontal_top(|ui| {
let score_points: PlotPoints = PlotPoints::from(self.score_plot_state.clone());

let line = Line::new(score_points);
Plot::new("my_plot")
.auto_bounds_x()
.auto_bounds_y()
.width(400.0)
.height(100.0)
.show(ui, |plot_ui| plot_ui.line(line));

ui.label(format!(
"elapsed seconds {}",
self.score_per_duration.elapsed.as_secs_f64()
));
ui.label(format!(
"average score per second {}",
self.score_per_duration.avg
));
ui.collapsing("Statistics", |ui| {
ui.heading(format!("Score {}", self.score));
ui.vertical(|ui| {
let score_points: PlotPoints = PlotPoints::from(self.score_plot_state.clone());

let line = Line::new(score_points);
Plot::new("my_plot")
.auto_bounds_x()
.auto_bounds_y()
.width(400.0)
.height(100.0)
.show(ui, |plot_ui| plot_ui.line(line));

ui.label(format!(
"elapsed seconds {}",
self.score_per_duration.elapsed.as_secs_f64()
));
ui.label(format!(
"average score per second {}",
self.score_per_duration.avg
));
});
});
}

Expand Down
14 changes: 5 additions & 9 deletions src/settings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ impl Default for TFSetting {

impl TFSetting {
pub fn render(&mut self, services: &mut Services, ui: &mut egui::Ui, ctx: &egui::Context) {
ui.horizontal_centered(|ui| {
level_render::render(&self.level, ui);
ui.horizontal(|ui| {
self.render_settings(services, ui, ctx);
level_render::render(&self.level, ui);
});
}

Expand All @@ -80,13 +80,9 @@ impl TFSetting {
ui.collapsing("Settings", |ui| {
ui.add_space(10.0);
ui.with_layout(egui::Layout::top_down(egui::Align::LEFT), |ui| {
egui::ScrollArea::vertical()
.id_source("settings")
.show(ui, |ui| {
command_helper_render::render(self, ui);
ui.add_space(10.0);
self.render_theme_choose(ui, ctx);
});
command_helper_render::render(self, ui);
ui.add_space(10.0);
self.render_theme_choose(ui, ctx);
});
});
}
Expand Down

0 comments on commit fe72c11

Please sign in to comment.