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 "llinventorymodel.h"
00042 #include <map>
00043
00044 class LLLineEditor;
00045 class LLRadioGroup;
00046 class LLPreview;
00047
00048 class LLMultiPreview : public LLMultiFloater
00049 {
00050 public:
00051 LLMultiPreview(const LLRect& rect);
00052
00053 void open();
00054 void tabOpen(LLFloater* opened_floater, bool from_click);
00055 void userSetShape(const LLRect& new_rect);
00056
00057 static LLMultiPreview* getAutoOpenInstance(const LLUUID& id);
00058 static void setAutoOpenInstance(LLMultiPreview* previewp, const LLUUID& id);
00059
00060 protected:
00061 typedef std::map<LLUUID, LLHandle<LLFloater> > handle_map_t;
00062 static handle_map_t sAutoOpenPreviewHandles;
00063 };
00064
00065
00066
00067 class LLPreview : public LLFloater, LLInventoryObserver
00068 {
00069 public:
00070 typedef enum e_asset_status
00071 {
00072 PREVIEW_ASSET_ERROR,
00073 PREVIEW_ASSET_UNLOADED,
00074 PREVIEW_ASSET_LOADING,
00075 PREVIEW_ASSET_LOADED
00076 } EAssetStatus;
00077 public:
00078
00079 LLPreview(const std::string& name);
00080 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 );
00081 virtual ~LLPreview();
00082
00083 void setItemID(const LLUUID& item_id);
00084 void setObjectID(const LLUUID& object_id);
00085 void setSourceID(const LLUUID& source_id);
00086 const LLViewerInventoryItem *getItem() const;
00087
00088 static LLPreview* find(const LLUUID& item_uuid);
00089 static LLPreview* show(const LLUUID& item_uuid, BOOL take_focus = TRUE );
00090 static void hide(const LLUUID& item_uuid, BOOL no_saving = FALSE );
00091 static void rename(const LLUUID& item_uuid, const std::string& new_name);
00092 static bool save(const LLUUID& item_uuid, LLPointer<LLInventoryItem>* itemptr);
00093
00094 virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask);
00095 virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask);
00096 virtual BOOL handleHover(S32 x, S32 y, MASK mask);
00097 virtual void open();
00098 virtual bool saveItem(LLPointer<LLInventoryItem>* itemptr);
00099
00100 void setAuxItem( const LLInventoryItem* item )
00101 {
00102 if ( mAuxItem )
00103 mAuxItem->copyItem(item);
00104 }
00105
00106 static void onBtnCopyToInv(void* userdata);
00107
00108 void addKeepDiscardButtons();
00109 static void onKeepBtn(void* data);
00110 static void onDiscardBtn(void* data);
00111 void userSetShape(const LLRect& new_rect);
00112
00113 void userResized() { mUserResized = TRUE; };
00114
00115 virtual void loadAsset() { mAssetStatus = PREVIEW_ASSET_LOADED; }
00116 virtual EAssetStatus getAssetStatus() { return mAssetStatus;}
00117
00118 static LLPreview* getFirstPreviewForSource(const LLUUID& source_id);
00119 void setNotecardInfo(const LLUUID& notecard_inv_id, const LLUUID& object_id)
00120 { mNotecardInventoryID = notecard_inv_id; mObjectID = object_id; }
00121
00122
00123 virtual void draw();
00124 void refreshFromItem(const LLInventoryItem* item);
00125
00126 protected:
00127 virtual void onCommit();
00128
00129 void addDescriptionUI();
00130
00131 static void onText(LLUICtrl*, void* userdata);
00132 static void onRadio(LLUICtrl*, void* userdata);
00133
00134
00135 virtual void changed(U32 mask);
00136 BOOL mDirty;
00137 virtual const char *getTitleName() const { return "Preview"; }
00138
00139 protected:
00140 LLUUID mItemUUID;
00141 LLUUID mSourceID;
00142
00143
00144
00145
00146 LLUUID mObjectUUID;
00147
00148 LLRect mClientRect;
00149
00150 LLPointer<LLInventoryItem> mAuxItem;
00151 LLButton* mCopyToInvBtn;
00152
00153
00154 BOOL mForceClose;
00155
00156 BOOL mUserResized;
00157
00158
00159
00160 BOOL mCloseAfterSave;
00161
00162 EAssetStatus mAssetStatus;
00163
00164 typedef std::map<LLUUID, LLPreview*> preview_map_t;
00165 typedef std::multimap<LLUUID, LLHandle<LLFloater> > preview_multimap_t;
00166
00167 static preview_multimap_t sPreviewsBySource;
00168 static preview_map_t sInstances;
00169 LLUUID mNotecardInventoryID;
00170 LLUUID mObjectID;
00171 LLPointer<LLViewerInventoryItem> mItem;
00172 };
00173
00174
00175 const S32 PREVIEW_BORDER = 4;
00176 const S32 PREVIEW_PAD = 5;
00177 const S32 PREVIEW_BUTTON_WIDTH = 100;
00178
00179 const S32 PREVIEW_LINE_HEIGHT = 19;
00180 const S32 PREVIEW_CLOSE_BOX_SIZE = 16;
00181 const S32 PREVIEW_BORDER_WIDTH = 2;
00182 const S32 PREVIEW_RESIZE_HANDLE_SIZE = S32(RESIZE_HANDLE_WIDTH * OO_SQRT2) + PREVIEW_BORDER_WIDTH;
00183 const S32 PREVIEW_VPAD = 2;
00184 const S32 PREVIEW_HPAD = PREVIEW_RESIZE_HANDLE_SIZE;
00185 const S32 PREVIEW_HEADER_SIZE = 2*PREVIEW_LINE_HEIGHT + 2 * PREVIEW_VPAD;
00186
00187 #endif // LL_LLPREVIEW_H