PageRenderTime 40ms CodeModel.GetById 7ms app.highlight 26ms RepoModel.GetById 1ms app.codeStats 1ms

/indra/llui/lltooltip.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 166 lines | 105 code | 26 blank | 35 comment | 0 complexity | 5e616c5446fcf5319c1c44d528188346 MD5 | raw file
  1/** 
  2 * @file lltooltip.h
  3 * @brief LLToolTipMgr class definition and related classes
  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_LLTOOLTIP_H
 28#define LL_LLTOOLTIP_H
 29
 30// Library includes
 31#include "llsingleton.h"
 32#include "llinitparam.h"
 33#include "llpanel.h"
 34#include "llstyle.h"
 35
 36//
 37// Classes
 38//
 39class LLToolTipView : public LLView
 40{
 41public:
 42	struct Params : public LLInitParam::Block<Params, LLView::Params>
 43	{
 44		Params();
 45	};
 46	LLToolTipView(const LLToolTipView::Params&);
 47	/*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask);
 48	/*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask);
 49	/*virtual*/ BOOL handleMiddleMouseDown(S32 x, S32 y, MASK mask);
 50	/*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
 51	/*virtual*/ BOOL handleScrollWheel( S32 x, S32 y, S32 clicks );
 52
 53	void drawStickyRect();
 54
 55	/*virtual*/ void draw();
 56};
 57
 58class LLToolTip : public LLPanel
 59{
 60public:
 61
 62	struct StyledText : public LLInitParam::Block<StyledText>
 63	{
 64		Mandatory<std::string>		text;
 65		Optional<LLStyle::Params>	style;
 66	};
 67
 68	struct Params : public LLInitParam::Block<Params, LLPanel::Params> 
 69	{
 70		typedef boost::function<void(void)> click_callback_t;
 71
 72		Optional<std::string>		message;
 73		Multiple<StyledText>		styled_message;
 74
 75		Optional<LLCoordGL>			pos;
 76		Optional<F32>				delay_time,
 77									visible_time_over,  // time for which tooltip is visible while mouse on it
 78									visible_time_near,	// time for which tooltip is visible while mouse near it
 79									visible_time_far;	// time for which tooltip is visible while mouse moved away
 80		Optional<LLRect>			sticky_rect;
 81		Optional<const LLFontGL*>	font;
 82		Optional<LLUIImage*>		image;
 83		Optional<LLUIColor>			text_color;
 84		Optional<bool>				time_based_media,
 85									web_based_media,
 86									media_playing;
 87		Optional<click_callback_t>	click_callback,
 88									click_playmedia_callback,
 89									click_homepage_callback;
 90		Optional<S32>				max_width,
 91									padding;
 92		Optional<bool>				wrap;
 93
 94		Params();
 95	};
 96	/*virtual*/ void draw();
 97	/*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask);
 98	/*virtual*/ void onMouseLeave(S32 x, S32 y, MASK mask);
 99	/*virtual*/ void setVisible(BOOL visible);
100
101	bool isFading();
102	F32 getVisibleTime();
103	bool hasClickCallback();
104
105	LLToolTip(const Params& p);
106	void initFromParams(const LLToolTip::Params& params);
107
108private:
109	class LLTextBox*	mTextBox;
110	class LLButton*     mInfoButton;
111	class LLButton*     mPlayMediaButton;
112	class LLButton*     mHomePageButton;
113
114	LLFrameTimer	mFadeTimer;
115	LLFrameTimer	mVisibleTimer;
116	bool			mHasClickCallback;
117	S32				mPadding;	// pixels
118};
119
120// used for the inspector tooltips which need different background images etc.
121class LLInspector : public LLToolTip
122{
123public:
124	struct Params : public LLInitParam::Block<Params, LLToolTip::Params> 
125	{};
126};
127
128class LLToolTipMgr : public LLSingleton<LLToolTipMgr>
129{
130	LOG_CLASS(LLToolTipMgr);
131public:
132	LLToolTipMgr();
133	void show(const LLToolTip::Params& params);
134	void show(const std::string& message);
135
136	void unblockToolTips();
137	void blockToolTips();
138
139	void hideToolTips();
140	bool toolTipVisible();
141	LLRect getToolTipRect();
142	LLRect getMouseNearRect();
143	void updateToolTipVisibility();
144
145private:
146	void createToolTip(const LLToolTip::Params& params);
147
148	bool				mToolTipsBlocked;
149	class LLToolTip*	mToolTip;
150
151	// tooltip creation is deferred until the UI is drawn every frame
152	// so the last tooltip to be created in a given frame will win
153	LLToolTip::Params	mLastToolTipParams;	// description of last tooltip we showed
154	LLToolTip::Params	mNextToolTipParams; // description of next tooltip we want to show
155	bool				mNeedsToolTip;		// do we want to show a tooltip
156
157	LLRect				mMouseNearRect;
158};
159
160//
161// Globals
162//
163
164extern LLToolTipView *gToolTipView;
165
166#endif