llscrollingpanellist.cpp

Go to the documentation of this file.
00001 
00032 #include "linden_common.h"
00033 #include "llstl.h"
00034 
00035 #include "llscrollingpanellist.h"
00036 
00037 static LLRegisterWidget<LLScrollingPanelList> r("scrolling_panel_list");
00038 
00039 
00041 // LLScrollingPanelList
00042 
00043 // This could probably be integrated with LLScrollContainer -SJB
00044 
00045 void LLScrollingPanelList::clearPanels()
00046 {
00047         deleteAllChildren();
00048         mPanelList.clear();
00049         reshape( 1, 1, FALSE );
00050 }
00051 
00052 void LLScrollingPanelList::addPanel( LLScrollingPanel* panel )
00053 {
00054         addChildAtEnd( panel );
00055         mPanelList.push_front( panel );
00056         
00057         const S32 GAP_BETWEEN_PANELS = 6;
00058 
00059         // Resize this view
00060         S32 total_height = 0;
00061         S32 max_width = 0;
00062         S32 cur_gap = 0;
00063         for (std::deque<LLScrollingPanel*>::iterator iter = mPanelList.begin();
00064                  iter != mPanelList.end(); ++iter)
00065         {
00066                 LLScrollingPanel *childp = *iter;
00067                 total_height += childp->getRect().getHeight() + cur_gap;
00068                 max_width = llmax( max_width, childp->getRect().getWidth() );
00069                 cur_gap = GAP_BETWEEN_PANELS;
00070         }
00071         reshape( max_width, total_height, FALSE );
00072 
00073         // Reposition each of the child views
00074         S32 cur_y = total_height;
00075         for (std::deque<LLScrollingPanel*>::iterator iter = mPanelList.begin();
00076                  iter != mPanelList.end(); ++iter)
00077         {
00078                 LLScrollingPanel *childp = *iter;
00079                 cur_y -= childp->getRect().getHeight();
00080                 childp->translate( -childp->getRect().mLeft, cur_y - childp->getRect().mBottom);
00081                 cur_y -= GAP_BETWEEN_PANELS;
00082         }
00083 }
00084         
00085 void LLScrollingPanelList::updatePanels(BOOL allow_modify)
00086 {
00087     for (std::deque<LLScrollingPanel*>::iterator iter = mPanelList.begin();
00088                  iter != mPanelList.end(); ++iter)
00089     {
00090                 LLScrollingPanel *childp = *iter;
00091                 childp->updatePanel(allow_modify);
00092     }
00093 }
00094 
00095 void LLScrollingPanelList::updatePanelVisiblilty()
00096 {
00097         // Determine visibility of children.
00098         S32 BORDER_WIDTH = 2;  // HACK
00099 
00100         LLRect parent_local_rect = getParent()->getRect();
00101         parent_local_rect.stretch( -BORDER_WIDTH );
00102         
00103         LLRect parent_screen_rect;
00104         getParent()->localPointToScreen( 
00105                 BORDER_WIDTH, 0, 
00106                 &parent_screen_rect.mLeft, &parent_screen_rect.mBottom );
00107         getParent()->localPointToScreen( 
00108                 parent_local_rect.getWidth() - BORDER_WIDTH, parent_local_rect.getHeight() - BORDER_WIDTH,
00109                 &parent_screen_rect.mRight, &parent_screen_rect.mTop );
00110 
00111         for (std::deque<LLScrollingPanel*>::iterator iter = mPanelList.begin();
00112                  iter != mPanelList.end(); ++iter)
00113         {
00114                 LLScrollingPanel *childp = *iter;
00115                 const LLRect& local_rect = childp->getRect();
00116                 LLRect screen_rect;
00117                 childp->localPointToScreen( 
00118                         0, 0, 
00119                         &screen_rect.mLeft, &screen_rect.mBottom );
00120                 childp->localPointToScreen(
00121                         local_rect.getWidth(), local_rect.getHeight(),
00122                         &screen_rect.mRight, &screen_rect.mTop );
00123 
00124                 BOOL intersects = 
00125                         ( (screen_rect.mRight > parent_screen_rect.mLeft) && (screen_rect.mLeft < parent_screen_rect.mRight) ) && 
00126                         ( (screen_rect.mTop > parent_screen_rect.mBottom) && (screen_rect.mBottom < parent_screen_rect.mTop) );
00127 
00128                 childp->setVisible( intersects );
00129         }
00130 }
00131 
00132 
00133 void LLScrollingPanelList::draw()
00134 {
00135         updatePanelVisiblilty();
00136 
00137         LLUICtrl::draw();
00138 }
00139 
00140 
00141 // static
00142 LLView* LLScrollingPanelList::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory)
00143 {
00144     LLString name("scrolling_panel_list");
00145     node->getAttributeString("name", name);
00146 
00147     LLRect rect;
00148     createRect(node, rect, parent, LLRect());
00149 
00150     LLScrollingPanelList* scrolling_panel_list = new LLScrollingPanelList(name, rect);
00151     scrolling_panel_list->initFromXML(node, parent);
00152     return scrolling_panel_list;
00153 }
00154 

Generated on Fri May 16 08:32:56 2008 for SecondLife by  doxygen 1.5.5