summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMerov Linden <merov@lindenlab.com>2011-10-07 18:30:57 -0700
committerMerov Linden <merov@lindenlab.com>2011-10-07 18:30:57 -0700
commitfeabe29f356ca2bae5275a5cb0d772614166d2c5 (patch)
tree178bc8f6022374ca28bf16a00f74e0cd3e5937b3
parent8919ef0ea442ae13076705d881b5e67cf8bed606 (diff)
EXP-1300 : Completed the drawing of drop zones on toolbars when dragging tools
-rw-r--r--indra/llui/lltoolbar.cpp4
-rw-r--r--indra/llui/lltoolbar.h6
-rw-r--r--indra/newview/llfloatertoybox.cpp6
-rw-r--r--indra/newview/lltoolbarview.cpp69
-rw-r--r--indra/newview/lltoolbarview.h7
-rw-r--r--indra/newview/skins/default/colors.xml4
-rw-r--r--indra/newview/skins/default/xui/en/panel_toolbar_view.xml12
-rw-r--r--indra/newview/skins/default/xui/en/widgets/toolbar.xml1
8 files changed, 63 insertions, 46 deletions
diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp
index 1f5fa5f361..5f7afb07fc 100644
--- a/indra/llui/lltoolbar.cpp
+++ b/indra/llui/lltoolbar.cpp
@@ -86,6 +86,7 @@ LLToolBar::Params::Params()
pad_right("pad_right"),
pad_bottom("pad_bottom"),
pad_between("pad_between"),
+ min_girth("min_girth"),
button_panel("button_panel")
{}
@@ -103,6 +104,7 @@ LLToolBar::LLToolBar(const LLToolBar::Params& p)
mPadTop(p.pad_top),
mPadBottom(p.pad_bottom),
mPadBetween(p.pad_between),
+ mMinGirth(p.min_girth),
mPopupMenuHandle(),
mStartDragItemCallback(NULL),
mHandleDragItemCallback(NULL),
@@ -517,6 +519,8 @@ void LLToolBar::updateLayoutAsNeeded()
S32 total_girth = cur_row // current row position...
+ max_row_girth // ...incremented by size of final row...
+ girth_pad_end; // ...plus padding reserved on end
+ total_girth = llmax(total_girth,mMinGirth);
+
max_row_length = llmax(max_row_length, row_running_length - mPadBetween + row_pad_end);
resizeButtonsInRow(buttons_in_row, max_row_girth);
diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h
index 4fac081130..be0589f3c6 100644
--- a/indra/llui/lltoolbar.h
+++ b/indra/llui/lltoolbar.h
@@ -141,7 +141,8 @@ public:
pad_top,
pad_right,
pad_bottom,
- pad_between;
+ pad_between,
+ min_girth;
// get rid of this
Multiple<LLCommandId::Params> commands;
@@ -219,7 +220,8 @@ private:
mPadRight,
mPadTop,
mPadBottom,
- mPadBetween;
+ mPadBetween,
+ mMinGirth;
LLToolBarButton::Params mButtonParams[LLToolBarEnums::BTNTYPE_COUNT];
diff --git a/indra/newview/llfloatertoybox.cpp b/indra/newview/llfloatertoybox.cpp
index 58bb417b71..609041803a 100644
--- a/indra/newview/llfloatertoybox.cpp
+++ b/indra/newview/llfloatertoybox.cpp
@@ -62,9 +62,9 @@ BOOL LLFloaterToybox::postBuild()
mBtnRestoreDefaults = getChild<LLButton>("btn_restore_defaults");
mToolBar = getChild<LLToolBar>("toybox_toolbar");
- mToolBar->setStartDragCallback(boost::bind(LLToolBarView::startDragItem,_1,_2,_3));
- mToolBar->setHandleDragCallback(boost::bind(LLToolBarView::handleDragItem,_1,_2,_3,_4));
- mToolBar->setHandleDropCallback(boost::bind(LLToolBarView::handleDrop,_1,_2,_3,_4));
+ mToolBar->setStartDragCallback(boost::bind(LLToolBarView::startDragTool,_1,_2,_3));
+ mToolBar->setHandleDragCallback(boost::bind(LLToolBarView::handleDragTool,_1,_2,_3,_4));
+ mToolBar->setHandleDropCallback(boost::bind(LLToolBarView::handleDropTool,_1,_2,_3,_4));
LLCommandManager& cmdMgr = LLCommandManager::instance();
diff --git a/indra/newview/lltoolbarview.cpp b/indra/newview/lltoolbarview.cpp
index 95ed603bbf..8c7dc53af0 100644
--- a/indra/newview/lltoolbarview.cpp
+++ b/indra/newview/lltoolbarview.cpp
@@ -43,6 +43,11 @@ LLToolBarView* gToolBarView = NULL;
static LLDefaultChildRegistry::Register<LLToolBarView> r("toolbar_view");
bool LLToolBarView::sDragStarted = false;
+bool isToolDragged()
+{
+ return (LLToolDragAndDrop::getInstance()->getSource() == LLToolDragAndDrop::SOURCE_VIEWER);
+}
+
LLToolBarView::Toolbar::Toolbar()
: button_display_mode("button_display_mode"),
commands("command")
@@ -80,17 +85,17 @@ BOOL LLToolBarView::postBuild()
mToolbarRight = getChild<LLToolBar>("toolbar_right");
mToolbarBottom = getChild<LLToolBar>("toolbar_bottom");
- mToolbarLeft->setStartDragCallback(boost::bind(LLToolBarView::startDragItem,_1,_2,_3));
- mToolbarLeft->setHandleDragCallback(boost::bind(LLToolBarView::handleDragItem,_1,_2,_3,_4));
- mToolbarLeft->setHandleDropCallback(boost::bind(LLToolBarView::handleDrop,_1,_2,_3,_4));
+ mToolbarLeft->setStartDragCallback(boost::bind(LLToolBarView::startDragTool,_1,_2,_3));
+ mToolbarLeft->setHandleDragCallback(boost::bind(LLToolBarView::handleDragTool,_1,_2,_3,_4));
+ mToolbarLeft->setHandleDropCallback(boost::bind(LLToolBarView::handleDropTool,_1,_2,_3,_4));
- mToolbarRight->setStartDragCallback(boost::bind(LLToolBarView::startDragItem,_1,_2,_3));
- mToolbarRight->setHandleDragCallback(boost::bind(LLToolBarView::handleDragItem,_1,_2,_3,_4));
- mToolbarRight->setHandleDropCallback(boost::bind(LLToolBarView::handleDrop,_1,_2,_3,_4));
+ mToolbarRight->setStartDragCallback(boost::bind(LLToolBarView::startDragTool,_1,_2,_3));
+ mToolbarRight->setHandleDragCallback(boost::bind(LLToolBarView::handleDragTool,_1,_2,_3,_4));
+ mToolbarRight->setHandleDropCallback(boost::bind(LLToolBarView::handleDropTool,_1,_2,_3,_4));
- mToolbarBottom->setStartDragCallback(boost::bind(LLToolBarView::startDragItem,_1,_2,_3));
- mToolbarBottom->setHandleDragCallback(boost::bind(LLToolBarView::handleDragItem,_1,_2,_3,_4));
- mToolbarBottom->setHandleDropCallback(boost::bind(LLToolBarView::handleDrop,_1,_2,_3,_4));
+ mToolbarBottom->setStartDragCallback(boost::bind(LLToolBarView::startDragTool,_1,_2,_3));
+ mToolbarBottom->setHandleDragCallback(boost::bind(LLToolBarView::handleDragTool,_1,_2,_3,_4));
+ mToolbarBottom->setHandleDropCallback(boost::bind(LLToolBarView::handleDropTool,_1,_2,_3,_4));
return TRUE;
}
@@ -306,37 +311,34 @@ void LLToolBarView::draw()
mToolbarRight->localRectToOtherView(mToolbarRight->getLocalRect(), &right_rect, this);
}
- // Debug draw
- LLColor4 back_color = LLColor4::blue;
- LLColor4 back_color_vert = LLColor4::red;
- LLColor4 back_color_hori = LLColor4::yellow;
- back_color[VALPHA] = 0.5f;
- back_color_hori[VALPHA] = 0.5f;
- back_color_vert[VALPHA] = 0.5f;
- //gl_rect_2d(getLocalRect(), back_color, TRUE);
- //gl_rect_2d(bottom_rect, back_color_hori, TRUE);
- //gl_rect_2d(left_rect, back_color_vert, TRUE);
- //gl_rect_2d(right_rect, back_color_vert, TRUE);
+ // Draw drop zones if drop of a tool is active
+ if (isToolDragged())
+ {
+ LLColor4 drop_color = LLUIColorTable::instance().getColor( "ToolbarDropZoneColor" );
+ gl_rect_2d(bottom_rect, drop_color, TRUE);
+ gl_rect_2d(left_rect, drop_color, TRUE);
+ gl_rect_2d(right_rect, drop_color, TRUE);
+ }
LLUICtrl::draw();
}
// ----------------------------------------
-// Drag and Drop hacks (under construction)
+// Drag and Drop Handling
// ----------------------------------------
-void LLToolBarView::startDragItem( S32 x, S32 y, const LLUUID& uuid)
+void LLToolBarView::startDragTool( S32 x, S32 y, const LLUUID& uuid)
{
- //llinfos << "Merov debug: startDragItem() : x = " << x << ", y = " << y << llendl;
+ //llinfos << "Merov debug: startDragTool() : x = " << x << ", y = " << y << llendl;
LLToolDragAndDrop::getInstance()->setDragStart( x, y );
sDragStarted = false;
}
-BOOL LLToolBarView::handleDragItem( S32 x, S32 y, const LLUUID& uuid, LLAssetType::EType type)
+BOOL LLToolBarView::handleDragTool( S32 x, S32 y, const LLUUID& uuid, LLAssetType::EType type)
{
-// llinfos << "Merov debug: handleDragItem() : x = " << x << ", y = " << y << ", uuid = " << uuid << llendl;
+// llinfos << "Merov debug: handleDragTool() : x = " << x << ", y = " << y << ", uuid = " << uuid << llendl;
if (LLToolDragAndDrop::getInstance()->isOverThreshold( x, y ))
{
if (!sDragStarted)
@@ -348,7 +350,7 @@ BOOL LLToolBarView::handleDragItem( S32 x, S32 y, const LLUUID& uuid, LLAssetTyp
gClipboard.setSourceObject(uuid,LLAssetType::AT_WIDGET);
LLToolDragAndDrop::ESource src = LLToolDragAndDrop::SOURCE_VIEWER;
LLUUID srcID;
- //llinfos << "Merov debug: handleDragItem() : beginMultiDrag()" << llendl;
+ //llinfos << "Merov debug: handleDragTool() : beginMultiDrag()" << llendl;
LLToolDragAndDrop::getInstance()->beginMultiDrag(types, cargo_ids, src, srcID);
sDragStarted = true;
return TRUE;
@@ -362,15 +364,15 @@ BOOL LLToolBarView::handleDragItem( S32 x, S32 y, const LLUUID& uuid, LLAssetTyp
return FALSE;
}
-BOOL LLToolBarView::handleDrop( void* cargo_data, S32 x, S32 y, LLToolBar* toolbar)
+BOOL LLToolBarView::handleDropTool( void* cargo_data, S32 x, S32 y, LLToolBar* toolbar)
{
LLInventoryItem* inv_item = (LLInventoryItem*)cargo_data;
- //llinfos << "Merov debug : handleDrop. Drop " << inv_item->getUUID() << " named " << inv_item->getName() << " of type " << inv_item->getType() << llendl;
-
+ //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 : handleDrop. Drop source is a widget -> drop it in place..." << llendl;
+ //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());
@@ -399,8 +401,11 @@ BOOL LLToolBarView::handleDrop( void* cargo_data, S32 x, S32 y, LLToolBar* toolb
llwarns << "Command couldn't be found in command manager" << llendl;
}
}
-
+ stopDragTool();
return TRUE;
}
-
+void LLToolBarView::stopDragTool()
+{
+ sDragStarted = false;
+}
diff --git a/indra/newview/lltoolbarview.h b/indra/newview/lltoolbarview.h
index 414fcd8751..a0c526ac54 100644
--- a/indra/newview/lltoolbarview.h
+++ b/indra/newview/lltoolbarview.h
@@ -74,9 +74,10 @@ public:
static bool loadDefaultToolbars();
- static void startDragItem( S32 x, S32 y, const LLUUID& uuid);
- static BOOL handleDragItem( S32 x, S32 y, const LLUUID& uuid, LLAssetType::EType type);
- static BOOL handleDrop( void* cargo_data, S32 x, S32 y, LLToolBar* toolbar);
+ static void startDragTool( S32 x, S32 y, const LLUUID& uuid);
+ static BOOL handleDragTool( S32 x, S32 y, const LLUUID& uuid, LLAssetType::EType type);
+ static BOOL handleDropTool( void* cargo_data, S32 x, S32 y, LLToolBar* toolbar);
+ static void stopDragTool();
protected:
friend class LLUICtrlFactory;
diff --git a/indra/newview/skins/default/colors.xml b/indra/newview/skins/default/colors.xml
index b5cc949ebf..8baaa14595 100644
--- a/indra/newview/skins/default/colors.xml
+++ b/indra/newview/skins/default/colors.xml
@@ -795,6 +795,10 @@
<color
name="DirectChatColor"
reference="LtOrange" />
+
+ <color
+ name="ToolbarDropZoneColor"
+ value=".48 .69 1 .5" />
<!-- Generic color names (legacy) -->
<color
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 44da813f61..7289001481 100644
--- a/indra/newview/skins/default/xui/en/panel_toolbar_view.xml
+++ b/indra/newview/skins/default/xui/en/panel_toolbar_view.xml
@@ -41,10 +41,10 @@
<toolbar follows="left|top|bottom"
button_panel.bg_opaque_image="Rounded_Rect_Right"
name="toolbar_left"
- height="500"
+ height="483"
width="30"
left="0"
- top="0"
+ top="10"
side="left"
button_display_mode="icons_only">
</toolbar>
@@ -63,10 +63,10 @@
button_panel.bg_opaque_image="Rounded_Rect_Left"
follows="right|top|bottom"
name="toolbar_right"
- height="500"
+ height="483"
width="30"
left="0"
- top="0"
+ top="10"
side="right"
button_display_mode="icons_only">
</toolbar>
@@ -83,8 +83,8 @@
button_panel.bg_opaque_image="Rounded_Rect_Top"
name="toolbar_bottom"
height="30"
- width="1024"
- left="0"
+ width="944"
+ left="40"
top="0"
side="bottom"
follows="left|right|bottom"
diff --git a/indra/newview/skins/default/xui/en/widgets/toolbar.xml b/indra/newview/skins/default/xui/en/widgets/toolbar.xml
index 613dc66762..d36b015005 100644
--- a/indra/newview/skins/default/xui/en/widgets/toolbar.xml
+++ b/indra/newview/skins/default/xui/en/widgets/toolbar.xml
@@ -4,6 +4,7 @@
pad_top="1"
pad_bottom="1"
pad_between="1"
+ min_girth="24"
mouse_opaque="false"
read_only="false">
<button_panel name="button_panel"