Get the scrollbar to expand with the window
This commit is contained in:
parent
e3f4ca246d
commit
a584fb4de3
|
@ -13,8 +13,8 @@ fn handle_response(api: CoreApi, window: gtk::ApplicationWindow, message: CoreRe
|
||||||
CoreResponse::HomeView(view) => perftrace("HomeView", || {
|
CoreResponse::HomeView(view) => perftrace("HomeView", || {
|
||||||
let api = api.clone();
|
let api = api.clone();
|
||||||
|
|
||||||
let new_game = Home::new(api, view);
|
let home = Home::new(api, view);
|
||||||
window.set_child(Some(&new_game));
|
window.set_child(Some(&home));
|
||||||
}),
|
}),
|
||||||
CoreResponse::PlayingFieldView(view) => perftrace("PlayingFieldView", || {
|
CoreResponse::PlayingFieldView(view) => perftrace("PlayingFieldView", || {
|
||||||
let api = api.clone();
|
let api = api.clone();
|
||||||
|
|
|
@ -1,14 +1,11 @@
|
||||||
use crate::{ui::GamePreview, CoreApi};
|
use crate::CoreApi;
|
||||||
use glib::{Object, Properties};
|
use glib::Object;
|
||||||
use gtk::{glib, prelude::*, subclass::prelude::*};
|
use gtk::{glib, prelude::*, subclass::prelude::*};
|
||||||
use kifu_core::{
|
use kifu_core::{
|
||||||
ui::{GamePreviewElement, HomeView, PlayerElement},
|
ui::{HomeView, PlayerElement},
|
||||||
CoreRequest, CreateGameRequest, HotseatPlayerRequest, PlayerInfoRequest,
|
CoreRequest, CreateGameRequest, HotseatPlayerRequest, PlayerInfoRequest,
|
||||||
};
|
};
|
||||||
use std::{
|
use std::{cell::RefCell, rc::Rc};
|
||||||
cell::{Cell, RefCell},
|
|
||||||
rc::Rc,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::GameDatabase;
|
use super::GameDatabase;
|
||||||
|
|
||||||
|
@ -105,39 +102,49 @@ impl Default for HomePrivate {
|
||||||
impl ObjectSubclass for HomePrivate {
|
impl ObjectSubclass for HomePrivate {
|
||||||
const NAME: &'static str = "Home";
|
const NAME: &'static str = "Home";
|
||||||
type Type = Home;
|
type Type = Home;
|
||||||
type ParentType = gtk::Grid;
|
type ParentType = gtk::Box;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ObjectImpl for HomePrivate {}
|
impl ObjectImpl for HomePrivate {}
|
||||||
impl WidgetImpl for HomePrivate {}
|
impl WidgetImpl for HomePrivate {}
|
||||||
impl GridImpl for HomePrivate {}
|
impl BoxImpl for HomePrivate {}
|
||||||
|
|
||||||
glib::wrapper! {
|
glib::wrapper! {
|
||||||
pub struct Home(ObjectSubclass<HomePrivate>) @extends gtk::Grid, gtk::Widget;
|
pub struct Home(ObjectSubclass<HomePrivate>) @extends gtk::Box, gtk::Widget, @implements gtk::Orientable;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Home {
|
impl Home {
|
||||||
pub fn new(api: CoreApi, view: HomeView) -> Home {
|
pub fn new(api: CoreApi, view: HomeView) -> Home {
|
||||||
let s: Self = Object::builder().build();
|
let s: Self = Object::builder().build();
|
||||||
|
s.set_spacing(4);
|
||||||
|
s.set_homogeneous(false);
|
||||||
|
s.set_orientation(gtk::Orientation::Vertical);
|
||||||
|
|
||||||
|
let players = gtk::Box::builder()
|
||||||
|
.spacing(4)
|
||||||
|
.orientation(gtk::Orientation::Horizontal)
|
||||||
|
.build();
|
||||||
|
s.append(&players);
|
||||||
|
|
||||||
let black_player = PlayerDataEntry::new(view.black_player);
|
let black_player = PlayerDataEntry::new(view.black_player);
|
||||||
s.attach(&black_player, 1, 1, 1, 1);
|
players.append(&black_player);
|
||||||
*s.imp().black_player.borrow_mut() = Some(black_player.clone());
|
*s.imp().black_player.borrow_mut() = Some(black_player.clone());
|
||||||
|
|
||||||
let white_player = PlayerDataEntry::new(view.white_player);
|
let white_player = PlayerDataEntry::new(view.white_player);
|
||||||
s.attach(&white_player, 2, 1, 1, 1);
|
players.append(&white_player);
|
||||||
*s.imp().white_player.borrow_mut() = Some(white_player.clone());
|
*s.imp().white_player.borrow_mut() = Some(white_player.clone());
|
||||||
|
|
||||||
let new_game_button = gtk::Button::builder().label(&view.start_game.label).build();
|
let new_game_button = gtk::Button::builder().label(&view.start_game.label).build();
|
||||||
s.attach(&new_game_button, 2, 2, 1, 1);
|
s.append(&new_game_button);
|
||||||
|
|
||||||
let library = GameDatabase::new();
|
let library = GameDatabase::new();
|
||||||
let library_view = gtk::ScrolledWindow::builder()
|
let library_view = gtk::ScrolledWindow::builder()
|
||||||
.hscrollbar_policy(gtk::PolicyType::Never)
|
.hscrollbar_policy(gtk::PolicyType::Never)
|
||||||
.min_content_width(360)
|
.min_content_width(360)
|
||||||
|
.vexpand(true)
|
||||||
|
.hexpand(true)
|
||||||
.child(&library)
|
.child(&library)
|
||||||
.build();
|
.build();
|
||||||
s.attach(&library_view, 0, 3, 4, 2);
|
s.append(&library_view);
|
||||||
|
|
||||||
library.set_games(view.games);
|
library.set_games(view.games);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue