llpanelface.cpp

Go to the documentation of this file.
00001 
00032 #include "llviewerprecompiledheaders.h"
00033 
00034 // file include
00035 #include "llpanelface.h"
00036  
00037 // library includes
00038 #include "llerror.h"
00039 #include "llfocusmgr.h"
00040 #include "llrect.h"
00041 #include "llstring.h"
00042 #include "llfontgl.h"
00043 
00044 // project includes
00045 #include "llbutton.h"
00046 #include "llcheckboxctrl.h"
00047 #include "llcolorswatch.h"
00048 #include "llcombobox.h"
00049 #include "lldrawpoolbump.h"
00050 #include "lllineeditor.h"
00051 #include "llresmgr.h"
00052 #include "llselectmgr.h"
00053 #include "llspinctrl.h"
00054 #include "lltextbox.h"
00055 #include "lltexturectrl.h"
00056 #include "lltextureentry.h"
00057 #include "lltooldraganddrop.h"
00058 #include "llui.h"
00059 #include "llviewercontrol.h"
00060 #include "llviewermedia.h"
00061 #include "llviewerobject.h"
00062 #include "llviewerstats.h"
00063 #include "lluictrlfactory.h"
00064 
00065 //
00066 // Methods
00067 //
00068 
00069 BOOL    LLPanelFace::postBuild()
00070 {
00071         LLRect  rect = this->getRect();
00072         LLTextureCtrl*  mTextureCtrl;
00073         LLColorSwatchCtrl*      mColorSwatch;
00074 
00075         LLTextBox*              mLabelTexGen;
00076         LLComboBox*             mComboTexGen;
00077 
00078         LLCheckBoxCtrl  *mCheckFullbright;
00079         
00080         LLTextBox*              mLabelColorTransp;
00081         LLSpinCtrl*             mCtrlColorTransp;               // transparency = 1 - alpha
00082 
00083         LLTextBox*      mLabelGlow;
00084         LLSpinCtrl*     mCtrlGlow;
00085 
00086         setMouseOpaque(FALSE);
00087         mTextureCtrl = getChild<LLTextureCtrl>("texture control");
00088         if(mTextureCtrl)
00089         {
00090                 mTextureCtrl->setDefaultImageAssetID(LLUUID( gSavedSettings.getString( "DefaultObjectTexture" )));
00091                 mTextureCtrl->setCommitCallback( LLPanelFace::onCommitTexture );
00092                 mTextureCtrl->setOnCancelCallback( LLPanelFace::onCancelTexture );
00093                 mTextureCtrl->setOnSelectCallback( LLPanelFace::onSelectTexture );
00094                 mTextureCtrl->setDragCallback(LLPanelFace::onDragTexture);
00095                 mTextureCtrl->setCallbackUserData( this );
00096                 mTextureCtrl->setFollowsTop();
00097                 mTextureCtrl->setFollowsLeft();
00098                 // Don't allow (no copy) or (no transfer) textures to be selected during immediate mode
00099                 mTextureCtrl->setImmediateFilterPermMask(PERM_COPY | PERM_TRANSFER);
00100                 // Allow any texture to be used during non-immediate mode.
00101                 mTextureCtrl->setNonImmediateFilterPermMask(PERM_NONE);
00102                 LLAggregatePermissions texture_perms;
00103                 if (LLSelectMgr::getInstance()->selectGetAggregateTexturePermissions(texture_perms))
00104                 {
00105                         BOOL can_copy = 
00106                                 texture_perms.getValue(PERM_COPY) == LLAggregatePermissions::AP_EMPTY || 
00107                                 texture_perms.getValue(PERM_COPY) == LLAggregatePermissions::AP_ALL;
00108                         BOOL can_transfer = 
00109                                 texture_perms.getValue(PERM_TRANSFER) == LLAggregatePermissions::AP_EMPTY || 
00110                                 texture_perms.getValue(PERM_TRANSFER) == LLAggregatePermissions::AP_ALL;
00111                         mTextureCtrl->setCanApplyImmediately(can_copy && can_transfer);
00112                 }
00113                 else
00114                 {
00115                         mTextureCtrl->setCanApplyImmediately(FALSE);
00116                 }
00117         }
00118 
00119         mColorSwatch = getChild<LLColorSwatchCtrl>("colorswatch");
00120         if(mColorSwatch)
00121         {
00122                 mColorSwatch->setCommitCallback(LLPanelFace::onCommitColor);
00123                 mColorSwatch->setOnCancelCallback(LLPanelFace::onCancelColor);
00124                 mColorSwatch->setOnSelectCallback(LLPanelFace::onSelectColor);
00125                 mColorSwatch->setCallbackUserData( this );
00126                 mColorSwatch->setFollowsTop();
00127                 mColorSwatch->setFollowsLeft();
00128                 mColorSwatch->setCanApplyImmediately(TRUE);
00129         }
00130 
00131         mLabelColorTransp = getChild<LLTextBox>("color trans");
00132         if(mLabelColorTransp)
00133         {
00134                 mLabelColorTransp->setFollowsTop();
00135                 mLabelColorTransp->setFollowsLeft();
00136         }
00137 
00138         mCtrlColorTransp = getChild<LLSpinCtrl>("ColorTrans");
00139         if(mCtrlColorTransp)
00140         {
00141                 mCtrlColorTransp->setCommitCallback(LLPanelFace::onCommitAlpha);
00142                 mCtrlColorTransp->setCallbackUserData(this);
00143                 mCtrlColorTransp->setPrecision(0);
00144                 mCtrlColorTransp->setFollowsTop();
00145                 mCtrlColorTransp->setFollowsLeft();
00146         }
00147 
00148         mCheckFullbright = getChild<LLCheckBoxCtrl>("checkbox fullbright");
00149         if (mCheckFullbright)
00150         {
00151                 mCheckFullbright->setCommitCallback(LLPanelFace::onCommitFullbright);
00152                 mCheckFullbright->setCallbackUserData( this );
00153         }
00154         mLabelTexGen = getChild<LLTextBox>("tex gen");
00155         mComboTexGen = getChild<LLComboBox>("combobox texgen");
00156         if(mComboTexGen)
00157         {
00158                 mComboTexGen->setCommitCallback(LLPanelFace::onCommitTexGen);
00159                 mComboTexGen->setFollows(FOLLOWS_LEFT | FOLLOWS_TOP);   
00160                 mComboTexGen->setCallbackUserData( this );
00161         }
00162 
00163         mLabelGlow = getChild<LLTextBox>("glow label");
00164         mCtrlGlow = getChild<LLSpinCtrl>("glow");
00165         if(mCtrlGlow)
00166         {
00167                 mCtrlGlow->setCommitCallback(LLPanelFace::onCommitGlow);
00168                 mCtrlGlow->setCallbackUserData(this);
00169         }
00170         
00171         childSetCommitCallback("combobox shininess",&LLPanelFace::onCommitShiny,this);
00172         childSetCommitCallback("combobox bumpiness",&LLPanelFace::onCommitBump,this);
00173         childSetCommitCallback("TexScaleU",&LLPanelFace::onCommitTextureInfo, this);
00174         childSetCommitCallback("checkbox flip s",&LLPanelFace::onCommitTextureInfo, this);
00175         childSetCommitCallback("TexScaleV",&LLPanelFace::onCommitTextureInfo, this);
00176         childSetCommitCallback("checkbox flip t",&LLPanelFace::onCommitTextureInfo, this);
00177         childSetCommitCallback("TexRot",&LLPanelFace::onCommitTextureInfo, this);
00178         childSetAction("button apply",&onClickApply,this);
00179         childSetCommitCallback("TexOffsetU",LLPanelFace::onCommitTextureInfo, this);
00180         childSetCommitCallback("TexOffsetV",LLPanelFace::onCommitTextureInfo, this);
00181         childSetAction("button align",onClickAutoFix,this);
00182 
00183         clearCtrls();
00184 
00185         return TRUE;
00186 }
00187 
00188 LLPanelFace::LLPanelFace(const std::string& name)
00189 :       LLPanel(name)
00190 {
00191 }
00192 
00193 
00194 LLPanelFace::~LLPanelFace()
00195 {
00196         // Children all cleaned up by default view destructor.
00197 }
00198 
00199 
00200 void LLPanelFace::sendTexture()
00201 {
00202         LLTextureCtrl* mTextureCtrl = getChild<LLTextureCtrl>("texture control");
00203         if(!mTextureCtrl) return;
00204         if( !mTextureCtrl->getTentative() )
00205         {
00206                 // we grab the item id first, because we want to do a
00207                 // permissions check in the selection manager. ARGH!
00208                 LLUUID id = mTextureCtrl->getImageItemID();
00209                 if(id.isNull())
00210                 {
00211                         id = mTextureCtrl->getImageAssetID();
00212                 }
00213                 LLSelectMgr::getInstance()->selectionSetImage(id);
00214         }
00215 }
00216 
00217 void LLPanelFace::sendBump()
00218 {       
00219         LLComboBox*     mComboBumpiness = getChild<LLComboBox>("combobox bumpiness");
00220         if(!mComboBumpiness)return;
00221         U8 bump = (U8) mComboBumpiness->getCurrentIndex() & TEM_BUMP_MASK;
00222         LLSelectMgr::getInstance()->selectionSetBumpmap( bump );
00223 }
00224 
00225 void LLPanelFace::sendTexGen()
00226 {
00227         LLComboBox*     mComboTexGen = getChild<LLComboBox>("combobox texgen");
00228         if(!mComboTexGen)return;
00229         U8 tex_gen = (U8) mComboTexGen->getCurrentIndex() << TEM_TEX_GEN_SHIFT;
00230         LLSelectMgr::getInstance()->selectionSetTexGen( tex_gen );
00231 }
00232 
00233 void LLPanelFace::sendShiny()
00234 {
00235         LLComboBox*     mComboShininess = getChild<LLComboBox>("combobox shininess");
00236         if(!mComboShininess)return;
00237         U8 shiny = (U8) mComboShininess->getCurrentIndex() & TEM_SHINY_MASK;
00238         LLSelectMgr::getInstance()->selectionSetShiny( shiny );
00239 }
00240 
00241 void LLPanelFace::sendFullbright()
00242 {
00243         LLCheckBoxCtrl* mCheckFullbright = getChild<LLCheckBoxCtrl>("checkbox fullbright");
00244         if(!mCheckFullbright)return;
00245         U8 fullbright = mCheckFullbright->get() ? TEM_FULLBRIGHT_MASK : 0;
00246         LLSelectMgr::getInstance()->selectionSetFullbright( fullbright );
00247 }
00248 
00249 void LLPanelFace::sendColor()
00250 {
00251         
00252         LLColorSwatchCtrl*      mColorSwatch = getChild<LLColorSwatchCtrl>("colorswatch");
00253         if(!mColorSwatch)return;
00254         LLColor4 color = mColorSwatch->get();
00255 
00256         LLSelectMgr::getInstance()->selectionSetColorOnly( color );
00257 }
00258 
00259 void LLPanelFace::sendAlpha()
00260 {       
00261         LLSpinCtrl*     mCtrlColorTransp = getChild<LLSpinCtrl>("ColorTrans");
00262         if(!mCtrlColorTransp)return;
00263         F32 alpha = (100.f - mCtrlColorTransp->get()) / 100.f;
00264 
00265         LLSelectMgr::getInstance()->selectionSetAlphaOnly( alpha );
00266 }
00267 
00268 
00269 void LLPanelFace::sendGlow()
00270 {
00271         LLSpinCtrl*     mCtrlGlow = getChild<LLSpinCtrl>("glow");
00272         F32 glow = mCtrlGlow->get();
00273 
00274         LLSelectMgr::getInstance()->selectionSetGlow( glow );
00275 }
00276 
00277 struct LLPanelFaceSetTEFunctor : public LLSelectedTEFunctor
00278 {
00279         LLPanelFaceSetTEFunctor(LLPanelFace* panel) : mPanel(panel) {}
00280         virtual bool apply(LLViewerObject* object, S32 te)
00281         {
00282                 BOOL valid;
00283                 F32 value;
00284                 LLSpinCtrl*     ctrlTexScaleS = mPanel->getChild<LLSpinCtrl>("TexScaleU");
00285                 LLSpinCtrl*     ctrlTexScaleT = mPanel->getChild<LLSpinCtrl>("TexScaleV");
00286                 LLSpinCtrl*     ctrlTexOffsetS = mPanel->getChild<LLSpinCtrl>("TexOffsetU");
00287                 LLSpinCtrl*     ctrlTexOffsetT = mPanel->getChild<LLSpinCtrl>("TexOffsetV");
00288                 LLSpinCtrl*     ctrlTexRotation = mPanel->getChild<LLSpinCtrl>("TexRot");
00289                 LLCheckBoxCtrl* checkFlipScaleS = mPanel->getChild<LLCheckBoxCtrl>("checkbox flip s");
00290                 LLCheckBoxCtrl* checkFlipScaleT = mPanel->getChild<LLCheckBoxCtrl>("checkbox flip t");
00291                 LLComboBox*             comboTexGen = mPanel->getChild<LLComboBox>("combobox texgen");
00292                 if (ctrlTexScaleS)
00293                 {
00294                         valid = !ctrlTexScaleS->getTentative() || !checkFlipScaleS->getTentative();
00295                         if (valid)
00296                         {
00297                                 value = ctrlTexScaleS->get();
00298                                 if( checkFlipScaleS->get() )
00299                                 {
00300                                         value = -value;
00301                                 }
00302                                 if (comboTexGen->getCurrentIndex() == 1)
00303                                 {
00304                                         value *= 0.5f;
00305                                 }
00306                                 object->setTEScaleS( te, value );
00307                         }
00308                 }
00309 
00310                 if (ctrlTexScaleT)
00311                 {
00312                         valid = !ctrlTexScaleT->getTentative() || !checkFlipScaleT->getTentative();
00313                         if (valid)
00314                         {
00315                                 value = ctrlTexScaleT->get();
00316                                 if( checkFlipScaleT->get() )
00317                                 {
00318                                         value = -value;
00319                                 }
00320                                 if (comboTexGen->getCurrentIndex() == 1)
00321                                 {
00322                                         value *= 0.5f;
00323                                 }
00324                                 object->setTEScaleT( te, value );
00325                         }
00326                 }
00327 
00328                 if (ctrlTexOffsetS)
00329                 {
00330                         valid = !ctrlTexOffsetS->getTentative();
00331                         if (valid)
00332                         {
00333                                 value = ctrlTexOffsetS->get();
00334                                 object->setTEOffsetS( te, value );
00335                         }
00336                 }
00337 
00338                 if (ctrlTexOffsetT)
00339                 {
00340                         valid = !ctrlTexOffsetT->getTentative();
00341                         if (valid)
00342                         {
00343                                 value = ctrlTexOffsetT->get();
00344                                 object->setTEOffsetT( te, value );
00345                         }
00346                 }
00347 
00348                 if (ctrlTexRotation)
00349                 {
00350                         valid = !ctrlTexRotation->getTentative();
00351                         if (valid)
00352                         {
00353                                 value = ctrlTexRotation->get() * DEG_TO_RAD;
00354                                 object->setTERotation( te, value );
00355                         }
00356                 }
00357                 return true;
00358         }
00359 private:
00360         LLPanelFace* mPanel;
00361 };
00362 
00363 struct LLPanelFaceSendFunctor : public LLSelectedObjectFunctor
00364 {
00365         virtual bool apply(LLViewerObject* object)
00366         {
00367                 object->sendTEUpdate();
00368                 return true;
00369         }
00370 };
00371 
00372 void LLPanelFace::sendTextureInfo()
00373 {
00374         LLPanelFaceSetTEFunctor setfunc(this);
00375         LLSelectMgr::getInstance()->getSelection()->applyToTEs(&setfunc);
00376 
00377         LLPanelFaceSendFunctor sendfunc;
00378         LLSelectMgr::getInstance()->getSelection()->applyToObjects(&sendfunc);
00379 }
00380 
00381 void LLPanelFace::getState()
00382 {
00383         LLViewerObject* objectp = LLSelectMgr::getInstance()->getSelection()->getFirstObject();
00384 
00385         if( objectp
00386                 && objectp->getPCode() == LL_PCODE_VOLUME
00387                 && objectp->permModify())
00388         {
00389                 BOOL editable = objectp->permModify();
00390 
00391                 // only turn on auto-adjust button if there is a media renderer and the media is loaded
00392                 childSetEnabled("textbox autofix",FALSE);
00393                 //mLabelTexAutoFix->setEnabled ( FALSE );
00394                 childSetEnabled("button align",FALSE);
00395                 //mBtnAutoFix->setEnabled ( FALSE );
00396                 
00397                 if(LLViewerMedia::hasMedia())
00398                 {
00399                         childSetEnabled("textbox autofix",editable);
00400                         childSetEnabled("button align",editable);
00401                 }
00402                 //if ( LLMediaEngine::getInstance()->getMediaRenderer () )
00403                 //      if ( LLMediaEngine::getInstance()->getMediaRenderer ()->isLoaded () )
00404                 //      {       
00405                 //              
00406                 //              //mLabelTexAutoFix->setEnabled ( editable );
00407                 //              
00408                 //              //mBtnAutoFix->setEnabled ( editable );
00409                 //      }
00410                 childSetEnabled("button apply",editable);
00411 
00412                 bool identical;
00413                 LLTextureCtrl*  texture_ctrl = getChild<LLTextureCtrl>("texture control");
00414                 
00415                 // Texture
00416                 {
00417                         LLUUID id;
00418                         struct f1 : public LLSelectedTEGetFunctor<LLUUID>
00419                         {
00420                                 LLUUID get(LLViewerObject* object, S32 te)
00421                                 {
00422                                         LLViewerImage* image = object->getTEImage(te);
00423                                         return image ? image->getID() : LLUUID::null;
00424                                 }
00425                         } func;
00426                         identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, id );
00427                         
00428                         if (identical)
00429                         {
00430                                 // All selected have the same texture
00431                                 if(texture_ctrl)
00432                                 {
00433                                         texture_ctrl->setTentative( FALSE );
00434                                         texture_ctrl->setEnabled( editable );
00435                                         texture_ctrl->setImageAssetID( id );
00436                                 }
00437                         }
00438                         else
00439                         {
00440                                 if(texture_ctrl)
00441                                 {
00442                                         if( id.isNull() )
00443                                         {
00444                                                 // None selected
00445                                                 texture_ctrl->setTentative( FALSE );
00446                                                 texture_ctrl->setEnabled( FALSE );
00447                                                 texture_ctrl->setImageAssetID( LLUUID::null );
00448                                         }
00449                                         else
00450                                         {
00451                                                 // Tentative: multiple selected with different textures
00452                                                 texture_ctrl->setTentative( TRUE );
00453                                                 texture_ctrl->setEnabled( editable );
00454                                                 texture_ctrl->setImageAssetID( id );
00455                                         }
00456                                 }
00457                         }
00458                 }
00459                 
00460                 LLAggregatePermissions texture_perms;
00461                 if(texture_ctrl)
00462                 {
00463 //                      texture_ctrl->setValid( editable );
00464                 
00465                         if (LLSelectMgr::getInstance()->selectGetAggregateTexturePermissions(texture_perms))
00466                         {
00467                                 BOOL can_copy = 
00468                                         texture_perms.getValue(PERM_COPY) == LLAggregatePermissions::AP_EMPTY || 
00469                                         texture_perms.getValue(PERM_COPY) == LLAggregatePermissions::AP_ALL;
00470                                 BOOL can_transfer = 
00471                                         texture_perms.getValue(PERM_TRANSFER) == LLAggregatePermissions::AP_EMPTY || 
00472                                         texture_perms.getValue(PERM_TRANSFER) == LLAggregatePermissions::AP_ALL;
00473                                 texture_ctrl->setCanApplyImmediately(can_copy && can_transfer);
00474                         }
00475                         else
00476                         {
00477                                 texture_ctrl->setCanApplyImmediately(FALSE);
00478                         }
00479                 }
00480 
00481                 // Texture scale
00482                 {
00483                         childSetEnabled("tex scale",editable);
00484                         //mLabelTexScale->setEnabled( editable );
00485                         F32 scale_s = 1.f;
00486                         struct f2 : public LLSelectedTEGetFunctor<F32>
00487                         {
00488                                 F32 get(LLViewerObject* object, S32 face)
00489                                 {
00490                                         return object->getTE(face)->mScaleS;
00491                                 }
00492                         } func;
00493                         identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, scale_s );
00494                         childSetValue("TexScaleU",editable ? llabs(scale_s) : 0);
00495                         childSetTentative("TexScaleU",LLSD((BOOL)(!identical)));
00496                         childSetEnabled("TexScaleU",editable);
00497                         childSetValue("checkbox flip s",LLSD((BOOL)(scale_s < 0 ? TRUE : FALSE )));
00498                         childSetTentative("checkbox flip s",LLSD((BOOL)((!identical) ? TRUE : FALSE )));
00499                         childSetEnabled("checkbox flip s",editable);
00500                 }
00501 
00502                 {
00503                         F32 scale_t = 1.f;
00504                         struct f3 : public LLSelectedTEGetFunctor<F32>
00505                         {
00506                                 F32 get(LLViewerObject* object, S32 face)
00507                                 {
00508                                         return object->getTE(face)->mScaleT;
00509                                 }
00510                         } func;
00511                         identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, scale_t );
00512 
00513                         childSetValue("TexScaleV",llabs(editable ? llabs(scale_t) : 0));
00514                         childSetTentative("TexScaleV",LLSD((BOOL)(!identical)));
00515                         childSetEnabled("TexScaleV",editable);
00516                         childSetValue("checkbox flip t",LLSD((BOOL)(scale_t< 0 ? TRUE : FALSE )));
00517                         childSetTentative("checkbox flip t",LLSD((BOOL)((!identical) ? TRUE : FALSE )));
00518                         childSetEnabled("checkbox flip t",editable);
00519                 }
00520 
00521                 // Texture offset
00522                 {
00523                         childSetEnabled("tex offset",editable);
00524                         F32 offset_s = 0.f;
00525                         struct f4 : public LLSelectedTEGetFunctor<F32>
00526                         {
00527                                 F32 get(LLViewerObject* object, S32 face)
00528                                 {
00529                                         return object->getTE(face)->mOffsetS;
00530                                 }
00531                         } func;
00532                         identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, offset_s );
00533                         childSetValue("TexOffsetU", editable ? offset_s : 0);
00534                         childSetTentative("TexOffsetU",!identical);
00535                         childSetEnabled("TexOffsetU",editable);
00536                 }
00537 
00538                 {
00539                         F32 offset_t = 0.f;
00540                         struct f5 : public LLSelectedTEGetFunctor<F32>
00541                         {
00542                                 F32 get(LLViewerObject* object, S32 face)
00543                                 {
00544                                         return object->getTE(face)->mOffsetT;
00545                                 }
00546                         } func;
00547                         identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, offset_t );
00548                         childSetValue("TexOffsetV", editable ? offset_t : 0);
00549                         childSetTentative("TexOffsetV",!identical);
00550                         childSetEnabled("TexOffsetV",editable);
00551                 }
00552 
00553                 // Texture rotation
00554                 {
00555                         childSetEnabled("tex rotate",editable);
00556                         F32 rotation = 0.f;
00557                         struct f6 : public LLSelectedTEGetFunctor<F32>
00558                         {
00559                                 F32 get(LLViewerObject* object, S32 face)
00560                                 {
00561                                         return object->getTE(face)->mRotation;
00562                                 }
00563                         } func;
00564                         identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, rotation );
00565                         childSetValue("TexRot", editable ? rotation * RAD_TO_DEG : 0);
00566                         childSetTentative("TexRot",!identical);
00567                         childSetEnabled("TexRot",editable);
00568                 }
00569 
00570                 // Color swatch
00571                 LLColorSwatchCtrl*      mColorSwatch = getChild<LLColorSwatchCtrl>("colorswatch");
00572                 LLColor4 color = LLColor4::white;
00573                 if(mColorSwatch)
00574                 {
00575                         struct f7 : public LLSelectedTEGetFunctor<LLColor4>
00576                         {
00577                                 LLColor4 get(LLViewerObject* object, S32 face)
00578                                 {
00579                                         return object->getTE(face)->getColor();
00580                                 }
00581                         } func;
00582                         identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, color );
00583                         
00584                         mColorSwatch->setOriginal(color);
00585                         mColorSwatch->set(color, TRUE);
00586 
00587                         mColorSwatch->setValid(editable);
00588                         mColorSwatch->setEnabled( editable );
00589                         mColorSwatch->setCanApplyImmediately( editable );
00590                 }
00591                 // Color transparency
00592                 {
00593                         childSetEnabled("color trans",editable);
00594                 }
00595 
00596                 F32 transparency = (1.f - color.mV[VALPHA]) * 100.f;
00597                 {
00598                         childSetValue("ColorTrans", editable ? transparency : 0);
00599                         childSetEnabled("ColorTrans",editable);
00600                 }
00601 
00602                 {
00603                         F32 glow = 0.f;
00604                         struct f8 : public LLSelectedTEGetFunctor<F32>
00605                         {
00606                                 F32 get(LLViewerObject* object, S32 face)
00607                                 {
00608                                         return object->getTE(face)->getGlow();
00609                                 }
00610                         } func;
00611                         identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, glow );
00612 
00613                         childSetValue("glow",glow);
00614                         childSetEnabled("glow",editable);
00615                         childSetTentative("glow",!identical);
00616                         childSetEnabled("glow label",editable);
00617 
00618                 }
00619 
00620                 // Bump
00621                 {
00622                         F32 shinyf = 0.f;
00623                         struct f9 : public LLSelectedTEGetFunctor<F32>
00624                         {
00625                                 F32 get(LLViewerObject* object, S32 face)
00626                                 {
00627                                         return (F32)(object->getTE(face)->getShiny());
00628                                 }
00629                         } func;
00630                         identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, shinyf );
00631                         LLCtrlSelectionInterface* combobox_shininess =
00632                               childGetSelectionInterface("combobox shininess");
00633                         if (combobox_shininess)
00634                         {
00635                                 combobox_shininess->selectNthItem((S32)shinyf);
00636                         }
00637                         else
00638                         {
00639                                 llwarns << "failed childGetSelectionInterface for 'combobox shininess'" << llendl;
00640                         }
00641                         childSetEnabled("combobox shininess",editable);
00642                         childSetTentative("combobox shininess",!identical);
00643                         childSetEnabled("label shininess",editable);
00644                 }
00645 
00646                 {
00647                         F32 bumpf = 0.f;
00648                         struct f10 : public LLSelectedTEGetFunctor<F32>
00649                         {
00650                                 F32 get(LLViewerObject* object, S32 face)
00651                                 {
00652                                         return (F32)(object->getTE(face)->getBumpmap());
00653                                 }
00654                         } func;
00655                         identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, bumpf );
00656                         LLCtrlSelectionInterface* combobox_bumpiness =
00657                               childGetSelectionInterface("combobox bumpiness");
00658                         if (combobox_bumpiness)
00659                         {
00660                                 combobox_bumpiness->selectNthItem((S32)bumpf);
00661                         }
00662                         else
00663                         {
00664                                 llwarns << "failed childGetSelectionInterface for 'combobox bumpiness'" << llendl;
00665                         }
00666                         childSetEnabled("combobox bumpiness",editable);
00667                         childSetTentative("combobox bumpiness",!identical);
00668                         childSetEnabled("label bumpiness",editable);
00669                 }
00670 
00671                 {
00672                         F32 genf = 0.f;
00673                         struct f11 : public LLSelectedTEGetFunctor<F32>
00674                         {
00675                                 F32 get(LLViewerObject* object, S32 face)
00676                                 {
00677                                         return (F32)(object->getTE(face)->getTexGen());
00678                                 }
00679                         } func;
00680                         identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, genf );
00681                         S32 selected_texgen = ((S32) genf) >> TEM_TEX_GEN_SHIFT;
00682                         LLCtrlSelectionInterface* combobox_texgen =
00683                               childGetSelectionInterface("combobox texgen");
00684                         if (combobox_texgen)
00685                         {
00686                                 combobox_texgen->selectNthItem(selected_texgen);
00687                         }
00688                         else
00689                         {
00690                                 llwarns << "failed childGetSelectionInterface for 'combobox texgen'" << llendl;
00691                         }
00692                         childSetEnabled("combobox texgen",editable);
00693                         childSetTentative("combobox texgen",!identical);
00694                         childSetEnabled("tex gen",editable);
00695 
00696                         if (selected_texgen == 1)
00697                         {
00698                                 childSetText("tex scale",getString("string repeats per meter"));
00699                                 childSetValue("TexScaleU", 2.0f * childGetValue("TexScaleU").asReal() );
00700                                 childSetValue("TexScaleV", 2.0f * childGetValue("TexScaleV").asReal() );
00701                         }
00702                         else
00703                         {
00704                                 childSetText("tex scale",getString("string repeats per face"));
00705                         }
00706 
00707                 }
00708 
00709                 {
00710                         F32 fullbrightf = 0.f;
00711                         struct f12 : public LLSelectedTEGetFunctor<F32>
00712                         {
00713                                 F32 get(LLViewerObject* object, S32 face)
00714                                 {
00715                                         return (F32)(object->getTE(face)->getFullbright());
00716                                 }
00717                         } func;
00718                         identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, fullbrightf );
00719 
00720                         childSetValue("checkbox fullbright",(S32)fullbrightf);
00721                         childSetEnabled("checkbox fullbright",editable);
00722                         childSetTentative("checkbox fullbright",!identical);
00723                 }
00724                 
00725                 // Repeats per meter label
00726                 {
00727                         childSetEnabled("rpt",editable);
00728                 }
00729 
00730                 // Repeats per meter
00731                 {
00732                         F32 repeats = 1.f;
00733                         struct f13 : public LLSelectedTEGetFunctor<F32>
00734                         {
00735                                 F32 get(LLViewerObject* object, S32 face)
00736                                 {
00737                                         U32 s_axis = VX;
00738                                         U32 t_axis = VY;
00739                                         // BUG: Only repeats along S axis
00740                                         // BUG: Only works for boxes.
00741                                         LLPrimitive::getTESTAxes(face, &s_axis, &t_axis);
00742                                         return object->getTE(face)->mScaleS / object->getScale().mV[s_axis];
00743                                 }
00744                         } func;                 
00745                         identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, repeats );
00746                         
00747                         childSetValue("rptctrl", editable ? repeats : 0);
00748                         childSetTentative("rptctrl",!identical);
00749                         LLComboBox*     mComboTexGen = getChild<LLComboBox>("combobox texgen");
00750                         if (mComboTexGen)
00751                         {
00752                                 BOOL enabled = editable && (!mComboTexGen || mComboTexGen->getCurrentIndex() != 1);
00753                                 childSetEnabled("rptctrl",enabled);
00754                                 childSetEnabled("button apply",enabled);
00755                         }
00756                 }
00757         }
00758         else
00759         {
00760                 // Disable all UICtrls
00761                 clearCtrls();
00762 
00763                 // Disable non-UICtrls
00764                 LLTextureCtrl*  texture_ctrl = getChild<LLTextureCtrl>("texture control"); 
00765                 if(texture_ctrl)
00766                 {
00767                         texture_ctrl->setImageAssetID( LLUUID::null );
00768                         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.
00769 //                      texture_ctrl->setValid(FALSE);
00770                 }
00771                 LLColorSwatchCtrl* mColorSwatch = getChild<LLColorSwatchCtrl>("colorswatch");
00772                 if(mColorSwatch)
00773                 {
00774                         mColorSwatch->setEnabled( FALSE );                      
00775                         mColorSwatch->setValid(FALSE);
00776                 }
00777                 childSetEnabled("color trans",FALSE);
00778                 childSetEnabled("rpt",FALSE);
00779                 childSetEnabled("tex scale",FALSE);
00780                 childSetEnabled("tex offset",FALSE);
00781                 childSetEnabled("tex rotate",FALSE);
00782                 childSetEnabled("tex gen",FALSE);
00783                 childSetEnabled("label shininess",FALSE);
00784                 childSetEnabled("label bumpiness",FALSE);
00785 
00786                 childSetEnabled("textbox autofix",FALSE);
00787 
00788                 childSetEnabled("button align",FALSE);
00789                 childSetEnabled("button apply",FALSE);
00790         }
00791 }
00792 
00793 
00794 void LLPanelFace::refresh()
00795 {
00796         getState();
00797 }
00798 
00799 //
00800 // Static functions
00801 //
00802 
00803 // static
00804 F32 LLPanelFace::valueGlow(LLViewerObject* object, S32 face)
00805 {
00806         return (F32)(object->getTE(face)->getGlow());
00807 }
00808 
00809 
00810 // static
00811 void LLPanelFace::onCommitColor(LLUICtrl* ctrl, void* userdata)
00812 {
00813         LLPanelFace* self = (LLPanelFace*) userdata;
00814         self->sendColor();
00815 }
00816 
00817 // static
00818 void LLPanelFace::onCommitAlpha(LLUICtrl* ctrl, void* userdata)
00819 {
00820         LLPanelFace* self = (LLPanelFace*) userdata;
00821         self->sendAlpha();
00822 }
00823 
00824 // static
00825 void LLPanelFace::onCancelColor(LLUICtrl* ctrl, void* userdata)
00826 {
00827         LLSelectMgr::getInstance()->selectionRevertColors();
00828 }
00829 
00830 // static
00831 void LLPanelFace::onSelectColor(LLUICtrl* ctrl, void* userdata)
00832 {
00833         LLPanelFace* self = (LLPanelFace*) userdata;
00834         LLSelectMgr::getInstance()->saveSelectedObjectColors();
00835         self->sendColor();
00836 }
00837 
00838 // static
00839 void LLPanelFace::onCommitBump(LLUICtrl* ctrl, void* userdata)
00840 {
00841         LLPanelFace* self = (LLPanelFace*) userdata;
00842         self->sendBump();
00843 }
00844 
00845 // static
00846 void LLPanelFace::onCommitTexGen(LLUICtrl* ctrl, void* userdata)
00847 {
00848         LLPanelFace* self = (LLPanelFace*) userdata;
00849         self->sendTexGen();
00850 }
00851 
00852 // static
00853 void LLPanelFace::onCommitShiny(LLUICtrl* ctrl, void* userdata)
00854 {
00855         LLPanelFace* self = (LLPanelFace*) userdata;
00856         self->sendShiny();
00857 }
00858 
00859 // static
00860 void LLPanelFace::onCommitFullbright(LLUICtrl* ctrl, void* userdata)
00861 {
00862         LLPanelFace* self = (LLPanelFace*) userdata;
00863         self->sendFullbright();
00864 }
00865 
00866 // static
00867 void LLPanelFace::onCommitGlow(LLUICtrl* ctrl, void* userdata)
00868 {
00869         LLPanelFace* self = (LLPanelFace*) userdata;
00870         self->sendGlow();
00871 }
00872 
00873 // static
00874 BOOL LLPanelFace::onDragTexture(LLUICtrl*, LLInventoryItem* item, void*)
00875 {
00876         BOOL accept = TRUE;
00877         for (LLObjectSelection::root_iterator iter = LLSelectMgr::getInstance()->getSelection()->root_begin();
00878                  iter != LLSelectMgr::getInstance()->getSelection()->root_end(); iter++)
00879         {
00880                 LLSelectNode* node = *iter;
00881                 LLViewerObject* obj = node->getObject();
00882                 if(!LLToolDragAndDrop::isInventoryDropAcceptable(obj, item))
00883                 {
00884                         accept = FALSE;
00885                         break;
00886                 }
00887         }
00888         return accept;
00889 }
00890 
00891 // static
00892 void LLPanelFace::onCommitTexture( LLUICtrl* ctrl, void* userdata )
00893 {
00894         LLPanelFace* self = (LLPanelFace*) userdata;
00895 
00896         LLViewerStats::getInstance()->incStat(LLViewerStats::ST_EDIT_TEXTURE_COUNT );
00897         
00898         self->sendTexture();
00899 }
00900 
00901 // static
00902 void LLPanelFace::onCancelTexture(LLUICtrl* ctrl, void* userdata)
00903 {
00904         LLSelectMgr::getInstance()->selectionRevertTextures();
00905 }
00906 
00907 // static
00908 void LLPanelFace::onSelectTexture(LLUICtrl* ctrl, void* userdata)
00909 {
00910         LLPanelFace* self = (LLPanelFace*) userdata;
00911         LLSelectMgr::getInstance()->saveSelectedObjectTextures();
00912         self->sendTexture();
00913 }
00914 
00915 
00916 // static
00917 void LLPanelFace::onCommitTextureInfo( LLUICtrl* ctrl, void* userdata )
00918 {
00919         LLPanelFace* self = (LLPanelFace*) userdata;
00920         self->sendTextureInfo();
00921 }
00922 
00923 // Commit the number of repeats per meter
00924 // static
00925 void LLPanelFace::onClickApply(void* userdata)
00926 {
00927         LLPanelFace* self = (LLPanelFace*) userdata;
00928         
00929         gFocusMgr.setKeyboardFocus( NULL );
00930 
00931         //F32 repeats_per_meter = self->mCtrlRepeatsPerMeter->get();
00932         F32 repeats_per_meter = (F32)self->childGetValue( "rptctrl" ).asReal();//self->mCtrlRepeatsPerMeter->get();
00933         LLSelectMgr::getInstance()->selectionTexScaleAutofit( repeats_per_meter );
00934 }
00935 
00936 // commit the fit media texture to prim button
00937 
00938 struct LLPanelFaceSetMediaFunctor : public LLSelectedTEFunctor
00939 {
00940         virtual bool apply(LLViewerObject* object, S32 te)
00941         {
00942                 // only do this if it's a media texture
00943                 if ( object->getTE ( te )->getID() == LLViewerMedia::getMediaTextureID() )
00944                 {
00945                         S32 media_width, media_height;
00946                         S32 texture_width, texture_height;
00947                         if ( LLViewerMedia::getMediaSize( &media_width, &media_height )
00948                                 && LLViewerMedia::getTextureSize( &texture_width, &texture_height ) )
00949                         {
00950                                 F32 scale_s = (F32)media_width / (F32)texture_width;
00951                                 F32 scale_t = (F32)media_height / (F32)texture_height;
00952 
00953                                 // set scale and adjust offset
00954                                 object->setTEScaleS( te, scale_s );
00955                                 object->setTEScaleT( te, scale_t );     // don't need to flip Y anymore since QT does this for us now.
00956                                 object->setTEOffsetS( te, -( 1.0f - scale_s ) / 2.0f );
00957                                 object->setTEOffsetT( te, -( 1.0f - scale_t ) / 2.0f );
00958                         }
00959                 }
00960                 return true;
00961         };
00962 };
00963 
00964 void LLPanelFace::onClickAutoFix(void* userdata)
00965 {
00966         LLPanelFaceSetMediaFunctor setfunc;
00967         LLSelectMgr::getInstance()->getSelection()->applyToTEs(&setfunc);
00968 
00969         LLPanelFaceSendFunctor sendfunc;
00970         LLSelectMgr::getInstance()->getSelection()->applyToObjects(&sendfunc);
00971 }

Generated on Fri May 16 08:33:50 2008 for SecondLife by  doxygen 1.5.5