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 {
|
||||
self.children[self.main].render_header()
|
||||
self.children[self.active].render_header()
|
||||
}
|
||||
|
||||
fn refresh(&mut self) {
|
||||
@ -67,6 +67,6 @@ impl Widget for HBox {
|
||||
|
||||
|
||||
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 {
|
||||
pub fn new(content: T, dimensions: (u16, u16), position: (u16, u16)) -> Self {
|
||||
pub fn new(content: T) -> Self {
|
||||
let view = ListView::<T> {
|
||||
content: content,
|
||||
selection: 0,
|
||||
offset: 0,
|
||||
buffer: Vec::new(),
|
||||
dimensions: dimensions,
|
||||
position: position
|
||||
dimensions: (1,1),
|
||||
position: (1,1)
|
||||
};
|
||||
view
|
||||
}
|
||||
|
@ -50,6 +50,17 @@ pub trait Widget {
|
||||
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_mut(&mut self) -> &mut Window<dyn Widget>;
|
||||
|
||||
|
@ -42,7 +42,7 @@ where
|
||||
}
|
||||
|
||||
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.flush().unwrap();
|
||||
|
Loading…
x
Reference in New Issue
Block a user