aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llpanelface.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/llpanelface.cpp')
-rw-r--r--linden/indra/newview/llpanelface.cpp421
1 files changed, 217 insertions, 204 deletions
diff --git a/linden/indra/newview/llpanelface.cpp b/linden/indra/newview/llpanelface.cpp
index b48d8c7..63e25d9 100644
--- a/linden/indra/newview/llpanelface.cpp
+++ b/linden/indra/newview/llpanelface.cpp
@@ -2,6 +2,8 @@
2 * @file llpanelface.cpp 2 * @file llpanelface.cpp
3 * @brief Panel in the tools floater for editing face textures, colors, etc. 3 * @brief Panel in the tools floater for editing face textures, colors, etc.
4 * 4 *
5 * $LicenseInfo:firstyear=2001&license=viewergpl$
6 *
5 * Copyright (c) 2001-2007, Linden Research, Inc. 7 * Copyright (c) 2001-2007, Linden Research, Inc.
6 * 8 *
7 * Second Life Viewer Source Code 9 * Second Life Viewer Source Code
@@ -24,6 +26,7 @@
24 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO 26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
25 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, 27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
26 * COMPLETENESS OR PERFORMANCE. 28 * COMPLETENESS OR PERFORMANCE.
29 * $/LicenseInfo$
27 */ 30 */
28 31
29#include "llviewerprecompiledheaders.h" 32#include "llviewerprecompiledheaders.h"
@@ -252,35 +255,32 @@ void LLPanelFace::sendAlpha()
252} 255}
253 256
254 257
255 258struct LLPanelFaceSetTEFunctor : public LLSelectedTEFunctor
256void LLPanelFace::sendTextureInfo()
257{ 259{
258 S32 te; 260 LLPanelFaceSetTEFunctor(LLPanelFace* panel) : mPanel(panel) {}
259 LLViewerObject* object; 261 virtual bool apply(LLViewerObject* object, S32 te)
260 LLObjectSelectionHandle selection = gSelectMgr->getSelection();
261 for ( selection->getFirstTE(&object, &te); object; selection->getNextTE(&object, &te) )
262 { 262 {
263 BOOL valid; 263 BOOL valid;
264 F32 value; 264 F32 value;
265 LLSpinCtrl* mCtrlTexScaleS = LLViewerUICtrlFactory::getSpinnerByName(this,"TexScaleU"); 265 LLSpinCtrl* ctrlTexScaleS = LLViewerUICtrlFactory::getSpinnerByName(mPanel,"TexScaleU");
266 LLSpinCtrl* mCtrlTexScaleT = LLViewerUICtrlFactory::getSpinnerByName(this,"TexScaleV"); 266 LLSpinCtrl* ctrlTexScaleT = LLViewerUICtrlFactory::getSpinnerByName(mPanel,"TexScaleV");
267 LLSpinCtrl* mCtrlTexOffsetS = LLViewerUICtrlFactory::getSpinnerByName(this,"TexOffsetU"); 267 LLSpinCtrl* ctrlTexOffsetS = LLViewerUICtrlFactory::getSpinnerByName(mPanel,"TexOffsetU");
268 LLSpinCtrl* mCtrlTexOffsetT = LLViewerUICtrlFactory::getSpinnerByName(this,"TexOffsetV"); 268 LLSpinCtrl* ctrlTexOffsetT = LLViewerUICtrlFactory::getSpinnerByName(mPanel,"TexOffsetV");
269 LLSpinCtrl* mCtrlTexRotation = LLViewerUICtrlFactory::getSpinnerByName(this,"TexRot"); 269 LLSpinCtrl* ctrlTexRotation = LLViewerUICtrlFactory::getSpinnerByName(mPanel,"TexRot");
270 LLCheckBoxCtrl* mCheckFlipScaleS = LLViewerUICtrlFactory::getCheckBoxByName(this,"checkbox flip s"); 270 LLCheckBoxCtrl* checkFlipScaleS = LLViewerUICtrlFactory::getCheckBoxByName(mPanel,"checkbox flip s");
271 LLCheckBoxCtrl* mCheckFlipScaleT = LLViewerUICtrlFactory::getCheckBoxByName(this,"checkbox flip t"); 271 LLCheckBoxCtrl* checkFlipScaleT = LLViewerUICtrlFactory::getCheckBoxByName(mPanel,"checkbox flip t");
272 LLComboBox* mComboTexGen = LLViewerUICtrlFactory::getComboBoxByName(this,"combobox texgen"); 272 LLComboBox* comboTexGen = LLViewerUICtrlFactory::getComboBoxByName(mPanel,"combobox texgen");
273 if (mCtrlTexScaleS) 273 if (ctrlTexScaleS)
274 { 274 {
275 valid = !mCtrlTexScaleS->getTentative() || !mCheckFlipScaleS->getTentative(); 275 valid = !ctrlTexScaleS->getTentative() || !checkFlipScaleS->getTentative();
276 if (valid) 276 if (valid)
277 { 277 {
278 value = mCtrlTexScaleS->get(); 278 value = ctrlTexScaleS->get();
279 if( mCheckFlipScaleS->get() ) 279 if( checkFlipScaleS->get() )
280 { 280 {
281 value = -value; 281 value = -value;
282 } 282 }
283 if (mComboTexGen->getCurrentIndex() == 1) 283 if (comboTexGen->getCurrentIndex() == 1)
284 { 284 {
285 value *= 0.5f; 285 value *= 0.5f;
286 } 286 }
@@ -288,17 +288,17 @@ void LLPanelFace::sendTextureInfo()
288 } 288 }
289 } 289 }
290 290
291 if (mCtrlTexScaleT) 291 if (ctrlTexScaleT)
292 { 292 {
293 valid = !mCtrlTexScaleT->getTentative() || !mCheckFlipScaleT->getTentative(); 293 valid = !ctrlTexScaleT->getTentative() || !checkFlipScaleT->getTentative();
294 if (valid) 294 if (valid)
295 { 295 {
296 value = mCtrlTexScaleT->get(); 296 value = ctrlTexScaleT->get();
297 if( mCheckFlipScaleT->get() ) 297 if( checkFlipScaleT->get() )
298 { 298 {
299 value = -value; 299 value = -value;
300 } 300 }
301 if (mComboTexGen->getCurrentIndex() == 1) 301 if (comboTexGen->getCurrentIndex() == 1)
302 { 302 {
303 value *= 0.5f; 303 value *= 0.5f;
304 } 304 }
@@ -306,41 +306,57 @@ void LLPanelFace::sendTextureInfo()
306 } 306 }
307 } 307 }
308 308
309 if (mCtrlTexOffsetS) 309 if (ctrlTexOffsetS)
310 { 310 {
311 valid = !mCtrlTexOffsetS->getTentative(); 311 valid = !ctrlTexOffsetS->getTentative();
312 if (valid) 312 if (valid)
313 { 313 {
314 value = mCtrlTexOffsetS->get(); 314 value = ctrlTexOffsetS->get();
315 object->setTEOffsetS( te, value ); 315 object->setTEOffsetS( te, value );
316 } 316 }
317 } 317 }
318 318
319 if (mCtrlTexOffsetT) 319 if (ctrlTexOffsetT)
320 { 320 {
321 valid = !mCtrlTexOffsetT->getTentative(); 321 valid = !ctrlTexOffsetT->getTentative();
322 if (valid) 322 if (valid)
323 { 323 {
324 value = mCtrlTexOffsetT->get(); 324 value = ctrlTexOffsetT->get();
325 object->setTEOffsetT( te, value ); 325 object->setTEOffsetT( te, value );
326 } 326 }
327 } 327 }
328 328
329 if (mCtrlTexRotation) 329 if (ctrlTexRotation)
330 { 330 {
331 valid = !mCtrlTexRotation->getTentative(); 331 valid = !ctrlTexRotation->getTentative();
332 if (valid) 332 if (valid)
333 { 333 {
334 value = mCtrlTexRotation->get() * DEG_TO_RAD; 334 value = ctrlTexRotation->get() * DEG_TO_RAD;
335 object->setTERotation( te, value ); 335 object->setTERotation( te, value );
336 } 336 }
337 } 337 }
338 return true;
338 } 339 }
340private:
341 LLPanelFace* mPanel;
342};
339 343
340 for ( object = gSelectMgr->getSelection()->getFirstObject(); object; object = gSelectMgr->getSelection()->getNextObject() ) 344struct LLPanelFaceSendFunctor : public LLSelectedObjectFunctor
345{
346 virtual bool apply(LLViewerObject* object)
341 { 347 {
342 object->sendTEUpdate(); 348 object->sendTEUpdate();
349 return true;
343 } 350 }
351};
352
353void LLPanelFace::sendTextureInfo()
354{
355 LLPanelFaceSetTEFunctor setfunc(this);
356 gSelectMgr->getSelection()->applyToTEs(&setfunc);
357
358 LLPanelFaceSendFunctor sendfunc;
359 gSelectMgr->getSelection()->applyToObjects(&sendfunc);
344} 360}
345 361
346void LLPanelFace::getState() 362void LLPanelFace::getState()
@@ -368,43 +384,58 @@ void LLPanelFace::getState()
368 } 384 }
369 childSetEnabled("button apply",editable); 385 childSetEnabled("button apply",editable);
370 386
387 bool identical;
388 LLTextureCtrl* texture_ctrl = LLViewerUICtrlFactory::getTexturePickerByName(this,"texture control");
389
371 // Texture 390 // Texture
372 LLUUID id;
373 BOOL identical = gSelectMgr->selectionGetTexUUID(id);
374 LLTextureCtrl* mTextureCtrl = LLViewerUICtrlFactory::getTexturePickerByName(this,"texture control");
375 if (identical)
376 {
377 // All selected have the same texture
378 if(mTextureCtrl){
379 mTextureCtrl->setTentative( FALSE );
380 mTextureCtrl->setEnabled( editable );
381 mTextureCtrl->setImageAssetID( id );
382 }
383 }
384 else
385 { 391 {
386 if(mTextureCtrl){ 392 LLUUID id;
387 if( id.isNull() ) 393 struct f1 : public LLSelectedTEGetFunctor<LLUUID>
394 {
395 LLUUID get(LLViewerObject* object, S32 te)
396 {
397 LLViewerImage* image = object->getTEImage(te);
398 return image ? image->getID() : LLUUID::null;
399 }
400 } func;
401 identical = gSelectMgr->getSelection()->getSelectedTEValue( &func, id );
402
403 if (identical)
404 {
405 // All selected have the same texture
406 if(texture_ctrl)
388 { 407 {
389 // None selected 408 texture_ctrl->setTentative( FALSE );
390 mTextureCtrl->setTentative( FALSE ); 409 texture_ctrl->setEnabled( editable );
391 mTextureCtrl->setEnabled( FALSE ); 410 texture_ctrl->setImageAssetID( id );
392 mTextureCtrl->setImageAssetID( LLUUID::null );
393 } 411 }
394 else 412 }
413 else
414 {
415 if(texture_ctrl)
395 { 416 {
396 // Tentative: multiple selected with different textures 417 if( id.isNull() )
397 mTextureCtrl->setTentative( TRUE ); 418 {
398 mTextureCtrl->setEnabled( editable ); 419 // None selected
399 mTextureCtrl->setImageAssetID( id ); 420 texture_ctrl->setTentative( FALSE );
421 texture_ctrl->setEnabled( FALSE );
422 texture_ctrl->setImageAssetID( LLUUID::null );
423 }
424 else
425 {
426 // Tentative: multiple selected with different textures
427 texture_ctrl->setTentative( TRUE );
428 texture_ctrl->setEnabled( editable );
429 texture_ctrl->setImageAssetID( id );
430 }
400 } 431 }
401 } 432 }
402 } 433 }
403 434
404 LLAggregatePermissions texture_perms; 435 LLAggregatePermissions texture_perms;
405 if(mTextureCtrl) 436 if(texture_ctrl)
406 { 437 {
407// mTextureCtrl->setValid( editable ); 438// texture_ctrl->setValid( editable );
408 439
409 if (gSelectMgr->selectGetAggregateTexturePermissions(texture_perms)) 440 if (gSelectMgr->selectGetAggregateTexturePermissions(texture_perms))
410 { 441 {
@@ -414,11 +445,11 @@ void LLPanelFace::getState()
414 BOOL can_transfer = 445 BOOL can_transfer =
415 texture_perms.getValue(PERM_TRANSFER) == LLAggregatePermissions::AP_EMPTY || 446 texture_perms.getValue(PERM_TRANSFER) == LLAggregatePermissions::AP_EMPTY ||
416 texture_perms.getValue(PERM_TRANSFER) == LLAggregatePermissions::AP_ALL; 447 texture_perms.getValue(PERM_TRANSFER) == LLAggregatePermissions::AP_ALL;
417 mTextureCtrl->setCanApplyImmediately(can_copy && can_transfer); 448 texture_ctrl->setCanApplyImmediately(can_copy && can_transfer);
418 } 449 }
419 else 450 else
420 { 451 {
421 mTextureCtrl->setCanApplyImmediately(FALSE); 452 texture_ctrl->setCanApplyImmediately(FALSE);
422 } 453 }
423 } 454 }
424 455
@@ -427,7 +458,14 @@ void LLPanelFace::getState()
427 childSetEnabled("tex scale",editable); 458 childSetEnabled("tex scale",editable);
428 //mLabelTexScale->setEnabled( editable ); 459 //mLabelTexScale->setEnabled( editable );
429 F32 scale_s = 1.f; 460 F32 scale_s = 1.f;
430 identical = allFacesSameValue( &LLPanelFace::valueScaleS, &scale_s ); 461 struct f2 : public LLSelectedTEGetFunctor<F32>
462 {
463 F32 get(LLViewerObject* object, S32 face)
464 {
465 return object->getTE(face)->mScaleS;
466 }
467 } func;
468 identical = gSelectMgr->getSelection()->getSelectedTEValue( &func, scale_s );
431 childSetValue("TexScaleU",editable ? llabs(scale_s) : 0); 469 childSetValue("TexScaleU",editable ? llabs(scale_s) : 0);
432 childSetTentative("TexScaleU",LLSD((BOOL)(!identical))); 470 childSetTentative("TexScaleU",LLSD((BOOL)(!identical)));
433 childSetEnabled("TexScaleU",editable); 471 childSetEnabled("TexScaleU",editable);
@@ -438,7 +476,14 @@ void LLPanelFace::getState()
438 476
439 { 477 {
440 F32 scale_t = 1.f; 478 F32 scale_t = 1.f;
441 identical = allFacesSameValue( &LLPanelFace::valueScaleT, &scale_t ); 479 struct f3 : public LLSelectedTEGetFunctor<F32>
480 {
481 F32 get(LLViewerObject* object, S32 face)
482 {
483 return object->getTE(face)->mScaleS;
484 }
485 } func;
486 identical = gSelectMgr->getSelection()->getSelectedTEValue( &func, scale_t );
442 487
443 childSetValue("TexScaleV",llabs(editable ? llabs(scale_t) : 0)); 488 childSetValue("TexScaleV",llabs(editable ? llabs(scale_t) : 0));
444 childSetTentative("TexScaleV",LLSD((BOOL)(!identical))); 489 childSetTentative("TexScaleV",LLSD((BOOL)(!identical)));
@@ -452,7 +497,14 @@ void LLPanelFace::getState()
452 { 497 {
453 childSetEnabled("tex offset",editable); 498 childSetEnabled("tex offset",editable);
454 F32 offset_s = 0.f; 499 F32 offset_s = 0.f;
455 identical = allFacesSameValue( &LLPanelFace::valueOffsetS, &offset_s ); 500 struct f4 : public LLSelectedTEGetFunctor<F32>
501 {
502 F32 get(LLViewerObject* object, S32 face)
503 {
504 return object->getTE(face)->mOffsetS;
505 }
506 } func;
507 identical = gSelectMgr->getSelection()->getSelectedTEValue( &func, offset_s );
456 childSetValue("TexOffsetU", editable ? offset_s : 0); 508 childSetValue("TexOffsetU", editable ? offset_s : 0);
457 childSetTentative("TexOffsetU",!identical); 509 childSetTentative("TexOffsetU",!identical);
458 childSetEnabled("TexOffsetU",editable); 510 childSetEnabled("TexOffsetU",editable);
@@ -460,7 +512,14 @@ void LLPanelFace::getState()
460 512
461 { 513 {
462 F32 offset_t = 0.f; 514 F32 offset_t = 0.f;
463 identical = allFacesSameValue( &LLPanelFace::valueOffsetT, &offset_t ); 515 struct f5 : public LLSelectedTEGetFunctor<F32>
516 {
517 F32 get(LLViewerObject* object, S32 face)
518 {
519 return object->getTE(face)->mOffsetT;
520 }
521 } func;
522 identical = gSelectMgr->getSelection()->getSelectedTEValue( &func, offset_t );
464 childSetValue("TexOffsetV", editable ? offset_t : 0); 523 childSetValue("TexOffsetV", editable ? offset_t : 0);
465 childSetTentative("TexOffsetV",!identical); 524 childSetTentative("TexOffsetV",!identical);
466 childSetEnabled("TexOffsetV",editable); 525 childSetEnabled("TexOffsetV",editable);
@@ -470,7 +529,14 @@ void LLPanelFace::getState()
470 { 529 {
471 childSetEnabled("tex rotate",editable); 530 childSetEnabled("tex rotate",editable);
472 F32 rotation = 0.f; 531 F32 rotation = 0.f;
473 identical = allFacesSameValue( &LLPanelFace::valueTexRotation, &rotation ); 532 struct f6 : public LLSelectedTEGetFunctor<F32>
533 {
534 F32 get(LLViewerObject* object, S32 face)
535 {
536 return object->getTE(face)->mRotation;
537 }
538 } func;
539 identical = gSelectMgr->getSelection()->getSelectedTEValue( &func, rotation );
474 childSetValue("TexRot", editable ? rotation * RAD_TO_DEG : 0); 540 childSetValue("TexRot", editable ? rotation * RAD_TO_DEG : 0);
475 childSetTentative("TexRot",!identical); 541 childSetTentative("TexRot",!identical);
476 childSetEnabled("TexRot",editable); 542 childSetEnabled("TexRot",editable);
@@ -481,7 +547,15 @@ void LLPanelFace::getState()
481 LLColor4 color = LLColor4::white; 547 LLColor4 color = LLColor4::white;
482 if(mColorSwatch) 548 if(mColorSwatch)
483 { 549 {
484 identical = gSelectMgr->selectionGetColor(color); 550 struct f7 : public LLSelectedTEGetFunctor<LLColor4>
551 {
552 LLColor4 get(LLViewerObject* object, S32 face)
553 {
554 return object->getTE(face)->getColor();
555 }
556 } func;
557 identical = gSelectMgr->getSelection()->getSelectedTEValue( &func, color );
558
485 mColorSwatch->setOriginal(color); 559 mColorSwatch->setOriginal(color);
486 mColorSwatch->set(color, TRUE); 560 mColorSwatch->set(color, TRUE);
487 561
@@ -503,7 +577,14 @@ void LLPanelFace::getState()
503 // Bump 577 // Bump
504 { 578 {
505 F32 shinyf = 0.f; 579 F32 shinyf = 0.f;
506 identical = allFacesSameValue( &LLPanelFace::valueShiny, &shinyf ); 580 struct f8 : public LLSelectedTEGetFunctor<F32>
581 {
582 F32 get(LLViewerObject* object, S32 face)
583 {
584 return (F32)(object->getTE(face)->getShiny());
585 }
586 } func;
587 identical = gSelectMgr->getSelection()->getSelectedTEValue( &func, shinyf );
507 LLCtrlSelectionInterface* combobox_shininess = 588 LLCtrlSelectionInterface* combobox_shininess =
508 childGetSelectionInterface("combobox shininess"); 589 childGetSelectionInterface("combobox shininess");
509 if (combobox_shininess) 590 if (combobox_shininess)
@@ -521,7 +602,14 @@ void LLPanelFace::getState()
521 602
522 { 603 {
523 F32 bumpf = 0.f; 604 F32 bumpf = 0.f;
524 identical = allFacesSameValue( &LLPanelFace::valueBump, &bumpf ); 605 struct f9 : public LLSelectedTEGetFunctor<F32>
606 {
607 F32 get(LLViewerObject* object, S32 face)
608 {
609 return (F32)(object->getTE(face)->getBumpmap());
610 }
611 } func;
612 identical = gSelectMgr->getSelection()->getSelectedTEValue( &func, bumpf );
525 LLCtrlSelectionInterface* combobox_bumpiness = 613 LLCtrlSelectionInterface* combobox_bumpiness =
526 childGetSelectionInterface("combobox bumpiness"); 614 childGetSelectionInterface("combobox bumpiness");
527 if (combobox_bumpiness) 615 if (combobox_bumpiness)
@@ -539,7 +627,14 @@ void LLPanelFace::getState()
539 627
540 { 628 {
541 F32 genf = 0.f; 629 F32 genf = 0.f;
542 identical = allFacesSameValue( &LLPanelFace::valueTexGen, &genf); 630 struct f10 : public LLSelectedTEGetFunctor<F32>
631 {
632 F32 get(LLViewerObject* object, S32 face)
633 {
634 return (F32)(object->getTE(face)->getTexGen());
635 }
636 } func;
637 identical = gSelectMgr->getSelection()->getSelectedTEValue( &func, genf );
543 S32 selected_texgen = ((S32) genf) >> TEM_TEX_GEN_SHIFT; 638 S32 selected_texgen = ((S32) genf) >> TEM_TEX_GEN_SHIFT;
544 LLCtrlSelectionInterface* combobox_texgen = 639 LLCtrlSelectionInterface* combobox_texgen =
545 childGetSelectionInterface("combobox texgen"); 640 childGetSelectionInterface("combobox texgen");
@@ -570,7 +665,14 @@ void LLPanelFace::getState()
570 665
571 { 666 {
572 F32 fullbrightf = 0.f; 667 F32 fullbrightf = 0.f;
573 identical = allFacesSameValue( &LLPanelFace::valueFullbright, &fullbrightf ); 668 struct f11 : public LLSelectedTEGetFunctor<F32>
669 {
670 F32 get(LLViewerObject* object, S32 face)
671 {
672 return (F32)(object->getTE(face)->getFullbright());
673 }
674 } func;
675 identical = gSelectMgr->getSelection()->getSelectedTEValue( &func, fullbrightf );
574 676
575 childSetValue("checkbox fullbright",(S32)fullbrightf); 677 childSetValue("checkbox fullbright",(S32)fullbrightf);
576 childSetEnabled("checkbox fullbright",editable); 678 childSetEnabled("checkbox fullbright",editable);
@@ -583,9 +685,22 @@ void LLPanelFace::getState()
583 } 685 }
584 686
585 // Repeats per meter 687 // Repeats per meter
586 F32 repeats = 1.f;
587 identical = allFacesSameValue( &LLPanelFace::valueRepeatsPerMeter, &repeats );
588 { 688 {
689 F32 repeats = 1.f;
690 struct f12 : public LLSelectedTEGetFunctor<F32>
691 {
692 F32 get(LLViewerObject* object, S32 face)
693 {
694 U32 s_axis = VX;
695 U32 t_axis = VY;
696 // BUG: Only repeats along S axis
697 // BUG: Only works for boxes.
698 LLPrimitive::getTESTAxes(face, &s_axis, &t_axis);
699 return object->getTE(face)->mScaleS / object->getScale().mV[s_axis];
700 }
701 } func;
702 identical = gSelectMgr->getSelection()->getSelectedTEValue( &func, repeats );
703
589 childSetValue("rptctrl", editable ? repeats : 0); 704 childSetValue("rptctrl", editable ? repeats : 0);
590 childSetTentative("rptctrl",!identical); 705 childSetTentative("rptctrl",!identical);
591 LLComboBox* mComboTexGen = LLViewerUICtrlFactory::getComboBoxByName(this,"combobox texgen"); 706 LLComboBox* mComboTexGen = LLViewerUICtrlFactory::getComboBoxByName(this,"combobox texgen");
@@ -603,12 +718,12 @@ void LLPanelFace::getState()
603 clearCtrls(); 718 clearCtrls();
604 719
605 // Disable non-UICtrls 720 // Disable non-UICtrls
606 LLTextureCtrl* mTextureCtrl = LLUICtrlFactory::getTexturePickerByName(this,"texture control"); 721 LLTextureCtrl* texture_ctrl = LLUICtrlFactory::getTexturePickerByName(this,"texture control");
607 if(mTextureCtrl) 722 if(texture_ctrl)
608 { 723 {
609 mTextureCtrl->setImageAssetID( LLUUID::null ); 724 texture_ctrl->setImageAssetID( LLUUID::null );
610 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. 725 texture_ctrl->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.
611// mTextureCtrl->setValid(FALSE); 726// texture_ctrl->setValid(FALSE);
612 } 727 }
613 LLColorSwatchCtrl* mColorSwatch = LLUICtrlFactory::getColorSwatchByName(this,"colorswatch"); 728 LLColorSwatchCtrl* mColorSwatch = LLUICtrlFactory::getColorSwatchByName(this,"colorswatch");
614 if(mColorSwatch) 729 if(mColorSwatch)
@@ -638,115 +753,10 @@ void LLPanelFace::refresh()
638 getState(); 753 getState();
639} 754}
640 755
641
642BOOL LLPanelFace::allFacesSameValue( F32 (get_face_value(LLViewerObject*, S32)), F32 *value)
643{
644 LLViewerObject* object;
645 S32 te;
646
647 // Get the value from the primary selected TE
648 F32 first_value = *value;
649 BOOL got_first = FALSE;
650 gSelectMgr->getSelection()->getPrimaryTE(&object, &te);
651 if (object)
652 {
653 first_value = get_face_value(object, te);
654 got_first = true;
655 }
656
657 // Now iterate through all TEs to test for sameness
658 BOOL identical = TRUE;
659 LLObjectSelectionHandle selection = gSelectMgr->getSelection();
660 for ( selection->getFirstTE(&object, &te); object; selection->getNextTE(&object, &te) )
661 {
662 if (!got_first)
663 {
664 first_value = get_face_value(object, te);
665 got_first = true;
666 }
667 if ( get_face_value(object, te) != first_value )
668 {
669 identical = FALSE;
670 break;
671 }
672 }
673
674 *value = first_value;
675 return identical;
676}
677
678
679// 756//
680// Static functions 757// Static functions
681// 758//
682 759
683// static
684F32 LLPanelFace::valueRepeatsPerMeter(LLViewerObject* object, S32 face)
685{
686 U32 s_axis = VX;
687 U32 t_axis = VY;
688
689 // BUG: Only repeats along S axis
690 // BUG: Only works for boxes.
691 gSelectMgr->getTESTAxes(object, face, &s_axis, &t_axis);
692 return object->getTE(face)->mScaleS / object->getScale().mV[s_axis];
693}
694
695// static
696F32 LLPanelFace::valueScaleS(LLViewerObject* object, S32 face)
697{
698 return object->getTE(face)->mScaleS;
699}
700
701
702// static
703F32 LLPanelFace::valueScaleT(LLViewerObject* object, S32 face)
704{
705 return object->getTE(face)->mScaleT;
706}
707
708// static
709F32 LLPanelFace::valueOffsetS(LLViewerObject* object, S32 face)
710{
711 return object->getTE(face)->mOffsetS;
712}
713
714// static
715F32 LLPanelFace::valueOffsetT(LLViewerObject* object, S32 face)
716{
717 return object->getTE(face)->mOffsetT;
718}
719
720// static
721F32 LLPanelFace::valueTexRotation(LLViewerObject* object, S32 face)
722{
723 return object->getTE(face)->mRotation;
724}
725
726// static
727F32 LLPanelFace::valueBump(LLViewerObject* object, S32 face)
728{
729 return (F32)(object->getTE(face)->getBumpmap());
730}
731
732// static
733F32 LLPanelFace::valueTexGen(LLViewerObject* object, S32 face)
734{
735 return (F32)(object->getTE(face)->getTexGen());
736}
737
738// static
739F32 LLPanelFace::valueShiny(LLViewerObject* object, S32 face)
740{
741 return (F32)(object->getTE(face)->getShiny());
742}
743
744// static
745F32 LLPanelFace::valueFullbright(LLViewerObject* object, S32 face)
746{
747 return (F32)(object->getTE(face)->getFullbright());
748}
749
750 760
751// static 761// static
752void LLPanelFace::onCommitColor(LLUICtrl* ctrl, void* userdata) 762void LLPanelFace::onCommitColor(LLUICtrl* ctrl, void* userdata)
@@ -808,13 +818,16 @@ void LLPanelFace::onCommitFullbright(LLUICtrl* ctrl, void* userdata)
808BOOL LLPanelFace::onDragTexture(LLUICtrl*, LLInventoryItem* item, void*) 818BOOL LLPanelFace::onDragTexture(LLUICtrl*, LLInventoryItem* item, void*)
809{ 819{
810 BOOL accept = TRUE; 820 BOOL accept = TRUE;
811 LLViewerObject* obj = gSelectMgr->getSelection()->getFirstRootObject(); 821 for (LLObjectSelection::root_iterator iter = gSelectMgr->getSelection()->root_begin();
812 while(accept && obj) 822 iter != gSelectMgr->getSelection()->root_end(); iter++)
813 { 823 {
824 LLSelectNode* node = *iter;
825 LLViewerObject* obj = node->getObject();
814 if(!LLToolDragAndDrop::isInventoryDropAcceptable(obj, item)) 826 if(!LLToolDragAndDrop::isInventoryDropAcceptable(obj, item))
827 {
815 accept = FALSE; 828 accept = FALSE;
816 else 829 break;
817 obj = gSelectMgr->getSelection()->getNextRootObject(); 830 }
818 } 831 }
819 return accept; 832 return accept;
820} 833}
@@ -865,14 +878,10 @@ void LLPanelFace::onClickApply(void* userdata)
865} 878}
866 879
867// commit the fit media texture to prim button 880// commit the fit media texture to prim button
868void LLPanelFace::onClickAutoFix(void* userdata)
869{
870 S32 te;
871 LLViewerObject* object;
872 881
873 // for all selected objects 882struct LLPanelFaceSetMediaFunctor : public LLSelectedTEFunctor
874 LLObjectSelectionHandle selection = gSelectMgr->getSelection(); 883{
875 for ( selection->getFirstTE(&object, &te); object; selection->getNextTE(&object, &te) ) 884 virtual bool apply(LLViewerObject* object, S32 te)
876 { 885 {
877 // only do this if it's a media texture 886 // only do this if it's a media texture
878 if ( object->getTE ( te )->getID() == LLMediaEngine::getInstance()->getImageUUID () ) 887 if ( object->getTE ( te )->getID() == LLMediaEngine::getInstance()->getImageUUID () )
@@ -892,13 +901,17 @@ void LLPanelFace::onClickAutoFix(void* userdata)
892 object->setTEScaleT( te, scaleT ); // don't need to flip Y anymore since QT does this for us now. 901 object->setTEScaleT( te, scaleT ); // don't need to flip Y anymore since QT does this for us now.
893 object->setTEOffsetS( te, -( 1.0f - scaleS ) / 2.0f ); 902 object->setTEOffsetS( te, -( 1.0f - scaleS ) / 2.0f );
894 object->setTEOffsetT( te, -( 1.0f - scaleT ) / 2.0f ); 903 object->setTEOffsetT( te, -( 1.0f - scaleT ) / 2.0f );
895 }; 904 }
896 }; 905 }
897 }; 906 return true;
907 }
908};
898 909
899 // not clear why this is in a separate loop but i followed the patter from further up this file just in case. 910void LLPanelFace::onClickAutoFix(void* userdata)
900 for ( object = gSelectMgr->getSelection()->getFirstObject(); object; object = gSelectMgr->getSelection()->getNextObject() ) 911{
901 { 912 LLPanelFaceSetMediaFunctor setfunc;
902 object->sendTEUpdate(); 913 gSelectMgr->getSelection()->applyToTEs(&setfunc);
903 }; 914
915 LLPanelFaceSendFunctor sendfunc;
916 gSelectMgr->getSelection()->applyToObjects(&sendfunc);
904} 917}