diff options
author | Andrew Dyukov <adyukov@productengine.com> | 2010-09-06 21:35:01 +0300 |
---|---|---|
committer | Andrew Dyukov <adyukov@productengine.com> | 2010-09-06 21:35:01 +0300 |
commit | e04dabd2b3309b595bbc1afa0dfa7d4081439eba (patch) | |
tree | cd4cf9f42953b7ac3cc7ecfe1be08c7cf0a9e934 /indra/newview/llbottomtray.h | |
parent | ebfbaad9696ce0389ed1a9642d58dfb4a0abdc17 (diff) |
VWR-20705 VWR-20706 FIXED Implemented drag'n'drop of buttons in bottomtray.
- Though visually user drags buttons, layout panels are really moved. To move one panel before other, new method movePanelBeforeOther() was added to layout stack.
- When drag'n'drop is finished, order of panels in layout stack mToolbarStack is changed, and also order vectors are updated in bottomtray.These are vectors mButtonsProcessOrder and mButtonsOrder. mButtonsOrder was introduced in this changeset to store 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(and for example Speak button is not included in it).
- To pass mouse events from buttons to bottomtray, new class LLBottomtrayButton was added (and new widget bottomtray_button for it).
Reviewed by Vadim Savchuk.
Diffstat (limited to 'indra/newview/llbottomtray.h')
-rw-r--r-- | indra/newview/llbottomtray.h | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/indra/newview/llbottomtray.h b/indra/newview/llbottomtray.h index bd9d35f209..6697d6f679 100644 --- a/indra/newview/llbottomtray.h +++ b/indra/newview/llbottomtray.h @@ -47,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::LLBottomtrayButton(const Params& p) + : LLButton(p) + { + + } + friend class LLUICtrlFactory; +}; + class LLBottomTray : public LLSingleton<LLBottomTray> , public LLPanel @@ -101,6 +125,18 @@ 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. + */ + /*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask); + void onDraggableButtonMouseDown(LLUICtrl* button, S32 x, S32 y, MASK mask); + void onDraggableButtonMouseUp(LLUICtrl* button, S32 x, S32 y, MASK mask); + + private: typedef enum e_resize_status_type { @@ -134,6 +170,24 @@ 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(); + /** * Updates child controls size and visibility when it is necessary to reduce total width. * @@ -360,6 +414,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: @@ -381,6 +442,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 |