complete widget submodule refactory

This commit is contained in:
yggverse 2024-09-22 22:23:44 +03:00
parent e45b7f0a4a
commit 1e42a75f2e
29 changed files with 585 additions and 145 deletions

View file

@ -1,16 +1,24 @@
mod pin;
mod title;
mod widget;
use gtk::prelude::BoxExt;
use gtk::Box;
pub fn new() -> Box {
let label = Box::builder()
.orientation(gtk::Orientation::Horizontal)
.build();
label.append(&pin::new(false));
label.append(&title::new());
label
pub struct Label {
widget: widget::Label,
}
impl Label {
// Construct
pub fn new() -> Label {
Self {
widget: widget::Label::new(
pin::Pin::new().widget().gtk(),
title::Title::new().widget().gtk(),
),
}
}
// Getters
pub fn widget(&self) -> &widget::Label {
&self.widget
}
}

View file

@ -1,8 +1,19 @@
use gtk::Image;
mod widget;
pub fn new(visible: bool) -> Image {
Image::builder()
.icon_name("view-pin-symbolic")
.visible(visible)
.build()
pub struct Pin {
widget: widget::Pin,
}
impl Pin {
// Construct
pub fn new() -> Pin {
Self {
widget: widget::Pin::new(),
}
}
// Getters
pub fn widget(&self) -> &widget::Pin {
&self.widget
}
}

View file

@ -0,0 +1,20 @@
pub struct Pin {
gtk: gtk::Image,
}
impl Pin {
// Construct
pub fn new() -> Pin {
let gtk = gtk::Image::builder()
.icon_name("view-pin-symbolic")
.visible(false) //@TODO
.build();
Self { gtk }
}
// Getters
pub fn gtk(&self) -> &gtk::Image {
&self.gtk
}
}

View file

@ -1,10 +1,19 @@
use gtk::Label;
mod widget;
pub fn new() -> Label {
Label::builder()
.label("New page")
.ellipsize(gtk::pango::EllipsizeMode::End)
.width_chars(16)
.single_line_mode(true)
.build()
pub struct Title {
widget: widget::Title,
}
impl Title {
// Construct
pub fn new() -> Title {
Self {
widget: widget::Title::new(),
}
}
// Getters
pub fn widget(&self) -> &widget::Title {
&self.widget
}
}

View file

@ -0,0 +1,22 @@
pub struct Title {
gtk: gtk::Label,
}
impl Title {
// Construct
pub fn new() -> Title {
let gtk = gtk::Label::builder()
.label("New page")
.ellipsize(gtk::pango::EllipsizeMode::End)
.width_chars(16)
.single_line_mode(true)
.build();
Self { gtk }
}
// Getters
pub fn gtk(&self) -> &gtk::Label {
&self.gtk
}
}

View file

@ -0,0 +1,24 @@
use gtk::prelude::BoxExt;
pub struct Label {
gtk: gtk::Box,
}
impl Label {
// Construct new object
pub fn new(pin: &gtk::Image, title: &gtk::Label) -> Label {
let gtk = gtk::Box::builder()
.orientation(gtk::Orientation::Horizontal)
.build();
gtk.append(pin);
gtk.append(title);
Self { gtk }
}
// Getters
pub fn gtk(&self) -> &gtk::Box {
&self.gtk
}
}