This Trac instance is not used for development anymore!

We migrated our development workflow to git and Gitea.
To test the future redirection, replace trac by ariadne in the page URL.

Ticket #1558: dropdown-list.patch

File dropdown-list.patch, 2.5 KB (added by Deiz, 12 years ago)
  • source/gui/CList.cpp

     
    3131//-------------------------------------------------------------------
    3232//  Constructor / Destructor
    3333//-------------------------------------------------------------------
    34 CList::CList()
     34CList::CList() :
     35    m_Modified(false)
    3536{
    3637    // Add sprite_disabled! TODO
    3738
     
    7475    if (!GetGUI())
    7576        return;
    7677
     78    m_Modified = true;
    7779    CGUIList *pList;
    7880    GUI<CGUIList>::GetSettingPointer(this, "list", pList);
    7981
     
    151153    IGUIScrollBarOwner::HandleMessage(Message);
    152154    //IGUITextOwner::HandleMessage(Message); <== placed it after the switch instead!
    153155
     156    m_Modified = false;
    154157    switch (Message.type)
    155158    {
    156159    case GUIM_SETTINGS_UPDATED:
  • source/gui/CList.h

     
    124124    void DrawList(const int &selected, const CStr& _sprite,
    125125                  const CStr& _sprite_selected, const CStr& _textcolor);
    126126
    127     // Get the area of the list. This is so that i can easily be changed, like in CDropDown
     127    // Get the area of the list. This is so that it can easily be changed, like in CDropDown
    128128    //  where the area is not equal to m_CachedActualSize.
    129129    virtual CRect GetListRect() const { return m_CachedActualSize; }
    130130
     131    // Returns whether SetupText() has run since the last message was received
     132    // (and thus whether list items have possibly changed).
     133    virtual bool GetModified() const { return m_Modified; }
     134
    131135    // List of items.
    132136    //CGUIList m_List;
    133137
     
    138142     * be zero, but still stored for easy handling.
    139143     */
    140144    std::vector<float> m_ItemsYPositions;
     145
     146private:
     147    // Whether the list's items have been modified since last handling a message.
     148    bool m_Modified;
    141149};
    142150
    143151#endif
  • source/gui/CDropDown.cpp

     
    192192
    193193    // Important that this is after, so that overshadowed implementations aren't processed
    194194    CList::HandleMessage(Message);
     195
     196    // As HandleMessage functions return void, we need to manually verify
     197    // whether the child list's items were modified.
     198    if (CList::GetModified())
     199        SetupText();
    195200}
    196201
    197202InReaction CDropDown::ManuallyHandleEvent(const SDL_Event_* ev)