diff options
Diffstat (limited to 'indra')
| -rw-r--r-- | indra/llui/llmenugl.cpp | 114 | ||||
| -rw-r--r-- | indra/llui/llmenugl.h | 41 | ||||
| -rw-r--r-- | indra/llui/lltoggleablemenu.cpp | 5 | ||||
| -rw-r--r-- | indra/llui/lltoggleablemenu.h | 2 | 
4 files changed, 90 insertions, 72 deletions
| diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp index efb9848a90..cd6cc6a75e 100644 --- a/indra/llui/llmenugl.cpp +++ b/indra/llui/llmenugl.cpp @@ -1764,6 +1764,25 @@ bool LLMenuGL::addChild(LLView* view, S32 tab_group)  	return false;  } +// Used in LLContextMenu and in LLTogleableMenu +// to add an item of context menu branch +bool LLMenuGL::addContextChild(LLView* view, S32 tab_group) +{ +	LLContextMenu* context = dynamic_cast<LLContextMenu*>(view); +	if (context) +		return appendContextSubMenu(context); + +	LLMenuItemSeparatorGL* separator = dynamic_cast<LLMenuItemSeparatorGL*>(view); +	if (separator) +		return append(separator); + +	LLMenuItemGL* item = dynamic_cast<LLMenuItemGL*>(view); +	if (item) +		return append(item); + +	return false; +} +  void LLMenuGL::removeChild( LLView* ctrl)  {  	// previously a dynamic_cast with if statement to check validity @@ -2501,6 +2520,30 @@ BOOL LLMenuGL::appendMenu( LLMenuGL* menu )  	return success;  } +// add a context menu branch +BOOL LLMenuGL::appendContextSubMenu(LLMenuGL *menu) +{ +	if (menu == this) +	{ +		llerrs << "Can't attach a context menu to itself" << llendl; +	} + +	LLContextMenuBranch *item; +	LLContextMenuBranch::Params p; +	p.name = menu->getName(); +	p.label = menu->getLabel(); +	p.branch = (LLContextMenu *)menu; +	p.enabled_color=LLUIColorTable::instance().getColor("MenuItemEnabledColor"); +	p.disabled_color=LLUIColorTable::instance().getColor("MenuItemDisabledColor"); +	p.highlight_bg_color=LLUIColorTable::instance().getColor("MenuItemHighlightBgColor"); +	p.highlight_fg_color=LLUIColorTable::instance().getColor("MenuItemHighlightFgColor"); + +	item = LLUICtrlFactory::create<LLContextMenuBranch>(p); +	LLMenuGL::sMenuContainer->addChild(item->getBranch()); + +	return append( item ); +} +  void LLMenuGL::setEnabledSubMenus(BOOL enable)  {  	setEnabled(enable); @@ -3725,39 +3768,6 @@ void LLTearOffMenu::closeTearOff()  	mMenu->setDropShadowed(TRUE);  } - -//----------------------------------------------------------------------------- -// class LLContextMenuBranch -// A branch to another context menu -//----------------------------------------------------------------------------- -class LLContextMenuBranch : public LLMenuItemGL -{ -public: -	struct Params : public LLInitParam::Block<Params, LLMenuItemGL::Params> -	{ -		Mandatory<LLContextMenu*> branch; -	}; - -	LLContextMenuBranch(const Params&); - -	virtual ~LLContextMenuBranch() -	{} - -	// called to rebuild the draw label -	virtual void	buildDrawLabel( void ); - -	// onCommit() - do the primary funcationality of the menu item. -	virtual void	onCommit( void ); - -	LLContextMenu*	getBranch() { return mBranch.get(); } -	void			setHighlight( BOOL highlight ); - -protected: -	void	showSubMenu(); - -	LLHandle<LLContextMenu> mBranch; -}; -  LLContextMenuBranch::LLContextMenuBranch(const LLContextMenuBranch::Params& p)   :	LLMenuItemGL(p),  	mBranch( p.branch()->getHandle() ) @@ -4034,44 +4044,8 @@ void LLContextMenu::draw()  	LLMenuGL::draw();  } -BOOL LLContextMenu::appendContextSubMenu(LLContextMenu *menu) -{ -	 -	if (menu == this) -	{ -		llerrs << "Can't attach a context menu to itself" << llendl; -	} - -	LLContextMenuBranch *item; -	LLContextMenuBranch::Params p; -	p.name = menu->getName(); -	p.label = menu->getLabel(); -	p.branch = menu; -	p.enabled_color=LLUIColorTable::instance().getColor("MenuItemEnabledColor"); -	p.disabled_color=LLUIColorTable::instance().getColor("MenuItemDisabledColor"); -	p.highlight_bg_color=LLUIColorTable::instance().getColor("MenuItemHighlightBgColor"); -	p.highlight_fg_color=LLUIColorTable::instance().getColor("MenuItemHighlightFgColor"); -	 -	item = LLUICtrlFactory::create<LLContextMenuBranch>(p); -	LLMenuGL::sMenuContainer->addChild(item->getBranch()); - -	return append( item ); -} -  bool LLContextMenu::addChild(LLView* view, S32 tab_group)  { -	LLContextMenu* context = dynamic_cast<LLContextMenu*>(view); -	if (context) -		return appendContextSubMenu(context); - -	LLMenuItemSeparatorGL* separator = dynamic_cast<LLMenuItemSeparatorGL*>(view); -	if (separator) -		return append(separator); - -	LLMenuItemGL* item = dynamic_cast<LLMenuItemGL*>(view); -	if (item) -		return append(item); - -	return false; +	return addContextChild(view, tab_group);  } diff --git a/indra/llui/llmenugl.h b/indra/llui/llmenugl.h index 67b3e1fbe6..00899020bc 100644 --- a/indra/llui/llmenugl.h +++ b/indra/llui/llmenugl.h @@ -519,6 +519,9 @@ public:  	void resetScrollPositionOnShow(bool reset_scroll_pos) { mResetScrollPositionOnShow = reset_scroll_pos; }  	bool isScrollPositionOnShowReset() { return mResetScrollPositionOnShow; } +	// add a context menu branch +	BOOL appendContextSubMenu(LLMenuGL *menu); +  protected:  	void createSpilloverBranch();  	void cleanupSpilloverBranch(); @@ -528,6 +531,10 @@ protected:  	// add a menu - this will create a cascading menu  	virtual BOOL appendMenu( LLMenuGL* menu ); +	// Used in LLContextMenu and in LLTogleableMenu +	// to add an item of context menu branch +	bool addContextChild(LLView* view, S32 tab_group); +  	// TODO: create accessor methods for these?  	typedef std::list< LLMenuItemGL* > item_list_t;  	item_list_t mItems; @@ -679,8 +686,6 @@ public:  	virtual bool	addChild			(LLView* view, S32 tab_group = 0); -			BOOL	appendContextSubMenu(LLContextMenu *menu); -  			LLHandle<LLContextMenu> getHandle() { return getDerivedHandle<LLContextMenu>(); }  			LLView*	getSpawningView() const		{ return mSpawningViewHandle.get(); } @@ -694,6 +699,38 @@ protected:  }; +//----------------------------------------------------------------------------- +// class LLContextMenuBranch +// A branch to another context menu +//----------------------------------------------------------------------------- +class LLContextMenuBranch : public LLMenuItemGL +{ +public: +	struct Params : public LLInitParam::Block<Params, LLMenuItemGL::Params> +	{ +		Mandatory<LLContextMenu*> branch; +	}; + +	LLContextMenuBranch(const Params&); + +	virtual ~LLContextMenuBranch() +	{} + +	// called to rebuild the draw label +	virtual void	buildDrawLabel( void ); + +	// onCommit() - do the primary funcationality of the menu item. +	virtual void	onCommit( void ); + +	LLContextMenu*	getBranch() { return mBranch.get(); } +	void			setHighlight( BOOL highlight ); + +protected: +	void	showSubMenu(); + +	LLHandle<LLContextMenu> mBranch; +}; +  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  // Class LLMenuBarGL diff --git a/indra/llui/lltoggleablemenu.cpp b/indra/llui/lltoggleablemenu.cpp index d29260750f..b4c6c6162b 100644 --- a/indra/llui/lltoggleablemenu.cpp +++ b/indra/llui/lltoggleablemenu.cpp @@ -99,3 +99,8 @@ bool LLToggleableMenu::toggleVisibility()  	return true;  } + +bool LLToggleableMenu::addChild(LLView* view, S32 tab_group) +{ +	return addContextChild(view, tab_group); +} diff --git a/indra/llui/lltoggleablemenu.h b/indra/llui/lltoggleablemenu.h index 2094bd776f..4717b0d0ba 100644 --- a/indra/llui/lltoggleablemenu.h +++ b/indra/llui/lltoggleablemenu.h @@ -47,6 +47,8 @@ public:  	virtual void handleVisibilityChange (BOOL curVisibilityIn); +	virtual bool addChild (LLView* view, S32 tab_group = 0); +  	const LLRect& getButtonRect() const { return mButtonRect; }  	// Converts the given local button rect to a screen rect | 
