PageRenderTime 59ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/newview/llpreview.h

https://bitbucket.org/lindenlab/viewer-beta/
C Header | 161 lines | 86 code | 38 blank | 37 comment | 0 complexity | 1ded96fc40a55effe943ba0bcd4365a9 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llpreview.h
  3. * @brief LLPreview class definition
  4. *
  5. * $LicenseInfo:firstyear=2002&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_LLPREVIEW_H
  27. #define LL_LLPREVIEW_H
  28. #include "llmultifloater.h"
  29. #include "llresizehandle.h"
  30. #include "llpointer.h"
  31. #include "lluuid.h"
  32. #include "llinventoryobserver.h"
  33. #include <map>
  34. class LLInventoryItem;
  35. class LLLineEditor;
  36. class LLRadioGroup;
  37. class LLPreview;
  38. class LLMultiPreview : public LLMultiFloater
  39. {
  40. public:
  41. LLMultiPreview();
  42. /*virtual*/void onOpen(const LLSD& key);
  43. /*virtual*/void tabOpen(LLFloater* opened_floater, bool from_click);
  44. /*virtual*/ void handleReshape(const LLRect& new_rect, bool by_user = false);
  45. };
  46. // https://wiki.lindenlab.com/mediawiki/index.php?title=LLPreview&oldid=81373
  47. class LLPreview : public LLFloater, LLInventoryObserver
  48. {
  49. public:
  50. typedef enum e_asset_status
  51. {
  52. PREVIEW_ASSET_ERROR,
  53. PREVIEW_ASSET_UNLOADED,
  54. PREVIEW_ASSET_LOADING,
  55. PREVIEW_ASSET_LOADED
  56. } EAssetStatus;
  57. public:
  58. LLPreview(const LLSD& key );
  59. virtual ~LLPreview();
  60. /*virtual*/ BOOL postBuild();
  61. virtual void setObjectID(const LLUUID& object_id);
  62. void setItem( LLInventoryItem* item );
  63. void setAssetId(const LLUUID& asset_id);
  64. const LLInventoryItem* getItem() const; // searches if not constructed with it
  65. static void hide(const LLUUID& item_uuid, BOOL no_saving = FALSE );
  66. static void dirty(const LLUUID& item_uuid);
  67. virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask);
  68. virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask);
  69. virtual BOOL handleHover(S32 x, S32 y, MASK mask);
  70. virtual void onOpen(const LLSD& key);
  71. void setAuxItem( const LLInventoryItem* item );
  72. static void onBtnCopyToInv(void* userdata);
  73. void addKeepDiscardButtons();
  74. static void onKeepBtn(void* data);
  75. static void onDiscardBtn(void* data);
  76. /*virtual*/ void handleReshape(const LLRect& new_rect, bool by_user = false);
  77. void userResized() { mUserResized = TRUE; };
  78. virtual void loadAsset() { mAssetStatus = PREVIEW_ASSET_LOADED; }
  79. virtual EAssetStatus getAssetStatus() { return mAssetStatus;}
  80. static LLPreview* getFirstPreviewForSource(const LLUUID& source_id);
  81. // Why is this at the LLPreview level? JC
  82. void setNotecardInfo(const LLUUID& notecard_inv_id, const LLUUID& object_id);
  83. // llview
  84. /*virtual*/ void draw();
  85. void refreshFromItem();
  86. protected:
  87. virtual void onCommit();
  88. void addDescriptionUI();
  89. static void onText(LLUICtrl*, void* userdata);
  90. static void onRadio(LLUICtrl*, void* userdata);
  91. // for LLInventoryObserver
  92. virtual void changed(U32 mask);
  93. BOOL mDirty;
  94. protected:
  95. LLUUID mItemUUID;
  96. // mObjectUUID will have a value if it is associated with a task in
  97. // the world, and will be == LLUUID::null if it's in the agent
  98. // inventory.
  99. LLUUID mObjectUUID;
  100. LLRect mClientRect;
  101. LLPointer<LLInventoryItem> mAuxItem; // HACK!
  102. LLPointer<LLInventoryItem> mItem; // For embedded items (Landmarks)
  103. LLButton* mCopyToInvBtn;
  104. // Close without saving changes
  105. BOOL mForceClose;
  106. BOOL mUserResized;
  107. // When closing springs a "Want to save?" dialog, we want
  108. // to keep the preview open until the save completes.
  109. BOOL mCloseAfterSave;
  110. EAssetStatus mAssetStatus;
  111. LLUUID mNotecardInventoryID;
  112. // I am unsure if this is always the same as mObjectUUID, or why it exists
  113. // at the LLPreview level. JC 2009-06-24
  114. LLUUID mNotecardObjectID;
  115. };
  116. const S32 PREVIEW_BORDER = 4;
  117. const S32 PREVIEW_PAD = 5;
  118. const S32 PREVIEW_LINE_HEIGHT = 19;
  119. const S32 PREVIEW_BORDER_WIDTH = 2;
  120. const S32 PREVIEW_RESIZE_HANDLE_SIZE = S32(RESIZE_HANDLE_WIDTH * OO_SQRT2) + PREVIEW_BORDER_WIDTH;
  121. const S32 PREVIEW_VPAD = 2;
  122. const S32 PREVIEW_HEADER_SIZE = 2*PREVIEW_LINE_HEIGHT + 2 * PREVIEW_VPAD;
  123. #endif // LL_LLPREVIEW_H