From f4663e098c1f338259b46085188be19f8fad7543 Mon Sep 17 00:00:00 2001 From: Tonya Souther Date: Thu, 10 Jan 2013 18:05:39 -0600 Subject: New controls for editing media. --- indra/newview/llpanelface.cpp | 159 +++++++++++--- indra/newview/llpanelface.h | 1 + .../skins/default/xui/en/panel_tools_texture.xml | 228 +++++++++++++++++---- 3 files changed, 321 insertions(+), 67 deletions(-) (limited to 'indra') diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index e74c8509ce..0dedfae7da 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -65,6 +65,20 @@ #include "llpluginclassmedia.h" #include "llviewertexturelist.h" +// +// Constant definitions for comboboxes +// Must match the commbobox definitions in panel_tools_texture.xml +// +const U32 MATMEDIA_MATERIAL = 0; // Material +const U32 MATMEDIA_MEDIA = 1; // Media +const U32 MATTYPE_DIFFUSE = 0; // Diffuse material texture +const U32 MATTYPE_NORMAL = 1; // Normal map +const U32 MATTYPE_SPECULAR = 2; // Specular map +const U32 ALPHAMODE_NONE = 0; // No alpha mask applied +const U32 ALPHAMODE_MASK = 2; // Alpha masking mode +const U32 BUMPY_TEXTURE = 18; // use supplied normal map +const U32 SHINY_TEXTURE = 4; // use supplied specular map + // // Methods // @@ -75,6 +89,7 @@ BOOL LLPanelFace::postBuild() childSetCommitCallback("combobox mattype",&LLPanelFace::onCommitMaterialType,this); childSetCommitCallback("combobox shininess",&LLPanelFace::onCommitShiny,this); childSetCommitCallback("combobox bumpiness",&LLPanelFace::onCommitBump,this); + childSetCommitCallback("combobox alphamode",&LLPanelFace::onCommitAlphaMode,this); childSetCommitCallback("TexScaleU",&LLPanelFace::onCommitTextureInfo, this); childSetCommitCallback("TexScaleV",&LLPanelFace::onCommitTextureInfo, this); childSetCommitCallback("TexRot",&LLPanelFace::onCommitTextureInfo, this); @@ -492,30 +507,33 @@ void LLPanelFace::getState() BOOL editable = objectp->permModify() && !objectp->isPermanentEnforced(); // only turn on auto-adjust button if there is a media renderer and the media is loaded - getChildView("textbox autofix")->setEnabled(editable); getChildView("button align")->setEnabled(editable); - LLCtrlSelectionInterface* combobox_matmedia = - childGetSelectionInterface("combobox matmedia"); + LLComboBox* combobox_matmedia = getChild("combobox matmedia"); if (combobox_matmedia) { - combobox_matmedia->selectNthItem(0); + if (combobox_matmedia->getCurrentIndex() < MATMEDIA_MATERIAL) + { + combobox_matmedia->selectNthItem(MATMEDIA_MATERIAL); + } } else { - llwarns << "failed childGetSelectionInterface for 'combobox matmedia'" << llendl; + llwarns << "failed getChild for 'combobox matmedia'" << llendl; } getChildView("combobox matmedia")->setEnabled(editable); - LLCtrlSelectionInterface* combobox_mattype = - childGetSelectionInterface("combobox mattype"); + LLComboBox* combobox_mattype = getChild("combobox mattype"); if (combobox_mattype) { - combobox_mattype->selectNthItem(0); + if (combobox_mattype->getCurrentIndex() < MATTYPE_DIFFUSE) + { + combobox_mattype->selectNthItem(MATTYPE_DIFFUSE); + } } else { - llwarns << "failed childGetSelectionInterface for 'combobox mattype'" << llendl; + llwarns << "failed getChild for 'combobox mattype'" << llendl; } getChildView("combobox mattype")->setEnabled(editable); onCommitMaterialsMedia(NULL, this); @@ -565,12 +583,41 @@ void LLPanelFace::getState() } func; identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, id ); + BOOL is_alpha = FALSE; + struct f2 : public LLSelectedTEGetFunctor + { + BOOL get(LLViewerObject* object, S32 te_index) + { + BOOL is_alpha = FALSE; + + LLViewerTexture* image = object->getTEImage(te_index); + if (image) is_alpha = image->getIsAlphaMask(); + return is_alpha; + } + } func2; + identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func2, is_alpha ); + if(LLViewerMedia::textureHasMedia(id)) { - getChildView("textbox autofix")->setEnabled(editable); getChildView("button align")->setEnabled(editable); } + if (!is_alpha) + { + // Selected texture has no alpha, force alpha mode None + LLCtrlSelectionInterface* combobox_alphamode = + childGetSelectionInterface("combobox alphamode"); + if (combobox_alphamode) + { + combobox_alphamode->selectNthItem(ALPHAMODE_NONE); + } + else + { + llwarns << "failed childGetSelectionInterface for 'combobox alphamode'" << llendl; + } + onCommitAlphaMode(getChild("combobox alpha"),this); + } + if (identical) { // All selected have the same texture @@ -579,6 +626,10 @@ void LLPanelFace::getState() texture_ctrl->setTentative( FALSE ); texture_ctrl->setEnabled( editable ); texture_ctrl->setImageAssetID( id ); + getChildView("combobox alphamode")->setEnabled(editable && is_alpha); + getChildView("label alphamode")->setEnabled(editable && is_alpha); + getChildView("maskcutoff")->setEnabled(editable && is_alpha); + getChildView("label maskcutoff")->setEnabled(editable && is_alpha); } } else @@ -591,6 +642,10 @@ void LLPanelFace::getState() texture_ctrl->setTentative( FALSE ); texture_ctrl->setEnabled( FALSE ); texture_ctrl->setImageAssetID( LLUUID::null ); + getChildView("combobox alphamode")->setEnabled( FALSE ); + getChildView("label alphamode")->setEnabled( FALSE ); + getChildView("maskcutoff")->setEnabled( FALSE); + getChildView("label maskcutoff")->setEnabled( FALSE ); } else { @@ -598,6 +653,10 @@ void LLPanelFace::getState() texture_ctrl->setTentative( TRUE ); texture_ctrl->setEnabled( editable ); texture_ctrl->setImageAssetID( id ); + getChildView("combobox alphamode")->setEnabled(editable && is_alpha); + getChildView("label alphamode")->setEnabled(editable && is_alpha); + getChildView("maskcutoff")->setEnabled(editable && is_alpha); + getChildView("label maskcutoff")->setEnabled(editable && is_alpha); } } } @@ -803,6 +862,15 @@ void LLPanelFace::getState() getChildView("combobox shininess")->setEnabled(editable); getChild("combobox shininess")->setTentative(!identical); getChildView("label shininess")->setEnabled(editable); + getChildView("glossiness")->setEnabled(editable); + getChild("glossiness")->setTentative(!identical); + getChildView("label glossiness")->setEnabled(editable); + getChildView("environment")->setEnabled(editable); + getChild("environment")->setTentative(!identical); + getChildView("label environment")->setEnabled(editable); + getChildView("shinycolorswatch")->setEnabled(editable); + getChild("shinycolorswatch")->setTentative(!identical); + getChildView("label shinycolor")->setEnabled(editable); } { @@ -955,12 +1023,9 @@ void LLPanelFace::getState() getChildView("label shininess")->setEnabled(FALSE); getChildView("label bumpiness")->setEnabled(FALSE); - getChildView("textbox autofix")->setEnabled(FALSE); - getChildView("button align")->setEnabled(FALSE); //getChildView("has media")->setEnabled(FALSE); //getChildView("media info set")->setEnabled(FALSE); - // Set variable values for numeric expressions LLCalc* calcp = LLCalc::getInstance(); @@ -1016,30 +1081,50 @@ void LLPanelFace::onSelectColor(const LLSD& data) void LLPanelFace::onCommitMaterialsMedia(LLUICtrl* ctrl, void* userdata) { LLPanelFace* self = (LLPanelFace*) userdata; - LLComboBox* mComboMaterialsMedia = self->getChild("combobox matmedia"); - if (!mComboMaterialsMedia) + LLComboBox* comboMaterialsMedia = self->getChild("combobox matmedia"); + if (!comboMaterialsMedia) { return; } - U32 materials_media = mComboMaterialsMedia->getCurrentIndex(); - LLComboBox* mComboMaterialType = self->getChild("combobox mattype"); - if (!mComboMaterialType) + U32 materials_media = comboMaterialsMedia->getCurrentIndex(); + LLComboBox* comboMaterialType = self->getChild("combobox mattype"); + if (!comboMaterialType) { return; } - U32 material_type = mComboMaterialType->getCurrentIndex(); - bool show_media = (materials_media == 1); - bool show_texture = (!show_media) && (material_type == 0); - bool show_bumpiness = (!show_media) && (material_type == 1); - bool show_shininess = (!show_media) && (material_type == 2); + U32 material_type = comboMaterialType->getCurrentIndex(); + bool show_media = (materials_media == MATMEDIA_MEDIA); + bool show_texture = (!show_media) && (material_type == MATTYPE_DIFFUSE); + bool show_bumpiness = (!show_media) && (material_type == MATTYPE_NORMAL); + bool show_shininess = (!show_media) && (material_type == MATTYPE_SPECULAR); self->getChildView("combobox mattype")->setVisible(!show_media); self->getChildView("media_info")->setVisible(show_media); self->getChildView("add_media")->setVisible(show_media); self->getChildView("delete_media")->setVisible(show_media); self->getChildView("button align")->setVisible(show_media); self->getChildView("texture control")->setVisible(show_texture); + self->getChildView("label alphamode")->setVisible(show_texture); + self->getChildView("combobox alphamode")->setVisible(show_texture); + self->getChildView("label maskcutoff")->setVisible(false); + self->getChildView("maskcutoff")->setVisible(false); + if (show_texture) + { + onCommitAlphaMode(ctrl, userdata); + } + self->getChildView("shinytexture control")->setVisible(show_shininess); self->getChildView("combobox shininess")->setVisible(show_shininess); self->getChildView("label shininess")->setVisible(show_shininess); + self->getChildView("label glossiness")->setVisible(false); + self->getChildView("glossiness")->setVisible(false); + self->getChildView("label environment")->setVisible(false); + self->getChildView("environment")->setVisible(false); + self->getChildView("label shinycolor")->setVisible(false); + self->getChildView("shinycolorswatch")->setVisible(false); + if (show_shininess) + { + onCommitShiny(ctrl, userdata); + } + self->getChildView("bumpytexture control")->setVisible(show_bumpiness); self->getChildView("combobox bumpiness")->setVisible(show_bumpiness); self->getChildView("label bumpiness")->setVisible(show_bumpiness); } @@ -1068,9 +1153,37 @@ void LLPanelFace::onCommitTexGen(LLUICtrl* ctrl, void* userdata) void LLPanelFace::onCommitShiny(LLUICtrl* ctrl, void* userdata) { LLPanelFace* self = (LLPanelFace*) userdata; + LLComboBox* comboShiny = self->getChild("combobox shininess"); + if (!comboShiny) + { + return; + } + U32 shiny_value = comboShiny->getCurrentIndex(); + bool show_shinyctrls = (shiny_value == SHINY_TEXTURE); // Use texture + self->getChildView("label glossiness")->setVisible(show_shinyctrls); + self->getChildView("glossiness")->setVisible(show_shinyctrls); + self->getChildView("label environment")->setVisible(show_shinyctrls); + self->getChildView("environment")->setVisible(show_shinyctrls); + self->getChildView("label shinycolor")->setVisible(show_shinyctrls); + self->getChildView("shinycolorswatch")->setVisible(show_shinyctrls); self->sendShiny(); } +// static +void LLPanelFace::onCommitAlphaMode(LLUICtrl* ctrl, void* userdata) +{ + LLPanelFace* self = (LLPanelFace*) userdata; + LLComboBox* comboAlphaMode = self->getChild("combobox alphamode"); + if (!comboAlphaMode) + { + return; + } + U32 alpha_value = comboAlphaMode->getCurrentIndex(); + bool show_alphactrls = (alpha_value == ALPHAMODE_MASK); // Alpha masking + self->getChildView("label maskcutoff")->setVisible(show_alphactrls); + self->getChildView("maskcutoff")->setVisible(show_alphactrls); +} + // static void LLPanelFace::onCommitFullbright(LLUICtrl* ctrl, void* userdata) { diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h index acac2c1bf5..56b4034a2d 100644 --- a/indra/newview/llpanelface.h +++ b/indra/newview/llpanelface.h @@ -85,6 +85,7 @@ protected: static void onCommitBump( LLUICtrl* ctrl, void* userdata); static void onCommitTexGen( LLUICtrl* ctrl, void* userdata); static void onCommitShiny( LLUICtrl* ctrl, void* userdata); + static void onCommitAlphaMode( LLUICtrl* ctrl, void* userdata); static void onCommitFullbright( LLUICtrl* ctrl, void* userdata); static void onCommitGlow( LLUICtrl* ctrl, void *userdata); static void onCommitPlanarAlign( LLUICtrl* ctrl, void* userdata); diff --git a/indra/newview/skins/default/xui/en/panel_tools_texture.xml b/indra/newview/skins/default/xui/en/panel_tools_texture.xml index 26b2d83351..21cbf9673d 100644 --- a/indra/newview/skins/default/xui/en/panel_tools_texture.xml +++ b/indra/newview/skins/default/xui/en/panel_tools_texture.xml @@ -155,36 +155,36 @@ follows="left|top" height="10" layout="topleft" - name="label shininess" left_pad="10" + name="label alphamode" text_readonly_color="LabelDisabledColor" - top_delta="6" + top_delta="0" width="90"> - Shininess + Alpha mode + left_delta="0" + name="combobox alphamode" + top_pad="4" + width="120"> + label="Alpha blending" + name="Alpha blending" + value="Alpha blending" /> + label="Alpha masking" + name="Alpha masking" + value="Alpha masking" /> + label="Emissive mask" + name="Emissive mask" + value="Emissive mask" /> + Mask cutoff + + + + + + + + + Shininess + + + + + + + + + Glossiness + + + + Environment + + + + Color + + + - - - -