Commit b35dec66 authored by Julian Sparber's avatar Julian Sparber Committed by Daniel Garcia Moreno

autoscroll: add button to scroll down to last message

parent 789048fa
......@@ -136,6 +136,11 @@ row:not(:selected) .member-uid {
padding: 0 18px 30px;
}
.scroll_button {
border-radius: 9999px;
-gtk-outline-radius: 9999px;
}
.msg-mention {
color: @error_color;
}
......
......@@ -636,29 +636,72 @@
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="messages_scroll">
<object class="GtkOverlay">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">never</property>
<property name="window_placement">bottom-left</property>
<property name="min_content_width">300</property>
<property name="min_content_height">300</property>
<child>
<object class="GtkViewport">
<object class="GtkScrolledWindow" id="messages_scroll">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">never</property>
<property name="window_placement">bottom-left</property>
<property name="min_content_width">300</property>
<property name="min_content_height">300</property>
<child>
<object class="GtkViewport">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="vscroll_policy">natural</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkListBox" id="message_list">
<property name="width_request">300</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="vexpand">True</property>
<style>
<class name="messages-history"/>
</style>
</object>
</child>
</object>
</child>
</object>
</child>
<child type="overlay">
<object class="GtkOverlay">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="vscroll_policy">natural</property>
<property name="shadow_type">none</property>
<property name="valign">end</property>
<property name="halign">end</property>
<property name="margin_end">24</property>
<property name="margin_bottom">24</property>
<child>
<object class="GtkListBox" id="message_list">
<property name="width_request">300</property>
<object class="GtkRevealer" id="scroll_btn_revealer">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="vexpand">True</property>
<style>
<class name="messages-history"/>
</style>
<property name="transition_type">crossfade</property>
<child>
<object class="GtkButton" id="scroll_btn">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">go-bottom-symbolic</property>
</object>
</child>
<style>
<class name="osd"/>
<class name="scroll_button"/>
</style>
</object>
</child>
</object>
<packing>
<property name="pass_through">False</property>
<property name="index">-1</property>
</packing>
</child>
</object>
</child>
......
......@@ -2806,6 +2806,12 @@ impl App {
let s = self.gtk_builder
.get_object::<gtk::ScrolledWindow>("messages_scroll")
.expect("Can't find message_scroll in ui file.");
let btn = self.gtk_builder
.get_object::<gtk::Button>("scroll_btn")
.expect("Can't find scroll_btn in ui file.");
let revealer = self.gtk_builder
.get_object::<gtk::Revealer>("scroll_btn_revealer")
.expect("Can't find scroll_btn_revealer in ui file.");
let op = self.op.clone();
s.connect_edge_overshot(move |_, dir| if dir == gtk::PositionType::Top {
......@@ -2824,12 +2830,20 @@ impl App {
adj.connect_value_changed(move |adj| {
let bottom = adj.get_upper() - adj.get_page_size();
if adj.get_value() == bottom {
revealer.set_reveal_child(false);
op.lock().unwrap().autoscroll = true;
} else {
revealer.set_reveal_child(true);
op.lock().unwrap().autoscroll = false;
}
});
}
btn.connect_clicked(move |_| {
if let Some(adj) = s.get_vadjustment() {
adj.set_value(adj.get_upper() - adj.get_page_size());
}
});
}
fn connect_send(&self) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment