PageRenderTime 210ms CodeModel.GetById 156ms app.highlight 49ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/llfolderview.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 352 lines | 202 code | 72 blank | 78 comment | 1 complexity | 561037717103cdea1b0c23dba474b419 MD5 | raw file
  1/** 
  2 * @file llfolderview.h
  3 * @brief Definition of the folder view collection of classes.
  4 *
  5 * $LicenseInfo:firstyear=2001&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/**
 28 *
 29 * The folder view collection of classes provides an interface for
 30 * making a 'folder view' similar to the way the a single pane file
 31 * folder interface works.
 32 *
 33 */
 34
 35#ifndef LL_LLFOLDERVIEW_H
 36#define LL_LLFOLDERVIEW_H
 37
 38#include "llfolderviewitem.h"	// because LLFolderView is-a LLFolderViewFolder
 39
 40#include "lluictrl.h"
 41#include "v4color.h"
 42#include "lldarray.h"
 43#include "stdenums.h"
 44#include "lldepthstack.h"
 45#include "lleditmenuhandler.h"
 46#include "llfontgl.h"
 47#include "lltooldraganddrop.h"
 48#include "llviewertexture.h"
 49
 50class LLFolderViewEventListener;
 51class LLFolderViewFolder;
 52class LLFolderViewItem;
 53class LLInventoryModel;
 54class LLPanel;
 55class LLLineEditor;
 56class LLMenuGL;
 57class LLScrollContainer;
 58class LLUICtrl;
 59class LLTextBox;
 60
 61//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 62// Class LLFolderView
 63//
 64// Th LLFolderView represents the root level folder view object. It
 65// manages the screen region of the folder view.
 66//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 67
 68class LLFolderView : public LLFolderViewFolder, public LLEditMenuHandler
 69{
 70public:
 71	struct Params : public LLInitParam::Block<Params, LLFolderViewFolder::Params>
 72	{
 73		Mandatory<LLPanel*>	    parent_panel;
 74		Optional<LLUUID>        task_id;
 75		Optional<std::string>   title;
 76		Optional<bool>			use_label_suffix,
 77								allow_multiselect,
 78								show_empty_message,
 79								show_load_status,
 80								use_ellipses;
 81
 82		Params();
 83	};
 84	LLFolderView(const Params&);
 85	virtual ~LLFolderView( void );
 86
 87	virtual BOOL canFocusChildren() const;
 88
 89	virtual LLFolderView*	getRoot() { return this; }
 90
 91	// FolderViews default to sort by name.  This will change that,
 92	// and resort the items if necessary.
 93	void setSortOrder(U32 order);
 94	void setFilterPermMask(PermissionMask filter_perm_mask);
 95	
 96	typedef boost::signals2::signal<void (const std::deque<LLFolderViewItem*>& items, BOOL user_action)> signal_t;
 97	void setSelectCallback(const signal_t::slot_type& cb) { mSelectSignal.connect(cb); }
 98	void setReshapeCallback(const signal_t::slot_type& cb) { mReshapeSignal.connect(cb); }
 99	
100	// filter is never null
101	LLInventoryFilter* getFilter();
102	const std::string getFilterSubString(BOOL trim = FALSE);
103	U32 getFilterObjectTypes() const;
104	PermissionMask getFilterPermissions() const;
105	// *NOTE: use getFilter()->getShowFolderState();
106	//LLInventoryFilter::EFolderShow getShowFolderState();
107	U32 getSortOrder() const;
108	BOOL isFilterModified();
109
110	bool getAllowMultiSelect() { return mAllowMultiSelect; }
111
112	// Close all folders in the view
113	void closeAllFolders();
114	void openTopLevelFolders();
115
116	virtual void toggleOpen() {};
117	virtual void setOpenArrangeRecursively(BOOL openitem, ERecurseType recurse);
118	virtual BOOL addFolder( LLFolderViewFolder* folder);
119
120	// Finds width and height of this object and it's children.  Also
121	// makes sure that this view and it's children are the right size.
122	virtual S32 arrange( S32* width, S32* height, S32 filter_generation );
123
124	void arrangeAll() { mArrangeGeneration++; }
125	S32 getArrangeGeneration() { return mArrangeGeneration; }
126
127	// applies filters to control visibility of inventory items
128	virtual void filter( LLInventoryFilter& filter);
129
130	// get the last selected item
131	virtual LLFolderViewItem* getCurSelectedItem( void );
132
133	// Record the selected item and pass it down the hierachy.
134	virtual BOOL setSelection(LLFolderViewItem* selection, BOOL openitem,
135		BOOL take_keyboard_focus);
136
137	// Used by menu callbacks
138	void setSelectionByID(const LLUUID& obj_id, BOOL take_keyboard_focus);
139
140	// Called once a frame to update the selection if mSelectThisID has been set
141	void updateSelection();
142
143	// This method is used to toggle the selection of an item. Walks
144	// children, and keeps track of selected objects.
145	virtual BOOL changeSelection(LLFolderViewItem* selection, BOOL selected);
146
147	virtual std::set<LLUUID> getSelectionList() const;
148
149	// make sure if ancestor is selected, descendents are not
150	void sanitizeSelection();
151	void clearSelection();
152	void addToSelectionList(LLFolderViewItem* item);
153	void removeFromSelectionList(LLFolderViewItem* item);
154
155	BOOL startDrag(LLToolDragAndDrop::ESource source);
156	void setDragAndDropThisFrame() { mDragAndDropThisFrame = TRUE; }
157	void setDraggingOverItem(LLFolderViewItem* item) { mDraggingOverItem = item; }
158	LLFolderViewItem* getDraggingOverItem() { return mDraggingOverItem; }
159
160	// deletion functionality
161 	void removeSelectedItems();
162
163	// open the selected item.
164	void openSelectedItems( void );
165	void propertiesSelectedItems( void );
166
167	// change the folder type
168	void changeType(LLInventoryModel *model, LLFolderType::EType new_folder_type);
169
170	void autoOpenItem(LLFolderViewFolder* item);
171	void closeAutoOpenedFolders();
172	BOOL autoOpenTest(LLFolderViewFolder* item);
173
174	// copy & paste
175	virtual void	copy();
176	virtual BOOL	canCopy() const;
177
178	virtual void	cut();
179	virtual BOOL	canCut() const;
180
181	virtual void	paste();
182	virtual BOOL	canPaste() const;
183
184	virtual void	doDelete();
185	virtual BOOL	canDoDelete() const;
186
187	// public rename functionality - can only start the process
188	void startRenamingSelectedItem( void );
189
190	// These functions were used when there was only one folderview,
191	// and relied on that concept. This functionality is now handled
192	// by the listeners and the lldraganddroptool.
193	//LLFolderViewItem*	getMovingItem() { return mMovingItem; }
194	//void setMovingItem( LLFolderViewItem* item ) { mMovingItem = item; }
195	//void				dragItemIntoFolder( LLFolderViewItem* moving_item, LLFolderViewFolder* dst_folder, BOOL drop, BOOL* accept );
196	//void				dragFolderIntoFolder( LLFolderViewFolder* moving_folder, LLFolderViewFolder* dst_folder, BOOL drop, BOOL* accept );
197
198	// LLView functionality
199	///*virtual*/ BOOL handleKey( KEY key, MASK mask, BOOL called_from_parent );
200	/*virtual*/ BOOL handleKeyHere( KEY key, MASK mask );
201	/*virtual*/ BOOL handleUnicodeCharHere(llwchar uni_char);
202	/*virtual*/ BOOL handleMouseDown( S32 x, S32 y, MASK mask );
203	/*virtual*/ BOOL handleDoubleClick( S32 x, S32 y, MASK mask );
204	/*virtual*/ BOOL handleRightMouseDown( S32 x, S32 y, MASK mask );
205	/*virtual*/ BOOL handleHover( S32 x, S32 y, MASK mask );
206	/*virtual*/ BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
207								   EDragAndDropType cargo_type,
208								   void* cargo_data,
209								   EAcceptance* accept,
210								   std::string& tooltip_msg);
211	/*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
212	/*virtual*/ void onMouseLeave(S32 x, S32 y, MASK mask) { setShowSelectionContext(FALSE); }
213	virtual void draw();
214	virtual void deleteAllChildren();
215
216	void scrollToShowSelection();
217	void scrollToShowItem(LLFolderViewItem* item, const LLRect& constraint_rect);
218	void setScrollContainer( LLScrollContainer* parent ) { mScrollContainer = parent; }
219	LLRect getVisibleRect();
220
221	BOOL search(LLFolderViewItem* first_item, const std::string &search_string, BOOL backward);
222	void setShowSelectionContext(BOOL show) { mShowSelectionContext = show; }
223	BOOL getShowSelectionContext();
224	void setShowSingleSelection(BOOL show);
225	BOOL getShowSingleSelection() { return mShowSingleSelection; }
226	F32  getSelectionFadeElapsedTime() { return mMultiSelectionFadeTimer.getElapsedTimeF32(); }
227	bool getUseEllipses() { return mUseEllipses; }
228
229	void addItemID(const LLUUID& id, LLFolderViewItem* itemp);
230	void removeItemID(const LLUUID& id);
231	LLFolderViewItem* getItemByID(const LLUUID& id);
232	LLFolderViewFolder* getFolderByID(const LLUUID& id);
233	
234	bool doToSelected(LLInventoryModel* model, const LLSD& userdata);
235	
236	void	doIdle();						// Real idle routine
237	static void idle(void* user_data);		// static glue to doIdle()
238
239	BOOL needsAutoSelect() { return mNeedsAutoSelect && !mAutoSelectOverride; }
240	BOOL needsAutoRename() { return mNeedsAutoRename; }
241	void setNeedsAutoRename(BOOL val) { mNeedsAutoRename = val; }
242	void setPinningSelectedItem(BOOL val) { mPinningSelectedItem = val; }
243	void setAutoSelectOverride(BOOL val) { mAutoSelectOverride = val; }
244
245	void setCallbackRegistrar(LLUICtrl::CommitCallbackRegistry::ScopedRegistrar* registrar) { mCallbackRegistrar = registrar; }
246
247	BOOL getDebugFilters() { return mDebugFilters; }
248
249	LLPanel* getParentPanel() { return mParentPanel; }
250	// DEBUG only
251	void dumpSelectionInformation();
252
253	virtual S32	notify(const LLSD& info) ;
254	
255	bool useLabelSuffix() { return mUseLabelSuffix; }
256	void updateMenu();
257
258private:
259	void updateMenuOptions(LLMenuGL* menu);
260	void updateRenamerPosition();
261
262protected:
263	LLScrollContainer* mScrollContainer;  // NULL if this is not a child of a scroll container.
264
265	void commitRename( const LLSD& data );
266	void onRenamerLost();
267
268	void finishRenamingItem( void );
269	void closeRenamer( void );
270
271	bool selectFirstItem();
272	bool selectLastItem();
273	
274	BOOL addNoOptions(LLMenuGL* menu) const;
275
276	void onItemsRemovalConfirmation(const LLSD& notification, const LLSD& response);
277
278protected:
279	LLHandle<LLView>					mPopupMenuHandle;
280	
281	typedef std::deque<LLFolderViewItem*> selected_items_t;
282	selected_items_t				mSelectedItems;
283	BOOL							mKeyboardSelection;
284	BOOL							mAllowMultiSelect;
285	BOOL							mShowEmptyMessage;
286	BOOL							mShowFolderHierarchy;
287	LLUUID							mSourceID;
288
289	// Renaming variables and methods
290	LLFolderViewItem*				mRenameItem;  // The item currently being renamed
291	LLLineEditor*					mRenamer;
292
293	BOOL							mNeedsScroll;
294	BOOL							mPinningSelectedItem;
295	LLRect							mScrollConstraintRect;
296	BOOL							mNeedsAutoSelect;
297	BOOL							mAutoSelectOverride;
298	BOOL							mNeedsAutoRename;
299	bool							mUseLabelSuffix;
300	
301	BOOL							mDebugFilters;
302	U32								mSortOrder;
303	LLDepthStack<LLFolderViewFolder>	mAutoOpenItems;
304	LLFolderViewFolder*				mAutoOpenCandidate;
305	LLFrameTimer					mAutoOpenTimer;
306	LLFrameTimer					mSearchTimer;
307	std::string						mSearchString;
308	LLInventoryFilter*				mFilter;
309	BOOL							mShowSelectionContext;
310	BOOL							mShowSingleSelection;
311	LLFrameTimer					mMultiSelectionFadeTimer;
312	S32								mArrangeGeneration;
313
314	signal_t						mSelectSignal;
315	signal_t						mReshapeSignal;
316	S32								mSignalSelectCallback;
317	S32								mMinWidth;
318	S32								mRunningHeight;
319	std::map<LLUUID, LLFolderViewItem*> mItemMap;
320	BOOL							mDragAndDropThisFrame;
321	
322	LLUUID							mSelectThisID; // if non null, select this item
323	
324	LLPanel*						mParentPanel;
325
326	/**
327	 * Is used to determine if we need to cut text In LLFolderViewItem to avoid horizontal scroll.
328	 * NOTE: For now it uses only to cut LLFolderViewItem::mLabel text to be used for Landmarks in Places Panel.
329	 */
330	bool							mUseEllipses; // See EXT-719
331
332	/**
333	 * Contains item under mouse pointer while dragging
334	 */
335	LLFolderViewItem*				mDraggingOverItem; // See EXT-719
336
337	LLUICtrl::CommitCallbackRegistry::ScopedRegistrar* mCallbackRegistrar;
338	
339public:
340	static F32 sAutoOpenTime;
341	LLTextBox*						mStatusTextBox;
342
343};
344
345bool sort_item_name(LLFolderViewItem* a, LLFolderViewItem* b);
346bool sort_item_date(LLFolderViewItem* a, LLFolderViewItem* b);
347
348// Flags for buildContextMenu()
349const U32 SUPPRESS_OPEN_ITEM = 0x1;
350const U32 FIRST_SELECTED_ITEM = 0x2;
351
352#endif // LL_LLFOLDERVIEW_H