mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 00:55:28 +00:00
reorganize widget modules
This commit is contained in:
parent
b9b226cc54
commit
4903968309
47 changed files with 352 additions and 786 deletions
|
|
@ -1,46 +1,47 @@
|
|||
mod pin;
|
||||
mod title;
|
||||
mod widget;
|
||||
|
||||
use std::sync::Arc;
|
||||
use gtk::prelude::{BoxExt, WidgetExt};
|
||||
use gtk::{Box, Orientation};
|
||||
use pin::Pin;
|
||||
use title::Title;
|
||||
|
||||
pub struct Label {
|
||||
// Components
|
||||
pin: Arc<pin::Pin>,
|
||||
title: Arc<title::Title>,
|
||||
pin: Pin,
|
||||
title: Title,
|
||||
|
||||
// Extras
|
||||
is_pinned: bool,
|
||||
widget: widget::Label,
|
||||
// GTK
|
||||
widget: Box,
|
||||
}
|
||||
|
||||
impl Label {
|
||||
// Construct
|
||||
pub fn new(is_pinned: bool) -> Arc<Label> {
|
||||
pub fn new(is_pinned: bool) -> Label {
|
||||
// Components
|
||||
let pin = pin::Pin::new(is_pinned);
|
||||
let title = title::Title::new();
|
||||
let pin = Pin::new(is_pinned);
|
||||
let title = Title::new();
|
||||
|
||||
// Extras
|
||||
let widget = widget::Label::new(pin.widget().image(), title.widget().label());
|
||||
// GTK
|
||||
let widget = Box::builder().orientation(Orientation::Horizontal).build();
|
||||
|
||||
widget.append(pin.widget());
|
||||
widget.append(title.widget());
|
||||
|
||||
// Result
|
||||
Arc::new(Self {
|
||||
pin,
|
||||
title,
|
||||
is_pinned,
|
||||
widget,
|
||||
})
|
||||
Self { pin, title, widget }
|
||||
}
|
||||
|
||||
// Actions
|
||||
pub fn pin(&mut self) {
|
||||
self.is_pinned = !self.is_pinned; // toggle
|
||||
// @TODO
|
||||
pub fn pin(&self) -> bool {
|
||||
self.pin
|
||||
.widget()
|
||||
.set_visible(!self.pin.widget().is_visible());
|
||||
self.pin.widget().is_visible()
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn widget(&self) -> &widget::Label {
|
||||
pub fn widget(&self) -> &Box {
|
||||
&self.widget
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue