Skip to content
Snippets Groups Projects
Commit 4f8e64fc authored by Finn Bear's avatar Finn Bear
Browse files

Fade in title.

parent 326ac405
No related branches found
No related tags found
No related merge requests found
...@@ -47,6 +47,9 @@ pub fn set_style_alpha_in_place(style: &mut Style, factor: f32) { ...@@ -47,6 +47,9 @@ pub fn set_style_alpha_in_place(style: &mut Style, factor: f32) {
] { ] {
set_widget_alpha_in_place(widget, factor); 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.hyperlink_color, factor);
set_alpha_in_place(&mut style.visuals.faint_bg_color, factor); set_alpha_in_place(&mut style.visuals.faint_bg_color, factor);
set_alpha_in_place(&mut style.visuals.extreme_bg_color, factor); set_alpha_in_place(&mut style.visuals.extreme_bg_color, factor);
......
use crate::egui::Align2; use crate::egui::{Align2, Context};
use crate::fade_in::fade_in;
use crate::slide::Slide; use crate::slide::Slide;
use crate::{ctx_img, Margin}; use crate::{ctx_img, Margin};
use eframe::egui::{Frame, TextureHandle, Ui, Vec2, Window}; use eframe::egui::{Frame, TextureHandle, Ui, Vec2, Window};
...@@ -7,9 +8,32 @@ use eframe::egui::{Frame, TextureHandle, Ui, Vec2, Window}; ...@@ -7,9 +8,32 @@ use eframe::egui::{Frame, TextureHandle, Ui, Vec2, Window};
#[derive(Default)] #[derive(Default)]
pub struct Title { pub struct Title {
examples: Vec<TextureHandle>, 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 { 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) { fn show(&mut self, ui: &mut Ui) {
if self.examples.is_empty() { if self.examples.is_empty() {
// For now, these images are somewhat like placeholders. // For now, these images are somewhat like placeholders.
...@@ -33,17 +57,29 @@ impl Slide for Title { ...@@ -33,17 +57,29 @@ impl Slide for Title {
}); });
} }
Window::new("title") if let &TitleState::Title { fade_start } = &self.state {
.title_bar(false) fade_in(ui, fade_start, |ui| {
.resizable(false) ui.scope(|ui| {
.anchor(Align2::CENTER_CENTER, Vec2::ZERO) // Extra large margins for title window.
.default_width(400.0) ui.style_mut().spacing.window_margin = Margin::same(20.0);
.frame(Frame::window(ui.style()))
.show(ui.ctx(), |ui| { Window::new("title")
ui.vertical_centered(|ui| { .title_bar(false)
ui.heading("Generative Art"); .resizable(false)
ui.label("By: Finn, Matthew, Nathan, Owen"); .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");
});
});
});
}); });
}); });
}
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment