Fix #2789: lobby chat scrolls to top on new messages if not at bottom

(cherry-picked from commit 1699c0d3f9)
This commit is contained in:
Jyrki Vesterinen 2018-07-10 19:53:10 +03:00
parent cb6ce938c7
commit c1ba1e77ba
2 changed files with 3 additions and 2 deletions

View file

@ -72,6 +72,8 @@
### User interface
* Improved the layout of the Statistics dialog.
* Allow changing dropdown menu selections with the scrollwheel (FR #3251).
* Fixed lobby chat box scrolling to top on a new message if it isn't at the
bottom (issue #2789).
* Fixed the unit preview pane not showing the default race icon when detailing
a single unit's stats.
* Sort units secondarily by XP in the unit list dialog.

View file

@ -217,6 +217,7 @@ void chatbox::append_to_chatbox(const std::string& text, std::size_t id, const b
scroll_label& log = find_widget<scroll_label>(&grid, "log_text", false);
const bool chatbox_at_end = log.vertical_scrollbar_at_end();
const unsigned chatbox_position = log.get_vertical_scrollbar_item_position();
const std::string new_text = formatter()
<< log.get_label() << "\n" << "<span color='#bcb088'>" << preferences::get_chat_timestamp(std::time(0)) << text << "</span>";
@ -229,8 +230,6 @@ void chatbox::append_to_chatbox(const std::string& text, std::size_t id, const b
log_->at(room_name).log = new_text;
}
const unsigned chatbox_position = log.get_vertical_scrollbar_item_position();
if(chatbox_at_end || force_scroll) {
log.scroll_vertical_scrollbar(scrollbar_base::END);
} else {