Properly re-initialize drop-down lists when the list items changes. Fixes #1558.
This was SVN commit r12244.
This commit is contained in:
parent
c708de489e
commit
b8b6ebb6ec
@ -192,6 +192,11 @@ void CDropDown::HandleMessage(SGUIMessage &Message)
|
||||
|
||||
// Important that this is after, so that overshadowed implementations aren't processed
|
||||
CList::HandleMessage(Message);
|
||||
|
||||
// As HandleMessage functions return void, we need to manually verify
|
||||
// whether the child list's items were modified.
|
||||
if (CList::GetModified())
|
||||
SetupText();
|
||||
}
|
||||
|
||||
InReaction CDropDown::ManuallyHandleEvent(const SDL_Event_* ev)
|
||||
|
@ -31,7 +31,8 @@ CList
|
||||
//-------------------------------------------------------------------
|
||||
// Constructor / Destructor
|
||||
//-------------------------------------------------------------------
|
||||
CList::CList()
|
||||
CList::CList() :
|
||||
m_Modified(false)
|
||||
{
|
||||
// Add sprite_disabled! TODO
|
||||
|
||||
@ -74,6 +75,7 @@ void CList::SetupText()
|
||||
if (!GetGUI())
|
||||
return;
|
||||
|
||||
m_Modified = true;
|
||||
CGUIList *pList;
|
||||
GUI<CGUIList>::GetSettingPointer(this, "list", pList);
|
||||
|
||||
@ -151,6 +153,7 @@ void CList::HandleMessage(SGUIMessage &Message)
|
||||
IGUIScrollBarOwner::HandleMessage(Message);
|
||||
//IGUITextOwner::HandleMessage(Message); <== placed it after the switch instead!
|
||||
|
||||
m_Modified = false;
|
||||
switch (Message.type)
|
||||
{
|
||||
case GUIM_SETTINGS_UPDATED:
|
||||
|
@ -124,10 +124,14 @@ protected:
|
||||
void DrawList(const int &selected, const CStr& _sprite,
|
||||
const CStr& _sprite_selected, const CStr& _textcolor);
|
||||
|
||||
// Get the area of the list. This is so that i can easily be changed, like in CDropDown
|
||||
// Get the area of the list. This is so that it can easily be changed, like in CDropDown
|
||||
// where the area is not equal to m_CachedActualSize.
|
||||
virtual CRect GetListRect() const { return m_CachedActualSize; }
|
||||
|
||||
// Returns whether SetupText() has run since the last message was received
|
||||
// (and thus whether list items have possibly changed).
|
||||
virtual bool GetModified() const { return m_Modified; }
|
||||
|
||||
// List of items.
|
||||
//CGUIList m_List;
|
||||
|
||||
@ -138,6 +142,10 @@ protected:
|
||||
* be zero, but still stored for easy handling.
|
||||
*/
|
||||
std::vector<float> m_ItemsYPositions;
|
||||
|
||||
private:
|
||||
// Whether the list's items have been modified since last handling a message.
|
||||
bool m_Modified;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user