Пример #1
0
void LLToolBarView::startDragTool(S32 x, S32 y, LLToolBarButton* toolbarButton)
{
	resetDragTool(toolbarButton);

	// Flag the tool dragging but don't start it yet
	LLToolDragAndDrop::getInstance()->setDragStart( x, y );
}
Пример #2
0
BOOL LLToolBarView::handleDropTool( void* cargo_data, S32 x, S32 y, LLToolBar* toolbar)
{
	BOOL handled = FALSE;
	LLInventoryItem* inv_item = (LLInventoryItem*)cargo_data;
	
	LLAssetType::EType type = inv_item->getType();
	if (type == LLAssetType::AT_WIDGET)
	{
		handled = TRUE;
		// Get the command from its uuid
		LLCommandManager& mgr = LLCommandManager::instance();
		LLCommandId command_id(inv_item->getUUID());
		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;

			if (old_toolbar_loc != 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
			if (!toolbar->isReadOnly())
			{
				int new_rank = toolbar->getRankFromPosition(x,y);
				toolbar->addCommand(command_id, new_rank);
			}
			
			// Save the new toolbars configuration
			gToolBarView->saveToolbars();
		}
		else
		{
			llwarns << "Command couldn't be found in command manager" << llendl;
		}
	}

	resetDragTool(NULL);
	return handled;
}
void LLToolBarView::startDragTool(S32 x, S32 y, LLToolBarButton* toolbarButton)
{
	// <FS:Zi> Do not drag and drop when toolbars are locked
	if(gSavedSettings.getBOOL("LockToolbars"))
	{
		return;
	}
	// </FS:Zi>

	resetDragTool(toolbarButton);

	// Flag the tool dragging but don't start it yet
	LLToolDragAndDrop::getInstance()->setDragStart( x, y );
}
BOOL LLToolBarView::handleDropTool( void* cargo_data, S32 x, S32 y, LLToolBar* toolbar)
{
	// <FS:Zi> Do not drag and drop when toolbars are locked
	if(gSavedSettings.getBOOL("LockToolbars"))
	{
		return FALSE;
	}
	// </FS:Zi>

	BOOL handled = FALSE;
	LLInventoryObject* inv_item = static_cast<LLInventoryObject*>(cargo_data);
	
	LLAssetType::EType type = inv_item->getType();
	if (type == LLAssetType::AT_WIDGET)
	{
		handled = TRUE;
		// Get the command from its uuid
		LLCommandManager& mgr = LLCommandManager::instance();
		LLCommandId command_id(inv_item->getUUID());
		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;

			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
			if (!toolbar->isReadOnly())
			{
				int new_rank = toolbar->getRankFromPosition(x,y);
				toolbar->addCommand(command_id, new_rank);
			}
			
			// Save the new toolbars configuration
			gToolBarView->saveToolbars();
		}
		else
		{
			LL_WARNS() << "Command couldn't be found in command manager" << LL_ENDL;
		}
	}

	resetDragTool(NULL);
	return handled;
}