// 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] );
}
예제 #2
0
BOOL LLPlacesInventoryPanel::postBuild()
{
	LLInventoryPanel::postBuild();

	// clear Contents();
	{
		mFolderRoot->destroyView();
		mFolderRoot->getParent()->removeChild(mFolderRoot);
		mFolderRoot->die();

		if( mScroller )
		{
			removeChild( mScroller );
			mScroller->die();
			mScroller = NULL;
		}
		mFolderRoot = NULL;
	}


	mCommitCallbackRegistrar.pushScope(); // registered as a widget; need to push callback scope ourselves

	// create root folder
	{
		LLRect folder_rect(0,
			0,
			getRect().getWidth(),
			0);
		LLPlacesFolderView::Params p;
		p.name = getName();
		p.title = getLabel();
		p.rect = folder_rect;
		p.parent_panel = this;
		mFolderRoot = (LLFolderView*)LLUICtrlFactory::create<LLPlacesFolderView>(p);
		mFolderRoot->setAllowMultiSelect(mAllowMultiSelect);
	}

	mCommitCallbackRegistrar.popScope();

	mFolderRoot->setCallbackRegistrar(&mCommitCallbackRegistrar);

	// scroller
	{
		LLRect scroller_view_rect = getRect();
		scroller_view_rect.translate(-scroller_view_rect.mLeft, -scroller_view_rect.mBottom);
		LLScrollContainer::Params p;
		p.name("Inventory Scroller");
		p.rect(scroller_view_rect);
		p.follows.flags(FOLLOWS_ALL);
		p.reserve_scroll_corner(true);
		p.tab_stop(true);
		mScroller = LLUICtrlFactory::create<LLScrollContainer>(p);
	}
	addChild(mScroller);
	mScroller->addChild(mFolderRoot);

	mFolderRoot->setScrollContainer(mScroller);
	mFolderRoot->addChild(mFolderRoot->mStatusTextBox);


	// cut subitems
	mFolderRoot->setUseEllipses(true);

	return TRUE;
}
void LLInventoryPanel::initFromParams(const LLInventoryPanel::Params& params)
{
	LLMemType mt(LLMemType::MTYPE_INVENTORY_POST_BUILD);

	mCommitCallbackRegistrar.pushScope(); // registered as a widget; need to push callback scope ourselves
	
	// Create root folder
	{
		LLRect folder_rect(0,
						   0,
						   getRect().getWidth(),
						   0);
		LLFolderView::Params p;
		p.name = getName();
		p.title = getLabel();
		p.rect = folder_rect;
		p.parent_panel = this;
		p.tool_tip = p.name;
		p.use_label_suffix = params.use_label_suffix;
		mFolderRoot = LLUICtrlFactory::create<LLFolderView>(p);
		mFolderRoot->setAllowMultiSelect(mAllowMultiSelect);
	}

	mCommitCallbackRegistrar.popScope();
	
	mFolderRoot->setCallbackRegistrar(&mCommitCallbackRegistrar);
	
	// Scroller
	{
		LLRect scroller_view_rect = getRect();
		scroller_view_rect.translate(-scroller_view_rect.mLeft, -scroller_view_rect.mBottom);
		LLScrollContainer::Params p;
		p.name("Inventory Scroller");
		p.rect(scroller_view_rect);
		p.follows.flags(FOLLOWS_ALL);
		p.reserve_scroll_corner(true);
		p.tab_stop(true);
		mScroller = LLUICtrlFactory::create<LLScrollContainer>(p);
		addChild(mScroller);
		mScroller->addChild(mFolderRoot);
		mFolderRoot->setScrollContainer(mScroller);
		mFolderRoot->addChild(mFolderRoot->mStatusTextBox);
	}

	// Set up the callbacks from the inventory we're viewing, and then build everything.
	mInventoryObserver = new LLInventoryPanelObserver(this);
	mInventory->addObserver(mInventoryObserver);

	mCompletionObserver = new LLInvPanelComplObserver(boost::bind(&LLInventoryPanel::onItemsCompletion, this));
	mInventory->addObserver(mCompletionObserver);

	// Build view of inventory if we need default full hierarchy and inventory ready,
	// otherwise wait for idle callback.
	if (mBuildDefaultHierarchy && mInventory->isInventoryUsable() && !mViewsInitialized)
	{
		initializeViews();
	}
	gIdleCallbacks.addFunction(onIdle, (void*)this);

	if (mSortOrderSetting != INHERIT_SORT_ORDER)
	{
		setSortOrder(gSavedSettings.getU32(mSortOrderSetting));
	}
	else
	{
		setSortOrder(gSavedSettings.getU32(DEFAULT_SORT_ORDER));
	}
	mFolderRoot->setSortOrder(getFilter()->getSortOrder());

	// Initialize base class params.
	LLPanel::initFromParams(params);
}