PageRenderTime 36ms CodeModel.GetById 9ms RepoModel.GetById 0ms app.codeStats 1ms

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