LLFlatListView::LLFlatListView(const LLFlatListView::Params& p) : LLScrollContainer(p) , mItemComparator(NULL) , mItemsPanel(NULL) , mItemPad(p.item_pad) , mAllowSelection(p.allow_select) , mMultipleSelection(p.multi_select) , mKeepOneItemSelected(p.keep_one_selected) , mCommitOnSelectionChange(false) , mPrevNotifyParentRect(LLRect()) , mNoItemsCommentTextbox(NULL) , mIsConsecutiveSelection(false) , mKeepSelectionVisibleOnReshape(p.keep_selection_visible_on_reshape) { mBorderThickness = getBorderWidth(); LLRect scroll_rect = getRect(); LLRect items_rect; setItemsNoScrollWidth(scroll_rect.getWidth()); items_rect.setLeftTopAndSize(mBorderThickness, scroll_rect.getHeight() - mBorderThickness, mItemsNoScrollWidth, 0); LLPanel::Params pp; pp.rect(items_rect); mItemsPanel = LLUICtrlFactory::create<LLPanel> (pp); addChild(mItemsPanel); //we don't need to stretch in vertical direction on reshaping by a parent //no bottom following! mItemsPanel->setFollows(FOLLOWS_LEFT | FOLLOWS_RIGHT | FOLLOWS_TOP); LLViewBorder::Params params; params.name("scroll border"); params.rect(getLastSelectedItemRect()); params.visible(false); params.bevel_style(LLViewBorder::BEVEL_IN); mSelectedItemsBorder = LLUICtrlFactory::create<LLViewBorder> (params); mItemsPanel->addChild( mSelectedItemsBorder ); { // create textbox for "No Items" comment text LLTextBox::Params text_p = p.no_items_text; if (!text_p.rect.isProvided()) { LLRect comment_rect = getRect(); comment_rect.setOriginAndSize(0, 0, comment_rect.getWidth(), comment_rect.getHeight()); comment_rect.stretch(-getBorderWidth()); text_p.rect(comment_rect); } text_p.border_visible(false); if (!text_p.follows.isProvided()) { text_p.follows.flags(FOLLOWS_ALL); } mNoItemsCommentTextbox = LLUICtrlFactory::create<LLTextBox>(text_p, this); } };
ZRange Button::calcZRange(void) const { /* Calculate the parent class widget's z range: */ ZRange myZRange=Label::calcZRange(); /* Adjust for the popping in/out when arming/disarming: */ myZRange+=ZRange(getExterior().origin[2]-getBorderWidth(),getExterior().origin[2]+getBorderWidth()); return myZRange; }
void LLScrollContainer::setBorderVisible(BOOL b) { mBorder->setVisible( b ); // Recompute inner rect, as border visibility changes it mInnerRect = getLocalRect(); mInnerRect.stretch( -getBorderWidth() ); }
// LLView functionality void LLScrollContainer::reshape(S32 width, S32 height, BOOL called_from_parent) { LLUICtrl::reshape( width, height, called_from_parent ); mInnerRect = getLocalRect(); mInnerRect.stretch( -getBorderWidth() ); if (mScrolledView) { const LLRect& scrolled_rect = mScrolledView->getRect(); S32 visible_width = 0; S32 visible_height = 0; BOOL show_v_scrollbar = FALSE; BOOL show_h_scrollbar = FALSE; calcVisibleSize( &visible_width, &visible_height, &show_h_scrollbar, &show_v_scrollbar ); mScrollbar[VERTICAL]->setDocSize( scrolled_rect.getHeight() ); mScrollbar[VERTICAL]->setPageSize( visible_height ); mScrollbar[HORIZONTAL]->setDocSize( scrolled_rect.getWidth() ); mScrollbar[HORIZONTAL]->setPageSize( visible_width ); updateScroll(); } }
//----------------------------------------------------------------------------- void ZonePlugin::zoneUtility( void ) { const osScalar drawExtent = _zoneExtent.x * OS_SCALAR( 2.0 ) - 0.005f; if( 1 == _solid ) { // colors for checkerboard const Color gray(0.27f); Color zoneGray( getZoneColor() ); zoneGray.setR( zoneGray.r() * gray.r() ); zoneGray.setG( zoneGray.g() * gray.g() ); zoneGray.setB( zoneGray.b() * gray.b() ); // draw checkerboard grid drawXZCheckerboardGrid( drawExtent, 10, position(), zoneGray, gray); #if 0 AABBox kZoneAABBox; kZoneAABBox.initializeWithCenterAndExtent( position(), _zoneExtent ); kZoneAABBox.draw( getZoneColor() ); #endif } else { // alternate style drawXZLineGrid( drawExtent, 1, position(), _ZoneColor ); } const osScalar borderWidth = getBorderWidth(); if( borderWidth > 0 ) { drawXZLineGrid( drawExtent + borderWidth * OS_SCALAR( 2.0 ), 1, position(), _BorderColor ); } }
void LLFlatListView::notifyParentItemsRectChanged() { S32 comment_height = 0; // take into account comment text height if exists if (mNoItemsCommentTextbox && mNoItemsCommentTextbox->getVisible()) { // top text padding inside the textbox is included into the height comment_height = mNoItemsCommentTextbox->getTextPixelHeight(); // take into account a distance from parent's top border to textbox's top comment_height += getRect().getHeight() - mNoItemsCommentTextbox->getRect().mTop; } LLRect req_rect = getItemsRect(); // get maximum of items total height and comment text height req_rect.setOriginAndSize(req_rect.mLeft, req_rect.mBottom, req_rect.getWidth(), llmax(req_rect.getHeight(), comment_height)); // take into account border size. req_rect.stretch(getBorderWidth()); if (req_rect == mPrevNotifyParentRect) return; mPrevNotifyParentRect = req_rect; LLSD params; params["action"] = "size_changes"; params["width"] = req_rect.getWidth(); params["height"] = req_rect.getHeight(); if (getParent()) // dummy widgets don't have a parent getParent()->notifyParent(params); }
// Default constructor LLScrollContainer::LLScrollContainer(const LLScrollContainer::Params& p) : LLUICtrl(p), mAutoScrolling( FALSE ), mAutoScrollRate( 0.f ), mBackgroundColor(p.bg_color()), mIsOpaque(p.is_opaque), mHideScrollbar(p.hide_scrollbar), mReserveScrollCorner(p.reserve_scroll_corner), mMinAutoScrollRate(p.min_auto_scroll_rate), mMaxAutoScrollRate(p.max_auto_scroll_rate), mScrolledView(NULL) { static LLUICachedControl<S32> scrollbar_size ("UIScrollbarSize", 0); LLRect border_rect( 0, getRect().getHeight(), getRect().getWidth(), 0 ); LLViewBorder::Params params; params.name("scroll border"); params.rect(border_rect); params.visible(p.border_visible); params.bevel_style(LLViewBorder::BEVEL_IN); mBorder = LLUICtrlFactory::create<LLViewBorder> (params); LLView::addChild( mBorder ); mInnerRect.set( 0, getRect().getHeight(), getRect().getWidth(), 0 ); mInnerRect.stretch( -getBorderWidth() ); LLRect vertical_scroll_rect = mInnerRect; vertical_scroll_rect.mLeft = vertical_scroll_rect.mRight - scrollbar_size; LLScrollbar::Params sbparams; sbparams.name("scrollable vertical"); sbparams.rect(vertical_scroll_rect); sbparams.orientation(LLScrollbar::VERTICAL); sbparams.doc_size(mInnerRect.getHeight()); sbparams.doc_pos(0); sbparams.page_size(mInnerRect.getHeight()); sbparams.step_size(VERTICAL_MULTIPLE); sbparams.follows.flags(FOLLOWS_RIGHT | FOLLOWS_TOP | FOLLOWS_BOTTOM); sbparams.visible(false); sbparams.change_callback(p.scroll_callback); mScrollbar[VERTICAL] = LLUICtrlFactory::create<LLScrollbar> (sbparams); LLView::addChild( mScrollbar[VERTICAL] ); LLRect horizontal_scroll_rect = mInnerRect; horizontal_scroll_rect.mTop = horizontal_scroll_rect.mBottom + scrollbar_size; sbparams.name("scrollable horizontal"); sbparams.rect(horizontal_scroll_rect); sbparams.orientation(LLScrollbar::HORIZONTAL); sbparams.doc_size(mInnerRect.getWidth()); sbparams.doc_pos(0); sbparams.page_size(mInnerRect.getWidth()); sbparams.step_size(VERTICAL_MULTIPLE); sbparams.visible(false); sbparams.follows.flags(FOLLOWS_LEFT | FOLLOWS_RIGHT); sbparams.change_callback(p.scroll_callback); mScrollbar[HORIZONTAL] = LLUICtrlFactory::create<LLScrollbar> (sbparams); LLView::addChild( mScrollbar[HORIZONTAL] ); }
void ScaleBar::pointerButtonDown(GLMotif::Event& event) { Scalar newScale=currentScale; /* Check if the event happened in the left or right corner: */ float relEventPos=(event.getWidgetPoint().getPoint()[0]-getInterior().origin[0])/getInterior().size[0]; if(relEventPos<=0.333f) { /* Calculate the next smaller quasi-binary scale factor: */ newScale=Scalar(getSmallerQuasiBinary(currentScale)); } else if(relEventPos>=0.667f) { /* Calculate the next bigger quasi-binary scale factor: */ newScale=Scalar(getBiggerQuasiBinary(currentScale)); } if(newScale!=currentScale&&activateNavigationTool(reinterpret_cast<const Tool*>(this))) { /* Adjust the navigation transformation: */ Scalar newNavScale; const Geometry::LinearUnit& unit=getCoordinateManager()->getUnit(); if(unit.isImperial()) { /* Calculate scale factor through imperial units: */ newNavScale=getInchFactor()*newScale/unit.getInchFactor(); } else { /* Calculate scale factor through metric units: */ newNavScale=getMeterFactor()*newScale/unit.getMeterFactor(); } /* Get the current navigation transformation and calculate the display center position in navigation coordinates: */ const NavTransform& nav=getNavigationTransformation(); Point center=nav.inverseTransform(getDisplayCenter()); /* Create the new navigation transformation: */ NavTransform newNav=NavTransform(nav.getTranslation(),nav.getRotation(),newNavScale); newNav.leftMultiply(NavTransform::translate(getDisplayCenter()-newNav.transform(center))); setNavigationTransformation(newNav); deactivateNavigationTool(reinterpret_cast<const Tool*>(this)); currentScale=newScale; /* Update the scale bar: */ calcSize(newNav); /* Resize the widget so that the clicked point stays in the same place: */ GLMotif::Vector newSize=calcNaturalSize(); GLfloat newInteriorWidth=newSize[0]-2.0f*getBorderWidth(); GLfloat newOrigin=event.getWidgetPoint().getPoint()[0]-newInteriorWidth*relEventPos-getBorderWidth(); resize(GLMotif::Box(GLMotif::Vector(newOrigin,0.0f,0.0f),newSize)); } }
QDomElement RptContainer::saveParamToXML(QDomDocument *xmlDoc) { QDomElement elem = xmlDoc->createElement(this->metaObject()->className()); elem.setAttribute("type",QtRPT::getFieldTypeName(m_type)); elem.setAttribute("printing",this->m_printing); elem.setAttribute("groupName",this->m_groupName); elem.setAttribute("name",this->objectName()); elem.setAttribute("borderWidth",QString::number(getBorderWidth())+"px"); elem.setAttribute("top",qRound(this->geometry().y()/scale)); elem.setAttribute("left",qRound(this->geometry().x()/scale)); elem.setAttribute("width",this->baseSize().width()); elem.setAttribute("height",this->baseSize().height()); return elem; }
LLRect LLScrollContainer::getContentWindowRect() { updateScroll(); LLRect scroller_view_rect; S32 visible_width = 0; S32 visible_height = 0; BOOL show_h_scrollbar = FALSE; BOOL show_v_scrollbar = FALSE; calcVisibleSize( &visible_width, &visible_height, &show_h_scrollbar, &show_v_scrollbar ); S32 border_width = getBorderWidth(); scroller_view_rect.setOriginAndSize(border_width, show_h_scrollbar ? mScrollbar[HORIZONTAL]->getRect().mTop : border_width, visible_width, visible_height); return scroller_view_rect; }
ZRange Popup::calcZRange(void) const { /* Calculate the parent class widget's z range: */ ZRange myZRange=Container::calcZRange(); /* Check the title widget: */ if(title!=0) myZRange+=title->calcZRange(); /* Check the child widget: */ if(child!=0) myZRange+=child->calcZRange(); /* Adjust the minimum z value to accomodate the popup's back side: */ myZRange.first-=getBorderWidth(); return myZRange; }
void LLScrollContainer::calcVisibleSize( S32 *visible_width, S32 *visible_height, BOOL* show_h_scrollbar, BOOL* show_v_scrollbar ) const { const LLRect& doc_rect = getScrolledViewRect(); static LLUICachedControl<S32> scrollbar_size ("UIScrollbarSize", 0); S32 doc_width = doc_rect.getWidth(); S32 doc_height = doc_rect.getHeight(); S32 border_width = getBorderWidth(); *visible_width = getRect().getWidth() - 2 * border_width; *visible_height = getRect().getHeight() - 2 * border_width; *show_v_scrollbar = FALSE; *show_h_scrollbar = FALSE; if (!mHideScrollbar) { if( *visible_height < doc_height ) { *show_v_scrollbar = TRUE; *visible_width -= scrollbar_size; } if( *visible_width < doc_width ) { *show_h_scrollbar = TRUE; *visible_height -= scrollbar_size; // Must retest now that visible_height has changed if( !*show_v_scrollbar && (*visible_height < doc_height) ) { *show_v_scrollbar = TRUE; *visible_width -= scrollbar_size; } } } }
void LLScrollContainer::updateScroll() { if (!mScrolledView) { return; } static LLUICachedControl<S32> scrollbar_size ("UIScrollbarSize", 0); LLRect doc_rect = mScrolledView->getRect(); S32 doc_width = doc_rect.getWidth(); S32 doc_height = doc_rect.getHeight(); S32 visible_width = 0; S32 visible_height = 0; BOOL show_v_scrollbar = FALSE; BOOL show_h_scrollbar = FALSE; calcVisibleSize( &visible_width, &visible_height, &show_h_scrollbar, &show_v_scrollbar ); S32 border_width = getBorderWidth(); if( show_v_scrollbar ) { if( doc_rect.mTop < getRect().getHeight() - border_width ) { mScrolledView->translate( 0, getRect().getHeight() - border_width - doc_rect.mTop ); } scrollVertical( mScrollbar[VERTICAL]->getDocPos() ); mScrollbar[VERTICAL]->setVisible( TRUE ); S32 v_scrollbar_height = visible_height; if( !show_h_scrollbar && mReserveScrollCorner ) { v_scrollbar_height -= scrollbar_size; } mScrollbar[VERTICAL]->reshape( scrollbar_size, v_scrollbar_height, TRUE ); // Make room for the horizontal scrollbar (or not) S32 v_scrollbar_offset = 0; if( show_h_scrollbar || mReserveScrollCorner ) { v_scrollbar_offset = scrollbar_size; } LLRect r = mScrollbar[VERTICAL]->getRect(); r.translate( 0, mInnerRect.mBottom - r.mBottom + v_scrollbar_offset ); mScrollbar[VERTICAL]->setRect( r ); } else { mScrolledView->translate( 0, getRect().getHeight() - border_width - doc_rect.mTop ); mScrollbar[VERTICAL]->setVisible( FALSE ); mScrollbar[VERTICAL]->setDocPos( 0 ); } if( show_h_scrollbar ) { if( doc_rect.mLeft > border_width ) { mScrolledView->translate( border_width - doc_rect.mLeft, 0 ); mScrollbar[HORIZONTAL]->setDocPos( 0 ); } else { scrollHorizontal( mScrollbar[HORIZONTAL]->getDocPos() ); } mScrollbar[HORIZONTAL]->setVisible( TRUE ); S32 h_scrollbar_width = visible_width; if( !show_v_scrollbar && mReserveScrollCorner ) { h_scrollbar_width -= scrollbar_size; } mScrollbar[HORIZONTAL]->reshape( h_scrollbar_width, scrollbar_size, TRUE ); } else { mScrolledView->translate( border_width - doc_rect.mLeft, 0 ); mScrollbar[HORIZONTAL]->setVisible( FALSE ); mScrollbar[HORIZONTAL]->setDocPos( 0 ); } mScrollbar[HORIZONTAL]->setDocSize( doc_width ); mScrollbar[HORIZONTAL]->setPageSize( visible_width ); mScrollbar[VERTICAL]->setDocSize( doc_height ); mScrollbar[VERTICAL]->setPageSize( visible_height ); } // end updateScroll