monorepo/otg/kifu-gtk-screenplay/screenplay.rs

53 lines
1.7 KiB
Rust
Raw Permalink Normal View History

use gtk::{prelude::*, subclass::prelude::*};
2024-03-22 03:48:48 +00:00
use otg_core::{
2023-03-24 13:59:04 +00:00
ui::{ChatElement, PlayerCardElement, PlayingFieldView},
Color,
};
2024-03-22 03:48:48 +00:00
use otg_gtk::ui::{playing_field_view, Chat, PlayerCard, PlayingField};
use screenplay::{Screen, Screenplay};
fn main() {
2024-03-22 03:48:48 +00:00
gio::resources_register_include!("com.luminescent-dreams.otg-gtk.gresource")
2023-03-31 02:25:11 +00:00
.expect("Failed to register resources");
let app = gtk::Application::builder()
2024-03-22 03:48:48 +00:00
.application_id("com.luminescent-dreams.otg-gtk.screenplay")
.build();
app.connect_activate(|app| {
let screens = vec![
Screen {
title: "PlayerCard".to_owned(),
widget: PlayerCard::new(PlayerCardElement {
color: Color::Black,
name: "Opal".to_owned(),
rank: "10 kyu".to_owned(),
clock: "25:00".to_owned(),
})
.upcast::<gtk::Widget>(),
adjustments: vec![],
},
Screen {
title: "ChatArea".to_owned(),
widget: Chat::new(ChatElement {
messages: vec![
"message 1".to_owned(),
"message 2".to_owned(),
"message 3".to_owned(),
],
})
.upcast::<gtk::Widget>(),
adjustments: vec![],
},
2023-03-24 13:59:04 +00:00
Screen {
title: "PlayingField".to_owned(),
widget: PlayingField::new(playing_field_view()).upcast::<gtk::Widget>(),
2023-03-24 13:59:04 +00:00
adjustments: vec![],
},
];
2023-03-24 13:59:04 +00:00
Screenplay::new(&app, screens).unwrap();
});
app.run();
}