summaryrefslogtreecommitdiffstats
path: root/src/hbox.rs
diff options
context:
space:
mode:
authorrabite <rabite@posteo.de>2019-01-21 14:44:34 +0100
committerrabite <rabite@posteo.de>2019-01-21 15:02:14 +0100
commit67c973c0af1d35f0f832d4eb594c12868ef78008 (patch)
treeefa11d04f19aec6bd269c931b0ce6a54e42a9371 /src/hbox.rs
First commit, did some refactoring around widgets, etc, etc
Diffstat (limited to 'src/hbox.rs')
-rw-r--r--src/hbox.rs51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/hbox.rs b/src/hbox.rs
new file mode 100644
index 0000000..3be950a
--- /dev/null
+++ b/src/hbox.rs
@@ -0,0 +1,51 @@
+use crate::widget::Widget;
+
+pub struct HBox {
+ dimensions: (u16, u16),
+ position: (u16, u16),
+ children: Vec<Box<Widget>>,
+ main: usize
+}
+
+impl HBox {
+ pub fn new(widgets: Vec<Box<Widget>>) -> HBox {
+ HBox {
+ dimensions: (100, 100),
+ position: (1, 1),
+ children: widgets,
+ main: 0
+ }
+ }
+}
+
+impl Widget for HBox {
+ fn render(&self) -> Vec<String> {
+ // self.children.iter().map(|child| {
+ // child.render()
+ // }).collect()
+ vec![]
+ }
+
+ fn render_header(&self) -> String {
+ self.children[self.main].render_header()
+ }
+
+ fn refresh(&mut self) {
+ for child in &mut self.children {
+ child.refresh();
+ }
+ }
+
+ fn get_drawlist(&mut self) -> String {
+ self.children.iter_mut().map(|child| {
+ child.get_drawlist()
+ }).collect()
+ }
+
+ fn get_dimensions(&self) -> (u16, u16) {
+ self.dimensions
+ }
+ fn get_position(&self) -> (u16, u16) {
+ self.position
+ }
+}