Render the playing field #35

Merged
savanni merged 3 commits from feature/kifu-render-playing-area into main 2023-03-25 03:59:22 +00:00
3 changed files with 36 additions and 1 deletions
Showing only changes of commit cbae0f47fc - Show all commits

View File

@ -0,0 +1,30 @@
use glib::Object;
use gtk::{prelude::*, subclass::prelude::*};
#[derive(Default)]
pub struct GobanPrivate;
#[glib::object_subclass]
impl ObjectSubclass for GobanPrivate {
const NAME: &'static str = "Goban";
type Type = Goban;
type ParentType = gtk::DrawingArea;
}
impl ObjectImpl for GobanPrivate {}
impl WidgetImpl for GobanPrivate {}
impl DrawingAreaImpl for GobanPrivate {}
glib::wrapper! {
pub struct Goban(ObjectSubclass<GobanPrivate>) @extends gtk::DrawingArea, gtk::Widget;
}
impl Goban {
pub fn new() -> Self {
let s: Self = Object::builder().build();
s.set_width_request(1024);
s.set_height_request(768);
s
}
}

View File

@ -6,3 +6,6 @@ pub use chat::Chat;
mod playing_field; mod playing_field;
pub use playing_field::{playing_field, PlayingField}; pub use playing_field::{playing_field, PlayingField};
mod goban;
pub use goban::Goban;

View File

@ -1,4 +1,4 @@
use crate::ui::{Chat, PlayerCard}; use crate::ui::{Chat, Goban, PlayerCard};
use glib::Object; use glib::Object;
use gtk::{prelude::*, subclass::prelude::*}; use gtk::{prelude::*, subclass::prelude::*};
use kifu_core::{ use kifu_core::{
@ -53,10 +53,12 @@ impl PlayingField {
pub fn new(view: PlayingFieldView) -> PlayingField { pub fn new(view: PlayingFieldView) -> PlayingField {
let s: Self = Object::builder().build(); let s: Self = Object::builder().build();
let goban = Goban::new();
let player_card_white = PlayerCard::new(view.player_card_white); let player_card_white = PlayerCard::new(view.player_card_white);
let player_card_black = PlayerCard::new(view.player_card_black); let player_card_black = PlayerCard::new(view.player_card_black);
let chat = Chat::new(view.chat); let chat = Chat::new(view.chat);
s.attach(&goban, 1, 1, 1, 2);
s.attach(&player_card_black, 2, 1, 1, 1); s.attach(&player_card_black, 2, 1, 1, 1);
s.attach(&player_card_white, 3, 1, 1, 1); s.attach(&player_card_white, 3, 1, 1, 1);
s.attach(&chat, 2, 2, 2, 1); s.attach(&chat, 2, 2, 2, 1);