Compare commits

..

2 Commits

Author SHA1 Message Date
Savanni D'Gerinel 8e63e5210c Add full-screen support 2024-11-03 13:30:03 -05:00
Savanni D'Gerinel db34e69cdf Make the text larger 2024-11-03 13:12:48 -05:00
1 changed files with 18 additions and 5 deletions

View File

@ -128,12 +128,12 @@ impl Animation for CrossFade {
let frames = (now - self.start_time).as_secs_f64() * FPS as f64; let frames = (now - self.start_time).as_secs_f64() * FPS as f64;
let alpha = alpha_rate * frames as f64; let alpha = alpha_rate * frames as f64;
let text_display = Text::new(self.old_text.clone(), context, 32., width); let text_display = Text::new(self.old_text.clone(), context, 64., width);
let _ = context.move_to(0., text_display.extents().height()); let _ = context.move_to(0., text_display.extents().height());
let _ = context.set_source_rgba(PURPLE.0, PURPLE.1, PURPLE.2, 1. - alpha); let _ = context.set_source_rgba(PURPLE.0, PURPLE.1, PURPLE.2, 1. - alpha);
text_display.draw(); text_display.draw();
let text_display = Text::new(self.new_text.clone(), context, 32., width); let text_display = Text::new(self.new_text.clone(), context, 64., width);
let _ = context.move_to(0., text_display.extents().height()); let _ = context.move_to(0., text_display.extents().height());
let _ = context.set_source_rgba(PURPLE.0, PURPLE.1, PURPLE.2, alpha); let _ = context.set_source_rgba(PURPLE.0, PURPLE.1, PURPLE.2, alpha);
text_display.draw(); text_display.draw();
@ -367,20 +367,29 @@ fn main() {
}); });
app.connect_activate(move |app| { app.connect_activate(move |app| {
let window = gtk::ApplicationWindow::new(app);
let screen = CyberScreen::new(script.read().unwrap().clone()); let screen = CyberScreen::new(script.read().unwrap().clone());
let events = EventControllerKey::new(); let events = EventControllerKey::new();
events.connect_key_released({ events.connect_key_released({
let app = app.clone();
let window = window.clone();
let screen = screen.clone(); let screen = screen.clone();
move |_, key, _, _| { move |_, key, _, _| {
if key.name() == Some(GString::from("Right")) { let name = key
screen.next_page(); .name()
.map(|s| s.as_str().to_owned())
.unwrap_or("".to_owned());
match name.as_ref() {
"Right" => screen.next_page(),
"q" => app.quit(),
"Escape" => window.unfullscreen(),
_ => {}
} }
} }
}); });
let window = gtk::ApplicationWindow::new(app);
window.add_controller(events); window.add_controller(events);
window.set_child(Some(&screen)); window.set_child(Some(&screen));
@ -388,6 +397,10 @@ fn main() {
window.set_height_request(600); window.set_height_request(600);
window.present(); window.present();
window.connect_maximized_notify(|window| {
window.fullscreen();
});
let _ = glib::spawn_future_local({ let _ = glib::spawn_future_local({
let screen = screen.clone(); let screen = screen.clone();
async move { async move {