PageRenderTime 22ms CodeModel.GetById 13ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llui/llmenubutton.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 93 lines | 47 code | 20 blank | 26 comment | 0 complexity | c5678ff850c60cdc8254e8a308a4a172 MD5 | raw file
 1/** 
 2 * @file llbutton.h
 3 * @brief Header for buttons
 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#ifndef LL_LLMENUBUTTON_H
28#define LL_LLMENUBUTTON_H
29
30#include "llbutton.h"
31
32class LLToggleableMenu;
33
34class LLMenuButton
35: public LLButton
36{
37public:
38	typedef enum e_menu_position
39	{
40		MP_TOP_LEFT,
41		MP_TOP_RIGHT,
42		MP_BOTTOM_LEFT
43	} EMenuPosition;
44
45	struct MenuPositions
46		:	public LLInitParam::TypeValuesHelper<EMenuPosition, MenuPositions>
47	{
48		static void declareValues();
49	};
50
51	struct Params 
52	:	public LLInitParam::Block<Params, LLButton::Params>
53	{
54		// filename for it's toggleable menu
55		Optional<std::string>	menu_filename;
56		Optional<EMenuPosition>	position;
57	
58		Params();
59	};
60
61
62	
63	boost::signals2::connection setMouseDownCallback( const mouse_signal_t::slot_type& cb );
64
65	/*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask);
66	/*virtual*/ BOOL handleKeyHere(KEY key, MASK mask );
67
68	void hideMenu();
69
70	LLToggleableMenu* getMenu();
71	void setMenu(LLToggleableMenu* menu, EMenuPosition position = MP_TOP_LEFT);
72
73	void setMenuPosition(EMenuPosition position) { mMenuPosition = position; }
74
75protected:
76	friend class LLUICtrlFactory;
77	LLMenuButton(const Params&);
78
79	void toggleMenu();
80	void updateMenuOrigin();
81
82	void onMenuVisibilityChange(const LLSD& param);
83
84private:
85	LLHandle<LLView>		mMenuHandle;
86	bool					mIsMenuShown;
87	EMenuPosition			mMenuPosition;
88	S32						mX;
89	S32						mY;
90};
91
92
93#endif  // LL_LLMENUBUTTON_H