PageRenderTime 34ms CodeModel.GetById 13ms app.highlight 15ms RepoModel.GetById 1ms app.codeStats 1ms

/indra/newview/llnavigationbar.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 153 lines | 91 code | 23 blank | 39 comment | 1 complexity | 6ee65e0fa972bf94cd29b5d0c3773882 MD5 | raw file
  1/** 
  2 * @file llnavigationbar.h
  3 * @brief Navigation bar definition
  4 *
  5 * $LicenseInfo:firstyear=2009&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_LLNAVIGATIONBAR_H
 28#define LL_LLNAVIGATIONBAR_H
 29
 30#include "llpanel.h"
 31#include "llbutton.h"
 32
 33class LLLocationInputCtrl;
 34class LLMenuGL;
 35class LLSearchEditor;
 36class LLSearchComboBox;
 37
 38/**
 39 * This button is able to handle click-dragging mouse event.
 40 * It has appropriated signal for this event.
 41 * Dragging direction can be set from xml attribute called 'direction'
 42 * 
 43 * *TODO: move to llui?  
 44 */
 45
 46class LLPullButton: public LLButton
 47{
 48	LOG_CLASS(LLPullButton);
 49
 50public:
 51	struct Params: public LLInitParam::Block<Params, LLButton::Params>
 52	{
 53		Optional<std::string> direction; // left, right, down, up
 54
 55		Params() 
 56		:	direction("direction", "down")
 57		{
 58		}
 59	};
 60	
 61	/*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask);
 62
 63	/*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask);
 64
 65	/*virtual*/ void onMouseLeave(S32 x, S32 y, MASK mask);
 66
 67	boost::signals2::connection setClickDraggingCallback(const commit_signal_t::slot_type& cb);
 68
 69protected:
 70	friend class LLUICtrlFactory;
 71	// convert string name into direction vector
 72	void setDirectionFromName(const std::string& name);
 73	LLPullButton(const LLPullButton::Params& params);
 74
 75	commit_signal_t mClickDraggingSignal;
 76	LLVector2 mLastMouseDown;
 77	LLVector2 mDraggingDirection;
 78};
 79
 80/**
 81 * Web browser-like navigation bar.
 82 */ 
 83class LLNavigationBar
 84	:	public LLPanel, public LLSingleton<LLNavigationBar>, private LLDestroyClass<LLNavigationBar>
 85{
 86	LOG_CLASS(LLNavigationBar);
 87	friend class LLDestroyClass<LLNavigationBar>;
 88	
 89public:
 90	LLNavigationBar();
 91	virtual ~LLNavigationBar();
 92	
 93	/*virtual*/ void	draw();
 94	/*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
 95	/*virtual*/ BOOL	postBuild();
 96	/*virtual*/ void	setVisible(BOOL visible);
 97
 98	void handleLoginComplete();
 99	void clearHistoryCache();
100
101	int getDefNavBarHeight();
102	int getDefFavBarHeight();
103	
104private:
105	// the distance between navigation panel and favorites panel in pixels
106	const static S32 FAVBAR_TOP_PADDING = 10;
107
108	void rebuildTeleportHistoryMenu();
109	void showTeleportHistoryMenu(LLUICtrl* btn_ctrl);
110	void invokeSearch(std::string search_text);
111	// callbacks
112	void onTeleportHistoryMenuItemClicked(const LLSD& userdata);
113	void onTeleportHistoryChanged();
114	void onBackButtonClicked();
115	void onBackOrForwardButtonHeldDown(LLUICtrl* ctrl, const LLSD& param);
116	void onNavigationButtonHeldUp(LLButton* nav_button);
117	void onForwardButtonClicked();
118	void onHomeButtonClicked();
119	void onLocationSelection();
120	void onLocationPrearrange(const LLSD& data);
121	void onTeleportFinished(const LLVector3d& global_agent_pos);
122	void onTeleportFailed();
123	void onRegionNameResponse(
124			std::string typed_location,
125			std::string region_name,
126			LLVector3 local_coords,
127			U64 region_handle, const std::string& url,
128			const LLUUID& snapshot_id, bool teleport);
129
130	static void destroyClass()
131	{
132		if (LLNavigationBar::instanceExists())
133		{
134			LLNavigationBar::getInstance()->setEnabled(FALSE);
135		}
136	}
137
138	LLMenuGL*					mTeleportHistoryMenu;
139	LLPullButton*				mBtnBack;
140	LLPullButton*				mBtnForward;
141	LLButton*					mBtnHome;
142	LLLocationInputCtrl*		mCmbLocation;
143	LLRect						mDefaultNbRect;
144	LLRect						mDefaultFpRect;
145	boost::signals2::connection	mTeleportFailedConnection;
146	boost::signals2::connection	mTeleportFinishConnection;
147	boost::signals2::connection	mHistoryMenuConnection;
148	bool						mPurgeTPHistoryItems;
149	// if true, save location to location history when teleport finishes
150	bool						mSaveToLocationHistory;
151};
152
153#endif