PageRenderTime 411ms CodeModel.GetById 24ms RepoModel.GetById 7ms app.codeStats 0ms

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