Introduce Orientation concept to List

When the Orientation is Bottom, we paint elements from the bottom of the list when underflowing and express scroll position relative to the bottom. In either orientation, when inserting elements outside the visible area, we adjust the scroll position as needed to keep the visible elements stable.

Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
This commit is contained in:
Nathan Sobo
2021-08-25 12:45:17 -06:00
co-authored by Max Brunsfeld Antonio Scandurra
parent 897826f710
commit 77c7fa53da
2 changed files with 60 additions and 12 deletions
+2 -1
View File
@@ -38,7 +38,7 @@ impl ChatPanel {
let mut this = Self {
channel_list,
active_channel: None,
messages: ListState::new(Vec::new()),
messages: ListState::new(Vec::new(), Orientation::Bottom),
input_editor,
settings,
};
@@ -82,6 +82,7 @@ impl ChatPanel {
.cursor::<(), ()>()
.map(|m| self.render_message(m))
.collect(),
Orientation::Bottom,
);
self.active_channel = Some((channel, subscription));
}