summaryrefslogtreecommitdiff
path: root/indra/newview/llbottomtray.h
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llbottomtray.h')
-rw-r--r--indra/newview/llbottomtray.h136
1 files changed, 115 insertions, 21 deletions
diff --git a/indra/newview/llbottomtray.h b/indra/newview/llbottomtray.h
index 05fed53936..1197c5a10a 100644
--- a/indra/newview/llbottomtray.h
+++ b/indra/newview/llbottomtray.h
@@ -2,31 +2,25 @@
* @file llbottomtray.h
* @brief LLBottomTray class header file
*
-* $LicenseInfo:firstyear=2009&license=viewergpl$
-*
-* Copyright (c) 2009, Linden Research, Inc.
-*
+* $LicenseInfo:firstyear=2009&license=viewerlgpl$
* Second Life Viewer Source Code
-* The source code in this file ("Source Code") is provided by Linden Lab
-* to you under the terms of the GNU General Public License, version 2.0
-* ("GPL"), unless you have obtained a separate licensing agreement
-* ("Other License"), formally executed by you and Linden Lab. Terms of
-* the GPL can be found in doc/GPL-license.txt in this distribution, or
-* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+* Copyright (C) 2010, Linden Research, Inc.
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License as published by the Free Software Foundation;
+* version 2.1 of the License only.
*
-* There are special exceptions to the terms and conditions of the GPL as
-* it is applied to this Source Code. View the full text of the exception
-* in the file doc/FLOSS-exception.txt in this software distribution, or
-* online at
-* http://secondlifegrid.net/programs/open_source/licensing/flossexception
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
*
-* By copying, modifying or distributing this software, you acknowledge
-* that you have read and understood your obligations described above,
-* and agree to abide by those obligations.
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
-* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
-* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
-* COMPLETENESS OR PERFORMANCE.
+* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
@@ -53,6 +47,30 @@ class LLBottomTrayLite;
extern template class LLBottomTray* LLSingleton<class LLBottomTray>::getInstance();
#endif
+/**
+ * Class for buttons that should have drag'n'drop ability in bottomtray.
+ * These buttons pass mouse events handling to bottomtray.
+ */
+class LLBottomtrayButton : public LLButton
+{
+public:
+ struct Params : public LLInitParam::Block<Params, LLButton::Params>
+ {
+ Params(){}
+ };
+ /*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask);
+ /*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask);
+ /*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask);
+
+protected:
+ LLBottomtrayButton(const Params& p)
+ : LLButton(p)
+ {
+
+ }
+ friend class LLUICtrlFactory;
+};
+
class LLBottomTray
: public LLSingleton<LLBottomTray>
, public LLPanel
@@ -107,6 +125,20 @@ public:
*/
LLIMChiclet* createIMChiclet(const LLUUID& session_id);
+ // Below are methods that were introduced or overriden in bottomtray to handle drag'n'drop
+
+ virtual void draw();
+
+ /**
+ * These three methods handle drag'n'drop, they may be called directly from child buttons.
+ * handleHover and other virtual handle* couldn't be used here, because we should call LLPanel::handle*,
+ * but x and y here are often outside of bottomtray.
+ */
+ void onDraggableButtonHover(S32 x, S32 y);
+ void onDraggableButtonMouseDown(LLUICtrl* button, S32 x, S32 y);
+ void onDraggableButtonMouseUp(LLUICtrl* button, S32 x, S32 y);
+
+
private:
typedef enum e_resize_status_type
{
@@ -140,6 +172,29 @@ private:
| RS_BUTTON_BUILD | RS_BUTTON_SEARCH | RS_BUTTON_WORLD_MAP | RS_BUTTON_MINI_MAP
}EResizeState;
+ // Below are three methods that were introduced to handle drag'n'drop
+
+ /**
+ * finds a panel under the specified LOCAL point
+ */
+ LLPanel* findChildPanelByLocalCoords(S32 x, S32 y);
+
+ /**
+ * checks whether the cursor is over an area where the dragged button may be dropped
+ */
+ bool isCursorOverDraggableArea(S32 x, S32 y);
+
+ /**
+ * Updates process(shrink/show/hide) order of buttons and order in which they'll be stored for further save/load.
+ * It is called when dragged button is dropped
+ */
+ void updateButtonsOrdersAfterDnD();
+
+ // saves order of buttons to file on disk
+ void saveButtonsOrder();
+ // reads order of buttons from file on disk
+ void loadButtonsOrder();
+
/**
* Updates child controls size and visibility when it is necessary to reduce total width.
*
@@ -366,6 +421,13 @@ private:
* Contains order in which child buttons should be processed in show/hide, extend/shrink methods.
*/
resize_state_vec_t mButtonsProcessOrder;
+ /**
+ * Contains order in which child buttons are shown.
+ * It traces order of all bottomtray buttons that may change place via drag'n'drop and should
+ * save and load it between sessions. mButtonsProcessOrder is not enough for it because it contains only
+ * buttons that may be hidden.
+ */
+ resize_state_vec_t mButtonsOrder;
protected:
@@ -387,6 +449,38 @@ protected:
LLButton* mMovementButton;
LLBottomTrayLite* mBottomTrayLite;
bool mIsInLiteMode;
+
+ // Drag'n'Drop
+
+ /**
+ * Is true if mouse down happened on draggable button.
+ * Set false whether on drag start or on mouse up.
+ */
+ bool mCheckForDrag;
+ /**
+ * These two variables hold corrdinates of mouse down on draggable button.
+ * They are used to compare with current coordinates of cursor and determine whether drag'n'drop should start.
+ */
+ S32 mStartX;
+ S32 mStartY;
+ /**
+ * True if drag'n'drop is happening.
+ */
+ bool mDragStarted;
+
+ /**
+ * Pointer to panel which is currently dragged (though it seems to user that button is dragged,
+ * we are changing place of layout panel).
+ */
+ LLPanel* mDraggedItem;
+ /**
+ * Panel before which the dragged button will be inserted.
+ */
+ LLPanel* mLandingTab;
+ /**
+ * Image used to show position where dragged button will be dropped.
+ */
+ LLUIImage* mImageDragIndication;
};
#endif // LL_LLBOTTOMPANEL_H