EXP-1300 : drop tool animation. First shot. Works but still a bit hacky and with some bugs (tools can be duplicated at times).
parent
60c85dff83
commit
ec5ea33c81
|
|
@ -41,7 +41,7 @@
|
|||
// LLCommandId class
|
||||
//
|
||||
|
||||
const LLCommandId LLCommandId::null("null command");
|
||||
const LLCommandId LLCommandId::null = LLCommandId();
|
||||
|
||||
//
|
||||
// LLCommand class
|
||||
|
|
|
|||
|
|
@ -50,6 +50,12 @@ public:
|
|||
{}
|
||||
};
|
||||
|
||||
LLCommandId()
|
||||
: mName("null command")
|
||||
{
|
||||
mUUID = LLUUID::generateNewID(mName);
|
||||
}
|
||||
|
||||
LLCommandId(const std::string& name)
|
||||
: mName(name)
|
||||
{
|
||||
|
|
@ -62,10 +68,9 @@ public:
|
|||
mUUID = LLUUID::generateNewID(p.name);
|
||||
}
|
||||
|
||||
LLCommandId(const LLUUID& uuid)
|
||||
: mName(""),
|
||||
LLCommandId(const std::string& name, const LLUUID& uuid)
|
||||
: mName(name),
|
||||
mUUID(uuid)
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@
|
|||
#include "llcommandmanager.h"
|
||||
#include "llmenugl.h"
|
||||
#include "lltrans.h"
|
||||
#include "llinventory.h"
|
||||
|
||||
// uncomment this and remove the one in llui.cpp when there is an external reference to this translation unit
|
||||
// thanks, MSVC!
|
||||
|
|
@ -113,6 +114,8 @@ LLToolBar::LLToolBar(const LLToolBar::Params& p)
|
|||
{
|
||||
mButtonParams[LLToolBarEnums::BTNTYPE_ICONS_WITH_TEXT] = p.button_icon_and_text;
|
||||
mButtonParams[LLToolBarEnums::BTNTYPE_ICONS_ONLY] = p.button_icon;
|
||||
mDraggedCommand = LLCommandId::null;
|
||||
mRank = 0;
|
||||
}
|
||||
|
||||
LLToolBar::~LLToolBar()
|
||||
|
|
@ -203,17 +206,24 @@ bool LLToolBar::addCommand(const LLCommandId& commandId, int rank)
|
|||
{
|
||||
LLCommand * command = LLCommandManager::instance().getCommand(commandId);
|
||||
if (!command) return false;
|
||||
|
||||
llinfos << "Merov debug : addCommand, " << commandId.name() << ", " << commandId.uuid() << llendl;
|
||||
|
||||
// Create the button and do the things that don't need ordering
|
||||
LLToolBarButton* button = createButton(commandId);
|
||||
mButtonPanel->addChild(button);
|
||||
mButtonMap.insert(std::make_pair(commandId, button));
|
||||
LLCommandId temp_command = commandId;
|
||||
if (commandId.name() == "Drag Tool")
|
||||
{
|
||||
temp_command = LLCommandId("Drag Tool");
|
||||
}
|
||||
mButtonMap.insert(std::make_pair(temp_command.uuid(), button));
|
||||
|
||||
|
||||
// Insert the command and button in the right place in their respective lists
|
||||
if ((rank >= mButtonCommands.size()) || (rank < 0))
|
||||
{
|
||||
// In that case, back load
|
||||
mButtonCommands.push_back(commandId);
|
||||
mButtonCommands.push_back(temp_command);
|
||||
mButtons.push_back(button);
|
||||
}
|
||||
else
|
||||
|
|
@ -228,7 +238,7 @@ bool LLToolBar::addCommand(const LLCommandId& commandId, int rank)
|
|||
rank--;
|
||||
}
|
||||
// ...then insert
|
||||
mButtonCommands.insert(it_command,commandId);
|
||||
mButtonCommands.insert(it_command,temp_command);
|
||||
mButtons.insert(it_button,button);
|
||||
}
|
||||
|
||||
|
|
@ -241,14 +251,20 @@ bool LLToolBar::removeCommand(const LLCommandId& commandId)
|
|||
{
|
||||
if (!hasCommand(commandId)) return false;
|
||||
|
||||
llinfos << "Merov debug : removeCommand, " << commandId.name() << ", " << commandId.uuid() << llendl;
|
||||
// First erase the map record
|
||||
command_id_map::iterator it = mButtonMap.find(commandId);
|
||||
LLCommandId temp_command = commandId;
|
||||
if (commandId.name() == "Drag Tool")
|
||||
{
|
||||
temp_command = LLCommandId("Drag Tool");
|
||||
}
|
||||
command_id_map::iterator it = mButtonMap.find(temp_command.uuid());
|
||||
mButtonMap.erase(it);
|
||||
|
||||
// Now iterate on the commands and buttons to identify the relevant records
|
||||
std::list<LLToolBarButton*>::iterator it_button = mButtons.begin();
|
||||
command_id_list_t::iterator it_command = mButtonCommands.begin();
|
||||
while (*it_command != commandId)
|
||||
while (*it_command != temp_command)
|
||||
{
|
||||
++it_button;
|
||||
++it_command;
|
||||
|
|
@ -276,7 +292,12 @@ bool LLToolBar::hasCommand(const LLCommandId& commandId) const
|
|||
{
|
||||
if (commandId != LLCommandId::null)
|
||||
{
|
||||
command_id_map::const_iterator it = mButtonMap.find(commandId);
|
||||
LLCommandId temp_command = commandId;
|
||||
if (commandId.name() == "Drag Tool")
|
||||
{
|
||||
temp_command = LLCommandId("Drag Tool");
|
||||
}
|
||||
command_id_map::const_iterator it = mButtonMap.find(temp_command.uuid());
|
||||
return (it != mButtonMap.end());
|
||||
}
|
||||
|
||||
|
|
@ -289,7 +310,12 @@ bool LLToolBar::enableCommand(const LLCommandId& commandId, bool enabled)
|
|||
|
||||
if (commandId != LLCommandId::null)
|
||||
{
|
||||
command_id_map::iterator it = mButtonMap.find(commandId);
|
||||
LLCommandId temp_command = commandId;
|
||||
if (commandId.name() == "Drag Tool")
|
||||
{
|
||||
temp_command = LLCommandId("Drag Tool");
|
||||
}
|
||||
command_id_map::iterator it = mButtonMap.find(temp_command.uuid());
|
||||
if (it != mButtonMap.end())
|
||||
{
|
||||
it->second->setEnabled(enabled);
|
||||
|
|
@ -507,7 +533,7 @@ void LLToolBar::updateLayoutAsNeeded()
|
|||
button_rect.setLeftTopAndSize(cur_row, panel_rect.mTop - cur_start, button_clamped_width, button->getRect().getHeight());
|
||||
}
|
||||
button->setShape(button_rect);
|
||||
|
||||
|
||||
buttons_in_row.push_back(button);
|
||||
|
||||
row_running_length += button_length + mPadBetween;
|
||||
|
|
@ -592,6 +618,12 @@ void LLToolBar::draw()
|
|||
}
|
||||
}
|
||||
}
|
||||
// HACK!!!
|
||||
if (!mDragAndDropTarget)
|
||||
{
|
||||
removeCommand(mDraggedCommand);
|
||||
mDraggedCommand = LLCommandId::null;
|
||||
}
|
||||
|
||||
updateLayoutAsNeeded();
|
||||
// rect may have shifted during layout
|
||||
|
|
@ -622,7 +654,12 @@ void LLToolBar::createButtons()
|
|||
LLToolBarButton* button = createButton(command_id);
|
||||
mButtons.push_back(button);
|
||||
mButtonPanel->addChild(button);
|
||||
mButtonMap.insert(std::make_pair(command_id, button));
|
||||
LLCommandId temp_command = command_id;
|
||||
if (command_id.name() == "Drag Tool")
|
||||
{
|
||||
temp_command = LLCommandId("Drag Tool");
|
||||
}
|
||||
mButtonMap.insert(std::make_pair(temp_command.uuid(), button));
|
||||
}
|
||||
mNeedsLayout = true;
|
||||
}
|
||||
|
|
@ -713,7 +750,31 @@ BOOL LLToolBar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
|
|||
*accept = (handled ? ACCEPT_YES_SINGLE : ACCEPT_NO);
|
||||
|
||||
// We'll use that flag to change the visual aspect of the toolbar target on draw()
|
||||
mDragAndDropTarget = handled;
|
||||
mDragAndDropTarget = false;
|
||||
|
||||
// HACK!!!
|
||||
if (!isReadOnly() && handled)
|
||||
{
|
||||
if (!drop)
|
||||
{
|
||||
LLInventoryItem* inv_item = (LLInventoryItem*)cargo_data;
|
||||
LLAssetType::EType type = inv_item->getType();
|
||||
if (type == LLAssetType::AT_WIDGET)
|
||||
{
|
||||
mRank = getRankFromPosition(x, y);
|
||||
mDraggedCommand = LLCommandId("Drag Tool",inv_item->getUUID());
|
||||
removeCommand(mDraggedCommand);
|
||||
addCommand(mDraggedCommand,mRank);
|
||||
mDragAndDropTarget = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
removeCommand(mDraggedCommand);
|
||||
mDraggedCommand = LLCommandId::null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return handled;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -184,6 +184,8 @@ protected:
|
|||
tool_handledrag_callback_t mHandleDragItemCallback;
|
||||
tool_handledrop_callback_t mHandleDropCallback;
|
||||
bool mDragAndDropTarget;
|
||||
int mRank;
|
||||
LLCommandId mDraggedCommand;
|
||||
|
||||
public:
|
||||
// Methods used in loading and saving toolbar settings
|
||||
|
|
@ -205,7 +207,7 @@ private:
|
|||
typedef std::list<LLToolBarButton*> toolbar_button_list;
|
||||
toolbar_button_list mButtons;
|
||||
command_id_list_t mButtonCommands;
|
||||
typedef std::map<LLCommandId, LLToolBarButton*> command_id_map;
|
||||
typedef std::map<LLUUID, LLToolBarButton*> command_id_map;
|
||||
command_id_map mButtonMap;
|
||||
|
||||
LLToolBarEnums::ButtonType mButtonType;
|
||||
|
|
|
|||
|
|
@ -375,7 +375,7 @@ BOOL LLToolBarView::handleDropTool( void* cargo_data, S32 x, S32 y, LLToolBar* t
|
|||
//llinfos << "Merov debug : handleDropTool. Drop source is a widget -> drop it in place..." << llendl;
|
||||
// Get the command from its uuid
|
||||
LLCommandManager& mgr = LLCommandManager::instance();
|
||||
LLCommandId command_id(inv_item->getUUID());
|
||||
LLCommandId command_id("",inv_item->getUUID());
|
||||
LLCommand* command = mgr.getCommand(command_id);
|
||||
if (command)
|
||||
{
|
||||
|
|
@ -387,9 +387,10 @@ BOOL LLToolBarView::handleDropTool( void* cargo_data, S32 x, S32 y, LLToolBar* t
|
|||
}
|
||||
// Suppress the command from the toolbars (including the one it's dropped in,
|
||||
// this will handle move position).
|
||||
gToolBarView->mToolbarLeft->removeCommand(command->id());
|
||||
gToolBarView->mToolbarRight->removeCommand(command->id());
|
||||
gToolBarView->mToolbarBottom->removeCommand(command->id());
|
||||
llinfos << "Merov debug : handleDropTool, " << command_id.name() << ", " << command_id.uuid() << llendl;
|
||||
gToolBarView->mToolbarLeft->removeCommand(command_id);
|
||||
gToolBarView->mToolbarRight->removeCommand(command_id);
|
||||
gToolBarView->mToolbarBottom->removeCommand(command_id);
|
||||
// Now insert it in the toolbar at the detected rank
|
||||
if (!toolbar->isReadOnly())
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue