PageRenderTime 19ms CodeModel.GetById 8ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llui/lldockablefloater.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 151 lines | 51 code | 25 blank | 75 comment | 2 complexity | b78eafd5f3c8e3268188f346a8d053ee MD5 | raw file
  1/** 
  2 * @file lldockablefloater.h
  3 * @brief Creates a panel of a specific kind for a toast.
  4 *
  5 * $LicenseInfo:firstyear=2003&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_DOCKABLEFLOATER_H
 28#define LL_DOCKABLEFLOATER_H
 29
 30#include "llerror.h"
 31#include "llfloater.h"
 32#include "lldockcontrol.h"
 33
 34/**
 35 * Represents floater that can dock.
 36 * In case impossibility deriving from LLDockableFloater use LLDockControl.
 37 */
 38class LLDockableFloater : public LLFloater
 39{
 40	static const U32 UNDOCK_LEAP_HEIGHT = 12;
 41
 42	static void init(LLDockableFloater* thiz);
 43public:
 44	LOG_CLASS(LLDockableFloater);
 45	LLDockableFloater(LLDockControl* dockControl, const LLSD& key,
 46			const Params& params = getDefaultParams());
 47
 48	/**
 49	 * Constructor.
 50	 * @param dockControl a pointer to the doc control instance
 51	 * @param uniqueDocking - a flag defines is docking should work as tab(at one
 52	 * moment only one docked floater can be shown), also this flag defines is dock
 53	 * tongue should be used.
 54	 * @params key a floater key.
 55 	 * @params params a floater parameters
 56	 */
 57	LLDockableFloater(LLDockControl* dockControl, bool uniqueDocking,
 58			const LLSD& key, const Params& params = getDefaultParams());
 59
 60	/**
 61	 * Constructor.
 62	 * @param dockControl a pointer to the doc control instance
 63	 * @param uniqueDocking - a flag defines is docking should work as tab(at one
 64	 * moment only one docked floater can be shown).
 65	 * @praram useTongue - a flag defines is dock tongue should be used.
 66	 * @params key a floater key.
 67 	 * @params params a floater parameters
 68	 */
 69	LLDockableFloater(LLDockControl* dockControl, bool uniqueDocking,
 70			bool useTongue, const LLSD& key,
 71			const Params& params = getDefaultParams());
 72
 73	virtual ~LLDockableFloater();
 74
 75	static LLHandle<LLFloater> getInstanceHandle() { return sInstanceHandle; }
 76
 77	static void toggleInstance(const LLSD& sdname);
 78
 79	/**
 80	 *  If descendant class overrides postBuild() in order to perform specific
 81	 *  construction then it must still invoke its superclass' implementation.
 82	 */
 83	/* virtula */BOOL postBuild();
 84	/* virtual */void setDocked(bool docked, bool pop_on_undock = true);
 85	/* virtual */void draw();
 86
 87	/**
 88	 *  If descendant class overrides setVisible() then it must still invoke its
 89	 *  superclass' implementation.
 90	 */
 91	/*virtual*/ void setVisible(BOOL visible);
 92
 93	/**
 94	 *  If descendant class overrides setMinimized() then it must still invoke its
 95	 *  superclass' implementation.
 96	 */
 97	/*virtual*/ void setMinimized(BOOL minimize);
 98
 99	LLView * getDockWidget();
100
101	virtual void onDockHidden();
102	virtual void onDockShown();
103
104	LLDockControl* getDockControl();
105
106	/**
107	 * Returns true if screen channel should consider floater's size when drawing toasts.
108	 *
109	 * By default returns false.
110	 */
111	virtual bool overlapsScreenChannel() { return mOverlapsScreenChannel && getVisible() && isDocked(); }
112	virtual void setOverlapsScreenChannel(bool overlaps) { mOverlapsScreenChannel = overlaps; }
113
114	bool getUniqueDocking() { return mUniqueDocking;	}
115	bool getUseTongue() { return mUseTongue; }
116
117	void setUseTongue(bool use_tongue) { mUseTongue = use_tongue;}
118private:
119	/**
120	 * Provides unique of dockable floater.
121	 * If dockable floater already exists it should  be closed.
122	 */
123	void resetInstance();
124
125protected:
126	void setDockControl(LLDockControl* dockControl);
127	const LLUIImagePtr& getDockTongue(LLDockControl::DocAt dock_side = LLDockControl::TOP);
128
129	// Checks if docking should be forced.
130	// It may be useful e.g. if floater created in mouselook mode (see EXT-5609)
131	boost::function<BOOL ()> mIsDockedStateForcedCallback;
132
133private:
134	std::auto_ptr<LLDockControl> mDockControl;
135	LLUIImagePtr mDockTongue;
136	static LLHandle<LLFloater> sInstanceHandle;
137	/**
138	 * Provides possibility to define that dockable floaters can be docked
139	 *  non exclusively.
140	 */
141	bool mUniqueDocking;
142
143	bool mUseTongue;
144
145	bool mOverlapsScreenChannel;
146
147	// Force docking when the floater is being shown for the first time.
148	bool mForceDocking;
149};
150
151#endif /* LL_DOCKABLEFLOATER_H */