mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-29 20:44:25 +00:00
move close button to the parent level
This commit is contained in:
parent
0d0eba83b9
commit
20e8d8892b
@ -1,3 +1,4 @@
|
|||||||
|
mod close;
|
||||||
mod form;
|
mod form;
|
||||||
mod placeholder;
|
mod placeholder;
|
||||||
mod subject;
|
mod subject;
|
||||||
@ -28,10 +29,11 @@ impl Search {
|
|||||||
let subject = Rc::new(RefCell::new(None));
|
let subject = Rc::new(RefCell::new(None));
|
||||||
let form = Rc::new(Form::new(&subject));
|
let form = Rc::new(Form::new(&subject));
|
||||||
let placeholder = Rc::new(Placeholder::new());
|
let placeholder = Rc::new(Placeholder::new());
|
||||||
|
let close = close::new();
|
||||||
|
|
||||||
// Init main container
|
// Init main container
|
||||||
let g_box = Box::builder()
|
let g_box = Box::builder()
|
||||||
.orientation(Orientation::Vertical)
|
.orientation(Orientation::Horizontal)
|
||||||
.valign(Align::Center)
|
.valign(Align::Center)
|
||||||
.vexpand(false)
|
.vexpand(false)
|
||||||
.visible(false)
|
.visible(false)
|
||||||
@ -39,12 +41,16 @@ impl Search {
|
|||||||
|
|
||||||
g_box.append(&form.g_box);
|
g_box.append(&form.g_box);
|
||||||
g_box.append(&placeholder.label);
|
g_box.append(&placeholder.label);
|
||||||
|
g_box.append(&close);
|
||||||
|
|
||||||
// Connect events
|
// Connect events
|
||||||
|
close.connect_clicked({
|
||||||
form.close.connect_clicked({
|
let form = form.clone();
|
||||||
let g_box = g_box.clone();
|
let g_box = g_box.clone();
|
||||||
move |_| g_box.set_visible(false)
|
move |_| {
|
||||||
|
g_box.set_visible(false);
|
||||||
|
form.clean()
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Done
|
// Done
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
mod close;
|
|
||||||
mod input;
|
mod input;
|
||||||
mod match_case;
|
mod match_case;
|
||||||
mod navigation;
|
mod navigation;
|
||||||
@ -11,12 +10,11 @@ use gtk::{
|
|||||||
prelude::{
|
prelude::{
|
||||||
BoxExt, ButtonExt, CheckButtonExt, EditableExt, TextBufferExt, TextViewExt, WidgetExt,
|
BoxExt, ButtonExt, CheckButtonExt, EditableExt, TextBufferExt, TextViewExt, WidgetExt,
|
||||||
},
|
},
|
||||||
Align, Box, Button, Orientation, TextIter, TextSearchFlags,
|
Align, Box, Orientation, TextIter, TextSearchFlags,
|
||||||
};
|
};
|
||||||
use std::{cell::RefCell, rc::Rc};
|
use std::{cell::RefCell, rc::Rc};
|
||||||
|
|
||||||
pub struct Form {
|
pub struct Form {
|
||||||
pub close: Button,
|
|
||||||
pub input: Rc<Input>,
|
pub input: Rc<Input>,
|
||||||
pub g_box: Box,
|
pub g_box: Box,
|
||||||
}
|
}
|
||||||
@ -27,7 +25,6 @@ impl Form {
|
|||||||
/// Create new `Self`
|
/// Create new `Self`
|
||||||
pub fn new(subject: &Rc<RefCell<Option<Subject>>>) -> Self {
|
pub fn new(subject: &Rc<RefCell<Option<Subject>>>) -> Self {
|
||||||
// Init components
|
// Init components
|
||||||
let close = close::new();
|
|
||||||
let input = Rc::new(Input::new());
|
let input = Rc::new(Input::new());
|
||||||
let match_case = match_case::new();
|
let match_case = match_case::new();
|
||||||
let navigation = Rc::new(Navigation::new());
|
let navigation = Rc::new(Navigation::new());
|
||||||
@ -43,14 +40,8 @@ impl Form {
|
|||||||
g_box.append(&input.entry);
|
g_box.append(&input.entry);
|
||||||
g_box.append(&navigation.g_box);
|
g_box.append(&navigation.g_box);
|
||||||
g_box.append(&match_case);
|
g_box.append(&match_case);
|
||||||
g_box.append(&close);
|
|
||||||
|
|
||||||
// Connect events
|
// Connect events
|
||||||
close.connect_clicked({
|
|
||||||
let input = input.clone();
|
|
||||||
move |_| input.clean()
|
|
||||||
});
|
|
||||||
|
|
||||||
input.entry.connect_changed({
|
input.entry.connect_changed({
|
||||||
let input = input.clone();
|
let input = input.clone();
|
||||||
let match_case = match_case.clone();
|
let match_case = match_case.clone();
|
||||||
@ -113,15 +104,15 @@ impl Form {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Done
|
// Done
|
||||||
Self {
|
Self { g_box, input }
|
||||||
close,
|
|
||||||
g_box,
|
|
||||||
input,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
|
|
||||||
|
pub fn clean(&self) {
|
||||||
|
self.input.clean();
|
||||||
|
}
|
||||||
|
|
||||||
pub fn show(&self) {
|
pub fn show(&self) {
|
||||||
self.g_box.set_visible(true);
|
self.g_box.set_visible(true);
|
||||||
self.input.entry.grab_focus();
|
self.input.entry.grab_focus();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user