diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/llpanelface.cpp | |
parent | README.txt (diff) | |
download | meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2 meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz |
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/newview/llpanelface.cpp')
-rw-r--r-- | linden/indra/newview/llpanelface.cpp | 874 |
1 files changed, 874 insertions, 0 deletions
diff --git a/linden/indra/newview/llpanelface.cpp b/linden/indra/newview/llpanelface.cpp new file mode 100644 index 0000000..56deb91 --- /dev/null +++ b/linden/indra/newview/llpanelface.cpp | |||
@@ -0,0 +1,874 @@ | |||
1 | /** | ||
2 | * @file llpanelface.cpp | ||
3 | * @brief Panel in the tools floater for editing face textures, colors, etc. | ||
4 | * | ||
5 | * Copyright (c) 2001-2007, Linden Research, Inc. | ||
6 | * | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
8 | * to you under the terms of the GNU General Public License, version 2.0 | ||
9 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
10 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
11 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
12 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
13 | * | ||
14 | * There are special exceptions to the terms and conditions of the GPL as | ||
15 | * it is applied to this Source Code. View the full text of the exception | ||
16 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
17 | * online at http://secondlife.com/developers/opensource/flossexception | ||
18 | * | ||
19 | * By copying, modifying or distributing this software, you acknowledge | ||
20 | * that you have read and understood your obligations described above, | ||
21 | * and agree to abide by those obligations. | ||
22 | * | ||
23 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
24 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
25 | * COMPLETENESS OR PERFORMANCE. | ||
26 | */ | ||
27 | |||
28 | #include "llviewerprecompiledheaders.h" | ||
29 | |||
30 | // file include | ||
31 | #include "llpanelface.h" | ||
32 | |||
33 | // library includes | ||
34 | #include "llerror.h" | ||
35 | #include "llfocusmgr.h" | ||
36 | #include "llrect.h" | ||
37 | #include "llstring.h" | ||
38 | #include "llfontgl.h" | ||
39 | |||
40 | // project includes | ||
41 | #include "llbutton.h" | ||
42 | #include "llcheckboxctrl.h" | ||
43 | #include "llcolorswatch.h" | ||
44 | #include "llcombobox.h" | ||
45 | #include "lldrawpoolbump.h" | ||
46 | #include "lllineeditor.h" | ||
47 | #include "llresmgr.h" | ||
48 | #include "llselectmgr.h" | ||
49 | #include "llspinctrl.h" | ||
50 | #include "lltextbox.h" | ||
51 | #include "lltexturectrl.h" | ||
52 | #include "lltextureentry.h" | ||
53 | #include "lltexturetable.h" | ||
54 | #include "lltooldraganddrop.h" | ||
55 | #include "llui.h" | ||
56 | #include "llviewercontrol.h" | ||
57 | #include "llviewerobject.h" | ||
58 | #include "llviewerstats.h" | ||
59 | #include "llmediaengine.h" | ||
60 | |||
61 | #include "llvieweruictrlfactory.h" | ||
62 | |||
63 | // | ||
64 | // Methods | ||
65 | // | ||
66 | |||
67 | BOOL LLPanelFace::postBuild() | ||
68 | { | ||
69 | LLRect rect = this->getRect(); | ||
70 | LLTextureCtrl* mTextureCtrl; | ||
71 | LLColorSwatchCtrl* mColorSwatch; | ||
72 | |||
73 | LLTextBox* mLabelTexGen; | ||
74 | LLComboBox* mComboTexGen; | ||
75 | |||
76 | LLCheckBoxCtrl *mCheckFullbright; | ||
77 | |||
78 | LLTextBox* mLabelColorTransp; | ||
79 | LLSpinCtrl* mCtrlColorTransp; // transparency = 1 - alpha | ||
80 | |||
81 | setMouseOpaque(FALSE); | ||
82 | mTextureCtrl = LLUICtrlFactory::getTexturePickerByName(this,"texture control"); | ||
83 | if(mTextureCtrl) | ||
84 | { | ||
85 | mTextureCtrl->setDefaultImageAssetID(LLUUID( gSavedSettings.getString( "DefaultObjectTexture" ))); | ||
86 | mTextureCtrl->setCommitCallback( LLPanelFace::onCommitTexture ); | ||
87 | mTextureCtrl->setOnCancelCallback( LLPanelFace::onCancelTexture ); | ||
88 | mTextureCtrl->setOnSelectCallback( LLPanelFace::onSelectTexture ); | ||
89 | mTextureCtrl->setDragCallback(LLPanelFace::onDragTexture); | ||
90 | mTextureCtrl->setCallbackUserData( this ); | ||
91 | mTextureCtrl->setFollowsTop(); | ||
92 | mTextureCtrl->setFollowsLeft(); | ||
93 | // Don't allow (no copy) or (no transfer) textures to be selected during immediate mode | ||
94 | mTextureCtrl->setImmediateFilterPermMask(PERM_COPY | PERM_TRANSFER); | ||
95 | // Allow any texture to be used during non-immediate mode. | ||
96 | mTextureCtrl->setNonImmediateFilterPermMask(PERM_NONE); | ||
97 | LLAggregatePermissions texture_perms; | ||
98 | if (gSelectMgr->selectGetAggregateTexturePermissions(texture_perms)) | ||
99 | { | ||
100 | BOOL can_copy = | ||
101 | texture_perms.getValue(PERM_COPY) == LLAggregatePermissions::AP_EMPTY || | ||
102 | texture_perms.getValue(PERM_COPY) == LLAggregatePermissions::AP_ALL; | ||
103 | BOOL can_transfer = | ||
104 | texture_perms.getValue(PERM_TRANSFER) == LLAggregatePermissions::AP_EMPTY || | ||
105 | texture_perms.getValue(PERM_TRANSFER) == LLAggregatePermissions::AP_ALL; | ||
106 | mTextureCtrl->setCanApplyImmediately(can_copy && can_transfer); | ||
107 | } | ||
108 | else | ||
109 | { | ||
110 | mTextureCtrl->setCanApplyImmediately(FALSE); | ||
111 | } | ||
112 | } | ||
113 | |||
114 | mColorSwatch = LLUICtrlFactory::getColorSwatchByName(this,"colorswatch"); | ||
115 | if(mColorSwatch) | ||
116 | { | ||
117 | mColorSwatch->setCommitCallback(LLPanelFace::onCommitColor); | ||
118 | mColorSwatch->setOnCancelCallback(LLPanelFace::onCancelColor); | ||
119 | mColorSwatch->setOnSelectCallback(LLPanelFace::onSelectColor); | ||
120 | mColorSwatch->setCallbackUserData( this ); | ||
121 | mColorSwatch->setFollowsTop(); | ||
122 | mColorSwatch->setFollowsLeft(); | ||
123 | mColorSwatch->setCanApplyImmediately(TRUE); | ||
124 | } | ||
125 | |||
126 | mLabelColorTransp = LLUICtrlFactory::getTextBoxByName(this,"color trans"); | ||
127 | if(mLabelColorTransp) | ||
128 | { | ||
129 | mLabelColorTransp->setFollowsTop(); | ||
130 | mLabelColorTransp->setFollowsLeft(); | ||
131 | } | ||
132 | |||
133 | mCtrlColorTransp = LLUICtrlFactory::getSpinnerByName(this,"ColorTrans"); | ||
134 | if(mCtrlColorTransp) | ||
135 | { | ||
136 | mCtrlColorTransp->setCommitCallback(LLPanelFace::onCommitAlpha); | ||
137 | mCtrlColorTransp->setCallbackUserData(this); | ||
138 | mCtrlColorTransp->setPrecision(0); | ||
139 | mCtrlColorTransp->setFollowsTop(); | ||
140 | mCtrlColorTransp->setFollowsLeft(); | ||
141 | } | ||
142 | |||
143 | mCheckFullbright = LLUICtrlFactory::getCheckBoxByName(this,"checkbox fullbright"); | ||
144 | if (mCheckFullbright) | ||
145 | { | ||
146 | mCheckFullbright->setCommitCallback(LLPanelFace::onCommitFullbright); | ||
147 | mCheckFullbright->setCallbackUserData( this ); | ||
148 | } | ||
149 | mLabelTexGen = LLUICtrlFactory::getTextBoxByName(this,"tex gen"); | ||
150 | mComboTexGen = LLUICtrlFactory::getComboBoxByName(this,"combobox texgen"); | ||
151 | if(mComboTexGen) | ||
152 | { | ||
153 | mComboTexGen->setCommitCallback(LLPanelFace::onCommitTexGen); | ||
154 | mComboTexGen->setFollows(FOLLOWS_LEFT | FOLLOWS_TOP); | ||
155 | mComboTexGen->setCallbackUserData( this ); | ||
156 | } | ||
157 | childSetCommitCallback("combobox shininess",&LLPanelFace::onCommitShiny,this); | ||
158 | childSetCommitCallback("combobox bumpiness",&LLPanelFace::onCommitBump,this); | ||
159 | childSetCommitCallback("TexScaleU",&LLPanelFace::onCommitTextureInfo, this); | ||
160 | childSetCommitCallback("checkbox flip s",&LLPanelFace::onCommitTextureInfo, this); | ||
161 | childSetCommitCallback("TexScaleV",&LLPanelFace::onCommitTextureInfo, this); | ||
162 | childSetCommitCallback("checkbox flip t",&LLPanelFace::onCommitTextureInfo, this); | ||
163 | childSetCommitCallback("TexRot",&LLPanelFace::onCommitTextureInfo, this); | ||
164 | childSetAction("button apply",&onClickApply,this); | ||
165 | childSetCommitCallback("TexOffsetU",LLPanelFace::onCommitTextureInfo, this); | ||
166 | childSetCommitCallback("TexOffsetV",LLPanelFace::onCommitTextureInfo, this); | ||
167 | childSetAction("button align",onClickAutoFix,this); | ||
168 | |||
169 | clearCtrls(); | ||
170 | |||
171 | return TRUE; | ||
172 | } | ||
173 | |||
174 | LLPanelFace::LLPanelFace(const std::string& name) | ||
175 | : LLPanel(name) | ||
176 | { | ||
177 | } | ||
178 | |||
179 | |||
180 | LLPanelFace::~LLPanelFace() | ||
181 | { | ||
182 | // Children all cleaned up by default view destructor. | ||
183 | } | ||
184 | |||
185 | |||
186 | void LLPanelFace::sendTexture() | ||
187 | { | ||
188 | LLTextureCtrl* mTextureCtrl = gUICtrlFactory->getTexturePickerByName(this,"texture control"); | ||
189 | if(!mTextureCtrl) return; | ||
190 | if( !mTextureCtrl->getTentative() ) | ||
191 | { | ||
192 | // we grab the item id first, because we want to do a | ||
193 | // permissions check in the selection manager. ARGH! | ||
194 | LLUUID id = mTextureCtrl->getImageItemID(); | ||
195 | if(id.isNull()) | ||
196 | { | ||
197 | id = mTextureCtrl->getImageAssetID(); | ||
198 | } | ||
199 | gSelectMgr->selectionSetImage(id); | ||
200 | } | ||
201 | } | ||
202 | |||
203 | void LLPanelFace::sendBump() | ||
204 | { | ||
205 | LLComboBox* mComboBumpiness = gUICtrlFactory->getComboBoxByName(this,"combobox bumpiness"); | ||
206 | if(!mComboBumpiness)return; | ||
207 | U8 bump = (U8) mComboBumpiness->getCurrentIndex() & TEM_BUMP_MASK; | ||
208 | gSelectMgr->selectionSetBumpmap( bump ); | ||
209 | } | ||
210 | |||
211 | void LLPanelFace::sendTexGen() | ||
212 | { | ||
213 | LLComboBox* mComboTexGen = gUICtrlFactory->getComboBoxByName(this,"combobox texgen"); | ||
214 | if(!mComboTexGen)return; | ||
215 | U8 tex_gen = (U8) mComboTexGen->getCurrentIndex() << TEM_TEX_GEN_SHIFT; | ||
216 | gSelectMgr->selectionSetTexGen( tex_gen ); | ||
217 | } | ||
218 | |||
219 | void LLPanelFace::sendShiny() | ||
220 | { | ||
221 | LLComboBox* mComboShininess = gUICtrlFactory->getComboBoxByName(this,"combobox shininess"); | ||
222 | if(!mComboShininess)return; | ||
223 | U8 shiny = (U8) mComboShininess->getCurrentIndex() & TEM_SHINY_MASK; | ||
224 | gSelectMgr->selectionSetShiny( shiny ); | ||
225 | } | ||
226 | |||
227 | void LLPanelFace::sendFullbright() | ||
228 | { | ||
229 | LLCheckBoxCtrl* mCheckFullbright = gUICtrlFactory->getCheckBoxByName(this,"checkbox fullbright"); | ||
230 | if(!mCheckFullbright)return; | ||
231 | U8 fullbright = mCheckFullbright->get() ? TEM_FULLBRIGHT_MASK : 0; | ||
232 | gSelectMgr->selectionSetFullbright( fullbright ); | ||
233 | } | ||
234 | |||
235 | void LLPanelFace::sendColor() | ||
236 | { | ||
237 | |||
238 | LLColorSwatchCtrl* mColorSwatch = LLViewerUICtrlFactory::getColorSwatchByName(this,"colorswatch"); | ||
239 | if(!mColorSwatch)return; | ||
240 | LLColor4 color = mColorSwatch->get(); | ||
241 | |||
242 | gSelectMgr->selectionSetColorOnly( color ); | ||
243 | } | ||
244 | |||
245 | void LLPanelFace::sendAlpha() | ||
246 | { | ||
247 | LLSpinCtrl* mCtrlColorTransp = LLViewerUICtrlFactory::getSpinnerByName(this,"ColorTrans"); | ||
248 | if(!mCtrlColorTransp)return; | ||
249 | F32 alpha = (100.f - mCtrlColorTransp->get()) / 100.f; | ||
250 | |||
251 | gSelectMgr->selectionSetAlphaOnly( alpha ); | ||
252 | } | ||
253 | |||
254 | |||
255 | |||
256 | void LLPanelFace::sendTextureInfo() | ||
257 | { | ||
258 | S32 te; | ||
259 | LLViewerObject* object; | ||
260 | for ( gSelectMgr->getFirstTE(&object, &te); object; gSelectMgr->getNextTE(&object, &te) ) | ||
261 | { | ||
262 | BOOL valid; | ||
263 | F32 value; | ||
264 | LLSpinCtrl* mCtrlTexScaleS = LLViewerUICtrlFactory::getSpinnerByName(this,"TexScaleU"); | ||
265 | LLSpinCtrl* mCtrlTexScaleT = LLViewerUICtrlFactory::getSpinnerByName(this,"TexScaleV"); | ||
266 | LLSpinCtrl* mCtrlTexOffsetS = LLViewerUICtrlFactory::getSpinnerByName(this,"TexOffsetU"); | ||
267 | LLSpinCtrl* mCtrlTexOffsetT = LLViewerUICtrlFactory::getSpinnerByName(this,"TexOffsetV"); | ||
268 | LLSpinCtrl* mCtrlTexRotation = LLViewerUICtrlFactory::getSpinnerByName(this,"TexRot"); | ||
269 | LLCheckBoxCtrl* mCheckFlipScaleS = LLViewerUICtrlFactory::getCheckBoxByName(this,"checkbox flip s"); | ||
270 | LLCheckBoxCtrl* mCheckFlipScaleT = LLViewerUICtrlFactory::getCheckBoxByName(this,"checkbox flip t"); | ||
271 | LLComboBox* mComboTexGen = LLViewerUICtrlFactory::getComboBoxByName(this,"combobox texgen"); | ||
272 | if (mCtrlTexScaleS) | ||
273 | { | ||
274 | valid = !mCtrlTexScaleS->getTentative() || !mCheckFlipScaleS->getTentative(); | ||
275 | if (valid) | ||
276 | { | ||
277 | value = mCtrlTexScaleS->get(); | ||
278 | if( mCheckFlipScaleS->get() ) | ||
279 | { | ||
280 | value = -value; | ||
281 | } | ||
282 | if (mComboTexGen->getCurrentIndex() == 1) | ||
283 | { | ||
284 | value *= 0.5f; | ||
285 | } | ||
286 | object->setTEScaleS( te, value ); | ||
287 | } | ||
288 | } | ||
289 | |||
290 | if (mCtrlTexScaleT) | ||
291 | { | ||
292 | valid = !mCtrlTexScaleT->getTentative() || !mCheckFlipScaleT->getTentative(); | ||
293 | if (valid) | ||
294 | { | ||
295 | value = mCtrlTexScaleT->get(); | ||
296 | if( mCheckFlipScaleT->get() ) | ||
297 | { | ||
298 | value = -value; | ||
299 | } | ||
300 | if (mComboTexGen->getCurrentIndex() == 1) | ||
301 | { | ||
302 | value *= 0.5f; | ||
303 | } | ||
304 | object->setTEScaleT( te, value ); | ||
305 | } | ||
306 | } | ||
307 | |||
308 | if (mCtrlTexOffsetS) | ||
309 | { | ||
310 | valid = !mCtrlTexOffsetS->getTentative(); | ||
311 | if (valid) | ||
312 | { | ||
313 | value = mCtrlTexOffsetS->get(); | ||
314 | object->setTEOffsetS( te, value ); | ||
315 | } | ||
316 | } | ||
317 | |||
318 | if (mCtrlTexOffsetT) | ||
319 | { | ||
320 | valid = !mCtrlTexOffsetT->getTentative(); | ||
321 | if (valid) | ||
322 | { | ||
323 | value = mCtrlTexOffsetT->get(); | ||
324 | object->setTEOffsetT( te, value ); | ||
325 | } | ||
326 | } | ||
327 | |||
328 | if (mCtrlTexRotation) | ||
329 | { | ||
330 | valid = !mCtrlTexRotation->getTentative(); | ||
331 | if (valid) | ||
332 | { | ||
333 | value = mCtrlTexRotation->get() * DEG_TO_RAD; | ||
334 | object->setTERotation( te, value ); | ||
335 | } | ||
336 | } | ||
337 | } | ||
338 | |||
339 | for ( object = gSelectMgr->getFirstObject(); object; object = gSelectMgr->getNextObject() ) | ||
340 | { | ||
341 | object->sendTEUpdate(); | ||
342 | } | ||
343 | } | ||
344 | |||
345 | void LLPanelFace::getState() | ||
346 | { | ||
347 | LLViewerObject* objectp = gSelectMgr->getFirstObject(); | ||
348 | |||
349 | if( objectp | ||
350 | && objectp->getPCode() == LL_PCODE_VOLUME) | ||
351 | { | ||
352 | BOOL editable = objectp->permModify(); | ||
353 | |||
354 | // only turn on auto-adjust button if there is a media renderer and the media is loaded | ||
355 | childSetEnabled("textbox autofix",FALSE); | ||
356 | //mLabelTexAutoFix->setEnabled ( FALSE ); | ||
357 | childSetEnabled("button align",FALSE); | ||
358 | //mBtnAutoFix->setEnabled ( FALSE ); | ||
359 | |||
360 | if ( LLMediaEngine::getInstance()->getMediaRenderer () ) | ||
361 | if ( LLMediaEngine::getInstance()->getMediaRenderer ()->isLoaded () ) | ||
362 | { | ||
363 | childSetEnabled("textbox autofix",editable); | ||
364 | //mLabelTexAutoFix->setEnabled ( editable ); | ||
365 | childSetEnabled("button align",editable); | ||
366 | //mBtnAutoFix->setEnabled ( editable ); | ||
367 | } | ||
368 | childSetEnabled("button apply",editable); | ||
369 | |||
370 | // Texture | ||
371 | LLUUID id; | ||
372 | BOOL identical = gSelectMgr->selectionGetTexUUID(id); | ||
373 | LLTextureCtrl* mTextureCtrl = LLViewerUICtrlFactory::getTexturePickerByName(this,"texture control"); | ||
374 | if (identical) | ||
375 | { | ||
376 | // All selected have the same texture | ||
377 | if(mTextureCtrl){ | ||
378 | mTextureCtrl->setTentative( FALSE ); | ||
379 | mTextureCtrl->setEnabled( editable ); | ||
380 | mTextureCtrl->setImageAssetID( id ); | ||
381 | } | ||
382 | } | ||
383 | else | ||
384 | { | ||
385 | if(mTextureCtrl){ | ||
386 | if( id.isNull() ) | ||
387 | { | ||
388 | // None selected | ||
389 | mTextureCtrl->setTentative( FALSE ); | ||
390 | mTextureCtrl->setEnabled( FALSE ); | ||
391 | mTextureCtrl->setImageAssetID( LLUUID::null ); | ||
392 | } | ||
393 | else | ||
394 | { | ||
395 | // Tentative: multiple selected with different textures | ||
396 | mTextureCtrl->setTentative( TRUE ); | ||
397 | mTextureCtrl->setEnabled( editable ); | ||
398 | mTextureCtrl->setImageAssetID( id ); | ||
399 | } | ||
400 | } | ||
401 | } | ||
402 | |||
403 | LLAggregatePermissions texture_perms; | ||
404 | if(mTextureCtrl) | ||
405 | { | ||
406 | // mTextureCtrl->setValid( editable ); | ||
407 | |||
408 | if (gSelectMgr->selectGetAggregateTexturePermissions(texture_perms)) | ||
409 | { | ||
410 | BOOL can_copy = | ||
411 | texture_perms.getValue(PERM_COPY) == LLAggregatePermissions::AP_EMPTY || | ||
412 | texture_perms.getValue(PERM_COPY) == LLAggregatePermissions::AP_ALL; | ||
413 | BOOL can_transfer = | ||
414 | texture_perms.getValue(PERM_TRANSFER) == LLAggregatePermissions::AP_EMPTY || | ||
415 | texture_perms.getValue(PERM_TRANSFER) == LLAggregatePermissions::AP_ALL; | ||
416 | mTextureCtrl->setCanApplyImmediately(can_copy && can_transfer); | ||
417 | } | ||
418 | else | ||
419 | { | ||
420 | mTextureCtrl->setCanApplyImmediately(FALSE); | ||
421 | } | ||
422 | } | ||
423 | |||
424 | // Texture scale | ||
425 | { | ||
426 | childSetEnabled("tex scale",editable); | ||
427 | //mLabelTexScale->setEnabled( editable ); | ||
428 | F32 scale_s = 1.f; | ||
429 | identical = allFacesSameValue( &LLPanelFace::valueScaleS, &scale_s ); | ||
430 | childSetValue("TexScaleU",editable ? llabs(scale_s) : 0); | ||
431 | childSetTentative("TexScaleU",LLSD((BOOL)(!identical))); | ||
432 | childSetEnabled("TexScaleU",editable); | ||
433 | childSetValue("checkbox flip s",LLSD((BOOL)(scale_s < 0 ? TRUE : FALSE ))); | ||
434 | childSetTentative("checkbox flip s",LLSD((BOOL)((!identical) ? TRUE : FALSE ))); | ||
435 | childSetEnabled("checkbox flip s",editable); | ||
436 | } | ||
437 | |||
438 | { | ||
439 | F32 scale_t = 1.f; | ||
440 | identical = allFacesSameValue( &LLPanelFace::valueScaleT, &scale_t ); | ||
441 | |||
442 | childSetValue("TexScaleV",llabs(editable ? llabs(scale_t) : 0)); | ||
443 | childSetTentative("TexScaleV",LLSD((BOOL)(!identical))); | ||
444 | childSetEnabled("TexScaleV",editable); | ||
445 | childSetValue("checkbox flip t",LLSD((BOOL)(scale_t< 0 ? TRUE : FALSE ))); | ||
446 | childSetTentative("checkbox flip t",LLSD((BOOL)((!identical) ? TRUE : FALSE ))); | ||
447 | childSetEnabled("checkbox flip t",editable); | ||
448 | } | ||
449 | |||
450 | // Texture offset | ||
451 | { | ||
452 | childSetEnabled("tex offset",editable); | ||
453 | F32 offset_s = 0.f; | ||
454 | identical = allFacesSameValue( &LLPanelFace::valueOffsetS, &offset_s ); | ||
455 | childSetValue("TexOffsetU", editable ? offset_s : 0); | ||
456 | childSetTentative("TexOffsetU",!identical); | ||
457 | childSetEnabled("TexOffsetU",editable); | ||
458 | } | ||
459 | |||
460 | { | ||
461 | F32 offset_t = 0.f; | ||
462 | identical = allFacesSameValue( &LLPanelFace::valueOffsetT, &offset_t ); | ||
463 | childSetValue("TexOffsetV", editable ? offset_t : 0); | ||
464 | childSetTentative("TexOffsetV",!identical); | ||
465 | childSetEnabled("TexOffsetV",editable); | ||
466 | } | ||
467 | |||
468 | // Texture rotation | ||
469 | { | ||
470 | childSetEnabled("tex rotate",editable); | ||
471 | F32 rotation = 0.f; | ||
472 | identical = allFacesSameValue( &LLPanelFace::valueTexRotation, &rotation ); | ||
473 | childSetValue("TexRot", editable ? rotation * RAD_TO_DEG : 0); | ||
474 | childSetTentative("TexRot",!identical); | ||
475 | childSetEnabled("TexRot",editable); | ||
476 | } | ||
477 | |||
478 | // Color swatch | ||
479 | LLColorSwatchCtrl* mColorSwatch = LLViewerUICtrlFactory::getColorSwatchByName(this,"colorswatch"); | ||
480 | LLColor4 color = LLColor4::white; | ||
481 | if(mColorSwatch) | ||
482 | { | ||
483 | identical = gSelectMgr->selectionGetColor(color); | ||
484 | mColorSwatch->setOriginal(color); | ||
485 | mColorSwatch->set(color, TRUE); | ||
486 | |||
487 | mColorSwatch->setValid(editable); | ||
488 | mColorSwatch->setEnabled( editable ); | ||
489 | mColorSwatch->setCanApplyImmediately( editable ); | ||
490 | } | ||
491 | // Color transparency | ||
492 | { | ||
493 | childSetEnabled("color trans",editable); | ||
494 | } | ||
495 | |||
496 | F32 transparency = (1.f - color.mV[VALPHA]) * 100.f; | ||
497 | { | ||
498 | childSetValue("ColorTrans", editable ? transparency : 0); | ||
499 | childSetEnabled("ColorTrans",editable); | ||
500 | } | ||
501 | |||
502 | // Bump | ||
503 | { | ||
504 | F32 shinyf = 0.f; | ||
505 | identical = allFacesSameValue( &LLPanelFace::valueShiny, &shinyf ); | ||
506 | childGetSelectionInterface("combobox shininess")->selectNthItem((S32)shinyf); | ||
507 | childSetEnabled("combobox shininess",editable); | ||
508 | childSetTentative("combobox shininess",!identical); | ||
509 | childSetEnabled("label shininess",editable); | ||
510 | } | ||
511 | |||
512 | { | ||
513 | F32 bumpf = 0.f; | ||
514 | identical = allFacesSameValue( &LLPanelFace::valueBump, &bumpf ); | ||
515 | childGetSelectionInterface("combobox bumpiness")->selectNthItem((S32)bumpf); | ||
516 | childSetEnabled("combobox bumpiness",editable); | ||
517 | childSetTentative("combobox bumpiness",!identical); | ||
518 | childSetEnabled("label bumpiness",editable); | ||
519 | } | ||
520 | |||
521 | { | ||
522 | F32 genf = 0.f; | ||
523 | identical = allFacesSameValue( &LLPanelFace::valueTexGen, &genf); | ||
524 | S32 selected_texgen = ((S32) genf) >> TEM_TEX_GEN_SHIFT; | ||
525 | childGetSelectionInterface("combobox texgen")->selectNthItem(selected_texgen); | ||
526 | childSetEnabled("combobox texgen",editable); | ||
527 | childSetTentative("combobox texgen",!identical); | ||
528 | childSetEnabled("tex gen",editable); | ||
529 | |||
530 | if (selected_texgen == 1) | ||
531 | { | ||
532 | childSetText("tex scale",childGetText("string repeats per meter")); | ||
533 | childSetValue("TexScaleU", 2.0f * childGetValue("TexScaleU").asReal() ); | ||
534 | childSetValue("TexScaleV", 2.0f * childGetValue("TexScaleV").asReal() ); | ||
535 | } | ||
536 | else | ||
537 | { | ||
538 | childSetText("tex scale",childGetText("string repeats per face")); | ||
539 | } | ||
540 | |||
541 | } | ||
542 | |||
543 | { | ||
544 | F32 fullbrightf = 0.f; | ||
545 | identical = allFacesSameValue( &LLPanelFace::valueFullbright, &fullbrightf ); | ||
546 | |||
547 | childSetValue("checkbox fullbright",(S32)fullbrightf); | ||
548 | childSetEnabled("checkbox fullbright",editable); | ||
549 | childSetTentative("checkbox fullbright",!identical); | ||
550 | } | ||
551 | |||
552 | // Repeats per meter label | ||
553 | { | ||
554 | childSetEnabled("rpt",editable); | ||
555 | } | ||
556 | |||
557 | // Repeats per meter | ||
558 | F32 repeats = 1.f; | ||
559 | identical = allFacesSameValue( &LLPanelFace::valueRepeatsPerMeter, &repeats ); | ||
560 | { | ||
561 | childSetValue("rptctrl", editable ? repeats : 0); | ||
562 | childSetTentative("rptctrl",!identical); | ||
563 | LLComboBox* mComboTexGen = LLViewerUICtrlFactory::getComboBoxByName(this,"combobox texgen"); | ||
564 | if (mComboTexGen) | ||
565 | { | ||
566 | BOOL enabled = editable && (!mComboTexGen || mComboTexGen->getCurrentIndex() != 1); | ||
567 | childSetEnabled("rptctrl",enabled); | ||
568 | childSetEnabled("button apply",enabled); | ||
569 | } | ||
570 | } | ||
571 | } | ||
572 | else | ||
573 | { | ||
574 | // Disable all UICtrls | ||
575 | clearCtrls(); | ||
576 | |||
577 | // Disable non-UICtrls | ||
578 | LLTextureCtrl* mTextureCtrl = LLUICtrlFactory::getTexturePickerByName(this,"texture control"); | ||
579 | if(mTextureCtrl) | ||
580 | { | ||
581 | mTextureCtrl->setImageAssetID( LLUUID::null ); | ||
582 | mTextureCtrl->setEnabled( FALSE ); // this is a LLUICtrl, but we don't want it to have keyboard focus so we add it as a child, not a ctrl. | ||
583 | // mTextureCtrl->setValid(FALSE); | ||
584 | } | ||
585 | LLColorSwatchCtrl* mColorSwatch = LLUICtrlFactory::getColorSwatchByName(this,"colorswatch"); | ||
586 | if(mColorSwatch) | ||
587 | { | ||
588 | mColorSwatch->setEnabled( FALSE ); | ||
589 | mColorSwatch->setValid(FALSE); | ||
590 | } | ||
591 | childSetEnabled("color trans",FALSE); | ||
592 | childSetEnabled("rpt",FALSE); | ||
593 | childSetEnabled("tex scale",FALSE); | ||
594 | childSetEnabled("tex offset",FALSE); | ||
595 | childSetEnabled("tex rotate",FALSE); | ||
596 | childSetEnabled("tex gen",FALSE); | ||
597 | childSetEnabled("label shininess",FALSE); | ||
598 | childSetEnabled("label bumpiness",FALSE); | ||
599 | |||
600 | childSetEnabled("textbox autofix",FALSE); | ||
601 | |||
602 | childSetEnabled("button align",FALSE); | ||
603 | childSetEnabled("button apply",FALSE); | ||
604 | } | ||
605 | } | ||
606 | |||
607 | |||
608 | void LLPanelFace::refresh() | ||
609 | { | ||
610 | getState(); | ||
611 | } | ||
612 | |||
613 | |||
614 | BOOL LLPanelFace::allFacesSameValue( F32 (get_face_value(LLViewerObject*, S32)), F32 *value) | ||
615 | { | ||
616 | LLViewerObject* object; | ||
617 | S32 te; | ||
618 | |||
619 | // Get the value from the primary selected TE | ||
620 | F32 first_value = *value; | ||
621 | BOOL got_first = FALSE; | ||
622 | gSelectMgr->getPrimaryTE(&object, &te); | ||
623 | if (object) | ||
624 | { | ||
625 | first_value = get_face_value(object, te); | ||
626 | got_first = true; | ||
627 | } | ||
628 | |||
629 | // Now iterate through all TEs to test for sameness | ||
630 | BOOL identical = TRUE; | ||
631 | for ( gSelectMgr->getFirstTE(&object, &te); object; gSelectMgr->getNextTE(&object, &te) ) | ||
632 | { | ||
633 | if (!got_first) | ||
634 | { | ||
635 | first_value = get_face_value(object, te); | ||
636 | got_first = true; | ||
637 | } | ||
638 | if ( get_face_value(object, te) != first_value ) | ||
639 | { | ||
640 | identical = FALSE; | ||
641 | break; | ||
642 | } | ||
643 | } | ||
644 | |||
645 | *value = first_value; | ||
646 | return identical; | ||
647 | } | ||
648 | |||
649 | |||
650 | // | ||
651 | // Static functions | ||
652 | // | ||
653 | |||
654 | // static | ||
655 | F32 LLPanelFace::valueRepeatsPerMeter(LLViewerObject* object, S32 face) | ||
656 | { | ||
657 | U32 s_axis = VX; | ||
658 | U32 t_axis = VY; | ||
659 | |||
660 | // BUG: Only repeats along S axis | ||
661 | // BUG: Only works for boxes. | ||
662 | gSelectMgr->getTESTAxes(object, face, &s_axis, &t_axis); | ||
663 | return object->getTE(face)->mScaleS / object->getScale().mV[s_axis]; | ||
664 | } | ||
665 | |||
666 | // static | ||
667 | F32 LLPanelFace::valueScaleS(LLViewerObject* object, S32 face) | ||
668 | { | ||
669 | return object->getTE(face)->mScaleS; | ||
670 | } | ||
671 | |||
672 | |||
673 | // static | ||
674 | F32 LLPanelFace::valueScaleT(LLViewerObject* object, S32 face) | ||
675 | { | ||
676 | return object->getTE(face)->mScaleT; | ||
677 | } | ||
678 | |||
679 | // static | ||
680 | F32 LLPanelFace::valueOffsetS(LLViewerObject* object, S32 face) | ||
681 | { | ||
682 | return object->getTE(face)->mOffsetS; | ||
683 | } | ||
684 | |||
685 | // static | ||
686 | F32 LLPanelFace::valueOffsetT(LLViewerObject* object, S32 face) | ||
687 | { | ||
688 | return object->getTE(face)->mOffsetT; | ||
689 | } | ||
690 | |||
691 | // static | ||
692 | F32 LLPanelFace::valueTexRotation(LLViewerObject* object, S32 face) | ||
693 | { | ||
694 | return object->getTE(face)->mRotation; | ||
695 | } | ||
696 | |||
697 | // static | ||
698 | F32 LLPanelFace::valueBump(LLViewerObject* object, S32 face) | ||
699 | { | ||
700 | return (F32)(object->getTE(face)->getBumpmap()); | ||
701 | } | ||
702 | |||
703 | // static | ||
704 | F32 LLPanelFace::valueTexGen(LLViewerObject* object, S32 face) | ||
705 | { | ||
706 | return (F32)(object->getTE(face)->getTexGen()); | ||
707 | } | ||
708 | |||
709 | // static | ||
710 | F32 LLPanelFace::valueShiny(LLViewerObject* object, S32 face) | ||
711 | { | ||
712 | return (F32)(object->getTE(face)->getShiny()); | ||
713 | } | ||
714 | |||
715 | // static | ||
716 | F32 LLPanelFace::valueFullbright(LLViewerObject* object, S32 face) | ||
717 | { | ||
718 | return (F32)(object->getTE(face)->getFullbright()); | ||
719 | } | ||
720 | |||
721 | |||
722 | // static | ||
723 | void LLPanelFace::onCommitColor(LLUICtrl* ctrl, void* userdata) | ||
724 | { | ||
725 | LLPanelFace* self = (LLPanelFace*) userdata; | ||
726 | self->sendColor(); | ||
727 | } | ||
728 | |||
729 | // static | ||
730 | void LLPanelFace::onCommitAlpha(LLUICtrl* ctrl, void* userdata) | ||
731 | { | ||
732 | LLPanelFace* self = (LLPanelFace*) userdata; | ||
733 | self->sendAlpha(); | ||
734 | } | ||
735 | |||
736 | // static | ||
737 | void LLPanelFace::onCancelColor(LLUICtrl* ctrl, void* userdata) | ||
738 | { | ||
739 | gSelectMgr->selectionRevertColors(); | ||
740 | } | ||
741 | |||
742 | // static | ||
743 | void LLPanelFace::onSelectColor(LLUICtrl* ctrl, void* userdata) | ||
744 | { | ||
745 | LLPanelFace* self = (LLPanelFace*) userdata; | ||
746 | gSelectMgr->saveSelectedObjectColors(); | ||
747 | self->sendColor(); | ||
748 | } | ||
749 | |||
750 | // static | ||
751 | void LLPanelFace::onCommitBump(LLUICtrl* ctrl, void* userdata) | ||
752 | { | ||
753 | LLPanelFace* self = (LLPanelFace*) userdata; | ||
754 | self->sendBump(); | ||
755 | } | ||
756 | |||
757 | // static | ||
758 | void LLPanelFace::onCommitTexGen(LLUICtrl* ctrl, void* userdata) | ||
759 | { | ||
760 | LLPanelFace* self = (LLPanelFace*) userdata; | ||
761 | self->sendTexGen(); | ||
762 | } | ||
763 | |||
764 | // static | ||
765 | void LLPanelFace::onCommitShiny(LLUICtrl* ctrl, void* userdata) | ||
766 | { | ||
767 | LLPanelFace* self = (LLPanelFace*) userdata; | ||
768 | self->sendShiny(); | ||
769 | } | ||
770 | |||
771 | // static | ||
772 | void LLPanelFace::onCommitFullbright(LLUICtrl* ctrl, void* userdata) | ||
773 | { | ||
774 | LLPanelFace* self = (LLPanelFace*) userdata; | ||
775 | self->sendFullbright(); | ||
776 | } | ||
777 | |||
778 | // static | ||
779 | BOOL LLPanelFace::onDragTexture(LLUICtrl*, LLInventoryItem* item, void*) | ||
780 | { | ||
781 | BOOL accept = TRUE; | ||
782 | LLViewerObject* obj = gSelectMgr->getFirstRootObject(); | ||
783 | while(accept && obj) | ||
784 | { | ||
785 | if(!LLToolDragAndDrop::isInventoryDropAcceptable(obj, item)) | ||
786 | accept = FALSE; | ||
787 | else | ||
788 | obj = gSelectMgr->getNextRootObject(); | ||
789 | } | ||
790 | return accept; | ||
791 | } | ||
792 | |||
793 | // static | ||
794 | void LLPanelFace::onCommitTexture( LLUICtrl* ctrl, void* userdata ) | ||
795 | { | ||
796 | LLPanelFace* self = (LLPanelFace*) userdata; | ||
797 | |||
798 | gViewerStats->incStat(LLViewerStats::ST_EDIT_TEXTURE_COUNT ); | ||
799 | |||
800 | self->sendTexture(); | ||
801 | } | ||
802 | |||
803 | // static | ||
804 | void LLPanelFace::onCancelTexture(LLUICtrl* ctrl, void* userdata) | ||
805 | { | ||
806 | gSelectMgr->selectionRevertTextures(); | ||
807 | } | ||
808 | |||
809 | // static | ||
810 | void LLPanelFace::onSelectTexture(LLUICtrl* ctrl, void* userdata) | ||
811 | { | ||
812 | LLPanelFace* self = (LLPanelFace*) userdata; | ||
813 | gSelectMgr->saveSelectedObjectTextures(); | ||
814 | self->sendTexture(); | ||
815 | } | ||
816 | |||
817 | |||
818 | // static | ||
819 | void LLPanelFace::onCommitTextureInfo( LLUICtrl* ctrl, void* userdata ) | ||
820 | { | ||
821 | LLPanelFace* self = (LLPanelFace*) userdata; | ||
822 | self->sendTextureInfo(); | ||
823 | } | ||
824 | |||
825 | // Commit the number of repeats per meter | ||
826 | // static | ||
827 | void LLPanelFace::onClickApply(void* userdata) | ||
828 | { | ||
829 | LLPanelFace* self = (LLPanelFace*) userdata; | ||
830 | |||
831 | gFocusMgr.setKeyboardFocus( NULL, NULL ); | ||
832 | |||
833 | //F32 repeats_per_meter = self->mCtrlRepeatsPerMeter->get(); | ||
834 | F32 repeats_per_meter = (F32)self->childGetValue( "rptctrl" ).asReal();//self->mCtrlRepeatsPerMeter->get(); | ||
835 | gSelectMgr->selectionTexScaleAutofit( repeats_per_meter ); | ||
836 | } | ||
837 | |||
838 | // commit the fit media texture to prim button | ||
839 | void LLPanelFace::onClickAutoFix(void* userdata) | ||
840 | { | ||
841 | S32 te; | ||
842 | LLViewerObject* object; | ||
843 | |||
844 | // for all selected objects | ||
845 | for ( gSelectMgr->getFirstTE(&object, &te); object; gSelectMgr->getNextTE(&object, &te) ) | ||
846 | { | ||
847 | // only do this if it's a media texture | ||
848 | if ( object->getTE ( te )->getID() == LLMediaEngine::getInstance()->getImageUUID () ) | ||
849 | { | ||
850 | // make sure we're valid | ||
851 | if ( LLMediaEngine::getInstance()->getMediaRenderer() ) | ||
852 | { | ||
853 | // calculate correct scaling based on media dimensions and next-power-of-2 texture dimensions | ||
854 | F32 scaleS = (F32)LLMediaEngine::getInstance()->getMediaRenderer()->getMediaWidth() / | ||
855 | (F32)LLMediaEngine::getInstance()->getMediaRenderer()->getTextureWidth(); | ||
856 | |||
857 | F32 scaleT = (F32)LLMediaEngine::getInstance()->getMediaRenderer()->getMediaHeight() / | ||
858 | (F32)LLMediaEngine::getInstance()->getMediaRenderer()->getTextureHeight(); | ||
859 | |||
860 | // set scale and adjust offset | ||
861 | object->setTEScaleS( te, scaleS ); | ||
862 | object->setTEScaleT( te, scaleT ); // don't need to flip Y anymore since QT does this for us now. | ||
863 | object->setTEOffsetS( te, -( 1.0f - scaleS ) / 2.0f ); | ||
864 | object->setTEOffsetT( te, -( 1.0f - scaleT ) / 2.0f ); | ||
865 | }; | ||
866 | }; | ||
867 | }; | ||
868 | |||
869 | // not clear why this is in a separate loop but i followed the patter from further up this file just in case. | ||
870 | for ( object = gSelectMgr->getFirstObject(); object; object = gSelectMgr->getNextObject() ) | ||
871 | { | ||
872 | object->sendTEUpdate(); | ||
873 | }; | ||
874 | } | ||