Fix GUI text input box scrollbars not moving when the window is resized.
This was SVN commit r8932.
This commit is contained in:
parent
387b801aed
commit
d600a400fe
@ -485,10 +485,10 @@ void CInput::HandleMessage(const SGUIMessage &Message)
|
||||
Message.value == CStr("z") ||
|
||||
Message.value == CStr("absolute")))
|
||||
{
|
||||
GetScrollBar(0).SetX( m_CachedActualSize.right );
|
||||
GetScrollBar(0).SetY( m_CachedActualSize.top );
|
||||
GetScrollBar(0).SetZ( GetBufferedZ() );
|
||||
GetScrollBar(0).SetLength( m_CachedActualSize.bottom - m_CachedActualSize.top );
|
||||
GetScrollBar(0).SetX(m_CachedActualSize.right);
|
||||
GetScrollBar(0).SetY(m_CachedActualSize.top);
|
||||
GetScrollBar(0).SetZ(GetBufferedZ());
|
||||
GetScrollBar(0).SetLength(m_CachedActualSize.bottom - m_CachedActualSize.top);
|
||||
}
|
||||
|
||||
// Update scrollbar
|
||||
@ -497,7 +497,7 @@ void CInput::HandleMessage(const SGUIMessage &Message)
|
||||
CStr scrollbar_style;
|
||||
GUI<CStr>::GetSetting(this, Message.value, scrollbar_style);
|
||||
|
||||
GetScrollBar(0).SetScrollBarStyle( scrollbar_style );
|
||||
GetScrollBar(0).SetScrollBarStyle(scrollbar_style);
|
||||
}
|
||||
|
||||
if (Message.value == CStr("size") ||
|
||||
@ -633,6 +633,24 @@ void CInput::HandleMessage(const SGUIMessage &Message)
|
||||
}
|
||||
}
|
||||
|
||||
void CInput::UpdateCachedSize()
|
||||
{
|
||||
// If an ancestor's size changed, this will let us intercept the change and
|
||||
// update our scrollbar positions
|
||||
|
||||
IGUIObject::UpdateCachedSize();
|
||||
|
||||
bool scrollbar;
|
||||
GUI<bool>::GetSetting(this, "scrollbar", scrollbar);
|
||||
if (scrollbar)
|
||||
{
|
||||
GetScrollBar(0).SetX(m_CachedActualSize.right);
|
||||
GetScrollBar(0).SetY(m_CachedActualSize.top);
|
||||
GetScrollBar(0).SetZ(GetBufferedZ());
|
||||
GetScrollBar(0).SetLength(m_CachedActualSize.bottom - m_CachedActualSize.top);
|
||||
}
|
||||
}
|
||||
|
||||
void CInput::Draw()
|
||||
{
|
||||
float bz = GetBufferedZ();
|
||||
@ -1400,15 +1418,15 @@ void CInput::UpdateText(int from, int to_before, int to_after)
|
||||
}
|
||||
|
||||
// add the final row (even if empty)
|
||||
m_CharacterPositions.insert( current_line, row );
|
||||
m_CharacterPositions.insert(current_line, row);
|
||||
|
||||
bool scrollbar;
|
||||
GUI<bool>::GetSetting(this, "scrollbar", scrollbar);
|
||||
// Update scollbar
|
||||
if (scrollbar)
|
||||
{
|
||||
GetScrollBar(0).SetScrollRange( m_CharacterPositions.size() * font.GetLineSpacing() + buffer_zone*2.f );
|
||||
GetScrollBar(0).SetScrollSpace( m_CachedActualSize.GetHeight() );
|
||||
GetScrollBar(0).SetScrollRange(m_CharacterPositions.size() * font.GetLineSpacing() + buffer_zone*2.f);
|
||||
GetScrollBar(0).SetScrollSpace(m_CachedActualSize.GetHeight());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,8 +95,10 @@ protected:
|
||||
*/
|
||||
virtual InReaction ManuallyHandleEvent(const SDL_Event_* ev);
|
||||
|
||||
// void InsertMessage(const wchar_t* szMessage, ...);
|
||||
// void InsertChar(const int szChar, const wchar_t cooked);
|
||||
/**
|
||||
* @see IGUIObject#UpdateCachedSize()
|
||||
*/
|
||||
virtual void UpdateCachedSize();
|
||||
|
||||
/**
|
||||
* Draws the Text
|
||||
|
@ -154,9 +154,6 @@ void CList::HandleMessage(const SGUIMessage &Message)
|
||||
switch (Message.type)
|
||||
{
|
||||
case GUIM_SETTINGS_UPDATED:
|
||||
bool scrollbar;
|
||||
GUI<bool>::GetSetting(this, "scrollbar", scrollbar);
|
||||
|
||||
if (Message.value == "list")
|
||||
{
|
||||
SetupText();
|
||||
|
Loading…
Reference in New Issue
Block a user