PageRenderTime 25ms CodeModel.GetById 15ms app.highlight 8ms RepoModel.GetById 1ms 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
  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
 28#ifndef LL_LLTOOLBARVIEW_H
 29#define LL_LLTOOLBARVIEW_H
 30
 31#include "lluictrl.h"
 32#include "lltoolbar.h"
 33#include "llcommandmanager.h"
 34
 35class LLUICtrlFactory;
 36
 37// Parent of all LLToolBar
 38
 39class LLToolBarView : public LLUICtrl
 40{
 41public:
 42	typedef enum
 43	{
 44		TOOLBAR_NONE = 0,
 45		TOOLBAR_LEFT,
 46		TOOLBAR_RIGHT,
 47		TOOLBAR_BOTTOM,
 48
 49		TOOLBAR_COUNT,
 50
 51		TOOLBAR_FIRST = TOOLBAR_LEFT,
 52		TOOLBAR_LAST = TOOLBAR_BOTTOM,
 53	} EToolBarLocation;
 54
 55	// Xui structure of the toolbar panel
 56	struct Params : public LLInitParam::Block<Params, LLUICtrl::Params> {};
 57
 58	// Note: valid children for LLToolBarView are stored in this registry
 59	typedef LLDefaultChildRegistry child_registry_t;
 60	
 61	// Xml structure of the toolbars.xml setting
 62	// Those live in a toolbars.xml found in app_settings (for the default) and in
 63	// the user folder for the user specific (saved) settings
 64	struct Toolbar : public LLInitParam::Block<Toolbar>
 65	{
 66		Mandatory<LLToolBarEnums::ButtonType>	button_display_mode;
 67		Multiple<LLCommandId::Params>	commands;
 68
 69		Toolbar();
 70	};
 71	struct ToolbarSet : public LLInitParam::Block<ToolbarSet>
 72	{
 73		Optional<Toolbar>	left_toolbar,
 74							right_toolbar,
 75							bottom_toolbar;
 76
 77		ToolbarSet();
 78	};
 79
 80	// Derived methods
 81	virtual ~LLToolBarView();
 82	virtual BOOL postBuild();
 83	virtual void draw();
 84
 85	// Toolbar view interface with the rest of the world
 86	// Checks if the commandId is being used somewhere in one of the toolbars, returns EToolBarLocation
 87	S32 hasCommand(const LLCommandId& commandId) const;
 88	S32 addCommand(const LLCommandId& commandId, EToolBarLocation toolbar, int rank = LLToolBar::RANK_NONE);
 89	S32 removeCommand(const LLCommandId& commandId, int& rank);	// Sets the rank the removed command was at, RANK_NONE if not found
 90	S32 enableCommand(const LLCommandId& commandId, bool enabled);
 91	S32 stopCommandInProgress(const LLCommandId& commandId);
 92	S32 flashCommand(const LLCommandId& commandId, bool flash);
 93
 94	// Loads the toolbars from the existing user or default settings
 95	bool loadToolbars(bool force_default = false);	// return false if load fails
 96	
 97	// Clears all buttons off the toolbars
 98	bool clearToolbars();
 99	
100	void setToolBarsVisible(bool visible);
101
102	static bool loadDefaultToolbars();
103	static bool clearAllToolbars();
104	
105	static void startDragTool(S32 x, S32 y, LLToolBarButton* toolbarButton);
106	static BOOL handleDragTool(S32 x, S32 y, const LLUUID& uuid, LLAssetType::EType type);
107	static BOOL handleDropTool(void* cargo_data, S32 x, S32 y, LLToolBar* toolbar);
108	static void resetDragTool(LLToolBarButton* toolbarButton);
109
110	bool isModified() const;
111	
112protected:
113	friend class LLUICtrlFactory;
114	LLToolBarView(const Params&);
115
116	void initFromParams(const Params&);
117
118private:
119	void	saveToolbars() const;
120	bool	addCommandInternal(const LLCommandId& commandId, LLToolBar*	toolbar);
121	void	addToToolset(command_id_list_t& command_list, Toolbar& toolbar) const;
122
123	static void	onToolBarButtonAdded(LLView* button);
124	static void onToolBarButtonRemoved(LLView* button);
125
126	// Pointers to the toolbars handled by the toolbar view
127	LLToolBar*  mToolbars[TOOLBAR_COUNT];
128	bool		mToolbarsLoaded;
129	
130	bool				mDragStarted;
131	LLToolBarButton*	mDragToolbarButton;
132	bool				mShowToolbars;
133};
134
135extern LLToolBarView* gToolBarView;
136
137#endif  // LL_LLTOOLBARVIEW_H