EXP-1300 : Implemented carets for DaD. Works with small bugs but OK for demo. Still in need of some cleanup
parent
7187991642
commit
3596c0f7e1
|
|
@ -34,6 +34,7 @@
|
|||
#include "llmenugl.h"
|
||||
#include "lltrans.h"
|
||||
#include "llinventory.h"
|
||||
#include "lliconctrl.h"
|
||||
|
||||
// uncomment this and remove the one in llui.cpp when there is an external reference to this translation unit
|
||||
// thanks, MSVC!
|
||||
|
|
@ -204,7 +205,6 @@ 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);
|
||||
|
|
@ -248,7 +248,6 @@ int LLToolBar::removeCommand(const LLCommandId& commandId)
|
|||
{
|
||||
if (!hasCommand(commandId)) return RANK_NONE;
|
||||
|
||||
llinfos << "Merov debug : removeCommand, " << commandId.name() << ", " << commandId.uuid() << llendl;
|
||||
// First erase the map record
|
||||
command_id_map::iterator it = mButtonMap.find(commandId.uuid());
|
||||
mButtonMap.erase(it);
|
||||
|
|
@ -398,7 +397,7 @@ void LLToolBar::resizeButtonsInRow(std::vector<LLToolBarButton*>& buttons_in_row
|
|||
// The rank is the position a tool dropped in (x,y) would assume in the button list.
|
||||
// The value returned is between 0 and mButtons.size(), 0 being the first element to the left
|
||||
// (or top) and mButtons.size() the last one to the right (or bottom).
|
||||
int LLToolBar::getRankFromPosition(S32 x, S32 y)
|
||||
int LLToolBar::getRankFromPosition(S32& x, S32& y)
|
||||
{
|
||||
int rank = 0;
|
||||
|
||||
|
|
@ -406,16 +405,16 @@ int LLToolBar::getRankFromPosition(S32 x, S32 y)
|
|||
S32 button_panel_x = 0;
|
||||
S32 button_panel_y = 0;
|
||||
localPointToOtherView(x, y, &button_panel_x, &button_panel_y, mButtonPanel);
|
||||
S32 dx = x - button_panel_x;
|
||||
S32 dy = y - button_panel_y;
|
||||
|
||||
//llinfos << "Merov debug : rank compute: orientation = " << orientation << ", x = " << button_panel_x << ", y = " << button_panel_y << llendl;
|
||||
|
||||
// Simply compare the passed coord with the buttons outbound box
|
||||
std::list<LLToolBarButton*>::iterator it_button = mButtons.begin();
|
||||
std::list<LLToolBarButton*>::iterator end_button = mButtons.end();
|
||||
LLRect button_rect;
|
||||
while (it_button != end_button)
|
||||
{
|
||||
LLRect button_rect = (*it_button)->getRect();
|
||||
//llinfos << "Merov debug : rank compute: rect = " << button_rect.mLeft << ", " << button_rect.mTop << ", " << button_rect.mRight << ", " << button_rect.mBottom << llendl;
|
||||
button_rect = (*it_button)->getRect();
|
||||
if (((orientation == LLLayoutStack::HORIZONTAL) && (button_rect.mRight > button_panel_x)) ||
|
||||
((orientation == LLLayoutStack::VERTICAL) && (button_rect.mBottom < button_panel_y)) )
|
||||
{
|
||||
|
|
@ -424,7 +423,16 @@ int LLToolBar::getRankFromPosition(S32 x, S32 y)
|
|||
rank++;
|
||||
++it_button;
|
||||
}
|
||||
//llinfos << "Merov debug : rank = " << rank << llendl;
|
||||
if (it_button != end_button)
|
||||
{
|
||||
x = button_rect.mRight + dx;
|
||||
y = button_rect.mTop + dy;
|
||||
}
|
||||
else
|
||||
{
|
||||
x = button_rect.mLeft + dx;
|
||||
y = button_rect.mBottom + dy;
|
||||
}
|
||||
|
||||
return rank;
|
||||
}
|
||||
|
|
@ -613,7 +621,40 @@ void LLToolBar::draw()
|
|||
LLUI::pushMatrix();
|
||||
LLUI::translate((F32)getRect().mLeft, (F32)getRect().mBottom, 0.f);
|
||||
|
||||
// Position the caret
|
||||
LLIconCtrl* caret = getChild<LLIconCtrl>("caret");
|
||||
caret->setVisible(FALSE);
|
||||
if (mDragAndDropTarget && !mButtonCommands.empty())
|
||||
{
|
||||
LLRect caret_rect = caret->getRect();
|
||||
LLRect toolbar_rect = getRect();
|
||||
if (mSideType == SIDE_BOTTOM)
|
||||
{
|
||||
caret->setRect(LLRect(mDragx-caret_rect.getWidth()/2+1,
|
||||
toolbar_rect.getHeight()+3,
|
||||
mDragx+caret_rect.getWidth()/2+1,
|
||||
toolbar_rect.getHeight()-caret_rect.getHeight()+3));
|
||||
}
|
||||
else if (mSideType == SIDE_LEFT)
|
||||
{
|
||||
|
||||
caret->setRect(LLRect(toolbar_rect.getWidth()-caret_rect.getWidth()+3,
|
||||
mDragy+caret_rect.getHeight()/2,
|
||||
toolbar_rect.getWidth()+3,
|
||||
mDragy-caret_rect.getHeight()/2));
|
||||
}
|
||||
else
|
||||
{
|
||||
caret->setRect(LLRect(-3,
|
||||
mDragy+caret_rect.getHeight()/2,
|
||||
caret_rect.getWidth()-3,
|
||||
mDragy-caret_rect.getHeight()/2));
|
||||
}
|
||||
caret->setVisible(TRUE);
|
||||
}
|
||||
|
||||
LLUICtrl::draw();
|
||||
caret->setVisible(FALSE);
|
||||
}
|
||||
|
||||
void LLToolBar::reshape(S32 width, S32 height, BOOL called_from_parent)
|
||||
|
|
@ -713,7 +754,6 @@ BOOL LLToolBar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
|
|||
EAcceptance* accept,
|
||||
std::string& tooltip_msg)
|
||||
{
|
||||
llinfos << "Merov debug : handleDragAndDrop. drop = " << drop << ", x = " << x << ", y = " << y << llendl;
|
||||
// If we have a drop callback, that means that we can handle the drop
|
||||
BOOL handled = (mHandleDropCallback ? TRUE : FALSE);
|
||||
|
||||
|
|
@ -729,21 +769,22 @@ BOOL LLToolBar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
|
|||
// We'll use that flag to change the visual aspect of the toolbar target on draw()
|
||||
mDragAndDropTarget = false;
|
||||
|
||||
// HACK!!!
|
||||
if (!isReadOnly() && handled)
|
||||
// Convert drag position into insert position and rank
|
||||
if (!isReadOnly() && handled && !drop)
|
||||
{
|
||||
if (!drop)
|
||||
LLInventoryItem* inv_item = (LLInventoryItem*)cargo_data;
|
||||
LLAssetType::EType type = inv_item->getType();
|
||||
if (type == LLAssetType::AT_WIDGET)
|
||||
{
|
||||
LLInventoryItem* inv_item = (LLInventoryItem*)cargo_data;
|
||||
LLAssetType::EType type = inv_item->getType();
|
||||
if (type == LLAssetType::AT_WIDGET)
|
||||
{
|
||||
LLCommandId dragged_command(inv_item->getUUID());
|
||||
int rank = getRankFromPosition(x, y);
|
||||
removeCommand(dragged_command);
|
||||
addCommand(dragged_command,rank);
|
||||
mDragAndDropTarget = true;
|
||||
}
|
||||
mDragx = x;
|
||||
mDragy = y;
|
||||
mDragRank = getRankFromPosition(mDragx, mDragy);
|
||||
mDragAndDropTarget = true;
|
||||
/* Do the following if you want to animate the button itself
|
||||
LLCommandId dragged_command(inv_item->getUUID());
|
||||
removeCommand(dragged_command);
|
||||
addCommand(dragged_command,rank);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -784,7 +825,6 @@ BOOL LLToolBarButton::handleMouseDown(S32 x, S32 y, MASK mask)
|
|||
|
||||
BOOL LLToolBarButton::handleHover(S32 x, S32 y, MASK mask)
|
||||
{
|
||||
// llinfos << "Merov debug: handleHover, x = " << x << ", y = " << y << ", mouse = " << hasMouseCapture() << llendl;
|
||||
BOOL handled = FALSE;
|
||||
|
||||
S32 mouse_distance_squared = (x - mMouseDownX) * (x - mMouseDownX) + (y - mMouseDownY) * (y - mMouseDownY);
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ public:
|
|||
// virtuals
|
||||
void draw();
|
||||
void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
|
||||
int getRankFromPosition(S32 x, S32 y);
|
||||
int getRankFromPosition(S32& x, S32& y);
|
||||
BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
|
||||
virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
|
||||
EDragAndDropType cargo_type,
|
||||
|
|
@ -188,6 +188,9 @@ protected:
|
|||
tool_handledrag_callback_t mHandleDragItemCallback;
|
||||
tool_handledrop_callback_t mHandleDropCallback;
|
||||
bool mDragAndDropTarget;
|
||||
int mDragRank;
|
||||
S32 mDragx,
|
||||
mDragy;
|
||||
|
||||
public:
|
||||
// Methods used in loading and saving toolbar settings
|
||||
|
|
@ -217,7 +220,7 @@ private:
|
|||
LLLayoutStack* mWrapStack;
|
||||
LLPanel* mButtonPanel;
|
||||
LLToolBarEnums::SideType mSideType;
|
||||
|
||||
|
||||
bool mWrap;
|
||||
bool mNeedsLayout;
|
||||
S32 mPadLeft,
|
||||
|
|
|
|||
|
|
@ -330,7 +330,6 @@ void LLToolBarView::draw()
|
|||
|
||||
void LLToolBarView::startDragTool( S32 x, S32 y, const LLUUID& uuid)
|
||||
{
|
||||
llinfos << "Merov debug: startDragTool() : x = " << x << ", y = " << y << ", uuid = " << uuid << llendl;
|
||||
// Flag the tool dragging but don't start it yet
|
||||
gToolBarView->mDragStarted = false;
|
||||
gToolBarView->mDragCommand = LLCommandId::null;
|
||||
|
|
@ -345,7 +344,6 @@ BOOL LLToolBarView::handleDragTool( S32 x, S32 y, const LLUUID& uuid, LLAssetTyp
|
|||
{
|
||||
if (!gToolBarView->mDragStarted)
|
||||
{
|
||||
llinfos << "Merov debug: handleDragTool() : x = " << x << ", y = " << y << ", uuid = " << uuid << llendl;
|
||||
// Start the tool dragging:
|
||||
|
||||
// First, create the global drag and drop object
|
||||
|
|
@ -357,7 +355,6 @@ BOOL LLToolBarView::handleDragTool( S32 x, S32 y, const LLUUID& uuid, LLAssetTyp
|
|||
LLToolDragAndDrop::ESource src = LLToolDragAndDrop::SOURCE_VIEWER;
|
||||
LLUUID srcID;
|
||||
LLToolDragAndDrop::getInstance()->beginMultiDrag(types, cargo_ids, src, srcID);
|
||||
llinfos << "Merov debug: beginMultiDrag() launched" << llendl;
|
||||
|
||||
// Second, check if the command is present in one of the 3 toolbars
|
||||
// If it is, store the command, the toolbar and the rank in the toolbar and
|
||||
|
|
@ -383,7 +380,6 @@ BOOL LLToolBarView::handleDragTool( S32 x, S32 y, const LLUUID& uuid, LLAssetTyp
|
|||
}
|
||||
*/
|
||||
|
||||
llinfos << "Merov debug: Drag started cleanly" << llendl;
|
||||
gToolBarView->mDragStarted = true;
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -399,12 +395,10 @@ BOOL LLToolBarView::handleDragTool( S32 x, S32 y, const LLUUID& uuid, LLAssetTyp
|
|||
BOOL LLToolBarView::handleDropTool( void* cargo_data, S32 x, S32 y, LLToolBar* toolbar)
|
||||
{
|
||||
LLInventoryItem* inv_item = (LLInventoryItem*)cargo_data;
|
||||
//llinfos << "Merov debug : handleDropTool. Drop " << inv_item->getUUID() << " named " << inv_item->getName() << " of type " << inv_item->getType() << llendl;
|
||||
|
||||
LLAssetType::EType type = inv_item->getType();
|
||||
if (type == LLAssetType::AT_WIDGET)
|
||||
{
|
||||
//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());
|
||||
|
|
@ -419,7 +413,6 @@ 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).
|
||||
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);
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 139 B After Width: | Height: | Size: 169 B |
Binary file not shown.
|
Before Width: | Height: | Size: 893 B After Width: | Height: | Size: 913 B |
Binary file not shown.
|
Before Width: | Height: | Size: 892 B After Width: | Height: | Size: 911 B |
|
|
@ -48,8 +48,8 @@
|
|||
side="left"
|
||||
button_display_mode="icons_only">
|
||||
<icon layout="topleft"
|
||||
height="7"
|
||||
width="5"
|
||||
height="10"
|
||||
width="10"
|
||||
follows="left|top"
|
||||
top="20"
|
||||
left="10"
|
||||
|
|
@ -99,8 +99,8 @@
|
|||
side="right"
|
||||
button_display_mode="icons_only">
|
||||
<icon layout="topleft"
|
||||
height="7"
|
||||
width="5"
|
||||
height="10"
|
||||
width="10"
|
||||
follows="left|top"
|
||||
top="20"
|
||||
left="10"
|
||||
|
|
@ -130,13 +130,14 @@
|
|||
button_display_mode="icons_with_text"
|
||||
visible="true">
|
||||
<icon layout="topleft"
|
||||
height="5"
|
||||
width="7"
|
||||
height="10"
|
||||
width="10"
|
||||
follows="left|top"
|
||||
top="20"
|
||||
left="10"
|
||||
tab_stop="false"
|
||||
visible="false"
|
||||
use_draw_context_alpha="false"
|
||||
image_name="Caret_Bottom_Icon"
|
||||
name="caret" />
|
||||
</toolbar>
|
||||
|
|
|
|||
Loading…
Reference in New Issue