PageRenderTime 216ms CodeModel.GetById 121ms app.highlight 16ms RepoModel.GetById 74ms app.codeStats 1ms

/indra/newview/llmediactrl.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 206 lines | 120 code | 41 blank | 45 comment | 0 complexity | 42c8d3aaf5060927b3645ad1acc0c8d0 MD5 | raw file
  1/**
  2 * @file llmediactrl.h
  3 * @brief Web browser UI control
  4 *
  5 * $LicenseInfo:firstyear=2006&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_LLMediaCtrl_H
 28#define LL_LLMediaCtrl_H
 29
 30#include "llviewermedia.h"
 31
 32#include "lluictrl.h"
 33#include "llframetimer.h"
 34
 35class LLViewBorder;
 36class LLUICtrlFactory;
 37class LLContextMenu;
 38
 39////////////////////////////////////////////////////////////////////////////////
 40//
 41class LLMediaCtrl :
 42	public LLPanel,
 43	public LLViewerMediaObserver,
 44	public LLViewerMediaEventEmitter,
 45	public LLInstanceTracker<LLMediaCtrl, LLUUID>
 46{
 47	LOG_CLASS(LLMediaCtrl);
 48public:
 49	struct Params : public LLInitParam::Block<Params, LLPanel::Params> 
 50	{
 51		Optional<std::string>	start_url;
 52		
 53		Optional<bool>			border_visible,
 54								hide_loading,
 55								decouple_texture_size,
 56								trusted_content,
 57								focus_on_click;
 58								
 59		Optional<S32>			texture_width,
 60								texture_height;
 61		
 62		Optional<LLUIColor>		caret_color;
 63
 64		Optional<std::string>	initial_mime_type;
 65		Optional<std::string>	media_id;
 66		Optional<std::string>	error_page_url;
 67		
 68		Params();
 69	};
 70	
 71protected:
 72	LLMediaCtrl(const Params&);
 73	friend class LLUICtrlFactory;
 74
 75public:
 76		virtual ~LLMediaCtrl();
 77
 78		void setBorderVisible( BOOL border_visible );
 79
 80		// For the tutorial window, we don't want to take focus on clicks,
 81		// as the examples include how to move around with the arrow
 82		// keys.  Thus we keep focus on the app by setting this false.
 83		// Defaults to true.
 84		void setTakeFocusOnClick( bool take_focus );
 85
 86		// handle mouse related methods
 87		virtual BOOL handleHover( S32 x, S32 y, MASK mask );
 88		virtual BOOL handleMouseUp( S32 x, S32 y, MASK mask );
 89		virtual BOOL handleMouseDown( S32 x, S32 y, MASK mask );
 90		virtual BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
 91		virtual BOOL handleRightMouseUp(S32 x, S32 y, MASK mask);
 92		virtual BOOL handleDoubleClick( S32 x, S32 y, MASK mask );
 93		virtual BOOL handleScrollWheel( S32 x, S32 y, S32 clicks );
 94		virtual BOOL handleToolTip(S32 x, S32 y, MASK mask);
 95
 96		// navigation
 97		void navigateTo( std::string url_in, std::string mime_type = "");
 98		void navigateBack();
 99		void navigateHome();
100		void navigateForward();	
101		void navigateToLocalPage( const std::string& subdir, const std::string& filename_in );
102		bool canNavigateBack();
103		bool canNavigateForward();
104		std::string getCurrentNavUrl();
105
106		// By default, we do not handle "secondlife:///app/" SLURLs, because
107		// those can cause teleports, open windows, etc.  We cannot be sure
108		// that each "click" is actually due to a user action, versus 
109		// Javascript or some other mechanism.  However, we need the search
110		// floater and login page to handle these URLs.  Those are safe
111		// because we control the page content.  See DEV-9530.  JC.
112		void setHomePageUrl( const std::string& urlIn, const std::string& mime_type = LLStringUtil::null );
113		std::string getHomePageUrl();
114
115		void setTarget(const std::string& target);
116
117		void setErrorPageURL(const std::string& url);
118		const std::string& getErrorPageURL();
119
120		// Clear the browser cache when the instance gets loaded
121		void clearCache();
122
123		// accessor/mutator for flag that indicates if frequent updates to texture happen
124		bool getFrequentUpdates() { return mFrequentUpdates; };
125		void setFrequentUpdates( bool frequentUpdatesIn ) {  mFrequentUpdates = frequentUpdatesIn; };
126
127		void setAlwaysRefresh(bool refresh) { mAlwaysRefresh = refresh; }
128		bool getAlwaysRefresh() { return mAlwaysRefresh; }
129		
130		void setForceUpdate(bool force_update) { mForceUpdate = force_update; }
131		bool getForceUpdate() { return mForceUpdate; }
132
133		bool ensureMediaSourceExists();
134		void unloadMediaSource();
135		
136		LLPluginClassMedia* getMediaPlugin();
137
138		bool setCaretColor( unsigned int red, unsigned int green, unsigned int blue );
139		
140		void setDecoupleTextureSize(bool decouple) { mDecoupleTextureSize = decouple; }
141		bool getDecoupleTextureSize() { return mDecoupleTextureSize; }
142
143		void setTextureSize(S32 width, S32 height);
144
145		void showNotification(boost::shared_ptr<class LLNotification> notify);
146		void hideNotification();
147
148		void setTrustedContent(bool trusted);
149
150		// over-rides
151		virtual BOOL handleKeyHere( KEY key, MASK mask);
152		virtual void handleVisibilityChange ( BOOL new_visibility );
153		virtual BOOL handleUnicodeCharHere(llwchar uni_char);
154		virtual void reshape( S32 width, S32 height, BOOL called_from_parent = TRUE);
155		virtual void draw();
156		virtual BOOL postBuild();
157
158		// focus overrides
159		void onFocusLost();
160		void onFocusReceived();
161		
162		// Incoming media event dispatcher
163		virtual void handleMediaEvent(LLPluginClassMedia* self, EMediaEvent event);
164
165		// right click debugging item
166		void onOpenWebInspector();
167
168		LLUUID getTextureID() {return mMediaTextureID;}
169
170	protected:
171		void convertInputCoords(S32& x, S32& y);
172
173	private:
174		void onVisibilityChange ( const LLSD& new_visibility );
175		void onPopup(const LLSD& notification, const LLSD& response);
176
177		const S32 mTextureDepthBytes;
178		LLUUID mMediaTextureID;
179		LLViewBorder* mBorder;
180		bool	mFrequentUpdates,
181				mForceUpdate,
182				mTrusted,
183				mAlwaysRefresh,
184				mTakeFocusOnClick,
185				mStretchToFill,
186				mMaintainAspectRatio,
187				mHideLoading,
188				mHidingInitialLoad,
189				mClearCache,
190				mHoverTextChanged,
191				mDecoupleTextureSize;
192
193		std::string mHomePageUrl,
194					mHomePageMimeType,
195					mCurrentNavUrl,
196					mErrorPageURL,
197					mTarget;
198		viewer_media_t mMediaSource;
199		S32 mTextureWidth,
200			mTextureHeight;
201
202		class LLWindowShade* mWindowShade;
203		LLContextMenu* mContextMenu;
204};
205
206#endif // LL_LLMediaCtrl_H