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