PageRenderTime 3025ms CodeModel.GetById 866ms app.highlight 429ms RepoModel.GetById 1012ms app.codeStats 0ms

/indra/newview/llmoveview.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 185 lines | 98 code | 29 blank | 58 comment | 0 complexity | d4be3845fd5452cba8cdab1b053ad0f0 MD5 | raw file
  1/** 
  2 * @file llmoveview.h
  3 * @brief Container for buttons for walking, turning, flying
  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_LLMOVEVIEW_H
 28#define LL_LLMOVEVIEW_H
 29
 30// Library includes
 31#include "llfloater.h"
 32
 33class LLButton;
 34class LLJoystickAgentTurn;
 35class LLJoystickAgentSlide;
 36
 37//
 38// Classes
 39//
 40class LLFloaterMove
 41:	public LLFloater
 42{
 43	LOG_CLASS(LLFloaterMove);
 44	friend class LLFloaterReg;
 45
 46private:
 47	LLFloaterMove(const LLSD& key);
 48	~LLFloaterMove();
 49public:
 50
 51	/*virtual*/	BOOL	postBuild();
 52	/*virtual*/ void	setVisible(BOOL visible);
 53	static F32	getYawRate(F32 time);
 54	static void setFlyingMode(BOOL fly);
 55	void setFlyingModeImpl(BOOL fly);
 56	static void setAlwaysRunMode(bool run);
 57	void setAlwaysRunModeImpl(bool run);
 58	static void setSittingMode(BOOL bSitting);
 59	static void enableInstance(BOOL bEnable);
 60	/*virtual*/ void onOpen(const LLSD& key);
 61
 62	static void sUpdateFlyingStatus();
 63
 64protected:
 65	void turnLeft();
 66	void turnRight();
 67
 68	void moveUp();
 69	void moveDown();
 70
 71private:
 72	typedef enum movement_mode_t
 73	{
 74		MM_WALK,
 75		MM_RUN,
 76		MM_FLY
 77	} EMovementMode;
 78	void onWalkButtonClick();
 79	void onRunButtonClick();
 80	void onFlyButtonClick();
 81	void initMovementMode();
 82	void setMovementMode(const EMovementMode mode);
 83	void initModeTooltips();
 84	void setModeTooltip(const EMovementMode mode);
 85	void setModeTitle(const EMovementMode mode);
 86	void initModeButtonMap();
 87	void setModeButtonToggleState(const EMovementMode mode);
 88	void updateButtonsWithMovementMode(const EMovementMode newMode);
 89	void showModeButtons(BOOL bShow);
 90
 91public:
 92
 93	LLJoystickAgentTurn*	mForwardButton;
 94	LLJoystickAgentTurn*	mBackwardButton;
 95	LLJoystickAgentSlide*	mSlideLeftButton;
 96	LLJoystickAgentSlide*	mSlideRightButton;
 97	LLButton*				mTurnLeftButton;
 98	LLButton*				mTurnRightButton;
 99	LLButton*				mMoveUpButton;
100	LLButton*				mMoveDownButton;
101private:
102	LLPanel*				mModeActionsPanel;
103	
104	typedef std::map<LLView*, std::string> control_tooltip_map_t;
105	typedef std::map<EMovementMode, control_tooltip_map_t> mode_control_tooltip_map_t;
106	mode_control_tooltip_map_t mModeControlTooltipsMap;
107
108	typedef std::map<EMovementMode, LLButton*> mode_control_button_map_t;
109	mode_control_button_map_t mModeControlButtonMap;
110	EMovementMode mCurrentMode;
111
112};
113
114
115/**
116 * This class contains Stand Up and Stop Flying buttons displayed above Move button in bottom tray
117 */
118class LLPanelStandStopFlying : public LLPanel
119{
120	LOG_CLASS(LLPanelStandStopFlying);
121public:
122	typedef enum stand_stop_flying_mode_t
123	{
124		SSFM_STAND,
125		SSFM_STOP_FLYING
126	} EStandStopFlyingMode;
127
128	/**
129	 * Attach or detach the panel to/from the movement controls floater.
130	 * 
131	 * Called when the floater gets opened/closed, user sits, stands up or starts/stops flying.
132	 * 
133	 * @param move_view The floater to attach to (not always accessible via floater registry).
134	 *        If NULL is passed, the panel gets reparented to its original container.
135	 *
136	 * @see mAttached
137	 * @see mOriginalParent 
138	 */
139	void reparent(LLFloaterMove* move_view);
140
141	static LLPanelStandStopFlying* getInstance();
142	static void setStandStopFlyingMode(EStandStopFlyingMode mode);
143	static void clearStandStopFlyingMode(EStandStopFlyingMode mode);
144	/*virtual*/ BOOL postBuild();
145	/*virtual*/ void setVisible(BOOL visible);
146
147	// *HACK: due to hard enough to have this control aligned with "Move" button while resizing
148	// let update its position in each frame
149	/*virtual*/ void draw(){updatePosition(); LLPanel::draw();}
150	/*virtual*/ BOOL handleToolTip(S32 x, S32 y, MASK mask);
151
152
153protected:
154	LLPanelStandStopFlying();
155
156
157private:
158	static LLPanelStandStopFlying* getStandStopFlyingPanel();
159	void onStandButtonClick();
160	void onStopFlyingButtonClick();
161	void updatePosition();
162
163	LLButton* mStandButton;
164	LLButton* mStopFlyingButton;
165
166	/**
167	 * The original parent of the panel.
168	 *  
169	 * Makes it possible to move (reparent) the panel to the movement controls floater and back.
170	 * 
171	 * @see reparent()
172	 */
173	LLHandle<LLPanel> mOriginalParent;
174
175	/**
176	 * True if the panel is currently attached to the movement controls floater.
177	 * 
178	 * @see reparent()
179	 * @see updatePosition()
180	 */
181	bool	mAttached;
182};
183
184
185#endif