mirror of https://github.com/YGGverse/Yoda.git
yggverse
1 month ago
9 changed files with 115 additions and 42 deletions
@ -1,31 +1,30 @@
@@ -1,31 +1,30 @@
|
||||
use gtk::{ |
||||
prelude::{EditableExt, EntryExt, WidgetExt}, |
||||
Entry, |
||||
}; |
||||
use gtk::{prelude::WidgetExt, TextView}; |
||||
use std::sync::Arc; |
||||
|
||||
pub struct Widget { |
||||
gobject: Entry, |
||||
gobject: TextView, |
||||
} |
||||
|
||||
impl Widget { |
||||
// Construct
|
||||
pub fn new_arc() -> Arc<Self> { |
||||
let gobject = Entry::builder().editable(true).hexpand(true).build(); |
||||
let gobject = TextView::builder() |
||||
.left_margin(8) |
||||
.pixels_above_lines(8) |
||||
.pixels_below_lines(8) |
||||
.right_margin(8) |
||||
.build(); |
||||
|
||||
Arc::new(Self { gobject }) |
||||
} |
||||
|
||||
// Actions
|
||||
pub fn set(&self, placeholder_text: &str, sensitive: bool) { |
||||
self.gobject.set_text(&""); // reset
|
||||
self.gobject.set_placeholder_text(Some(placeholder_text)); |
||||
// self.gobject.set_sensitive(sensitive);
|
||||
pub fn grab_focus(&self) { |
||||
self.gobject.grab_focus(); |
||||
} |
||||
|
||||
// Getters
|
||||
pub fn gobject(&self) -> &Entry { |
||||
pub fn gobject(&self) -> &TextView { |
||||
&self.gobject |
||||
} |
||||
} |
||||
|
@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
|
||||
mod widget; |
||||
|
||||
use widget::Widget; |
||||
|
||||
use gtk::Label; |
||||
use std::sync::Arc; |
||||
|
||||
pub struct Title { |
||||
widget: Arc<Widget>, |
||||
} |
||||
|
||||
impl Title { |
||||
// Construct
|
||||
pub fn new_arc() -> Arc<Self> { |
||||
// Init widget
|
||||
let widget = Widget::new_arc(); |
||||
|
||||
// Result
|
||||
Arc::new(Self { widget }) |
||||
} |
||||
|
||||
// Actions
|
||||
pub fn set(&self, text: Option<&str>) { |
||||
self.widget.set(text); |
||||
} |
||||
|
||||
// Getters
|
||||
pub fn gobject(&self) -> &Label { |
||||
&self.widget.gobject() |
||||
} |
||||
} |
@ -0,0 +1,38 @@
@@ -0,0 +1,38 @@
|
||||
use gtk::{prelude::WidgetExt, Align, Label}; |
||||
use std::sync::Arc; |
||||
|
||||
pub struct Widget { |
||||
gobject: Label, |
||||
} |
||||
|
||||
impl Widget { |
||||
// Construct
|
||||
pub fn new_arc() -> Arc<Self> { |
||||
let gobject = Label::builder() |
||||
.halign(Align::Start) |
||||
.margin_end(8) |
||||
.margin_start(8) |
||||
.visible(false) |
||||
.build(); |
||||
|
||||
Arc::new(Self { gobject }) |
||||
} |
||||
|
||||
// Actions
|
||||
pub fn set(&self, text: Option<&str>) { |
||||
match text { |
||||
Some(value) => { |
||||
self.gobject.set_label(value); |
||||
self.gobject.set_visible(!value.is_empty()); |
||||
} |
||||
None => { |
||||
self.gobject.set_visible(false); |
||||
} |
||||
} |
||||
} |
||||
|
||||
// Getters
|
||||
pub fn gobject(&self) -> &Label { |
||||
&self.gobject |
||||
} |
||||
} |
Loading…
Reference in new issue