diff options
author | rabite <rabite@posteo.de> | 2019-01-22 21:05:06 +0100 |
---|---|---|
committer | rabite <rabite@posteo.de> | 2019-01-22 21:05:06 +0100 |
commit | ab9baf17f110622391d143122195e2b82acc7d10 (patch) | |
tree | cb3fc15e8a51b78b012bb78f9bd9693b1618abc9 /src/hbox.rs | |
parent | 00c2eb8e461d135b33756da79009df3d7c1bc8ff (diff) |
basic browsing working
Diffstat (limited to 'src/hbox.rs')
-rw-r--r-- | src/hbox.rs | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/src/hbox.rs b/src/hbox.rs index 4719544..3cd8f53 100644 --- a/src/hbox.rs +++ b/src/hbox.rs @@ -9,7 +9,6 @@ use crate::widget::Widget; // active: bool // } - pub struct HBox { dimensions: (u16, u16), position: (u16, u16), @@ -39,27 +38,20 @@ impl HBox { let hbox_position = dbg!(self.position); let cell_size = dbg!(hbox_size.0 / self.children.len() as u16); let mut current_pos = dbg!(hbox_position.1); - let mut current_edge = dbg!(cell_size); - - for mut widget in &mut self.children { + + for widget in &mut self.children { widget.set_dimensions(dbg!((cell_size, hbox_size.1))); widget.set_position(dbg!((current_pos, hbox_position.1))); widget.refresh(); dbg!(current_pos += cell_size); - dbg!(current_edge += cell_size); } } - pub fn resize_child(&mut self, index: usize, size: (u16, u16)) { - self.children[index].set_dimensions(size); - } - - - pub fn widget(&self, index: usize) -> &Box<Widget> { - &self.children[index] - } + // pub fn widget(&self, index: usize) -> &Box<Widget> { + // &self.children[index] + // } - pub fn active_widget(&self, index: usize) -> &Box<Widget> { + pub fn active_widget(&self) -> &Box<Widget> { &self.children[self.active] } @@ -75,7 +67,7 @@ impl Widget for HBox { } fn render_header(&self) -> String { - self.children[self.active].render_header() + self.active_widget().render_header() } fn refresh(&mut self) { |