llviewermediafocus.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /**
  2. * @file llviewermediafocus.h
  3. * @brief Declaration for the class governing focus on media prims
  4. *
  5. * $LicenseInfo:firstyear=2003&license=viewergpl$
  6. *
  7. * Copyright (c) 2003-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. #ifndef LL_VIEWERMEDIAFOCUS_H
  33. #define LL_VIEWERMEDIAFOCUS_H
  34. #include "llfocusmgr.h"
  35. #include "llselectmgr.h"
  36. #include "llviewermedia.h"
  37. #include "llviewerobject.h"
  38. #include "llviewerwindow.h" // For LLPickInfo
  39. class LLViewerMediaImpl;
  40. class LLPanelMediaHUD;
  41. class LLViewerMediaFocus : public LLFocusableElement,
  42. public LLSingleton<LLViewerMediaFocus>
  43. {
  44. friend class LLSingleton<LLViewerMediaFocus>;
  45. protected:
  46. LOG_CLASS(LLViewerMediaFocus);
  47. public:
  48. LLViewerMediaFocus();
  49. ~LLViewerMediaFocus();
  50. static void cleanupClass();
  51. void setFocusFace(bool face_auto_zoom, LLPointer<LLViewerObject> objectp,
  52. S32 face, viewer_media_t media_impl,
  53. LLVector3 pick_normal = LLVector3::zero);
  54. void clearFocus();
  55. // Set/clear the face that has "media hover" (has the mimimal set of
  56. // controls to zoom in or pop out into a media browser). If a media face
  57. // has focus, the media hover will be ignored.
  58. void setHoverFace(LLPointer<LLViewerObject> objectp,
  59. S32 face,
  60. viewer_media_t media_impl,
  61. LLVector3 pick_normal = LLVector3::zero);
  62. void clearHover();
  63. LL_INLINE void setPickInfo(LLPickInfo pick_info) { mPickInfo = pick_info; }
  64. bool getFocus();
  65. // The MOAP objects want keyup and keydown events. Overridden from
  66. // LLFocusableElement to return true.
  67. LL_INLINE bool wantsKeyUpKeyDown() const override { return true; }
  68. LL_INLINE bool wantsReturnKey() const override { return true; }
  69. bool handleKey(KEY key, MASK mask, bool called_from_parent) override;
  70. bool handleKeyUp(KEY key, MASK mask, bool called_from_parent) override;
  71. bool handleUnicodeChar(llwchar uni_char, bool called_from_parent) override;
  72. bool handleScrollWheel(S32 x, S32 y, S32 clicks);
  73. void update();
  74. void setCameraZoom(LLViewerObject* object, LLVector3 normal,
  75. F32 padding_factor, bool zoom_in_only = true);
  76. void focusZoomOnMedia(const LLUUID& media_id);
  77. void unZoom();
  78. bool isZoomed();
  79. bool isZoomedOnMedia(const LLUUID& media_id);
  80. F32 getBBoxAspectRatio(const LLBBox& bbox, const LLVector3& normal,
  81. F32* height, F32* width, F32* depth);
  82. bool isFocusedOnFace(LLPointer<LLViewerObject> objectp, S32 face);
  83. bool isHoveringOverFace(LLPointer<LLViewerObject> objectp, S32 face);
  84. // These look up (by uuid) and return the values that were set with
  85. // setFocusFace. They will return null if the objects have been destroyed.
  86. LLViewerMediaImpl* getFocusedMediaImpl();
  87. LLViewerObject* getFocusedObject();
  88. LL_INLINE S32 getFocusedFace() { return mFocusedObjectFace; }
  89. LL_INLINE LLUUID getFocusedObjectID() { return mFocusedObjectID; }
  90. LL_INLINE LLObjectSelectionHandle getSelection() { return mSelection; }
  91. // These look up (by uuid) and return the values that were set with
  92. // setHoverFace. They will return null if the objects have been destroyed.
  93. LLViewerMediaImpl* getHoverMediaImpl();
  94. LLViewerObject* getHoverObject();
  95. LL_INLINE S32 getHoverFace() { return mHoverObjectFace; }
  96. LL_INLINE bool isFocusableCtrl() const override { return false; }
  97. protected:
  98. void onFocusReceived() override;
  99. void onFocusLost() override;
  100. private:
  101. LLHandle<LLPanelMediaHUD> mMediaHUD;
  102. LLObjectSelectionHandle mSelection;
  103. LLUUID mFocusedObjectID;
  104. LLUUID mFocusedImplID;
  105. LLUUID mPrevFocusedImplID;
  106. LLUUID mHoverObjectID;
  107. LLUUID mHoverImplID;
  108. LLVector3 mFocusedObjectNormal;
  109. LLVector3 mHoverObjectNormal;
  110. S32 mFocusedObjectFace;
  111. S32 mHoverObjectFace;
  112. LLPickInfo mPickInfo;
  113. bool mFocusedIsHUDObject;
  114. };
  115. #endif // LL_VIEWERMEDIAFOCUS_H