Ticket #3415: t3415_cleanup_dropdown_v1.patch

File t3415_cleanup_dropdown_v1.patch, 2.8 KB (added by elexis, 9 years ago)

Simplifies existing code by reusing m_HideScrollBar.

  • source/gui/CDropDown.cpp

     
    489491
    490492        CPos pos(m_CachedActualSize.left, m_CachedActualSize.top);
    491493        DrawText(selected, color, pos, bz+0.1f, cliparea);
    492494    }
    493495
    494     bool* scrollbar = NULL;
    495     bool old;
    496     GUI<bool>::GetSettingPointer(this, "scrollbar", scrollbar);
    497 
    498     old = *scrollbar;
    499 
    500496    if (m_Open)
    501     {
    502         if (m_HideScrollBar)
    503             *scrollbar = false;
    504 
    505         DrawList(m_ElementHighlight, "sprite_list", "sprite_selectarea", "textcolor");
    506 
    507         if (m_HideScrollBar)
    508             *scrollbar = old;
    509     }
     497        DrawList(m_ElementHighlight, "sprite_list", "sprite_selectarea", "textcolor", m_HideScrollBar);
    510498}
    511499
    512500// When a dropdown list is opened, it needs to be visible above all the other
    513501// controls on the page. The only way I can think of to do this is to increase
    514502// its z value when opened, so that it's probably on top.
  • source/gui/CList.cpp

     
    292293    GUI<int>::GetSetting(this, "selected", selected);
    293294
    294295    DrawList(selected, "sprite", "sprite_selectarea", "textcolor");
    295296}
    296297
    297 void CList::DrawList(const int& selected, const CStr& _sprite, const CStr& _sprite_selected, const CStr& _textcolor)
     298void CList::DrawList(const int& selected, const CStr& _sprite, const CStr& _sprite_selected, const CStr& _textcolor, const bool hideScrollbar)
    298299{
    299300    float bz = GetBufferedZ();
    300301
    301302    // First call draw on ScrollBarOwner
    302303    bool scrollbar;
    303304    GUI<bool>::GetSetting(this, "scrollbar", scrollbar);
     305    scrollbar = scrollbar && !hideScrollbar;
    304306
    305307    if (scrollbar)
    306308        IGUIScrollBarOwner::Draw();
    307309
    308310    if (GetGUI())
  • source/gui/CList.h

     
    8383    virtual bool HandleAdditionalChildren(const XMBElement& child, CXeromyces* pFile);
    8484
    8585    // Called every time the auto-scrolling should be checked.
    8686    void UpdateAutoScroll();
    8787
    88     // Extended drawing interface, this is so that classes built on the this one
    89     //  can use other sprite names.
    90     virtual void DrawList(const int& selected, const CStr& _sprite, const CStr& _sprite_selected, const CStr& _textcolor);
     88    // Extended drawing interface, this is so that classes built on this one can use other sprite names.
     89    virtual void DrawList(const int& selected, const CStr& _sprite, const CStr& _sprite_selected, const CStr& _textcolor, const bool hideScrollbar = false);
    9190
    9291    // Get the area of the list. This is so that it can easily be changed, like in CDropDown
    9392    //  where the area is not equal to m_CachedActualSize.
    9493    virtual CRect GetListRect() const { return m_CachedActualSize; }
    9594