diff --git a/src/color.rs b/src/color.rs index 248cc49906dfbf36268dcff49f8d0b412dc76e1d..001f71b22873450560c000429a8cfae9e4111a89 100644 --- a/src/color.rs +++ b/src/color.rs @@ -47,6 +47,9 @@ pub fn set_style_alpha_in_place(style: &mut Style, factor: f32) { ] { set_widget_alpha_in_place(widget, factor); } + if let Some(override_text_color) = style.visuals.override_text_color.as_mut() { + set_alpha_in_place(override_text_color, factor); + } set_alpha_in_place(&mut style.visuals.hyperlink_color, factor); set_alpha_in_place(&mut style.visuals.faint_bg_color, factor); set_alpha_in_place(&mut style.visuals.extreme_bg_color, factor); diff --git a/src/slide/s1_title.rs b/src/slide/s1_title.rs index 69418a9e168c98667300a893428b73df56ec942d..9e4c09715eb32fee5774ff58069c263459d233d7 100644 --- a/src/slide/s1_title.rs +++ b/src/slide/s1_title.rs @@ -1,4 +1,5 @@ -use crate::egui::Align2; +use crate::egui::{Align2, Context}; +use crate::fade_in::fade_in; use crate::slide::Slide; use crate::{ctx_img, Margin}; use eframe::egui::{Frame, TextureHandle, Ui, Vec2, Window}; @@ -7,9 +8,32 @@ use eframe::egui::{Frame, TextureHandle, Ui, Vec2, Window}; #[derive(Default)] pub struct Title { examples: Vec<TextureHandle>, + state: TitleState, +} + +#[derive(Default)] +enum TitleState { + #[default] + Initial, + Title { + // When we started fading in the title. + fade_start: f64, + }, } impl Slide for Title { + fn transition(&mut self, ctx: &Context) -> bool { + match &self.state { + TitleState::Initial => { + self.state = TitleState::Title { + fade_start: ctx.input().time, + } + } + TitleState::Title { .. } => return true, + } + false + } + fn show(&mut self, ui: &mut Ui) { if self.examples.is_empty() { // For now, these images are somewhat like placeholders. @@ -33,17 +57,29 @@ impl Slide for Title { }); } - Window::new("title") - .title_bar(false) - .resizable(false) - .anchor(Align2::CENTER_CENTER, Vec2::ZERO) - .default_width(400.0) - .frame(Frame::window(ui.style())) - .show(ui.ctx(), |ui| { - ui.vertical_centered(|ui| { - ui.heading("Generative Art"); - ui.label("By: Finn, Matthew, Nathan, Owen"); + if let &TitleState::Title { fade_start } = &self.state { + fade_in(ui, fade_start, |ui| { + ui.scope(|ui| { + // Extra large margins for title window. + ui.style_mut().spacing.window_margin = Margin::same(20.0); + + Window::new("title") + .title_bar(false) + .resizable(false) + .anchor(Align2::CENTER_CENTER, Vec2::ZERO) + .default_width(400.0) + .frame(Frame::window(ui.style())) + .show(ui.ctx(), |ui| { + // Nested fade since fade doesn't propagate through window. + fade_in(ui, fade_start, |ui| { + ui.vertical_centered(|ui| { + ui.heading("Generative Art"); + ui.label("By: Finn, Matthew, Nathan, Owen"); + }); + }); + }); }); }); + } } }