PageRenderTime 30ms CodeModel.GetById 4ms RepoModel.GetById 12ms app.codeStats 0ms

/indra/newview/lltoolbarview.h

https://bitbucket.org/lindenlab/viewer-beta/
C Header | 137 lines | 71 code | 28 blank | 38 comment | 0 complexity | f3df947b22a3da101781a012a49543d7 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file lltoolbarview.h
  3. * @author Merov Linden
  4. * @brief User customizable toolbar class
  5. *
  6. * $LicenseInfo:firstyear=2011&license=viewerlgpl$
  7. * Second Life Viewer Source Code
  8. * Copyright (C) 2011, Linden Research, Inc.
  9. *
  10. * This library is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU Lesser General Public
  12. * License as published by the Free Software Foundation;
  13. * version 2.1 of the License only.
  14. *
  15. * This library is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * Lesser General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Lesser General Public
  21. * License along with this library; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  23. *
  24. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  25. * $/LicenseInfo$
  26. */
  27. #ifndef LL_LLTOOLBARVIEW_H
  28. #define LL_LLTOOLBARVIEW_H
  29. #include "lluictrl.h"
  30. #include "lltoolbar.h"
  31. #include "llcommandmanager.h"
  32. class LLUICtrlFactory;
  33. // Parent of all LLToolBar
  34. class LLToolBarView : public LLUICtrl
  35. {
  36. public:
  37. typedef enum
  38. {
  39. TOOLBAR_NONE = 0,
  40. TOOLBAR_LEFT,
  41. TOOLBAR_RIGHT,
  42. TOOLBAR_BOTTOM,
  43. TOOLBAR_COUNT,
  44. TOOLBAR_FIRST = TOOLBAR_LEFT,
  45. TOOLBAR_LAST = TOOLBAR_BOTTOM,
  46. } EToolBarLocation;
  47. // Xui structure of the toolbar panel
  48. struct Params : public LLInitParam::Block<Params, LLUICtrl::Params> {};
  49. // Note: valid children for LLToolBarView are stored in this registry
  50. typedef LLDefaultChildRegistry child_registry_t;
  51. // Xml structure of the toolbars.xml setting
  52. // Those live in a toolbars.xml found in app_settings (for the default) and in
  53. // the user folder for the user specific (saved) settings
  54. struct Toolbar : public LLInitParam::Block<Toolbar>
  55. {
  56. Mandatory<LLToolBarEnums::ButtonType> button_display_mode;
  57. Multiple<LLCommandId::Params> commands;
  58. Toolbar();
  59. };
  60. struct ToolbarSet : public LLInitParam::Block<ToolbarSet>
  61. {
  62. Optional<Toolbar> left_toolbar,
  63. right_toolbar,
  64. bottom_toolbar;
  65. ToolbarSet();
  66. };
  67. // Derived methods
  68. virtual ~LLToolBarView();
  69. virtual BOOL postBuild();
  70. virtual void draw();
  71. // Toolbar view interface with the rest of the world
  72. // Checks if the commandId is being used somewhere in one of the toolbars, returns EToolBarLocation
  73. S32 hasCommand(const LLCommandId& commandId) const;
  74. S32 addCommand(const LLCommandId& commandId, EToolBarLocation toolbar, int rank = LLToolBar::RANK_NONE);
  75. S32 removeCommand(const LLCommandId& commandId, int& rank); // Sets the rank the removed command was at, RANK_NONE if not found
  76. S32 enableCommand(const LLCommandId& commandId, bool enabled);
  77. S32 stopCommandInProgress(const LLCommandId& commandId);
  78. S32 flashCommand(const LLCommandId& commandId, bool flash);
  79. // Loads the toolbars from the existing user or default settings
  80. bool loadToolbars(bool force_default = false); // return false if load fails
  81. // Clears all buttons off the toolbars
  82. bool clearToolbars();
  83. void setToolBarsVisible(bool visible);
  84. static bool loadDefaultToolbars();
  85. static bool clearAllToolbars();
  86. static void startDragTool(S32 x, S32 y, LLToolBarButton* toolbarButton);
  87. static BOOL handleDragTool(S32 x, S32 y, const LLUUID& uuid, LLAssetType::EType type);
  88. static BOOL handleDropTool(void* cargo_data, S32 x, S32 y, LLToolBar* toolbar);
  89. static void resetDragTool(LLToolBarButton* toolbarButton);
  90. bool isModified() const;
  91. protected:
  92. friend class LLUICtrlFactory;
  93. LLToolBarView(const Params&);
  94. void initFromParams(const Params&);
  95. private:
  96. void saveToolbars() const;
  97. bool addCommandInternal(const LLCommandId& commandId, LLToolBar* toolbar);
  98. void addToToolset(command_id_list_t& command_list, Toolbar& toolbar) const;
  99. static void onToolBarButtonAdded(LLView* button);
  100. static void onToolBarButtonRemoved(LLView* button);
  101. // Pointers to the toolbars handled by the toolbar view
  102. LLToolBar* mToolbars[TOOLBAR_COUNT];
  103. bool mToolbarsLoaded;
  104. bool mDragStarted;
  105. LLToolBarButton* mDragToolbarButton;
  106. bool mShowToolbars;
  107. };
  108. extern LLToolBarView* gToolBarView;
  109. #endif // LL_LLTOOLBARVIEW_H