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

Generated on Thu Jul 1 06:08:57 2010 for Second Life Viewer by  doxygen 1.4.7