PageRenderTime 50ms CodeModel.GetById 29ms app.highlight 16ms RepoModel.GetById 2ms app.codeStats 0ms

/indra/newview/llfavoritesbar.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 165 lines | 86 code | 37 blank | 42 comment | 0 complexity | a8ac4053c33633729cf945ce87393106 MD5 | raw file
  1/** 
  2 * @file llfavoritesbar.h
  3 * @brief LLFavoritesBarCtrl base class
  4 *
  5 * $LicenseInfo:firstyear=2009&license=viewerlgpl$
  6 * Second Life Viewer Source Code
  7 * Copyright (C) 2010, Linden Research, Inc.
  8 * 
  9 * This library is free software; you can redistribute it and/or
 10 * modify it under the terms of the GNU Lesser General Public
 11 * License as published by the Free Software Foundation;
 12 * version 2.1 of the License only.
 13 * 
 14 * This library is distributed in the hope that it will be useful,
 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 17 * Lesser General Public License for more details.
 18 * 
 19 * You should have received a copy of the GNU Lesser General Public
 20 * License along with this library; if not, write to the Free Software
 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 22 * 
 23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 24 * $/LicenseInfo$
 25 */
 26
 27#ifndef LL_LLFAVORITESBARCTRL_H
 28#define LL_LLFAVORITESBARCTRL_H
 29
 30#include "llbutton.h"
 31#include "lluictrl.h"
 32#include "lltextbox.h"
 33
 34#include "llinventoryobserver.h"
 35#include "llinventorymodel.h"
 36
 37class LLMenuItemCallGL;
 38class LLToggleableMenu;
 39
 40class LLFavoritesBarCtrl : public LLUICtrl, public LLInventoryObserver
 41{
 42public:
 43	struct Params : public LLInitParam::Block<Params, LLUICtrl::Params>
 44	{
 45		Optional<LLUIImage*> image_drag_indication;
 46		Optional<LLTextBox::Params> more_button;
 47		Optional<LLTextBox::Params> label;
 48		Params();
 49	};
 50
 51protected:
 52	LLFavoritesBarCtrl(const Params&);
 53	friend class LLUICtrlFactory;
 54public:
 55	virtual ~LLFavoritesBarCtrl();
 56
 57	/*virtual*/ BOOL postBuild();
 58
 59	/*virtual*/ BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
 60								   EDragAndDropType cargo_type,
 61								   void* cargo_data,
 62								   EAcceptance* accept,
 63								   std::string& tooltip_msg);
 64
 65	/*virtual*/ BOOL	handleHover(S32 x, S32 y, MASK mask);
 66	/*virtual*/ BOOL	handleRightMouseDown(S32 x, S32 y, MASK mask);
 67	// LLInventoryObserver observer trigger
 68	virtual void changed(U32 mask);
 69	virtual void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
 70	virtual void draw();
 71
 72	void showDragMarker(BOOL show) { mShowDragMarker = show; }
 73	void setLandingTab(LLUICtrl* tab) { mLandingTab = tab; }
 74
 75protected:
 76	void updateButtons();
 77	LLButton* createButton(const LLPointer<LLViewerInventoryItem> item, const LLButton::Params& button_params, S32 x_offset );
 78	const LLButton::Params& getButtonParams();
 79	BOOL collectFavoriteItems(LLInventoryModel::item_array_t &items);
 80
 81	void onButtonClick(LLUUID id);
 82	void onButtonRightClick(LLUUID id,LLView* button,S32 x,S32 y,MASK mask);
 83	
 84	void onButtonMouseDown(LLUUID id, LLUICtrl* button, S32 x, S32 y, MASK mask);
 85	void onOverflowMenuItemMouseDown(LLUUID id, LLUICtrl* item, S32 x, S32 y, MASK mask);
 86	void onButtonMouseUp(LLUUID id, LLUICtrl* button, S32 x, S32 y, MASK mask);
 87
 88	void onEndDrag();
 89
 90	bool enableSelected(const LLSD& userdata);
 91	void doToSelected(const LLSD& userdata);
 92	BOOL isClipboardPasteable() const;
 93	void pastFromClipboard() const;
 94	
 95	void showDropDownMenu();
 96
 97	LLHandle<LLView> mOverflowMenuHandle;
 98	LLHandle<LLView> mContextMenuHandle;
 99
100	LLUUID mFavoriteFolderId;
101	const LLFontGL *mFont;
102	S32 mFirstDropDownItem;
103	bool mUpdateDropDownItems;
104	bool mRestoreOverflowMenu;
105
106	LLUUID mSelectedItemID;
107
108	LLUIImage* mImageDragIndication;
109
110private:
111	/*
112	 * Helper function to make code more readable. It handles all drag and drop
113	 * operations of the existing favorites items on the favorites bar.
114	 */
115	void handleExistingFavoriteDragAndDrop(S32 x, S32 y);
116
117	/*
118	 * Helper function to make code more readable. It handles all drag and drop
119	 * operations of the new landmark to the favorites bar.
120	 */
121	void handleNewFavoriteDragAndDrop(LLInventoryItem *item, const LLUUID& favorites_id, S32 x, S32 y);
122
123	// finds a control under the specified LOCAL point
124	LLUICtrl* findChildByLocalCoords(S32 x, S32 y);
125
126	// checks if the current order of the favorites items must be saved
127	BOOL needToSaveItemsOrder(const LLInventoryModel::item_array_t& items);
128
129	/**
130	 * inserts an item identified by insertedItemId BEFORE an item identified by beforeItemId.
131	 * this function assumes that an item identified by insertedItemId doesn't exist in items array.
132	 */
133	void insertItem(LLInventoryModel::item_array_t& items, const LLUUID& dest_item_id, LLViewerInventoryItem* insertedItem, bool insert_before);
134
135	// finds an item by it's UUID in the items array
136	LLInventoryModel::item_array_t::iterator findItemByUUID(LLInventoryModel::item_array_t& items, const LLUUID& id);
137
138	void createOverflowMenu();
139
140	void updateMenuItems(LLToggleableMenu* menu);
141
142	// Fits menu item label width with favorites menu width
143	void fitLabelWidth(LLMenuItemCallGL* menu_item);
144
145	void addOpenLandmarksMenuItem(LLToggleableMenu* menu);
146
147	void positionAndShowMenu(LLToggleableMenu* menu);
148
149	BOOL mShowDragMarker;
150	LLUICtrl* mLandingTab;
151	LLUICtrl* mLastTab;
152	LLTextBox* mMoreTextBox;
153	LLTextBox* mBarLabel;
154
155	LLUUID mDragItemId;
156	BOOL mStartDrag;
157	LLInventoryModel::item_array_t mItems;
158
159	BOOL mTabsHighlightEnabled;
160
161	boost::signals2::connection mEndDragConnection;
162};
163
164
165#endif // LL_LLFAVORITESBARCTRL_H