llpreview.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLPREVIEW_H
00033 #define LL_LLPREVIEW_H
00034 
00035 #include "llfloater.h"
00036 #include "llresizehandle.h"
00037 #include "llmap.h"
00038 #include "lluuid.h"
00039 #include "llviewerinventory.h"
00040 #include "lltabcontainer.h"
00041 #include <map>
00042 
00043 class LLLineEditor;
00044 class LLRadioGroup;
00045 class LLPreview;
00046 
00047 class LLMultiPreview : public LLMultiFloater
00048 {
00049 public:
00050         LLMultiPreview(const LLRect& rect);
00051 
00052         /*virtual*/void open();         /*Flawfinder: ignore*/
00053         /*virtual*/void tabOpen(LLFloater* opened_floater, bool from_click);
00054         /*virtual*/ void userSetShape(const LLRect& new_rect);
00055 
00056         static LLMultiPreview* getAutoOpenInstance(const LLUUID& id);
00057         static void setAutoOpenInstance(LLMultiPreview* previewp, const LLUUID& id);
00058 
00059 protected:
00060         typedef std::map<LLUUID, LLViewHandle> handle_map_t;
00061         static std::map<LLUUID, LLViewHandle> sAutoOpenPreviewHandles;
00062 };
00063 
00064 class LLPreview : public LLFloater
00065 {
00066 public:
00067         typedef enum e_asset_status
00068         {
00069                 PREVIEW_ASSET_ERROR,
00070                 PREVIEW_ASSET_UNLOADED,
00071                 PREVIEW_ASSET_LOADING,
00072                 PREVIEW_ASSET_LOADED
00073         } EAssetStatus;
00074 public:
00075         // Used for XML-based construction.
00076         LLPreview(const std::string& name);
00077         LLPreview(const std::string& name, const LLRect& rect, const std::string& title, const LLUUID& item_uuid, const LLUUID& object_uuid, BOOL allow_resize = FALSE, S32 min_width = 0, S32 min_height = 0, LLPointer<LLViewerInventoryItem> inv_item = NULL );
00078         virtual ~LLPreview();
00079 
00080         void setItemID(const LLUUID& item_id);
00081         void setObjectID(const LLUUID& object_id);
00082         void setSourceID(const LLUUID& source_id);
00083         const LLViewerInventoryItem *getItem() const; // searches if not constructed with it
00084 
00085         static LLPreview* find(const LLUUID& item_uuid);
00086         static LLPreview*       show(const LLUUID& item_uuid, BOOL take_focus = TRUE );
00087         static void                     hide(const LLUUID& item_uuid, BOOL no_saving = FALSE );
00088         static void                     rename(const LLUUID& item_uuid, const std::string& new_name);
00089         static bool                     save(const LLUUID& item_uuid, LLPointer<LLInventoryItem>* itemptr);
00090 
00091         virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask);
00092         virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask);
00093         virtual BOOL handleHover(S32 x, S32 y, MASK mask);
00094         virtual void open();            /*Flawfinder: ignore*/
00095         virtual bool saveItem(LLPointer<LLInventoryItem>* itemptr);
00096  
00097         void setAuxItem( const LLInventoryItem* item )
00098         {
00099                 if ( mAuxItem ) 
00100                         mAuxItem->copy(item);
00101         }
00102 
00103         static void                     onBtnCopyToInv(void* userdata);
00104 
00105         void                            addKeepDiscardButtons();
00106         static void                     onKeepBtn(void* data);
00107         static void                     onDiscardBtn(void* data);
00108         /*virtual*/ void        userSetShape(const LLRect& new_rect);
00109 
00110         void userResized() { mUserResized = TRUE; };
00111 
00112         virtual void loadAsset() { mAssetStatus = PREVIEW_ASSET_LOADED; }
00113         virtual EAssetStatus getAssetStatus() { return mAssetStatus;}
00114 
00115         static LLPreview* getFirstPreviewForSource(const LLUUID& source_id);
00116         void setNotecardInfo(const LLUUID& notecard_inv_id, const LLUUID& object_id)
00117         { mNotecardInventoryID = notecard_inv_id; mObjectID = object_id; }
00118 
00119 protected:
00120         virtual void onCommit();
00121 
00122         void addDescriptionUI();
00123 
00124         static void onText(LLUICtrl*, void* userdata);
00125         static void onRadio(LLUICtrl*, void* userdata);
00126         
00127 
00128 protected:
00129         LLUUID mItemUUID;
00130         LLUUID  mSourceID;
00131 
00132         // mObjectID will have a value if it is associated with a task in
00133         // the world, and will be == LLUUID::null if it's in the agent
00134         // inventory.
00135         LLUUID mObjectUUID;
00136 
00137         LLRect mClientRect;
00138 
00139         LLPointer<LLInventoryItem> mAuxItem;  // HACK!
00140         LLButton* mCopyToInvBtn;
00141 
00142         // Close without saving changes
00143         BOOL mForceClose;
00144 
00145         BOOL mUserResized;
00146 
00147         // When closing springs a "Want to save?" dialog, we want
00148         // to keep the preview open until the save completes.
00149         BOOL mCloseAfterSave;
00150 
00151         EAssetStatus mAssetStatus;
00152 
00153         typedef std::map<LLUUID, LLPreview*> preview_map_t;
00154         typedef std::multimap<LLUUID, LLViewHandle> preview_multimap_t;
00155 
00156         static preview_multimap_t sPreviewsBySource;
00157         static preview_map_t sInstances;
00158         LLUUID mNotecardInventoryID;
00159         LLUUID mObjectID;
00160         LLPointer<LLViewerInventoryItem> mItem;
00161 };
00162 
00163 
00164 const S32 PREVIEW_BORDER = 4;
00165 const S32 PREVIEW_PAD = 5;
00166 const S32 PREVIEW_BUTTON_WIDTH = 100;
00167 
00168 const S32 PREVIEW_LINE_HEIGHT = 19;
00169 const S32 PREVIEW_CLOSE_BOX_SIZE = 16;
00170 const S32 PREVIEW_BORDER_WIDTH = 2;
00171 const S32 PREVIEW_RESIZE_HANDLE_SIZE = S32(RESIZE_HANDLE_WIDTH * OO_SQRT2) + PREVIEW_BORDER_WIDTH;
00172 const S32 PREVIEW_VPAD = 2;
00173 const S32 PREVIEW_HPAD = PREVIEW_RESIZE_HANDLE_SIZE;
00174 const S32 PREVIEW_HEADER_SIZE = 2*PREVIEW_LINE_HEIGHT + 2 * PREVIEW_VPAD;
00175 
00176 #endif  // LL_LLPREVIEW_H

Generated on Thu Jul 1 06:09:01 2010 for Second Life Viewer by  doxygen 1.4.7