Partial fix for bug #14741 (chat log scrolling to top on message added).
Will now scroll to bottom which is a less dumb thing to do. Added a tscrollbar_container::scroll_to_vertical_end()... ...member function in gui as I couldn't find a way to change the scroll position from within dialog code.
This commit is contained in:
parent
130786103c
commit
19fd729b65
3 changed files with 11 additions and 1 deletions
|
@ -25,6 +25,7 @@
|
|||
#include "gui/widgets/listbox.hpp"
|
||||
#include "gui/widgets/minimap.hpp"
|
||||
#include "gui/widgets/multi_page.hpp"
|
||||
#include "gui/widgets/scroll_label.hpp"
|
||||
#include "gui/widgets/text_box.hpp"
|
||||
#include "gui/widgets/toggle_button.hpp"
|
||||
#include "gui/widgets/toggle_panel.hpp"
|
||||
|
@ -247,8 +248,9 @@ void tlobby_main::append_to_chatbox(const std::string& text)
|
|||
void tlobby_main::append_to_chatbox(const std::string& text, size_t id)
|
||||
{
|
||||
tgrid& grid = chat_log_container_->page_grid(id);
|
||||
tcontrol& log = find_widget<tcontrol>(&grid, "log_text", false);
|
||||
tscroll_label& log = find_widget<tscroll_label>(&grid, "log_text", false);
|
||||
log.set_label(log.label() + "\n" + preferences::get_chat_timestamp(time(0)) + text);
|
||||
log.scroll_to_vertical_end();
|
||||
}
|
||||
|
||||
void tlobby_main::do_notify(t_notify_mode mode)
|
||||
|
|
|
@ -754,6 +754,12 @@ void tscrollbar_container::set_scrollbar_button_status()
|
|||
}
|
||||
}
|
||||
|
||||
void tscrollbar_container::scroll_to_vertical_end()
|
||||
{
|
||||
vertical_scrollbar_->scroll(tscrollbar_::END);
|
||||
scrollbar_moved();
|
||||
}
|
||||
|
||||
void tscrollbar_container::handle_key_home(SDLMod /*modifier*/, bool& handled)
|
||||
{
|
||||
assert(vertical_scrollbar_ && horizontal_scrollbar_);
|
||||
|
|
|
@ -157,6 +157,8 @@ public:
|
|||
const SDL_Rect& content_visible_area() const
|
||||
{ return content_visible_area_; }
|
||||
|
||||
void scroll_to_vertical_end();
|
||||
|
||||
/**
|
||||
* Callback when the scrollbar moves (NOTE maybe only one callback needed).
|
||||
* Maybe also make protected or private and add a friend.
|
||||
|
|
Loading…
Add table
Reference in a new issue