aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llmediactrl.h
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/llmediactrl.h')
-rw-r--r--linden/indra/newview/llmediactrl.h201
1 files changed, 201 insertions, 0 deletions
diff --git a/linden/indra/newview/llmediactrl.h b/linden/indra/newview/llmediactrl.h
new file mode 100644
index 0000000..77f59c7
--- /dev/null
+++ b/linden/indra/newview/llmediactrl.h
@@ -0,0 +1,201 @@
1/**
2 * @file llmediactrl.h
3 * @brief Web browser UI control
4 *
5 * $LicenseInfo:firstyear=2006&license=viewergpl$
6 *
7 * Copyright (c) 2006-2009, Linden Research, Inc.
8 *
9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab
11 * to you under the terms of the GNU General Public License, version 2.0
12 * ("GPL"), unless you have obtained a separate licensing agreement
13 * ("Other License"), formally executed by you and Linden Lab. Terms of
14 * the GPL can be found in doc/GPL-license.txt in this distribution, or
15 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
16 *
17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at
21 * http://secondlifegrid.net/programs/open_source/licensing/flossexception
22 *
23 * By copying, modifying or distributing this software, you acknowledge
24 * that you have read and understood your obligations described above,
25 * and agree to abide by those obligations.
26 *
27 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
28 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
29 * COMPLETENESS OR PERFORMANCE.
30 * $/LicenseInfo$
31 */
32
33#ifndef LL_LLMediaCtrl_H
34#define LL_LLMediaCtrl_H
35
36#include "llviewermedia.h"
37
38#include "lluictrl.h"
39#include "llframetimer.h"
40#include "lldynamictexture.h"
41
42class LLViewBorder;
43class LLWebBrowserTexture;
44class LLUICtrlFactory;
45
46////////////////////////////////////////////////////////////////////////////////
47//
48class LLMediaCtrl :
49 public LLUICtrl,
50 public LLViewerMediaObserver,
51 public LLViewerMediaEventEmitter
52{
53 public:
54 LLMediaCtrl( const std::string& name, const LLRect& rect );
55 virtual ~LLMediaCtrl();
56
57 void setBorderVisible( BOOL border_visible );
58
59 // For the tutorial window, we don't want to take focus on clicks,
60 // as the examples include how to move around with the arrow
61 // keys. Thus we keep focus on the app by setting this false.
62 // Defaults to true.
63 void setTakeFocusOnClick( bool take_focus );
64
65 virtual LLXMLNodePtr getXML(bool save_children = true) const;
66 static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
67
68 // handle mouse related methods
69 virtual BOOL handleHover( S32 x, S32 y, MASK mask );
70 virtual BOOL handleMouseUp( S32 x, S32 y, MASK mask );
71 virtual BOOL handleMouseDown( S32 x, S32 y, MASK mask );
72 virtual BOOL handleDoubleClick( S32 x, S32 y, MASK mask );
73 virtual BOOL handleScrollWheel( S32 x, S32 y, S32 clicks );
74
75 // navigation
76 void navigateTo( std::string url_in, std::string mime_type = "");
77 void navigateBack();
78 void navigateHome();
79 void navigateForward();
80 void navigateToLocalPage( const std::string& subdir, const std::string& filename_in );
81 bool canNavigateBack();
82 bool canNavigateForward();
83 void setOpenInExternalBrowser( bool valIn );
84 void setOpenInInternalBrowser( bool valIn );
85 std::string getCurrentNavUrl();
86
87 // By default, we do not handle "secondlife:///app/" SLURLs, because
88 // those can cause teleports, open windows, etc. We cannot be sure
89 // that each "click" is actually due to a user action, versus
90 // Javascript or some other mechanism. However, we need the search
91 // floater and login page to handle these URLs. Those are safe
92 // because we control the page content. See DEV-9530. JC.
93 void setTrusted( bool valIn );
94
95 void setHomePageUrl( const std::string urlIn );
96 std::string getHomePageUrl();
97
98 // set/clear URL to visit when a 404 page is reached
99 void set404RedirectUrl( std::string redirect_url );
100 void clr404RedirectUrl();
101
102 // accessor/mutator for flag that indicates if frequent updates to texture happen
103 bool getFrequentUpdates() { return mFrequentUpdates; };
104 void setFrequentUpdates( bool frequentUpdatesIn ) { mFrequentUpdates = frequentUpdatesIn; };
105
106 void setIgnoreUIScale(bool ignore) { mIgnoreUIScale = ignore; }
107 bool getIgnoreUIScale() { return mIgnoreUIScale; }
108
109 void setAlwaysRefresh(bool refresh) { mAlwaysRefresh = refresh; }
110 bool getAlwaysRefresh() { return mAlwaysRefresh; }
111
112 void setForceUpdate(bool force_update) { mForceUpdate = force_update; }
113 bool getForceUpdate() { return mForceUpdate; }
114
115 LLPluginClassMedia* getMediaPlugin();
116
117 bool setCaretColor( unsigned int red, unsigned int green, unsigned int blue );
118
119
120 // over-rides
121 virtual BOOL handleKeyHere( KEY key, MASK mask);
122 virtual void handleVisibilityChange ( BOOL new_visibility );
123 virtual BOOL handleUnicodeCharHere(llwchar uni_char);
124 virtual void reshape( S32 width, S32 height, BOOL called_from_parent = TRUE);
125 virtual void draw();
126 virtual void onVisibilityChange ( BOOL curVisibilityIn );
127
128 // focus overrides
129 void onFocusLost();
130 void onFocusReceived();
131
132 // Incoming media event dispatcher
133 virtual void handleMediaEvent(LLPluginClassMedia* self, EMediaEvent event);
134
135 // handlers for individual events (could be done inside the switch in handleMediaEvent, they're just individual functions for clarity)
136 void onClickLinkHref( LLPluginClassMedia* self );
137 void onClickLinkNoFollow( LLPluginClassMedia* self );
138
139 protected:
140 void convertInputCoords(S32& x, S32& y);
141
142 private:
143 static bool onClickLinkExternalTarget( const LLSD&, const LLSD& );
144
145 const S32 mTextureDepthBytes;
146 LLWebBrowserTexture* mWebBrowserImage;
147 LLViewBorder* mBorder;
148 bool mFrequentUpdates;
149 bool mForceUpdate;
150 bool mOpenLinksInExternalBrowser;
151 bool mOpenLinksInInternalBrowser;
152 bool mTrusted;
153 std::string mHomePageUrl;
154 std::string mExternalUrl;
155 std::string mCurrentNavUrl;
156 bool mIgnoreUIScale;
157 bool mAlwaysRefresh;
158 viewer_media_t mMediaSource;
159 bool mTakeFocusOnClick;
160 ECursorType mLastSetCursor;
161 bool mStretchToFill;
162 bool mMaintainAspectRatio;
163 bool mHideLoading;
164};
165
166////////////////////////////////////////////////////////////////////////////////
167//
168class LLWebBrowserTexture : public LLDynamicTexture
169{
170LOG_CLASS(LLWebBrowserTexture);
171 public:
172 LLWebBrowserTexture( S32 width, S32 height, LLMediaCtrl* browserCtrl, viewer_media_t media_source );
173 virtual ~LLWebBrowserTexture();
174
175 virtual BOOL needsRender();
176 virtual void preRender( BOOL clear_depth = TRUE ) {};
177 virtual void postRender( BOOL success ) {};
178 virtual BOOL render();
179
180 bool adjustSize();
181 S32 getMediaWidth();
182 S32 getMediaHeight();
183 bool getNeedsUpdate();
184 void setNeedsUpdate();
185 bool getTextureCoordsOpenGL();
186
187 void resize( S32 new_width, S32 new_height );
188 bool updateBrowserTexture();
189
190 protected:
191 S32 mMediaWidth;
192 S32 mMediaHeight;
193 bool mNeedsUpdate;
194 bool mNeedsResize;
195 bool mTextureCoordsOpenGL;
196 LLFrameTimer mElapsedTime;
197 LLMediaCtrl* mWebBrowserCtrl;
198 viewer_media_t mMediaSource;
199};
200
201#endif // LL_LLMediaCtrl_H