aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/floaterlocalassetbrowse.h
blob: e02a7d3d2a17613b9207972178cb91ce9302fea6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
/**
* @file floaterlocalassetbrowse.h
* @brief Local texture support
*
* $LicenseInfo:firstyear=2009&license=viewergpl$
*
* 2010, original author Vaalith Jinn
*
* Imprudence Viewer Source Code
* The source code in this file ("Source Code") is provided to you
* under the terms of the GNU General Public License, version 2.0
* ("GPL"). Terms of the GPL can be found in doc/GPL-license.txt in
* this distribution, or online at
* http://secondlifegrid.net/programs/open_source/licensing/gplv2
*
* There are special exceptions to the terms and conditions of the GPL as
* it is applied to this Source Code. View the full text of the exception
* in the file doc/FLOSS-exception.txt in this software distribution, or
* online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
*
* By copying, modifying or distributing this software, you acknowledge
* that you have read and understood your obligations described above,
* and agree to abide by those obligations.
*
* ALL SOURCE CODE IS PROVIDED "AS IS." THE AUTHOR MAKES NO
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
* COMPLETENESS OR PERFORMANCE.
* $/LicenseInfo$
*/

/* Local Asset Browser: header 

tag: vaa emerald local_asset_browser

*/


#ifndef VAA_LOCALBROWSER
#define VAA_LOCALBROWSER

#include "llfloater.h"
#include "llscrolllistctrl.h"
#include "lltexturectrl.h"
#include "lldrawable.h"


/*=======================================*/
/*  Global structs / enums / defines     */
/*=======================================*/ 

#define LF_FLOATER_EXPAND_WIDTH 735
#define LF_FLOATER_CONTRACT_WIDTH 415
#define LF_FLOATER_HEIGHT 260

#define LOCAL_USE_MIPMAPS true
#define LOCAL_DISCARD_LEVEL 0
#define NO_IMAGE LLUUID::null

#define TIMER_HEARTBEAT 3.0

#define SLAM_FOR_DEBUG true

enum bitmaplist_cols
{
	BITMAPLIST_COL_NAME,
	BITMAPLIST_COL_ID
};

/* upload & sculpt update related */
struct affected_object
{
	LLViewerObject* object;
	std::vector<LLFace*> face_list;
	bool local_sculptmap;

};

/* texture picker defines */

#define LOCAL_TEXTURE_PICKER_NAME "texture picker"
#define LOCAL_TEXTURE_PICKER_LIST_NAME "local_name_list"
#define LOCAL_TEXTURE_PICKER_RECURSE true
#define LOCAL_TEXTURE_PICKER_CREATEIFMISSING true


/*=======================================*/
/*  LocalBitmap: unit class              */
/*=======================================*/ 
/*
	The basic unit class responsible for
	containing one loaded local texture.
*/

class LocalBitmap
{
	public:
		LocalBitmap(std::string filename);
		virtual ~LocalBitmap(void);
		friend class LocalAssetBrowser;

	public: /* [enums, typedefs, etc] */
		enum link_status
		{
			LINK_UNKNOWN, /* default fallback */
			LINK_ON,
			LINK_OFF,
			LINK_BROKEN,
			LINK_UPDATING /* currently redundant, but left in case necessary later. */
		};

		enum extension_type
		{
			IMG_EXTEN_BMP,
			IMG_EXTEN_TGA,
			IMG_EXTEN_JPG,
			IMG_EXTEN_PNG
		};

		enum bitmap_type
		{
			TYPE_TEXTURE = 0,
			TYPE_SCULPT = 1,
			TYPE_LAYER = 2
		};

	public: /* [information query functions] */
		std::string getShortName(void);
		std::string getFileName(void);
		LLUUID      getID(void);
		LLSD        getLastModified(void);
		std::string getLinkStatus(void);
		bool        getUpdateBool(void);
		void        setType( S32 );
		bool        getIfValidBool(void);
		S32		    getType(void);
		void		getDebugInfo(void);

	private: /* [maintenence functions] */
		void updateSelf(void);
		bool decodeSelf(LLImageRaw* rawimg);
		void setUpdateBool(void);

		LocalBitmap*				 getThis(void);
		std::vector<LLFace*>		 getFaceUsesThis(LLDrawable*);
		std::vector<affected_object> getUsingObjects(bool seek_by_type = true,
												     bool seek_textures = false, bool seek_sculptmaps = false);

	protected: /* [basic properties] */
		std::string    shortname;
		std::string    filename;
		extension_type extension;
		LLUUID         id;
		LLSD           last_modified;
		link_status    linkstatus;
		bool           keep_updating;
		bool           valid;
		S32		       bitmap_type;
		bool           sculpt_dirty;
		bool           volume_dirty;
};

