void LLAccordionCtrl::arrange() { if( mAccordionTabs.size() == 0) { //We do not arrange if we do not have what should be arranged return; } if(mAccordionTabs.size() == 1) { S32 panel_top = getRect().getHeight() - BORDER_MARGIN; // Top coordinate of the first panel S32 panel_width = getRect().getWidth() - 4; // Top coordinate of the first panel LLAccordionCtrlTab* accordion_tab = dynamic_cast<LLAccordionCtrlTab*>(mAccordionTabs[0]); LLRect panel_rect = accordion_tab->getRect(); S32 panel_height = getRect().getHeight() - 2*BORDER_MARGIN; ctrlSetLeftTopAndSize(accordion_tab,panel_rect.mLeft,panel_top,panel_width,panel_height); show_hide_scrollbar(getRect().getWidth(),getRect().getHeight()); return; } if(mSingleExpansion) arrangeSinge (); else arrangeMultiple (); }
void LLAccordionCtrl::arrangeMultiple() { S32 panel_left = BORDER_MARGIN; // Margin from left side of Splitter S32 panel_top = getRect().getHeight() - BORDER_MARGIN; // Top coordinate of the first panel S32 panel_width = getRect().getWidth() - 4; // Top coordinate of the first panel //Calculate params for(size_t i = 0; i < mAccordionTabs.size(); i++ ) { LLAccordionCtrlTab* accordion_tab = dynamic_cast<LLAccordionCtrlTab*>(mAccordionTabs[i]); if(accordion_tab->getVisible() == false) //skip hidden accordion tabs continue; if(!accordion_tab->isExpanded() ) { ctrlSetLeftTopAndSize(mAccordionTabs[i], panel_left, panel_top, panel_width, accordion_tab->getRect().getHeight()); panel_top-=mAccordionTabs[i]->getRect().getHeight(); } else { S32 panel_height = accordion_tab->getRect().getHeight(); if(mFitParent) { // all expanded tabs will have equal height panel_height = calcExpandedTabHeight(i, panel_top); ctrlSetLeftTopAndSize(accordion_tab, panel_left, panel_top, panel_width, panel_height); // try to make accordion tab fit accordion view height. // Accordion View should implement getRequiredRect() and provide valid height S32 optimal_height = accordion_tab->getAccordionView()->getRequiredRect().getHeight(); optimal_height += accordion_tab->getHeaderHeight() + 2 * BORDER_MARGIN; if(optimal_height < panel_height) { panel_height = optimal_height; } // minimum tab height is equal to header height if(mAccordionTabs[i]->getHeaderHeight() > panel_height) { panel_height = mAccordionTabs[i]->getHeaderHeight(); } } ctrlSetLeftTopAndSize(mAccordionTabs[i], panel_left, panel_top, panel_width, panel_height); panel_top-=panel_height; } } show_hide_scrollbar(getRect().getWidth(),getRect().getHeight()); updateLayout(getRect().getWidth(),getRect().getHeight()); }
void LLAccordionCtrlTab::adjustContainerPanel(const LLRect& child_rect) { if(!mContainerPanel) return; if(!mFitPanel) { show_hide_scrollbar(child_rect); updateLayout(child_rect); } else { mContainerPanel->reshape(child_rect.getWidth(),child_rect.getHeight()); mContainerPanel->setRect(child_rect); } }
void LLAccordionCtrl::arrangeSinge() { S32 panel_left = BORDER_MARGIN; // Margin from left side of Splitter S32 panel_top = getRect().getHeight() - BORDER_MARGIN; // Top coordinate of the first panel S32 panel_width = getRect().getWidth() - 4; // Top coordinate of the first panel S32 panel_height; S32 collapsed_height = 0; for(size_t i=0;i<mAccordionTabs.size();++i) { LLAccordionCtrlTab* accordion_tab = dynamic_cast<LLAccordionCtrlTab*>(mAccordionTabs[i]); if(accordion_tab->getVisible() == false) //skip hidden accordion tabs continue; if(!accordion_tab->isExpanded() ) { collapsed_height+=mAccordionTabs[i]->getRect().getHeight(); } } S32 expanded_height = getRect().getHeight() - BORDER_MARGIN - collapsed_height; for(size_t i=0;i<mAccordionTabs.size();++i) { LLAccordionCtrlTab* accordion_tab = dynamic_cast<LLAccordionCtrlTab*>(mAccordionTabs[i]); if(accordion_tab->getVisible() == false) //skip hidden accordion tabs continue; if(!accordion_tab->isExpanded() ) { panel_height = accordion_tab->getRect().getHeight(); } else { if(mFitParent) { panel_height = expanded_height; } else { if(accordion_tab->getAccordionView()) { panel_height = accordion_tab->getAccordionView()->getRect().getHeight() + accordion_tab->getHeaderHeight() + 2*BORDER_MARGIN; } else { panel_height = accordion_tab->getRect().getHeight(); } } } // make sure at least header is shown panel_height = llmax(panel_height, accordion_tab->getHeaderHeight()); ctrlSetLeftTopAndSize(mAccordionTabs[i], panel_left, panel_top, panel_width, panel_height); panel_top-=mAccordionTabs[i]->getRect().getHeight(); } show_hide_scrollbar(getRect().getWidth(), getRect().getHeight()); updateLayout(getRect().getWidth(), getRect().getHeight()); }