PageRenderTime 274ms CodeModel.GetById 161ms app.highlight 10ms RepoModel.GetById 101ms app.codeStats 0ms

/indra/newview/llfloatercamera.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 166 lines | 83 code | 32 blank | 51 comment | 0 complexity | 372064927fe27b09513bb9e5e1e76812 MD5 | raw file
  1/** 
  2 * @file llfloatercamera.h
  3 * @brief Container for camera control buttons (zoom, pan, orbit)
  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 LLFLOATERCAMERA_H
 28#define LLFLOATERCAMERA_H
 29
 30#include "llfloater.h"
 31#include "lliconctrl.h"
 32#include "lltextbox.h"
 33#include "llflatlistview.h"
 34
 35class LLJoystickCameraRotate;
 36class LLJoystickCameraTrack;
 37class LLFloaterReg;
 38class LLPanelCameraZoom;
 39
 40enum ECameraControlMode
 41{
 42	CAMERA_CTRL_MODE_MODES,
 43	CAMERA_CTRL_MODE_PAN,
 44	CAMERA_CTRL_MODE_FREE_CAMERA,
 45	CAMERA_CTRL_MODE_PRESETS
 46};
 47
 48class LLFloaterCamera : public LLFloater
 49{
 50	friend class LLFloaterReg;
 51	
 52public:
 53
 54	/* whether in free camera mode */
 55	static bool inFreeCameraMode();
 56	/* callback for camera items selection changing */
 57	static void onClickCameraItem(const LLSD& param);
 58
 59	static void onLeavingMouseLook();
 60
 61	/** resets current camera mode to orbit mode */
 62	static void resetCameraMode();
 63
 64	/** Called when Avatar is entered/exited editing appearance mode */
 65	static void onAvatarEditingAppearance(bool editing);
 66
 67	/* determines actual mode and updates ui */
 68	void update();
 69
 70	/*switch to one of the camera presets (front, rear, side)*/
 71	static void switchToPreset(const std::string& name);
 72
 73	/* move to CAMERA_CTRL_MODE_PRESETS from CAMERA_CTRL_MODE_FREE_CAMERA if we are on presets panel and
 74	   are not in free camera mode*/
 75	void fromFreeToPresets();
 76
 77	virtual void onOpen(const LLSD& key);
 78	virtual void onClose(bool app_quitting);
 79
 80	LLJoystickCameraRotate* mRotate;
 81	LLPanelCameraZoom*	mZoom;
 82	LLJoystickCameraTrack*	mTrack;
 83
 84private:
 85
 86	LLFloaterCamera(const LLSD& val);
 87	~LLFloaterCamera() {};
 88
 89	/* return instance if it exists - created by LLFloaterReg */
 90	static LLFloaterCamera* findInstance();
 91
 92	/*virtual*/ BOOL postBuild();
 93
 94	ECameraControlMode determineMode();
 95
 96	/* resets to the previous mode */
 97	void toPrevMode();
 98
 99	/* sets a new mode and performs related actions */
100	void switchMode(ECameraControlMode mode);
101
102	/* sets a new mode preserving previous one and updates ui*/
103	void setMode(ECameraControlMode mode);
104
105	/* updates the state (UI) according to the current mode */
106	void updateState();
107
108	/* update camera modes items selection and camera preset items selection according to the currently selected preset */
109	void updateItemsSelection();
110
111	void onClickBtn(ECameraControlMode mode);
112	void assignButton2Mode(ECameraControlMode mode, const std::string& button_name);
113	
114	// fills flatlist with items from given panel
115	void fillFlatlistFromPanel (LLFlatListView* list, LLPanel* panel);
116
117	void handleAvatarEditingAppearance(bool editing);
118
119	// set to true when free camera mode is selected in modes list
120	// remains true until preset camera mode is chosen, or pan button is clicked, or escape pressed
121	static bool sFreeCamera;
122	static bool sAppearanceEditing;
123	BOOL mClosed;
124	ECameraControlMode mPrevMode;
125	ECameraControlMode mCurrMode;
126	std::map<ECameraControlMode, LLButton*> mMode2Button;
127};
128
129/**
130 * Class used to represent widgets from panel_camera_item.xml- 
131 * panels that contain pictures and text. Pictures are different
132 * for selected and unselected state (this state is nor stored- icons
133 * are changed in setValue()). This class doesn't implement selection logic-
134 * it's items are used inside of flatlist.
135 */
136class LLPanelCameraItem 
137	: public LLPanel
138{
139public:
140	struct Params :	public LLInitParam::Block<Params, LLPanel::Params>
141	{
142		Optional<LLIconCtrl::Params> icon_over;
143		Optional<LLIconCtrl::Params> icon_selected;
144		Optional<LLIconCtrl::Params> picture;
145		Optional<LLIconCtrl::Params> selected_picture;
146
147		Optional<LLTextBox::Params> text;
148		Optional<CommitCallbackParam> mousedown_callback;
149		Params();
150	};
151	/*virtual*/ BOOL postBuild();
152	/** setting on/off background icon to indicate selected state */
153	/*virtual*/ void setValue(const LLSD& value);
154	// sends commit signal
155	void onAnyMouseClick();
156protected:
157	friend class LLUICtrlFactory;
158	LLPanelCameraItem(const Params&);
159	LLIconCtrl* mIconOver;
160	LLIconCtrl* mIconSelected;
161	LLIconCtrl* mPicture;
162	LLIconCtrl* mPictureSelected;
163	LLTextBox* mText;
164};
165
166#endif