/*=======================================*/
/*  LocalAssetBrowser: main class        */
/*=======================================*/ 
/*
	Responsible for internal workings.
	Instantiated at the top of the source file.
	Sits in memory until the viewer is closed.

*/


class LocalAssetBrowser
{
	public:
		LocalAssetBrowser();
		virtual ~LocalAssetBrowser();
		friend class FloaterLocalAssetBrowser;
		friend class LocalAssetBrowserTimer;
		static void UpdateTextureCtrlList(LLScrollListCtrl*);
		static void setLayerUpdated(bool toggle) { mLayerUpdated = toggle; }
		static void setSculptUpdated(bool toggle) { mSculptUpdated = toggle; }
		static void AddBitmap(void);
		static void DelBitmap( std::vector<LLScrollListItem*>, S32 column = BITMAPLIST_COL_ID );

		/* UpdateTextureCtrlList was made public cause texturectrl requests it once on spawn 
		   ( added: when it's own add/remove funcs are used. )
		   i've made it update on spawn instead of on pressing 'local' because the former does it once, 
		   the latter - each time the button's pressed. */

	private:
		static void onChangeHappened(void);
		static void onUpdateBool(LLUUID);
		static void onSetType(LLUUID, S32);
		static LocalBitmap* GetBitmapUnit(LLUUID);
		static bool IsDoingUpdates(void);
		static void PingTimer(void);
		static void PerformTimedActions(void);
		static void PerformSculptUpdates(LocalBitmap*);

	protected:
		static  std::vector<LocalBitmap*> loaded_bitmaps;
		typedef std::vector<LocalBitmap*>::iterator local_list_iter;
		static  bool    mLayerUpdated;
		static  bool    mSculptUpdated; 
};

/*==================================================*/
/*  FloaterLocalAssetBrowser : interface class      */
/*==================================================*/ 
/*
	Responsible for talking to the user.
	Instantiated by user request.
	Destroyed when the floater is closed.

*/
class FloaterLocalAssetBrowser : public LLFloater
{
public:
    FloaterLocalAssetBrowser();
    virtual ~FloaterLocalAssetBrowser();
    static void show(void*);


 
private: 
	/* Widget related callbacks */
    // Button callback declarations
    static void onClickAdd(void* userdata);
	static void onClickDel(void* userdata);
	static void onClickMore(void* userdata);
	static void onClickLess(void* userdata);
	static void onClickUpload(void* userdata);

	// ScrollList callback declarations
	static void onChooseBitmapList(LLUICtrl* ctrl, void* userdata);

	// Checkbox callback declarations
	static void onClickUpdateChkbox(LLUICtrl* ctrl, void* userdata);

	// Combobox type select
	static void onCommitTypeCombo(LLUICtrl* ctrl, void* userdata);

	// Widgets
	LLButton* mAddBtn;
	LLButton* mDelBtn;
	LLButton* mUploadBtn;

	LLScrollListCtrl* mBitmapList;
	LLScrollListCtrl* mUsedList;
	LLTextureCtrl*    mTextureView;
	LLCheckBoxCtrl*   mUpdateChkBox;

	LLLineEditor* mPathTxt;
	LLLineEditor* mUUIDTxt;
	LLLineEditor* mNameTxt;

	LLTextBox*  mLinkTxt;
	LLTextBox*  mTimeTxt;
	LLComboBox* mTypeComboBox;

	LLTextBox* mCaptionPathTxt;
	LLTextBox* mCaptionUUIDTxt;
	LLTextBox* mCaptionLinkTxt;
	LLTextBox* mCaptionNameTxt;
	LLTextBox* mCaptionTimeTxt;

	/* static pointer to self, wai? oh well. */
    static FloaterLocalAssetBrowser* sLFInstance;

	// non-widget functions
	static void UpdateRightSide(void);

public:
	static void UpdateBitmapScrollList(void);


};

/*==================================================*/
/*     LocalAssetBrowserTimer : timer class         */
/*==================================================*/ 
/*
	A small, simple timer class inheriting from
	LLEventTimer, responsible for pinging the
	LocalAssetBrowser class to perform it's
	updates / checks / etc.

*/
class LocalAssetBrowserTimer : public LLEventTimer
{
	public:
		LocalAssetBrowserTimer();
		~LocalAssetBrowserTimer();
		virtual BOOL tick();
		void		 start();
		void		 stop();
		bool         isRunning();
};

#endif