thread: re-enables horizontal thread view
Re-implemnts horizontal thread view. Default is still vertical, but pressing toggle_layout now has an effect. Signed-off-by: Guillaume Ranquet <granquet@baylibre.com>pull/375/head
parent
a69c674c07
commit
c53a32de4c
|
@ -638,162 +638,68 @@ impl ThreadView {
|
||||||
context.dirty_areas.push_back(area);
|
context.dirty_areas.push_back(area);
|
||||||
}
|
}
|
||||||
|
|
||||||
//fn draw_horz(&mut self, grid: &mut CellBuffer, area: Area, context: &mut
|
fn draw_horz(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) {
|
||||||
// Context) { if self.entries.is_empty() {
|
if self.entries.is_empty() {
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
// let upper_left = area.upper_left();
|
|
||||||
// let bottom_right = area.bottom_right();
|
|
||||||
// let total_rows = area.height();
|
|
||||||
|
|
||||||
// let pager_ratio = *mailbox_settings!(
|
let mid = self.content.area().width().min(area.height() / 2);
|
||||||
// context[self.coordinates.0][&self.coordinates.1]
|
|
||||||
// .pager
|
|
||||||
// .pager_ratio
|
|
||||||
// );
|
|
||||||
// let mut bottom_entity_rows = (pager_ratio * total_rows) / 100;
|
|
||||||
|
|
||||||
// if bottom_entity_rows > total_rows {
|
let theme_default = crate::conf::value(context, "theme_default");
|
||||||
// bottom_entity_rows = total_rows.saturating_sub(1);
|
// First draw the thread subject on the first row
|
||||||
// }
|
if self.dirty {
|
||||||
|
grid.clear_area(area, theme_default);
|
||||||
|
let account = &context.accounts[&self.coordinates.0];
|
||||||
|
let threads = account.collection.get_threads(self.coordinates.1);
|
||||||
|
let thread_root = threads.thread_iter(self.thread_group).next().unwrap().1;
|
||||||
|
let thread_node = &threads.thread_nodes()[&thread_root];
|
||||||
|
let i = thread_node.message().unwrap_or_else(|| {
|
||||||
|
let mut iter_ptr = thread_node.children()[0];
|
||||||
|
while threads.thread_nodes()[&iter_ptr].message().is_none() {
|
||||||
|
iter_ptr = threads.thread_nodes()[&iter_ptr].children()[0];
|
||||||
|
}
|
||||||
|
threads.thread_nodes()[&iter_ptr].message().unwrap()
|
||||||
|
});
|
||||||
|
let envelope: EnvelopeRef = account.collection.get_env(i);
|
||||||
|
|
||||||
// let mut mid = get_y(upper_left) + total_rows - bottom_entity_rows;
|
grid.write_string(
|
||||||
// if mid >= get_y(bottom_right) {
|
&envelope.subject(),
|
||||||
// mid = get_y(bottom_right) / 2;
|
theme_default.fg,
|
||||||
// }
|
theme_default.bg,
|
||||||
// let mid = mid;
|
theme_default.attrs,
|
||||||
|
area,
|
||||||
|
Some(0),
|
||||||
|
);
|
||||||
|
context.dirty_areas.push_back(area);
|
||||||
|
};
|
||||||
|
|
||||||
// let theme_default = crate::conf::value(context, "theme_default");
|
let area = area.skip_rows(2);
|
||||||
// // First draw the thread subject on the first row
|
let (width, height) = self.content.area().size();
|
||||||
// let y = {
|
if height == 0 || height == self.cursor_pos || width == 0 {
|
||||||
// grid.clear_area(area, theme_default);
|
return;
|
||||||
// let account = &context.accounts[&self.coordinates.0];
|
}
|
||||||
// let threads = account.collection.get_threads(self.coordinates.1);
|
|
||||||
// let thread_root =
|
|
||||||
// threads.thread_iter(self.thread_group).next().unwrap().1; let
|
|
||||||
// thread_node = &threads.thread_nodes()[&thread_root]; let i =
|
|
||||||
// thread_node.message().unwrap_or_else(|| { let mut iter_ptr =
|
|
||||||
// thread_node.children()[0]; while
|
|
||||||
// threads.thread_nodes()[&iter_ptr].message().is_none() {
|
|
||||||
// iter_ptr = threads.thread_nodes()[&iter_ptr].children()[0]; }
|
|
||||||
// threads.thread_nodes()[&iter_ptr].message().unwrap()
|
|
||||||
// });
|
|
||||||
// let envelope: EnvelopeRef = account.collection.get_env(i);
|
|
||||||
|
|
||||||
// let (x, y) = grid.write_string(
|
match self.focus {
|
||||||
// &envelope.subject(),
|
ThreadViewFocus::None => {
|
||||||
// theme_default.fg,
|
self.draw_list(grid, area.take_rows(mid), context);
|
||||||
// theme_default.bg,
|
self.entries[self.new_expanded_pos].mailview.draw(
|
||||||
// theme_default.attrs,
|
grid,
|
||||||
// area,
|
area.skip_rows(mid + 1),
|
||||||
// Some(get_x(upper_left)),
|
context,
|
||||||
// );
|
);
|
||||||
// for x in x..=get_x(bottom_right) {
|
}
|
||||||
// grid[(x, y)]
|
ThreadViewFocus::Thread => {
|
||||||
// .set_ch(' ')
|
self.dirty = true;
|
||||||
// .set_fg(theme_default.fg)
|
self.draw_list(grid, area.skip_rows(0), context);
|
||||||
// .set_bg(theme_default.bg);
|
}
|
||||||
// }
|
ThreadViewFocus::MailView => {
|
||||||
// context.dirty_areas.push_back(area);
|
self.entries[self.new_expanded_pos]
|
||||||
// y + 2
|
.mailview
|
||||||
// };
|
.draw(grid, area, context);
|
||||||
|
}
|
||||||
// for x in get_x(upper_left)..=get_x(bottom_right) {
|
}
|
||||||
// set_and_join_box(grid, (x, y - 1), BoxBoundary::Horizontal);
|
context.dirty_areas.push_back(area);
|
||||||
// grid[(x, y - 1)]
|
}
|
||||||
// .set_fg(theme_default.fg)
|
|
||||||
// .set_bg(theme_default.bg);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// let (width, height) = self.content.area().size();
|
|
||||||
// if height == 0 || height == self.cursor_pos || width == 0 {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// grid.clear_area(area.skip_rows(y).take_rows(mid + 1), theme_default);
|
|
||||||
|
|
||||||
// match self.focus {
|
|
||||||
// ThreadViewFocus::None => {
|
|
||||||
// let area = area.skip_rows(y).take_rows(mid);
|
|
||||||
// let rows = area.height() / 2;
|
|
||||||
// if rows == 0 {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// let page_no = (self.new_cursor_pos).wrapping_div(rows);
|
|
||||||
// let top_idx = page_no * rows;
|
|
||||||
|
|
||||||
// grid.copy_area(
|
|
||||||
// self.content.grid(),
|
|
||||||
// area,
|
|
||||||
// self.content.area().skip_rows(top_idx),
|
|
||||||
// );
|
|
||||||
// context.dirty_areas.push_back(area);
|
|
||||||
// }
|
|
||||||
// ThreadViewFocus::Thread => {
|
|
||||||
// let area = {
|
|
||||||
// let val = area.skip_rows(y);
|
|
||||||
// if val.height() < 20 {
|
|
||||||
// area
|
|
||||||
// } else {
|
|
||||||
// val
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
// let rows = area.height() / 2;
|
|
||||||
// if rows == 0 {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// let page_no = (self.new_cursor_pos).wrapping_div(rows);
|
|
||||||
// let top_idx = page_no * rows;
|
|
||||||
|
|
||||||
// grid.copy_area(
|
|
||||||
// self.content.grid(),
|
|
||||||
// area,
|
|
||||||
// self.content.area().skip_rows(top_idx),
|
|
||||||
// );
|
|
||||||
// context.dirty_areas.push_back(area);
|
|
||||||
// }
|
|
||||||
// ThreadViewFocus::MailView => { /* show only envelope */ }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// match self.focus {
|
|
||||||
// ThreadViewFocus::None => {
|
|
||||||
// {
|
|
||||||
// let area = {
|
|
||||||
// let val = area.skip_rows(mid);
|
|
||||||
// if val.height() < 20 {
|
|
||||||
// area
|
|
||||||
// } else {
|
|
||||||
// val
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
// context.dirty_areas.push_back(area);
|
|
||||||
// for x in get_x(area.upper_left())..=get_x(area.bottom_right())
|
|
||||||
// { set_and_join_box(grid, (x, mid),
|
|
||||||
// BoxBoundary::Horizontal); grid[(x, mid)]
|
|
||||||
// .set_fg(theme_default.fg)
|
|
||||||
// .set_bg(theme_default.bg);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// {
|
|
||||||
// let area = area.skip_rows(y).take_rows(mid - 1);
|
|
||||||
// self.draw_list(grid, area, context);
|
|
||||||
// }
|
|
||||||
// let area = area.take_rows(mid);
|
|
||||||
// self.entries[self.new_expanded_pos]
|
|
||||||
// .mailview
|
|
||||||
// .draw(grid, area, context);
|
|
||||||
// }
|
|
||||||
// ThreadViewFocus::Thread => {
|
|
||||||
// self.dirty = true;
|
|
||||||
// self.draw_list(grid, area.skip_rows(y), context);
|
|
||||||
// }
|
|
||||||
// ThreadViewFocus::MailView => {
|
|
||||||
// self.entries[self.new_expanded_pos]
|
|
||||||
// .mailview
|
|
||||||
// .draw(grid, area, context);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
fn recalc_visible_entries(&mut self) {
|
fn recalc_visible_entries(&mut self) {
|
||||||
if self.entries.is_empty() {
|
if self.entries.is_empty() {
|
||||||
|
@ -893,6 +799,8 @@ impl Component for ThreadView {
|
||||||
self.entries[self.new_expanded_pos]
|
self.entries[self.new_expanded_pos]
|
||||||
.mailview
|
.mailview
|
||||||
.draw(grid, area, context);
|
.draw(grid, area, context);
|
||||||
|
} else if Some(true) == self.horizontal {
|
||||||
|
self.draw_horz(grid, area, context);
|
||||||
} else {
|
} else {
|
||||||
self.draw_vert(grid, area, context);
|
self.draw_vert(grid, area, context);
|
||||||
}
|
}
|
||||||
|
@ -939,7 +847,7 @@ impl Component for ThreadView {
|
||||||
if let Some(ref mut v) = self.horizontal {
|
if let Some(ref mut v) = self.horizontal {
|
||||||
*v = !*v;
|
*v = !*v;
|
||||||
} else {
|
} else {
|
||||||
self.horizontal = Some(false);
|
self.horizontal = Some(true);
|
||||||
}
|
}
|
||||||
self.set_dirty(true);
|
self.set_dirty(true);
|
||||||
true
|
true
|
||||||
|
|
Loading…
Reference in New Issue