refactor ui layout
This commit is contained in:
parent
2b8e462c9d
commit
a1ab52b311
5 changed files with 44 additions and 35 deletions
|
|
@ -13,11 +13,11 @@ pub struct DockItem {
|
|||
impl ObjectSubclass for DockItem {
|
||||
const NAME: &'static str = "DockItem";
|
||||
type Type = super::DockItem;
|
||||
type ParentType = gtk4::Box;
|
||||
type ParentType = gtk4::Button;
|
||||
}
|
||||
|
||||
impl ObjectImpl for DockItem {}
|
||||
|
||||
impl WidgetImpl for DockItem {}
|
||||
|
||||
impl BoxImpl for DockItem {}
|
||||
impl ButtonImpl for DockItem {}
|
||||
|
|
|
|||
|
|
@ -5,8 +5,11 @@ use gtk4::glib;
|
|||
use gtk4::prelude::*;
|
||||
use gtk4::subclass::prelude::*;
|
||||
use gtk4::Align;
|
||||
use gtk4::AspectFrame;
|
||||
use gtk4::Box;
|
||||
use gtk4::Image;
|
||||
use gtk4::Label;
|
||||
use gtk4::Orientation;
|
||||
|
||||
use crate::dock_object::DockObject;
|
||||
use crate::utils::BoxedWindowList;
|
||||
|
|
@ -15,9 +18,8 @@ mod imp;
|
|||
|
||||
glib::wrapper! {
|
||||
pub struct DockItem(ObjectSubclass<imp::DockItem>)
|
||||
@extends gtk4::Widget, gtk4::Box,
|
||||
@implements gtk4::Accessible, gtk4::Buildable, gtk4::ConstraintTarget, gtk4::Orientable;
|
||||
|
||||
@extends gtk4::Button, gtk4::Widget,
|
||||
@implements gtk4::Accessible, gtk4::Actionable, gtk4::Buildable, gtk4::ConstraintTarget;
|
||||
}
|
||||
|
||||
impl Default for DockItem {
|
||||
|
|
@ -29,21 +31,24 @@ impl Default for DockItem {
|
|||
impl DockItem {
|
||||
pub fn new() -> Self {
|
||||
let self_: DockItem = glib::Object::new(&[]).expect("Failed to create DockItem");
|
||||
self_.set_orientation(gtk4::Orientation::Vertical);
|
||||
|
||||
let item_box = Box::new(Orientation::Vertical, 0);
|
||||
self_.set_child(Some(&item_box));
|
||||
|
||||
let image = cascade! {
|
||||
Image::new();
|
||||
..set_margin_start(4);
|
||||
..set_margin_end(4);
|
||||
..set_margin_top(4);
|
||||
..set_pixel_size(48);
|
||||
..set_hexpand(true);
|
||||
..set_halign(Align::Center);
|
||||
..set_pixel_size(64);
|
||||
};
|
||||
let dots = cascade! {
|
||||
Label::new(Some(""));
|
||||
..set_hexpand(true);
|
||||
..set_halign(Align::Center);
|
||||
};
|
||||
self_.append(&image);
|
||||
self_.append(&dots);
|
||||
item_box.append(&image);
|
||||
item_box.append(&dots);
|
||||
|
||||
let imp = imp::DockItem::from_instance(&self_);
|
||||
imp.image.replace(image);
|
||||
imp.dots.replace(dots);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue