diff options
author | rabite <rabite@posteo.de> | 2019-01-21 21:46:13 +0100 |
---|---|---|
committer | rabite <rabite@posteo.de> | 2019-01-21 21:46:13 +0100 |
commit | 8ed80cea89a11a58497094a73fcdd0e5a3d99c81 (patch) | |
tree | e38514662459768a80412da8cf7c3e06882f9763 /src | |
parent | 8ad1b657ec3d20bab2199b33a22ff9a191dfe58d (diff) |
got it somewhat working (hopefully)
Diffstat (limited to 'src')
-rw-r--r-- | src/hbox.rs | 4 | ||||
-rw-r--r-- | src/listview.rs | 6 | ||||
-rw-r--r-- | src/widget.rs | 11 | ||||
-rw-r--r-- | src/window.rs | 2 |
4 files changed, 17 insertions, 6 deletions
diff --git a/src/hbox.rs b/src/hbox.rs index 9c9c900..538edf5 100644 --- a/src/hbox.rs +++ b/src/hbox.rs @@ -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); } } diff --git a/src/listview.rs b/src/listview.rs index e5f7c77..bb4b701 100644 --- a/src/listview.rs +++ b/src/listview.rs @@ -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 } diff --git a/src/widget.rs b/src/widget.rs index 4e173ed..c9012c9 100644 --- a/src/widget.rs +++ b/src/widget.rs @@ -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>; diff --git a/src/window.rs b/src/window.rs index 2d7ef6c..ec5acbe 100644 --- a/src/window.rs +++ b/src/window.rs @@ -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(); |