diff options
author | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-05-09 12:53:47 +0300 |
---|---|---|
committer | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-06-10 19:40:48 +0300 |
commit | d231865f885672e8d4f797e5344682890a90f0cc (patch) | |
tree | dd1cb5c74aff58bf43af19a5eeb585c2da9ba3aa /ui/src/components/mail/view | |
parent | dad7c09158b5a366206c559ebf64647db39aa86f (diff) |
ui: add scrollbar widget in view/thread.rs
Diffstat (limited to 'ui/src/components/mail/view')
-rw-r--r-- | ui/src/components/mail/view/thread.rs | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/ui/src/components/mail/view/thread.rs b/ui/src/components/mail/view/thread.rs index 917ce64f..b8741491 100644 --- a/ui/src/components/mail/view/thread.rs +++ b/ui/src/components/mail/view/thread.rs @@ -360,7 +360,7 @@ impl ThreadView { /// draw the list fn draw_list(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) { - let upper_left = upper_left!(area); + let mut upper_left = pos_inc(upper_left!(area), (1, 0)); let bottom_right = bottom_right!(area); let (width, height) = self.content.size(); if height == 0 { @@ -373,7 +373,9 @@ impl ThreadView { let page_no = (self.new_cursor_pos).wrapping_div(rows); let top_idx = page_no * rows; - + if (rows >= height!(self.content.area())) { + upper_left = pos_dec(upper_left!(area), (1, 0)); + } /* This closure (written for code clarity, should be inlined by the compiler) returns the * **line** of an entry in the ThreadView grid. */ let get_entry_area = |idx: usize, entries: &[ThreadEntry]| { @@ -454,6 +456,18 @@ impl ThreadView { ); self.highlight_line(grid, dest_area, src_area, idx); + if (rows < height!(self.content.area())) { + ScrollBar::draw( + grid, + ( + upper_left!(area), + set_x(bottom_right, get_x(upper_left!(area)) + 1), + ), + self.cursor_pos, + rows, + visibles.len(), + ); + } self.dirty = false; context.dirty_areas.push_back(area); } else { @@ -491,6 +505,22 @@ impl ThreadView { ); self.highlight_line(grid, dest_area, src_area, entry_idx); + if (rows < height!(self.content.area())) { + ScrollBar::draw( + grid, + ( + upper_left!(area), + set_x(bottom_right, get_x(upper_left!(area)) + 1), + ), + self.cursor_pos, + rows, + visibles.len(), + ); + context.dirty_areas.push_back(( + upper_left!(area), + set_x(bottom_right, get_x(upper_left!(area)) + 1), + )); + } let (upper_left, bottom_right) = dest_area; context |