EXP-1207 : Introduced an hasCommand() method for toolbars and toolbar view

meow-7.2.2
Merov Linden 2011-09-26 16:06:57 -07:00
parent 92368dbdfc
commit bb1776de68
4 changed files with 35 additions and 0 deletions

View File

@ -240,6 +240,20 @@ bool LLToolBar::addCommand(LLCommand * command)
return true;
}
bool LLToolBar::hasCommand(const std::string& command_name)
{
bool has_command = false;
for (std::list<LLToolBarButton*>::iterator cmd = mButtons.begin(); cmd != mButtons.end(); cmd++)
{
if ((*cmd)->getName() == command_name)
{
has_command = true;
break;
}
}
return has_command;
}
BOOL LLToolBar::handleRightMouseDown(S32 x, S32 y, MASK mask)
{
BOOL handle_it_here = !mReadOnly;

View File

@ -122,6 +122,7 @@ public:
void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
bool addCommand(LLCommand * command);
bool hasCommand(const std::string& command_name);
protected:
friend class LLUICtrlFactory;

View File

@ -62,6 +62,24 @@ BOOL LLToolBarView::postBuild()
return TRUE;
}
bool LLToolBarView::hasCommand(const std::string& command_name)
{
bool has_command = false;
if (mToolbarLeft && !has_command)
{
has_command = mToolbarLeft->hasCommand(command_name);
}
if (mToolbarRight && !has_command)
{
has_command = mToolbarRight->hasCommand(command_name);
}
if (mToolbarBottom && !has_command)
{
has_command = mToolbarBottom->hasCommand(command_name);
}
return has_command;
}
void LLToolBarView::draw()
{
static bool debug_print = true;

View File

@ -45,6 +45,8 @@ public:
virtual void draw();
bool hasCommand(const std::string& command_name);
// valid children for LLToolBarView are stored in this registry
typedef LLDefaultChildRegistry child_registry_t;