Newer
Older
use crate::slide::s1_title::Title;
use crate::slide::s2_introduction::Introduction;
use crate::slide::s3_complexity::Complexity;
use crate::slide::s4_automata::Automata;
use crate::slide::s5_fractals::Fractals;
use crate::slide::s7_mosaic::Mosaic;
use crate::slide::s8_conclusion::Conclusion;
use eframe::egui::style::Margin;
use eframe::egui::{Key, Style, TextStyle, Visuals};
always_on_top: false,
maximized: false,
decorated: true,
drag_and_drop_support: false,
icon_data: None,
initial_window_pos: None,
initial_window_size: Some(size),
min_window_size: None,
transparent: false,
};
eframe::run_native(Box::new(app), native_options);
}
/// When we started fading in the current slide, in seconds (with respect to `ctx.input().time`).
/// Creates all the slides from default values. This will reset any and all animations and
/// transitions built into the slides.
///
/// This is also how the chronology of the slideshow is determined.
fn create_slides() -> Vec<Box<dyn Slide>> {
vec![
Box::new(Title::default()) as Box<dyn Slide>,
Box::new(Introduction::default()),
Box::new(Complexity::default()),
Box::new(Automata::default()),
Box::new(Fractals::default()),
Box::new(Mosaic::default()),
Box::new(Conclusion::default()),
/// The title of the window, which is mostly irrelevant.
fn setup(&mut self, ctx: &egui::Context, _frame: &Frame, _storage: Option<&dyn Storage>) {
let mut style = Style::default();
style.animation_time = 0.5;
style.visuals = Visuals::light();
{
let header_style = style.text_styles.get_mut(&TextStyle::Heading).unwrap();
header_style.size = 48.0;
}
{
let body_style = style.text_styles.get_mut(&TextStyle::Body).unwrap();
body_style.size = 30.0;
}
{
let small_style = style.text_styles.get_mut(&TextStyle::Small).unwrap();
small_style.size = 22.0;
}
// TODO(finnb): This doesn't work. May have to fork syntax coloring code to fix it.
{
let monospaced_style = style.text_styles.get_mut(&TextStyle::Monospace).unwrap();
monospaced_style.size = 22.0;
}
/// Put your widgets into a `SidePanel`, `TopPanel`, `CentralPanel`, `Window` or `Area`.
fn update(&mut self, ctx: &egui::Context, _frame: &epi::Frame) {
// For inspiration and more examples, go to https://emilk.github.io/egui
/*
egui::TopBottomPanel::top("top_panel").show(ctx, |ui| {
egui::menu::bar(ui, |ui| {
ui.menu_button("File", |ui| {
if ui.button("Quit").clicked() {
frame.quit();
}
});
});
});
*/
// Go forward one slide (don't wait for intra-slide transitions).
//
// This will wrap around to the beginning.
let force_advance =
ctx.input().key_pressed(Key::ArrowRight) || ctx.input().key_pressed(Key::D);
// Play the next intra-slide transition or, if there isn't one, then go forward one slide.
//
// This will wrap around to the beginning.
let advance = force_advance || ctx.input().key_pressed(Key::Space);
// Go backward one slide (don't wait for intra-slide transitions).
//
// This will wrap around to the end.
let retreat = ctx.input().key_pressed(Key::ArrowLeft) || ctx.input().key_pressed(Key::A);
if advance || retreat {
self.slide_index = if advance {
if force_advance || self.slides[self.slide_index].transition(ctx) {
let new = (self.slide_index + 1) % self.slides.len();
if new == 0 {
// We wrapped around to the beginning, so create slides to reset transitions.
ctx.request_repaint();
new
} else {
self.slide_index
}
} else {
ctx.request_repaint();
self.slide_index
.checked_sub(1)
.unwrap_or(self.slides.len() - 1)
self.slides[self.slide_index].show(ui);
});