MAINT-1415 FIXED Empty non-functional 'Take off' menu is presented in inspector:

- class LLToggleableMenu had been updated with two methods like: appendContextSubMenu and addChild, which based on similar in LLContextMenu
master
MaksymS ProductEngine 2012-08-24 00:22:40 +03:00
parent 67750daf23
commit 99300085d4
4 changed files with 90 additions and 72 deletions

View File

@ -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);
}

View File

@ -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

View File

@ -99,3 +99,8 @@ bool LLToggleableMenu::toggleVisibility()
return true;
}
bool LLToggleableMenu::addChild(LLView* view, S32 tab_group)
{
return addContextChild(view, tab_group);
}

View File

@ -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