diff options
author | Vinegret43 <67828321+Vinegret43@users.noreply.github.com> | 2021-12-16 01:00:13 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-15 20:00:13 -0500 |
commit | 8a4b1c17d5b539c07daaf5af4f3187247b47c626 (patch) | |
tree | dfd5b977b5737ceb6e3529635c60802cf836285c /src/ui | |
parent | d11f45afd046bcac85a8be93f9c98ac695b82d10 (diff) |
add dynamic number of columns (#111)
column_ratio property can now contain only 2 elements
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/views/tui_folder_view.rs | 16 | ||||
-rw-r--r-- | src/ui/widgets/tui_dirlist.rs | 5 |
2 files changed, 13 insertions, 8 deletions
diff --git a/src/ui/views/tui_folder_view.rs b/src/ui/views/tui_folder_view.rs index 9284674..de3c8a0 100644 --- a/src/ui/views/tui_folder_view.rs +++ b/src/ui/views/tui_folder_view.rs @@ -32,7 +32,6 @@ impl<'a> Widget for TuiFolderView<'a> { let curr_tab = self.context.tab_context_ref().curr_tab_ref(); let curr_list = curr_tab.curr_list_ref(); - let parent_list = curr_tab.parent_list_ref(); let child_list = curr_tab.child_list_ref(); let curr_entry = curr_list.and_then(|c| c.curr_entry_ref()); @@ -87,7 +86,11 @@ impl<'a> Widget for TuiFolderView<'a> { right, }; - intersections.render_left(buf); + // Won't render intersections if parent view is turned off + match constraints[0] { + Constraint::Ratio(0, _) => (), + _ => intersections.render_left(buf), + } if default_layout { intersections.render_right(buf); } @@ -121,8 +124,13 @@ impl<'a> Widget for TuiFolderView<'a> { }; // render parent view - if let Some(list) = parent_list.as_ref() { - TuiDirList::new(list).render(layout_rect[0], buf); + match constraints[0] { + Constraint::Ratio(0, _) => (), + _ => { + if let Some(list) = curr_tab.parent_list_ref().as_ref() { + TuiDirList::new(list).render(layout_rect[0], buf); + } + } } // render current view diff --git a/src/ui/widgets/tui_dirlist.rs b/src/ui/widgets/tui_dirlist.rs index f66c9f0..9a14e6a 100644 --- a/src/ui/widgets/tui_dirlist.rs +++ b/src/ui/widgets/tui_dirlist.rs @@ -20,10 +20,7 @@ impl<'a> TuiDirList<'a> { impl<'a> Widget for TuiDirList<'a> { fn render(self, area: Rect, buf: &mut Buffer) { - if area.width < 1 || area.height < 1 { - return; - } - if area.width < 4 { + if area.width < 4 || area.height < 1 { return; } let x = area.left(); |