Create a cyberpunk-style splash screen with a title and a countdown #39

Merged
savanni merged 11 commits from cyberpunk-display into main 2023-04-13 23:14:29 +00:00
1 changed files with 19 additions and 3 deletions
Showing only changes of commit 8d7574da16 - Show all commits

View File

@ -2,8 +2,8 @@ use cairo::{
Context, FontSlant, FontWeight, Format, ImageSurface, LineCap, LinearGradient, Pattern,
TextExtents,
};
use glib::Object;
use gtk::{prelude::*, subclass::prelude::*};
use glib::{GString, Object};
use gtk::{gdk::Key, prelude::*, subclass::prelude::*, EventControllerKey};
use std::{
cell::RefCell,
rc::Rc,
@ -514,12 +514,28 @@ fn main() {
let splash = Splash::new("GTK Kifu".to_owned(), countdown.clone());
window.set_child(Some(&splash));
// window.fullscreen();
window.connect_maximized_notify(|window| {
window.fullscreen();
});
let keyboard_events = EventControllerKey::new();
keyboard_events.connect_key_released({
let window = window.clone();
move |_, key, _, _| {
let name = key
.name()
.map(|s| s.as_str().to_owned())
.unwrap_or("".to_owned());
match name.as_ref() {
"Escape" => window.unfullscreen(),
"space" => println!("space pressed"),
_ => {}
}
}
});
window.add_controller(keyboard_events);
gtk_rx.attach(None, move |event| {
match event {
Event::Frames(frames) => splash.tick(frames),