diff options
-rw-r--r-- | indra/llui/lltoolbar.cpp | 92 | ||||
-rw-r--r-- | indra/llui/lltoolbar.h | 6 | ||||
-rw-r--r-- | indra/newview/lltoolbarview.cpp | 4 | ||||
-rw-r--r-- | indra/newview/skins/default/textures/textures.xml | 6 | ||||
-rw-r--r-- | indra/newview/skins/default/textures/toolbar_icons/caret_bottom.png | bin | 169 -> 195 bytes | |||
-rw-r--r-- | indra/newview/skins/default/textures/toolbar_icons/caret_left.png | bin | 913 -> 948 bytes | |||
-rw-r--r-- | indra/newview/skins/default/textures/toolbar_icons/caret_right.png | bin | 911 -> 949 bytes | |||
-rw-r--r-- | indra/newview/skins/default/xui/en/panel_toolbar_view.xml | 12 |
8 files changed, 81 insertions, 39 deletions
diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index a1ea4ba18b..ce3ef1db97 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -395,12 +395,14 @@ void LLToolBar::resizeButtonsInRow(std::vector<LLToolBarButton*>& buttons_in_row // Returns the position of the coordinates as a rank in the button list. // 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 +// The returned value 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) +// Various drag data are stored in the toolbar object though are not exposed outside (and shouldn't). +int LLToolBar::getRankFromPosition(S32 x, S32 y) { int rank = 0; + // Convert the toolbar coord into button panel coords LLLayoutStack::ELayoutOrientation orientation = getOrientation(mSideType); S32 button_panel_x = 0; S32 button_panel_y = 0; @@ -408,32 +410,72 @@ int LLToolBar::getRankFromPosition(S32& x, S32& y) S32 dx = x - button_panel_x; S32 dy = y - button_panel_y; - // Simply compare the passed coord with the buttons outbound box + // Simply compare the passed coord with the buttons outbound box + padding std::list<LLToolBarButton*>::iterator it_button = mButtons.begin(); std::list<LLToolBarButton*>::iterator end_button = mButtons.end(); LLRect button_rect; while (it_button != end_button) { button_rect = (*it_button)->getRect(); - if (((orientation == LLLayoutStack::HORIZONTAL) && (button_rect.mRight > button_panel_x)) || - ((orientation == LLLayoutStack::VERTICAL) && (button_rect.mBottom < button_panel_y)) ) + S32 point_x, point_y; + if (orientation == LLLayoutStack::HORIZONTAL) + { + // Horizontal + point_x = (button_rect.mRight + button_rect.mLeft) / 2; + point_y = button_rect.mBottom - mPadBottom; + } + else + { + // Vertical + point_x = button_rect.mRight + mPadRight; + point_y = (button_rect.mTop + button_rect.mBottom) / 2; + } + + if ((button_panel_x < point_x) && (button_panel_y > point_y)) { break; } + mDragCommand = (*it_button)->mId; rank++; ++it_button; } - if (it_button != end_button) + + // Update the passed coordinates to the hit button relevant corner + // (different depending on toolbar orientation) + if (rank < mButtons.size()) { - x = button_rect.mLeft + dx; - y = button_rect.mTop + dy; + mDragx = button_rect.mLeft - mPadLeft; + mDragy = button_rect.mTop + mPadTop; } else { - x = button_rect.mRight + dx; - y = button_rect.mBottom + dy; + // We hit passed the end of the list so put the insertion point at the end + if (orientation == LLLayoutStack::HORIZONTAL) + { + mDragx = button_rect.mRight + mPadRight; + mDragy = button_rect.mTop + mPadTop; + } + else + { + mDragx = button_rect.mLeft - mPadLeft; + mDragy = button_rect.mBottom - mPadBottom; + } + } + + // Update the "girth" of the caret, i.e. the width or height (depending of orientation) + if (orientation == LLLayoutStack::HORIZONTAL) + { + mDragGirth = button_rect.getHeight() + mPadBottom + mPadTop; + } + else + { + mDragGirth = button_rect.getWidth() + mPadLeft + mPadRight; } + // The delta account for the coord model change (i.e. convert back to toolbar coord) + mDragx += dx; + mDragy += dy; + return rank; } @@ -628,26 +670,18 @@ void LLToolBar::draw() { LLRect caret_rect = caret->getRect(); LLRect toolbar_rect = getRect(); - if (mSideType == SIDE_BOTTOM) + if (getOrientation(mSideType) == LLLayoutStack::HORIZONTAL) { caret->setRect(LLRect(mDragx-caret_rect.getWidth()/2+1, - toolbar_rect.getHeight()+3, + mDragy, 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)); + mDragy-mDragGirth)); } else { - caret->setRect(LLRect(-3, + caret->setRect(LLRect(mDragx, mDragy+caret_rect.getHeight()/2, - caret_rect.getWidth()-3, + mDragx+mDragGirth, mDragy-caret_rect.getHeight()/2)); } caret->setVisible(TRUE); @@ -791,16 +825,20 @@ BOOL LLToolBar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, LLAssetType::EType type = inv_item->getType(); if (type == LLAssetType::AT_WIDGET) { - mDragx = x; - mDragy = y; - mDragRank = getRankFromPosition(mDragx, mDragy); - mDragAndDropTarget = true; + mDragRank = getRankFromPosition(x, y); + // Don't DaD if we're dragging a command on itself + mDragAndDropTarget = (mDragCommand.uuid() != inv_item->getUUID()); + //llinfos << "Merov debug : DaD, rank = " << mDragRank << ", hit uuid = " << mDragCommand.uuid() << ", dragged uui = " << inv_item->getUUID() << llendl; /* Do the following if you want to animate the button itself LLCommandId dragged_command(inv_item->getUUID()); removeCommand(dragged_command); addCommand(dragged_command,rank); */ } + else + { + handled = FALSE; + } } return handled; diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index 709399c59f..8fd509bacc 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, @@ -192,7 +192,9 @@ protected: bool mDragAndDropTarget; int mDragRank; S32 mDragx, - mDragy; + mDragy, + mDragGirth; + LLCommandId mDragCommand; public: // Methods used in loading and saving toolbar settings diff --git a/indra/newview/lltoolbarview.cpp b/indra/newview/lltoolbarview.cpp index 133835aafc..a3b9552f91 100644 --- a/indra/newview/lltoolbarview.cpp +++ b/indra/newview/lltoolbarview.cpp @@ -394,11 +394,13 @@ BOOL LLToolBarView::handleDragTool( S32 x, S32 y, const LLUUID& uuid, LLAssetTyp 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()); @@ -443,7 +445,7 @@ BOOL LLToolBarView::handleDropTool( void* cargo_data, S32 x, S32 y, LLToolBar* t } } stopDragTool(); - return TRUE; + return handled; } void LLToolBarView::stopDragTool() diff --git a/indra/newview/skins/default/textures/textures.xml b/indra/newview/skins/default/textures/textures.xml index 27577d42ea..c221f683c2 100644 --- a/indra/newview/skins/default/textures/textures.xml +++ b/indra/newview/skins/default/textures/textures.xml @@ -149,9 +149,9 @@ with the same filename but different name <texture name="Command_Speak_Icon" file_name="toolbar_icons/speak.png" preload="true" /> <texture name="Command_View_Icon" file_name="toolbar_icons/view.png" preload="true" /> <texture name="Command_Voice_Icon" file_name="toolbar_icons/nearbyvoice.png" preload="true" /> - <texture name="Caret_Bottom_Icon" file_name="toolbar_icons/caret_bottom.png" preload="true" /> - <texture name="Caret_Right_Icon" file_name="toolbar_icons/caret_right.png" preload="true" /> - <texture name="Caret_Left_Icon" file_name="toolbar_icons/caret_left.png" preload="true" /> + <texture name="Caret_Bottom_Icon" file_name="toolbar_icons/caret_bottom.png" preload="true" scale.left="1" scale.top="23" scale.right="15" scale.bottom="1" /> + <texture name="Caret_Right_Icon" file_name="toolbar_icons/caret_right.png" preload="true" scale.left="5" scale.top="15" scale.right="28" scale.bottom="1" /> + <texture name="Caret_Left_Icon" file_name="toolbar_icons/caret_left.png" preload="true" scale.left="1" scale.top="15" scale.right="23" scale.bottom="1" /> <texture name="ComboButton_Disabled" file_name="widgets/ComboButton_Disabled.png" preload="true" scale.left="2" scale.top="19" scale.right="18" scale.bottom="2" /> <texture name="ComboButton_Selected" file_name="widgets/ComboButton_Selected.png" preload="true" scale.left="2" scale.top="19" scale.right="18" scale.bottom="2" /> diff --git a/indra/newview/skins/default/textures/toolbar_icons/caret_bottom.png b/indra/newview/skins/default/textures/toolbar_icons/caret_bottom.png Binary files differindex d506cda5c9..5f6a01eaa1 100644 --- a/indra/newview/skins/default/textures/toolbar_icons/caret_bottom.png +++ b/indra/newview/skins/default/textures/toolbar_icons/caret_bottom.png diff --git a/indra/newview/skins/default/textures/toolbar_icons/caret_left.png b/indra/newview/skins/default/textures/toolbar_icons/caret_left.png Binary files differindex b1284aaf79..0b8090314c 100644 --- a/indra/newview/skins/default/textures/toolbar_icons/caret_left.png +++ b/indra/newview/skins/default/textures/toolbar_icons/caret_left.png diff --git a/indra/newview/skins/default/textures/toolbar_icons/caret_right.png b/indra/newview/skins/default/textures/toolbar_icons/caret_right.png Binary files differindex bf6a4ed66c..044751560f 100644 --- a/indra/newview/skins/default/textures/toolbar_icons/caret_right.png +++ b/indra/newview/skins/default/textures/toolbar_icons/caret_right.png diff --git a/indra/newview/skins/default/xui/en/panel_toolbar_view.xml b/indra/newview/skins/default/xui/en/panel_toolbar_view.xml index 9ffd62f7a9..5475fcd245 100644 --- a/indra/newview/skins/default/xui/en/panel_toolbar_view.xml +++ b/indra/newview/skins/default/xui/en/panel_toolbar_view.xml @@ -48,8 +48,8 @@ side="left" button_display_mode="icons_only"> <icon layout="topleft" - height="10" - width="10" + height="15" + width="28" follows="left|top" top="20" left="10" @@ -99,8 +99,8 @@ side="right" button_display_mode="icons_only"> <icon layout="topleft" - height="10" - width="10" + height="15" + width="28" follows="left|top" top="20" left="10" @@ -130,8 +130,8 @@ button_display_mode="icons_with_text" visible="true"> <icon layout="topleft" - height="10" - width="10" + height="28" + width="15" follows="left|top" top="20" left="10" |