diff options
author | Steven Bennetts <steve@lindenlab.com> | 2009-06-21 08:04:56 +0000 |
---|---|---|
committer | Steven Bennetts <steve@lindenlab.com> | 2009-06-21 08:04:56 +0000 |
commit | 9ec432034dc3c45d7ce763eb02dae4cc7f6b8da8 (patch) | |
tree | 4a505c1e0919af52800b3ffb3eaf135e7d6f9ce6 /indra/llui/llscrollingpanellist.cpp | |
parent | 351ebe9fcb76f3b99c2957004bb8493a904869ee (diff) |
merge -r 122421-124917 viewer-2.0.0-2 -> viewer-2.0.0-3
ignore-dead-branch
Diffstat (limited to 'indra/llui/llscrollingpanellist.cpp')
-rw-r--r-- | indra/llui/llscrollingpanellist.cpp | 64 |
1 files changed, 45 insertions, 19 deletions
diff --git a/indra/llui/llscrollingpanellist.cpp b/indra/llui/llscrollingpanellist.cpp index 05d0c6f753..1f3a7f9fcf 100644 --- a/indra/llui/llscrollingpanellist.cpp +++ b/indra/llui/llscrollingpanellist.cpp @@ -35,7 +35,7 @@ #include "llscrollingpanellist.h" -static LLRegisterWidget<LLScrollingPanelList> r("scrolling_panel_list"); +static LLDefaultWidgetRegistry::Register<LLScrollingPanelList> r("scrolling_panel_list"); ///////////////////////////////////////////////////////////////////// @@ -52,9 +52,9 @@ void LLScrollingPanelList::clearPanels() void LLScrollingPanelList::addPanel( LLScrollingPanel* panel ) { - addChildAtEnd( panel ); + addChildInBack( panel ); mPanelList.push_front( panel ); - + const S32 GAP_BETWEEN_PANELS = 6; // Resize this view @@ -82,7 +82,48 @@ void LLScrollingPanelList::addPanel( LLScrollingPanel* panel ) cur_y -= GAP_BETWEEN_PANELS; } } - + +void LLScrollingPanelList::removePanel( U32 panel_index ) +{ + if ( mPanelList.empty() || panel_index >= mPanelList.size() ) + { + llwarns << "Panel index " << panel_index << " is out of range!" << llendl; + return; + } + else + { + removeChild( mPanelList.at(panel_index) ); + mPanelList.erase( mPanelList.begin() + panel_index ); + } + + const S32 GAP_BETWEEN_PANELS = 6; + + // Resize this view + S32 total_height = 0; + S32 max_width = 0; + S32 cur_gap = 0; + for (std::deque<LLScrollingPanel*>::iterator iter = mPanelList.begin(); + iter != mPanelList.end(); ++iter) + { + LLScrollingPanel *childp = *iter; + total_height += childp->getRect().getHeight() + cur_gap; + max_width = llmax( max_width, childp->getRect().getWidth() ); + cur_gap = GAP_BETWEEN_PANELS; + } + reshape( max_width, total_height, FALSE ); + + // Reposition each of the child views + S32 cur_y = total_height; + for (std::deque<LLScrollingPanel*>::iterator iter = mPanelList.begin(); + iter != mPanelList.end(); ++iter) + { + LLScrollingPanel *childp = *iter; + cur_y -= childp->getRect().getHeight(); + childp->translate( -childp->getRect().mLeft, cur_y - childp->getRect().mBottom); + cur_y -= GAP_BETWEEN_PANELS; + } +} + void LLScrollingPanelList::updatePanels(BOOL allow_modify) { for (std::deque<LLScrollingPanel*>::iterator iter = mPanelList.begin(); @@ -138,18 +179,3 @@ void LLScrollingPanelList::draw() LLUICtrl::draw(); } - -// static -LLView* LLScrollingPanelList::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) -{ - std::string name("scrolling_panel_list"); - node->getAttributeString("name", name); - - LLRect rect; - createRect(node, rect, parent, LLRect()); - - LLScrollingPanelList* scrolling_panel_list = new LLScrollingPanelList(name, rect); - scrolling_panel_list->initFromXML(node, parent); - return scrolling_panel_list; -} - |