mirror of
https://github.com/bobwen-dev/hunter
synced 2025-04-12 00:55:41 +02:00
got it somewhat working (hopefully)
This commit is contained in:
parent
8ad1b657ec
commit
8ed80cea89
@ -37,7 +37,7 @@ impl Widget for HBox {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn render_header(&self) -> String {
|
fn render_header(&self) -> String {
|
||||||
self.children[self.main].render_header()
|
self.children[self.active].render_header()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn refresh(&mut self) {
|
fn refresh(&mut self) {
|
||||||
@ -67,6 +67,6 @@ impl Widget for HBox {
|
|||||||
|
|
||||||
|
|
||||||
fn on_event(&mut self, event: Event) {
|
fn on_event(&mut self, event: Event) {
|
||||||
self.children[self.main].on_event(event);
|
self.children[self.active].on_event(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,14 +17,14 @@ pub struct ListView<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<T: 'static> ListView<T> where ListView<T>: Widget {
|
impl<T: 'static> ListView<T> where ListView<T>: Widget {
|
||||||
pub fn new(content: T, dimensions: (u16, u16), position: (u16, u16)) -> Self {
|
pub fn new(content: T) -> Self {
|
||||||
let view = ListView::<T> {
|
let view = ListView::<T> {
|
||||||
content: content,
|
content: content,
|
||||||
selection: 0,
|
selection: 0,
|
||||||
offset: 0,
|
offset: 0,
|
||||||
buffer: Vec::new(),
|
buffer: Vec::new(),
|
||||||
dimensions: dimensions,
|
dimensions: (1,1),
|
||||||
position: position
|
position: (1,1)
|
||||||
};
|
};
|
||||||
view
|
view
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,17 @@ pub trait Widget {
|
|||||||
self.show_status(&format!("Stop the nasty stuff!! {:?} does nothing!", event));
|
self.show_status(&format!("Stop the nasty stuff!! {:?} does nothing!", event));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_header_drawlist(&mut self) -> String {
|
||||||
|
format!(
|
||||||
|
"{}{}{}{:xsize$}",
|
||||||
|
crate::term::goto_xy(1,1),
|
||||||
|
crate::term::header_color(),
|
||||||
|
self.render_header(),
|
||||||
|
" ",
|
||||||
|
xsize = crate::term::xsize()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
//fn get_window(&self) -> Window<Widget>;
|
//fn get_window(&self) -> Window<Widget>;
|
||||||
//fn get_window_mut(&mut self) -> &mut Window<dyn Widget>;
|
//fn get_window_mut(&mut self) -> &mut Window<dyn Widget>;
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn draw(&mut self) {
|
pub fn draw(&mut self) {
|
||||||
let output = self.widget.get_drawlist();
|
let output = self.widget.get_drawlist() + &self.widget.get_header_drawlist();
|
||||||
self.screen.write(output.as_ref()).unwrap();
|
self.screen.write(output.as_ref()).unwrap();
|
||||||
|
|
||||||
self.screen.flush().unwrap();
|
self.screen.flush().unwrap();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user