Newer
Older
/**
* @file lltoolbarview.cpp
* @author Merov Linden
* @brief User customizable toolbar class
*
* $LicenseInfo:firstyear=2011&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2011, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#include "lltoolbarview.h"
Leslie Linden
committed
#include "llappviewer.h"
Leslie Linden
committed
#include "llbutton.h"
#include "llclipboard.h"
Merov Linden
committed
#include "lldir.h"
Leslie Linden
committed
#include "lldockablefloater.h"
#include "lldockcontrol.h"
#include "llimview.h"
#include "lltransientfloatermgr.h"
#include "lltoolbar.h"
Merov Linden
committed
#include "lltooldraganddrop.h"
Leslie Linden
committed
#include "llxmlnode.h"
Leslie Linden
committed
#include "llagent.h" // HACK for destinations guide on startup
#include "llfloaterreg.h" // HACK for destinations guide on startup
#include "llviewercontrol.h" // HACK for destinations guide on startup
Merov Linden
committed
#include <boost/foreach.hpp>
LLToolBarView* gToolBarView = NULL;
static LLDefaultChildRegistry::Register<LLToolBarView> r("toolbar_view");
Merov Linden
committed
bool isToolDragged()
{
return (LLToolDragAndDrop::getInstance()->getSource() == LLToolDragAndDrop::SOURCE_VIEWER);
}
Merov Linden
committed
LLToolBarView::Toolbar::Toolbar()
Merov Linden
committed
: button_display_mode("button_display_mode"),
commands("command")
Merov Linden
committed
{}
LLToolBarView::ToolbarSet::ToolbarSet()
: left_toolbar("left_toolbar"),
right_toolbar("right_toolbar"),
bottom_toolbar("bottom_toolbar")
{}
LLToolBarView::LLToolBarView(const LLToolBarView::Params& p)
: LLUICtrl(p),
mDragStarted(false),
Richard Linden
committed
mShowToolbars(true),
Merov Linden
committed
mDragToolbarButton(NULL),
Merov Linden
committed
mDragItem(NULL),
mToolbarsLoaded(false),
mBottomToolbarPanel(NULL)
maksymsproductengine
committed
for (S32 i = 0; i < LLToolBarEnums::TOOLBAR_COUNT; i++)
{
mToolbars[i] = NULL;
}
void LLToolBarView::initFromParams(const LLToolBarView::Params& p)
{
// Initialize the base object
LLUICtrl::initFromParams(p);
}
LLToolBarView::~LLToolBarView()
saveToolbars();
BOOL LLToolBarView::postBuild()
{
maksymsproductengine
committed
mToolbars[LLToolBarEnums::TOOLBAR_LEFT] = getChild<LLToolBar>("toolbar_left");
mToolbars[LLToolBarEnums::TOOLBAR_LEFT]->getCenterLayoutPanel()->setLocationId(LLToolBarEnums::TOOLBAR_LEFT);
mToolbars[LLToolBarEnums::TOOLBAR_RIGHT] = getChild<LLToolBar>("toolbar_right");
mToolbars[LLToolBarEnums::TOOLBAR_RIGHT]->getCenterLayoutPanel()->setLocationId(LLToolBarEnums::TOOLBAR_RIGHT);
mToolbars[LLToolBarEnums::TOOLBAR_BOTTOM] = getChild<LLToolBar>("toolbar_bottom");
mToolbars[LLToolBarEnums::TOOLBAR_BOTTOM]->getCenterLayoutPanel()->setLocationId(LLToolBarEnums::TOOLBAR_BOTTOM);
mBottomToolbarPanel = getChild<LLView>("bottom_toolbar_panel");
maksymsproductengine
committed
for (int i = LLToolBarEnums::TOOLBAR_FIRST; i <= LLToolBarEnums::TOOLBAR_LAST; i++)
{
mToolbars[i]->setStartDragCallback(boost::bind(LLToolBarView::startDragTool,_1,_2,_3));
mToolbars[i]->setHandleDragCallback(boost::bind(LLToolBarView::handleDragTool,_1,_2,_3,_4));
mToolbars[i]->setHandleDropCallback(boost::bind(LLToolBarView::handleDropTool,_1,_2,_3,_4));
mToolbars[i]->setButtonAddCallback(boost::bind(LLToolBarView::onToolBarButtonAdded,_1));
Leslie Linden
committed
mToolbars[i]->setButtonRemoveCallback(boost::bind(LLToolBarView::onToolBarButtonRemoved,_1));
}
Merov Linden
committed
return TRUE;
}
S32 LLToolBarView::hasCommand(const LLCommandId& commandId) const
{
maksymsproductengine
committed
S32 command_location = LLToolBarEnums::TOOLBAR_NONE;
maksymsproductengine
committed
for (S32 loc = LLToolBarEnums::TOOLBAR_FIRST; loc <= LLToolBarEnums::TOOLBAR_LAST; loc++)
{
if (mToolbars[loc]->hasCommand(commandId))
{
command_location = loc;
break;
}
}
return command_location;
}
maksymsproductengine
committed
S32 LLToolBarView::addCommand(const LLCommandId& commandId, LLToolBarEnums::EToolBarLocation toolbar, int rank)
{
int old_rank;
removeCommand(commandId, old_rank);
S32 command_location = mToolbars[toolbar]->addCommand(commandId, rank);
return command_location;
}
S32 LLToolBarView::removeCommand(const LLCommandId& commandId, int& rank)
{
S32 command_location = hasCommand(commandId);
rank = LLToolBar::RANK_NONE;
maksymsproductengine
committed
if (command_location != LLToolBarEnums::TOOLBAR_NONE)
{
rank = mToolbars[command_location]->removeCommand(commandId);
}
return command_location;
}
S32 LLToolBarView::enableCommand(const LLCommandId& commandId, bool enabled)
{
S32 command_location = hasCommand(commandId);
maksymsproductengine
committed
if (command_location != LLToolBarEnums::TOOLBAR_NONE)
{
mToolbars[command_location]->enableCommand(commandId, enabled);
}
return command_location;
}
S32 LLToolBarView::stopCommandInProgress(const LLCommandId& commandId)
{
S32 command_location = hasCommand(commandId);
maksymsproductengine
committed
if (command_location != LLToolBarEnums::TOOLBAR_NONE)
{
mToolbars[command_location]->stopCommandInProgress(commandId);
}
return command_location;
}
Mnikolenko ProductEngine
committed
S32 LLToolBarView::flashCommand(const LLCommandId& commandId, bool flash, bool force_flashing/* = false */)
{
S32 command_location = hasCommand(commandId);
maksymsproductengine
committed
if (command_location != LLToolBarEnums::TOOLBAR_NONE)
{
Mnikolenko ProductEngine
committed
mToolbars[command_location]->flashCommand(commandId, flash, force_flashing);
}
return command_location;
}
bool LLToolBarView::addCommandInternal(const LLCommandId& command, LLToolBar* toolbar)
{
LLCommandManager& mgr = LLCommandManager::instance();
if (mgr.getCommand(command))
{
toolbar->addCommand(command);
}
else
{
LL_WARNS() << "Toolbars creation : the command with id " << command.uuid().asString() << " cannot be found in the command manager" << LL_ENDL;
return false;
}
return true;
}
Merov Linden
committed
bool LLToolBarView::loadToolbars(bool force_default)
LLToolBarView::ToolbarSet toolbar_set;
Merov Linden
committed
bool err = false;
Merov Linden
committed
// Load the toolbars.xml file
std::string toolbar_file = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, "toolbars.xml");
Merov Linden
committed
if (force_default)
{
toolbar_file = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "toolbars.xml");
}
else if (!gDirUtilp->fileExists(toolbar_file))
{
LL_WARNS() << "User toolbars def not found -> use default" << LL_ENDL;
toolbar_file = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "toolbars.xml");
}
LLXMLNodePtr root;
if(!LLXMLNode::parseFile(toolbar_file, root, NULL))
LL_WARNS() << "Unable to load toolbars from file: " << toolbar_file << LL_ENDL;
Merov Linden
committed
err = true;
Merov Linden
committed
if (!err && !root->hasName("toolbars"))
LL_WARNS() << toolbar_file << " is not a valid toolbars definition file" << LL_ENDL;
Merov Linden
committed
err = true;
}
// Parse the toolbar settings
LLXUIParser parser;
Merov Linden
committed
if (!err)
AlexanderP ProductEngine
committed
parser.readXUI(root, toolbar_set, toolbar_file);
Merov Linden
committed
}
AlexanderP ProductEngine
committed
Merov Linden
committed
if (!err && !toolbar_set.validateBlock())
{
LL_WARNS() << "Unable to validate toolbars from file: " << toolbar_file << LL_ENDL;
Merov Linden
committed
err = true;
}
if (err)
{
if (force_default)
{
LL_ERRS() << "Unable to load toolbars from default file : " << toolbar_file << LL_ENDL;
AlexanderP ProductEngine
committed
return false;
}
Merov Linden
committed
// Try to load the default toolbars
return loadToolbars(true);
Merov Linden
committed
// Clear the toolbars now before adding the loaded commands and settings
maksymsproductengine
committed
for (S32 i = LLToolBarEnums::TOOLBAR_FIRST; i <= LLToolBarEnums::TOOLBAR_LAST; i++)
Merov Linden
committed
{
if (mToolbars[i])
{
mToolbars[i]->clearCommandsList();
}
Merov Linden
committed
}
// Add commands to each toolbar
maksymsproductengine
committed
if (toolbar_set.left_toolbar.isProvided() && mToolbars[LLToolBarEnums::TOOLBAR_LEFT])
Merov Linden
committed
if (toolbar_set.left_toolbar.button_display_mode.isProvided())
{
LLToolBarEnums::ButtonType button_type = toolbar_set.left_toolbar.button_display_mode;
maksymsproductengine
committed
mToolbars[LLToolBarEnums::TOOLBAR_LEFT]->setButtonType(button_type);
Merov Linden
committed
}
BOOST_FOREACH(const LLCommandId::Params& command_params, toolbar_set.left_toolbar.commands)
Brad Payne (Vir Linden)
committed
if (!addCommandInternal(LLCommandId(command_params), mToolbars[LLToolBarEnums::TOOLBAR_LEFT]))
{
LL_WARNS() << "Error adding command '" << command_params.name() << "' to left toolbar." << LL_ENDL;
}
maksymsproductengine
committed
if (toolbar_set.right_toolbar.isProvided() && mToolbars[LLToolBarEnums::TOOLBAR_RIGHT])
Merov Linden
committed
if (toolbar_set.right_toolbar.button_display_mode.isProvided())
{
LLToolBarEnums::ButtonType button_type = toolbar_set.right_toolbar.button_display_mode;
maksymsproductengine
committed
mToolbars[LLToolBarEnums::TOOLBAR_RIGHT]->setButtonType(button_type);
Merov Linden
committed
}
BOOST_FOREACH(const LLCommandId::Params& command_params, toolbar_set.right_toolbar.commands)
Brad Payne (Vir Linden)
committed
if (!addCommandInternal(LLCommandId(command_params), mToolbars[LLToolBarEnums::TOOLBAR_RIGHT]))
{
LL_WARNS() << "Error adding command '" << command_params.name() << "' to right toolbar." << LL_ENDL;
}
maksymsproductengine
committed
if (toolbar_set.bottom_toolbar.isProvided() && mToolbars[LLToolBarEnums::TOOLBAR_BOTTOM])
Merov Linden
committed
if (toolbar_set.bottom_toolbar.button_display_mode.isProvided())
{
LLToolBarEnums::ButtonType button_type = toolbar_set.bottom_toolbar.button_display_mode;
maksymsproductengine
committed
mToolbars[LLToolBarEnums::TOOLBAR_BOTTOM]->setButtonType(button_type);
Merov Linden
committed
}
BOOST_FOREACH(const LLCommandId::Params& command_params, toolbar_set.bottom_toolbar.commands)
Brad Payne (Vir Linden)
committed
if (!addCommandInternal(LLCommandId(command_params), mToolbars[LLToolBarEnums::TOOLBAR_BOTTOM]))
{
LL_WARNS() << "Error adding command '" << command_params.name() << "' to bottom toolbar." << LL_ENDL;
}
Merov Linden
committed
mToolbarsLoaded = true;
return true;
}
Leslie Linden
committed
bool LLToolBarView::clearToolbars()
{
maksymsproductengine
committed
for (S32 i = LLToolBarEnums::TOOLBAR_FIRST; i <= LLToolBarEnums::TOOLBAR_LAST; i++)
Leslie Linden
committed
{
if (mToolbars[i])
{
mToolbars[i]->clearCommandsList();
}
}
return true;
}
Leslie Linden
committed
//static
bool LLToolBarView::loadDefaultToolbars()
{
bool retval = false;
if (gToolBarView)
{
retval = gToolBarView->loadToolbars(true);
Merov Linden
committed
if (retval)
{
gToolBarView->saveToolbars();
}
Leslie Linden
committed
}
return retval;
}
Leslie Linden
committed
//static
bool LLToolBarView::clearAllToolbars()
{
bool retval = false;
if (gToolBarView)
{
retval = gToolBarView->clearToolbars();
if (retval)
{
gToolBarView->saveToolbars();
}
}
return retval;
}
void LLToolBarView::saveToolbars() const
{
Merov Linden
committed
if (!mToolbarsLoaded)
return;
// Build the parameter tree from the toolbar data
LLToolBarView::ToolbarSet toolbar_set;
maksymsproductengine
committed
if (mToolbars[LLToolBarEnums::TOOLBAR_LEFT])
maksymsproductengine
committed
toolbar_set.left_toolbar.button_display_mode = mToolbars[LLToolBarEnums::TOOLBAR_LEFT]->getButtonType();
addToToolset(mToolbars[LLToolBarEnums::TOOLBAR_LEFT]->getCommandsList(), toolbar_set.left_toolbar);
maksymsproductengine
committed
if (mToolbars[LLToolBarEnums::TOOLBAR_RIGHT])
maksymsproductengine
committed
toolbar_set.right_toolbar.button_display_mode = mToolbars[LLToolBarEnums::TOOLBAR_RIGHT]->getButtonType();
addToToolset(mToolbars[LLToolBarEnums::TOOLBAR_RIGHT]->getCommandsList(), toolbar_set.right_toolbar);
maksymsproductengine
committed
if (mToolbars[LLToolBarEnums::TOOLBAR_BOTTOM])
maksymsproductengine
committed
toolbar_set.bottom_toolbar.button_display_mode = mToolbars[LLToolBarEnums::TOOLBAR_BOTTOM]->getButtonType();
addToToolset(mToolbars[LLToolBarEnums::TOOLBAR_BOTTOM]->getCommandsList(), toolbar_set.bottom_toolbar);
}
// Serialize the parameter tree
LLXMLNodePtr output_node = new LLXMLNode("toolbars", false);
LLXUIParser parser;
parser.writeXUI(output_node, toolbar_set);
// Write the resulting XML to file
if(!output_node->isNull())
{
const std::string& filename = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, "toolbars.xml");
LLFILE *fp = LLFile::fopen(filename, "w");
if (fp != NULL)
{
LLXMLNode::writeHeaderToFile(fp);
output_node->writeToFile(fp);
fclose(fp);
}
}
}
// Enumerate the commands in command_list and add them as Params to the toolbar
void LLToolBarView::addToToolset(command_id_list_t& command_list, Toolbar& toolbar) const
{
LLCommandManager& mgr = LLCommandManager::instance();
for (command_id_list_t::const_iterator it = command_list.begin();
it != command_list.end();
++it)
{
LLCommand* command = mgr.getCommand(*it);
if (command)
{
LLCommandId::Params command_name_param;
command_name_param.name = command->name();
toolbar.commands.add(command_name_param);
}
}
}
Seth ProductEngine
committed
void LLToolBarView::onToolBarButtonAdded(LLView* button)
{
Leslie Linden
committed
llassert(button);
if (button->getName() == "speak")
Seth ProductEngine
committed
{
// Add the "Speak" button as a control view in LLTransientFloaterMgr
// to prevent hiding the transient IM floater upon pressing "Speak".
LLTransientFloaterMgr::getInstance()->addControlView(button);
Leslie Linden
committed
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
// Redock incoming and/or outgoing call windows, if applicable
LLFloater* incoming_floater = LLFloaterReg::getLastFloaterInGroup("incoming_call");
LLFloater* outgoing_floater = LLFloaterReg::getLastFloaterInGroup("outgoing_call");
if (incoming_floater && incoming_floater->isShown())
{
LLCallDialog* incoming = dynamic_cast<LLCallDialog *>(incoming_floater);
llassert(incoming);
LLDockControl* dock_control = incoming->getDockControl();
if (dock_control->getDock() == NULL)
{
incoming->dockToToolbarButton("speak");
}
}
if (outgoing_floater && outgoing_floater->isShown())
{
LLCallDialog* outgoing = dynamic_cast<LLCallDialog *>(outgoing_floater);
llassert(outgoing);
LLDockControl* dock_control = outgoing->getDockControl();
if (dock_control->getDock() == NULL)
{
outgoing->dockToToolbarButton("speak");
}
}
Seth ProductEngine
committed
}
Leslie Linden
committed
else if (button->getName() == "voice")
Seth ProductEngine
committed
{
// Add the "Voice controls" button as a control view in LLTransientFloaterMgr
// to prevent hiding the transient IM floater upon pressing "Voice controls".
LLTransientFloaterMgr::getInstance()->addControlView(button);
}
}
Leslie Linden
committed
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
void LLToolBarView::onToolBarButtonRemoved(LLView* button)
{
llassert(button);
if (button->getName() == "speak")
{
LLTransientFloaterMgr::getInstance()->removeControlView(button);
// Undock incoming and/or outgoing call windows
LLFloater* incoming_floater = LLFloaterReg::getLastFloaterInGroup("incoming_call");
LLFloater* outgoing_floater = LLFloaterReg::getLastFloaterInGroup("outgoing_call");
if (incoming_floater && incoming_floater->isShown())
{
LLDockableFloater* incoming = dynamic_cast<LLDockableFloater *>(incoming_floater);
llassert(incoming);
LLDockControl* dock_control = incoming->getDockControl();
dock_control->setDock(NULL);
}
if (outgoing_floater && outgoing_floater->isShown())
{
LLDockableFloater* outgoing = dynamic_cast<LLDockableFloater *>(outgoing_floater);
llassert(outgoing);
LLDockControl* dock_control = outgoing->getDockControl();
dock_control->setDock(NULL);
}
}
else if (button->getName() == "voice")
{
LLTransientFloaterMgr::getInstance()->removeControlView(button);
}
}
void LLToolBarView::draw()
{
maksymsproductengine
committed
LLRect toolbar_rects[LLToolBarEnums::TOOLBAR_COUNT];
maksymsproductengine
committed
for (S32 i = LLToolBarEnums::TOOLBAR_FIRST; i <= LLToolBarEnums::TOOLBAR_LAST; i++)
Richard Nelson
committed
{
if (mToolbars[i])
{
LLView::EOrientation orientation = LLToolBarEnums::getOrientation(mToolbars[i]->getSideType());
if (orientation == LLLayoutStack::HORIZONTAL)
{
mToolbars[i]->getParent()->reshape(mToolbars[i]->getParent()->getRect().getWidth(), mToolbars[i]->getRect().getHeight());
}
else
{
mToolbars[i]->getParent()->reshape(mToolbars[i]->getRect().getWidth(), mToolbars[i]->getParent()->getRect().getHeight());
}
mToolbars[i]->localRectToOtherView(mToolbars[i]->getLocalRect(), &toolbar_rects[i], this);
}
Richard Nelson
committed
}
maksymsproductengine
committed
for (S32 i = LLToolBarEnums::TOOLBAR_FIRST; i <= LLToolBarEnums::TOOLBAR_LAST; i++)
Richard Linden
committed
mToolbars[i]->getParent()->setVisible(mShowToolbars
&& (mToolbars[i]->hasButtons()
|| isToolDragged()));
Merov Linden
committed
// Draw drop zones if drop of a tool is active
if (isToolDragged())
{
LLColor4 drop_color = LLUIColorTable::instance().getColor( "ToolbarDropZoneColor" );
maksymsproductengine
committed
for (S32 i = LLToolBarEnums::TOOLBAR_FIRST; i <= LLToolBarEnums::TOOLBAR_LAST; i++)
{
gl_rect_2d(toolbar_rects[i], drop_color, TRUE);
}
Merov Linden
committed
}
LLUICtrl::draw();
}
Merov Linden
committed
// ----------------------------------------
Merov Linden
committed
// Drag and Drop Handling
Merov Linden
committed
// ----------------------------------------
void LLToolBarView::startDragTool(S32 x, S32 y, LLToolBarButton* toolbarButton)
Merov Linden
committed
{
resetDragTool(toolbarButton);
Merov Linden
committed
// Flag the tool dragging but don't start it yet
Merov Linden
committed
LLToolDragAndDrop::getInstance()->setDragStart( x, y );
}
Merov Linden
committed
BOOL LLToolBarView::handleDragTool( S32 x, S32 y, const LLUUID& uuid, LLAssetType::EType type)
Merov Linden
committed
{
if (LLToolDragAndDrop::getInstance()->isOverThreshold( x, y ))
{
Merov Linden
committed
if (!gToolBarView->mDragStarted)
Merov Linden
committed
{
Merov Linden
committed
// Start the tool dragging:
// First, create the global drag and drop object
Merov Linden
committed
std::vector<EDragAndDropType> types;
uuid_vec_t cargo_ids;
types.push_back(DAD_WIDGET);
cargo_ids.push_back(uuid);
LLToolDragAndDrop::ESource src = LLToolDragAndDrop::SOURCE_VIEWER;
LLUUID srcID;
LLToolDragAndDrop::getInstance()->beginMultiDrag(types, cargo_ids, src, srcID);
Leslie Linden
committed
// Second, stop the command if it is in progress and requires stopping!
LLCommandId command_id = LLCommandId(uuid);
gToolBarView->stopCommandInProgress(command_id);
Merov Linden
committed
gToolBarView->mDragStarted = true;
Merov Linden
committed
return TRUE;
}
else
{
MASK mask = 0;
return LLToolDragAndDrop::getInstance()->handleHover( x, y, mask );
}
}
return FALSE;
}
Merov Linden
committed
BOOL LLToolBarView::handleDropTool( void* cargo_data, S32 x, S32 y, LLToolBar* toolbar)
Merov Linden
committed
{
BOOL handled = FALSE;
Seth ProductEngine
committed
LLInventoryObject* inv_item = static_cast<LLInventoryObject*>(cargo_data);
Merov Linden
committed
Merov Linden
committed
LLAssetType::EType type = inv_item->getType();
if (type == LLAssetType::AT_WIDGET)
{
handled = TRUE;
// Get the command from its uuid
LLCommandManager& mgr = LLCommandManager::instance();
Merov Linden
committed
LLCommandId command_id(inv_item->getUUID());
Merov Linden
committed
LLCommand* command = mgr.getCommand(command_id);
if (command)
{
// Suppress the command from the toolbars (including the one it's dropped in,
// this will handle move position).
S32 old_toolbar_loc = gToolBarView->hasCommand(command_id);
LLToolBar* old_toolbar = NULL;
maksymsproductengine
committed
if (old_toolbar_loc != LLToolBarEnums::TOOLBAR_NONE)
{
llassert(gToolBarView->mDragToolbarButton);
old_toolbar = gToolBarView->mDragToolbarButton->getParentByType<LLToolBar>();
if (old_toolbar->isReadOnly() && toolbar->isReadOnly())
{
// do nothing
}
else
{
int old_rank = LLToolBar::RANK_NONE;
gToolBarView->removeCommand(command_id, old_rank);
}
}
// Convert the (x,y) position in rank in toolbar
int new_rank = toolbar->getRankFromPosition(x,y);
toolbar->addCommand(command_id, new_rank);
Merov Linden
committed
// Save the new toolbars configuration
gToolBarView->saveToolbars();
}
else
{
LL_WARNS() << "Command couldn't be found in command manager" << LL_ENDL;
Merov Linden
committed
}
resetDragTool(NULL);
return handled;
Merov Linden
committed
}
void LLToolBarView::resetDragTool(LLToolBarButton* toolbarButton)
Merov Linden
committed
{
Merov Linden
committed
// Clear the saved command, toolbar and rank
gToolBarView->mDragStarted = false;
gToolBarView->mDragToolbarButton = toolbarButton;
Merov Linden
committed
// Provide a handle on a free standing inventory item containing references to the tool.
// This might be used by Drag and Drop to move around references to tool items.
LLInventoryObject* LLToolBarView::getDragItem()
{
if (mDragToolbarButton)
{
LLUUID item_uuid = mDragToolbarButton->getCommandId().uuid();
mDragItem = new LLInventoryObject (item_uuid, LLUUID::null, LLAssetType::AT_WIDGET, "");
}
return mDragItem;
}
void LLToolBarView::setToolBarsVisible(bool visible)
{
Richard Linden
committed
mShowToolbars = visible;
bool LLToolBarView::isModified() const
{
bool modified = false;
maksymsproductengine
committed
for (S32 i = LLToolBarEnums::TOOLBAR_FIRST; i <= LLToolBarEnums::TOOLBAR_LAST; i++)
{
modified |= mToolbars[i]->isModified();
}
return modified;
}