diff options
author | Merov Linden <merov@lindenlab.com> | 2011-10-11 15:06:16 -0700 |
---|---|---|
committer | Merov Linden <merov@lindenlab.com> | 2011-10-11 15:06:16 -0700 |
commit | 3596c0f7e139724f31258ffb96157146aeba77b1 (patch) | |
tree | a6905a500bf4687a97f7f7ffbc87976f508279d9 /indra/llui | |
parent | 71879916428e9e15081d73696f46bb4a32877265 (diff) |
EXP-1300 : Implemented carets for DaD. Works with small bugs but OK for demo. Still in need of some cleanup
Diffstat (limited to 'indra/llui')
-rw-r--r-- | indra/llui/lltoolbar.cpp | 86 | ||||
-rw-r--r-- | indra/llui/lltoolbar.h | 7 |
2 files changed, 68 insertions, 25 deletions
diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 89184f781f..7c1e2017c0 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -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); diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index ca04a0e5d5..f3457028e7 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -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, |