PageRenderTime 38ms CodeModel.GetById 22ms RepoModel.GetById 0ms 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
Possible License(s): LGPL-2.1
  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. #ifndef LL_LLFAVORITESBARCTRL_H
  27. #define LL_LLFAVORITESBARCTRL_H
  28. #include "llbutton.h"
  29. #include "lluictrl.h"
  30. #include "lltextbox.h"
  31. #include "llinventoryobserver.h"
  32. #include "llinventorymodel.h"
  33. class LLMenuItemCallGL;
  34. class LLToggleableMenu;
  35. class LLFavoritesBarCtrl : public LLUICtrl, public LLInventoryObserver
  36. {
  37. public:
  38. struct Params : public LLInitParam::Block<Params, LLUICtrl::Params>
  39. {
  40. Optional<LLUIImage*> image_drag_indication;
  41. Optional<LLTextBox::Params> more_button;
  42. Optional<LLTextBox::Params> label;
  43. Params();
  44. };
  45. protected:
  46. LLFavoritesBarCtrl(const Params&);
  47. friend class LLUICtrlFactory;
  48. public:
  49. virtual ~LLFavoritesBarCtrl();
  50. /*virtual*/ BOOL postBuild();
  51. /*virtual*/ BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
  52. EDragAndDropType cargo_type,
  53. void* cargo_data,
  54. EAcceptance* accept,
  55. std::string& tooltip_msg);
  56. /*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask);
  57. /*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
  58. // LLInventoryObserver observer trigger
  59. virtual void changed(U32 mask);
  60. virtual void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
  61. virtual void draw();
  62. void showDragMarker(BOOL show) { mShowDragMarker = show; }
  63. void setLandingTab(LLUICtrl* tab) { mLandingTab = tab; }
  64. protected:
  65. void updateButtons();
  66. LLButton* createButton(const LLPointer<LLViewerInventoryItem> item, const LLButton::Params& button_params, S32 x_offset );
  67. const LLButton::Params& getButtonParams();
  68. BOOL collectFavoriteItems(LLInventoryModel::item_array_t &items);
  69. void onButtonClick(LLUUID id);
  70. void onButtonRightClick(LLUUID id,LLView* button,S32 x,S32 y,MASK mask);
  71. void onButtonMouseDown(LLUUID id, LLUICtrl* button, S32 x, S32 y, MASK mask);
  72. void onOverflowMenuItemMouseDown(LLUUID id, LLUICtrl* item, S32 x, S32 y, MASK mask);
  73. void onButtonMouseUp(LLUUID id, LLUICtrl* button, S32 x, S32 y, MASK mask);
  74. void onEndDrag();
  75. bool enableSelected(const LLSD& userdata);
  76. void doToSelected(const LLSD& userdata);
  77. BOOL isClipboardPasteable() const;
  78. void pastFromClipboard() const;
  79. void showDropDownMenu();
  80. LLHandle<LLView> mOverflowMenuHandle;
  81. LLHandle<LLView> mContextMenuHandle;
  82. LLUUID mFavoriteFolderId;
  83. const LLFontGL *mFont;
  84. S32 mFirstDropDownItem;
  85. bool mUpdateDropDownItems;
  86. bool mRestoreOverflowMenu;
  87. LLUUID mSelectedItemID;
  88. LLUIImage* mImageDragIndication;
  89. private:
  90. /*
  91. * Helper function to make code more readable. It handles all drag and drop
  92. * operations of the existing favorites items on the favorites bar.
  93. */
  94. void handleExistingFavoriteDragAndDrop(S32 x, S32 y);
  95. /*
  96. * Helper function to make code more readable. It handles all drag and drop
  97. * operations of the new landmark to the favorites bar.
  98. */
  99. void handleNewFavoriteDragAndDrop(LLInventoryItem *item, const LLUUID& favorites_id, S32 x, S32 y);
  100. // finds a control under the specified LOCAL point
  101. LLUICtrl* findChildByLocalCoords(S32 x, S32 y);
  102. // checks if the current order of the favorites items must be saved
  103. BOOL needToSaveItemsOrder(const LLInventoryModel::item_array_t& items);
  104. /**
  105. * inserts an item identified by insertedItemId BEFORE an item identified by beforeItemId.
  106. * this function assumes that an item identified by insertedItemId doesn't exist in items array.
  107. */
  108. void insertItem(LLInventoryModel::item_array_t& items, const LLUUID& dest_item_id, LLViewerInventoryItem* insertedItem, bool insert_before);
  109. // finds an item by it's UUID in the items array
  110. LLInventoryModel::item_array_t::iterator findItemByUUID(LLInventoryModel::item_array_t& items, const LLUUID& id);
  111. void createOverflowMenu();
  112. void updateMenuItems(LLToggleableMenu* menu);
  113. // Fits menu item label width with favorites menu width
  114. void fitLabelWidth(LLMenuItemCallGL* menu_item);
  115. void addOpenLandmarksMenuItem(LLToggleableMenu* menu);
  116. void positionAndShowMenu(LLToggleableMenu* menu);
  117. BOOL mShowDragMarker;
  118. LLUICtrl* mLandingTab;
  119. LLUICtrl* mLastTab;
  120. LLTextBox* mMoreTextBox;
  121. LLTextBox* mBarLabel;
  122. LLUUID mDragItemId;
  123. BOOL mStartDrag;
  124. LLInventoryModel::item_array_t mItems;
  125. BOOL mTabsHighlightEnabled;
  126. boost::signals2::connection mEndDragConnection;
  127. };
  128. #endif // LL_LLFAVORITESBARCTRL_H