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 
00038 // LLScrollingPanelList
00039 
00040 // This could probably be integrated with LLScrollContainer -SJB
00041 
00042 void LLScrollingPanelList::clearPanels()
00043 {
00044         deleteAllChildren();
00045         mPanelList.clear();
00046         reshape( 1, 1, FALSE );
00047 }
00048 
00049 void LLScrollingPanelList::addPanel( LLScrollingPanel* panel )
00050 {
00051         addChildAtEnd( panel );
00052         mPanelList.push_front( panel );
00053         
00054         const S32 GAP_BETWEEN_PANELS = 6;
00055 
00056         // Resize this view
00057         S32 total_height = 0;
00058         S32 max_width = 0;
00059         S32 cur_gap = 0;
00060         for (std::deque<LLScrollingPanel*>::iterator iter = mPanelList.begin();
00061                  iter != mPanelList.end(); ++iter)
00062         {
00063                 LLScrollingPanel *childp = *iter;
00064                 total_height += childp->getRect().getHeight() + cur_gap;
00065                 max_width = llmax( max_width, childp->getRect().getWidth() );
00066                 cur_gap = GAP_BETWEEN_PANELS;
00067         }
00068         reshape( max_width, total_height, FALSE );
00069 
00070         // Reposition each of the child views
00071         S32 cur_y = total_height;
00072         for (std::deque<LLScrollingPanel*>::iterator iter = mPanelList.begin();
00073                  iter != mPanelList.end(); ++iter)
00074         {
00075                 LLScrollingPanel *childp = *iter;
00076                 cur_y -= childp->getRect().getHeight();
00077                 childp->translate( -childp->getRect().mLeft, cur_y - childp->getRect().mBottom);
00078                 cur_y -= GAP_BETWEEN_PANELS;
00079         }
00080 }
00081         
00082 void LLScrollingPanelList::updatePanels(BOOL allow_modify)
00083 {
00084     for (std::deque<LLScrollingPanel*>::iterator iter = mPanelList.begin();
00085                  iter != mPanelList.end(); ++iter)
00086     {
00087                 LLScrollingPanel *childp = *iter;
00088                 childp->updatePanel(allow_modify);
00089     }
00090 }
00091 
00092 void LLScrollingPanelList::updatePanelVisiblilty()
00093 {
00094         // Determine visibility of children.
00095         S32 BORDER_WIDTH = 2;  // HACK
00096 
00097         LLRect parent_local_rect = getParent()->getRect();
00098         parent_local_rect.stretch( -BORDER_WIDTH );
00099         
00100         LLRect parent_screen_rect;
00101         getParent()->localPointToScreen( 
00102                 BORDER_WIDTH, 0, 
00103                 &parent_screen_rect.mLeft, &parent_screen_rect.mBottom );
00104         getParent()->localPointToScreen( 
00105                 parent_local_rect.getWidth() - BORDER_WIDTH, parent_local_rect.getHeight() - BORDER_WIDTH,
00106                 &parent_screen_rect.mRight, &parent_screen_rect.mTop );
00107 
00108         for (std::deque<LLScrollingPanel*>::iterator iter = mPanelList.begin();
00109                  iter != mPanelList.end(); ++iter)
00110         {
00111                 LLScrollingPanel *childp = *iter;
00112                 const LLRect& local_rect = childp->getRect();
00113                 LLRect screen_rect;
00114                 childp->localPointToScreen( 
00115                         0, 0, 
00116                         &screen_rect.mLeft, &screen_rect.mBottom );
00117                 childp->localPointToScreen(
00118                         local_rect.getWidth(), local_rect.getHeight(),
00119                         &screen_rect.mRight, &screen_rect.mTop );
00120 
00121                 BOOL intersects = 
00122                         ( (screen_rect.mRight > parent_screen_rect.mLeft) && (screen_rect.mLeft < parent_screen_rect.mRight) ) && 
00123                         ( (screen_rect.mTop > parent_screen_rect.mBottom) && (screen_rect.mBottom < parent_screen_rect.mTop) );
00124 
00125                 childp->setVisible( intersects );
00126         }
00127 }
00128 
00129 void LLScrollingPanelList::setValue(const LLSD& value)
00130 {
00131 
00132 }
00133 
00134 EWidgetType LLScrollingPanelList::getWidgetType() const
00135 {
00136         return WIDGET_TYPE_SCROLLING_PANEL_LIST;
00137 }
00138 
00139 LLString LLScrollingPanelList::getWidgetTag() const
00140 {
00141         return LL_SCROLLING_PANEL_LIST_TAG;
00142 }
00143 
00144 void LLScrollingPanelList::draw()
00145 {
00146         if( getVisible() )
00147         {
00148                 updatePanelVisiblilty();
00149         }
00150         LLUICtrl::draw();
00151 }
00152 
00153 
00154 // static
00155 LLView* LLScrollingPanelList::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory)
00156 {
00157     LLString name("scrolling_panel_list");
00158     node->getAttributeString("name", name);
00159 
00160     LLRect rect;
00161     createRect(node, rect, parent, LLRect());
00162 
00163     LLScrollingPanelList* scrolling_panel_list = new LLScrollingPanelList(name, rect);
00164     scrolling_panel_list->initFromXML(node, parent);
00165     return scrolling_panel_list;
00166 }
00167 
00168 // virtual
00169 LLXMLNodePtr LLScrollingPanelList::getXML(bool save_children) const
00170 {
00171     LLXMLNodePtr node = LLUICtrl::getXML();
00172     return node;
00173 }

Generated on Thu Jul 1 06:09:05 2010 for Second Life Viewer by  doxygen 1.4.7