Override updates for window resizing and scrollbar changes for textbox text best fit.
This commit is contained in:
parent
1f94869fd7
commit
5cf466942a
2 changed files with 15 additions and 11 deletions
|
@ -49,6 +49,13 @@ textbox::~textbox()
|
|||
{
|
||||
}
|
||||
|
||||
void textbox::update_location(SDL_Rect const &rect)
|
||||
{
|
||||
scrollarea::update_location(rect);
|
||||
update_text_cache(true);
|
||||
set_dirty(true);
|
||||
}
|
||||
|
||||
void textbox::set_inner_location(SDL_Rect const &rect)
|
||||
{
|
||||
bg_register(rect);
|
||||
|
@ -66,17 +73,13 @@ const std::string textbox::text() const
|
|||
// set_text does not respect max_size_
|
||||
void textbox::set_text(const std::string& text, const SDL_Color& color)
|
||||
{
|
||||
// Loop twice so that if a scrollbar needs to be shown/hidden the
|
||||
// horizontal text fit is recalculated.
|
||||
for (size_t i=0; i<2; ++i) {
|
||||
text_ = utils::string_to_wstring(text);
|
||||
cursor_ = text_.size();
|
||||
text_pos_ = 0;
|
||||
selstart_ = -1;
|
||||
selend_ = -1;
|
||||
set_dirty(true);
|
||||
update_text_cache(true, color);
|
||||
}
|
||||
text_ = utils::string_to_wstring(text);
|
||||
cursor_ = text_.size();
|
||||
text_pos_ = 0;
|
||||
selstart_ = -1;
|
||||
selend_ = -1;
|
||||
set_dirty(true);
|
||||
update_text_cache(true, color);
|
||||
handle_text_changed(text_);
|
||||
}
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@ public:
|
|||
|
||||
protected:
|
||||
virtual void draw_contents();
|
||||
virtual void update_location(SDL_Rect const &rect);
|
||||
virtual void set_inner_location(SDL_Rect const &);
|
||||
virtual void scroll(unsigned int pos);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue