diff options
Diffstat (limited to 'indra/newview/llpaneleditwearable.cpp')
-rw-r--r-- | indra/newview/llpaneleditwearable.cpp | 169 |
1 files changed, 42 insertions, 127 deletions
diff --git a/indra/newview/llpaneleditwearable.cpp b/indra/newview/llpaneleditwearable.cpp index 85bddab02c..1aedfec86f 100644 --- a/indra/newview/llpaneleditwearable.cpp +++ b/indra/newview/llpaneleditwearable.cpp @@ -2,25 +2,31 @@ * @file llpaneleditwearable.cpp * @brief UI panel for editing of a particular wearable item. * - * $LicenseInfo:firstyear=2009&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * + * Copyright (c) 2009-2009, Linden Research, Inc. * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. * $/LicenseInfo$ */ @@ -41,7 +47,6 @@ #include "llvoavatarself.h" #include "lltexteditor.h" #include "lltextbox.h" -#include "llaccordionctrl.h" #include "llaccordionctrltab.h" #include "llagentwearables.h" #include "llscrollingpanelparam.h" @@ -58,7 +63,6 @@ #include "llcommandhandler.h" #include "lltextutil.h" -#include "llappearancemgr.h" // register panel with appropriate XML static LLRegisterPanelClassWrapper<LLPanelEditWearable> t_edit_wearable("panel_edit_wearable"); @@ -378,31 +382,6 @@ LLEditWearableDictionary::PickerControlEntry::PickerControlEntry(ETextureIndex t { } -/** - * Class to prevent hack in LLButton's constructor and use paddings declared in xml. - */ -class LLLabledBackButton : public LLButton -{ -public: - struct Params : public LLInitParam::Block<Params, LLButton::Params> - { - Params() {} - }; -protected: - friend class LLUICtrlFactory; - LLLabledBackButton(const Params&); -}; - -static LLDefaultChildRegistry::Register<LLLabledBackButton> labeled_back_btn("labeled_back_button"); - -LLLabledBackButton::LLLabledBackButton(const Params& params) -: LLButton(params) -{ - // override hack in LLButton's constructor to use paddings have been set in xml - setLeftHPad(params.pad_left); - setRightHPad(params.pad_right); -} - // Helper functions. static const texture_vec_t null_texture_vec; @@ -661,35 +640,6 @@ void LLPanelEditWearable::updateAvatarHeightLabel() mTxtAvatarHeight->appendText(this->mReplacementMetricUrl, false, param); } -void LLPanelEditWearable::onWearablePanelVisibilityChange(const LLSD &in_visible_chain, LLAccordionCtrl* accordion_ctrl) -{ - if (in_visible_chain.asBoolean() && accordion_ctrl != NULL) - { - accordion_ctrl->expandDefaultTab(); - } -} - -void LLPanelEditWearable::setWearablePanelVisibilityChangeCallback(LLPanel* bodypart_panel) -{ - if (bodypart_panel != NULL) - { - LLAccordionCtrl* accordion_ctrl = bodypart_panel->getChild<LLAccordionCtrl>("wearable_accordion"); - - if (accordion_ctrl != NULL) - { - bodypart_panel->setVisibleCallback( - boost::bind(&LLPanelEditWearable::onWearablePanelVisibilityChange, this, _2, accordion_ctrl)); - } - else - { - llwarns << "accordion_ctrl is NULL" << llendl; - } - } - else - { - llwarns << "bodypart_panel is NULL" << llendl; - } -} // virtual BOOL LLPanelEditWearable::postBuild() @@ -699,12 +649,10 @@ BOOL LLPanelEditWearable::postBuild() mBtnRevert->setClickedCallback(boost::bind(&LLPanelEditWearable::onRevertButtonClicked, this)); mBtnBack = getChild<LLButton>("back_btn"); - mBackBtnLabel = mBtnBack->getLabelUnselected(); - mBtnBack->setLabel(LLStringUtil::null); // handled at appearance panel level? //mBtnBack->setClickedCallback(boost::bind(&LLPanelEditWearable::onBackButtonClicked, this)); - mNameEditor = getChild<LLLineEditor>("description"); + mTextEditor = getChild<LLTextEditor>("description"); mPanelTitle = getChild<LLTextBox>("edit_wearable_title"); mDescTitle = getChild<LLTextBox>("description_text"); @@ -719,14 +667,6 @@ BOOL LLPanelEditWearable::postBuild() mPanelEyes = getChild<LLPanel>("edit_eyes_panel"); mPanelHair = getChild<LLPanel>("edit_hair_panel"); - // Setting the visibility callback is applied only to the bodyparts panel - // because currently they are the only ones whose 'wearable_accordion' has - // multiple accordion tabs (see EXT-8164 for details). - setWearablePanelVisibilityChangeCallback(mPanelShape); - setWearablePanelVisibilityChangeCallback(mPanelSkin); - setWearablePanelVisibilityChangeCallback(mPanelEyes); - setWearablePanelVisibilityChangeCallback(mPanelHair); - //clothes mPanelShirt = getChild<LLPanel>("edit_shirt_panel"); mPanelPants = getChild<LLPanel>("edit_pants_panel"); @@ -818,7 +758,7 @@ BOOL LLPanelEditWearable::isDirty() const if (mWearablePtr) { if (mWearablePtr->isDirty() || - mWearableItem->getName().compare(mNameEditor->getText()) != 0) + mWearablePtr->getName().compare(mTextEditor->getText()) != 0) { isDirty = TRUE; } @@ -856,7 +796,7 @@ void LLPanelEditWearable::onRevertButtonClicked(void* userdata) void LLPanelEditWearable::onSaveAsButtonClicked() { LLSD args; - args["DESC"] = mNameEditor->getText(); + args["DESC"] = mTextEditor->getText(); LLNotificationsUtil::add("SaveWearableAs", args, LLSD(), boost::bind(&LLPanelEditWearable::saveAsCallback, this, _1, _2)); } @@ -870,8 +810,8 @@ void LLPanelEditWearable::saveAsCallback(const LLSD& notification, const LLSD& r LLStringUtil::trim(wearable_name); if( !wearable_name.empty() ) { - mNameEditor->setText(wearable_name); - saveChanges(true); + mTextEditor->setText(wearable_name); + saveChanges(); } } } @@ -928,7 +868,7 @@ void LLPanelEditWearable::onTexturePickerCommit(const LLUICtrl* ctrl) { // Set the new version LLViewerFetchedTexture* image = LLViewerTextureManager::getFetchedTexture(texture_ctrl->getImageAssetID()); - if( image->getID() == IMG_DEFAULT ) + if( image->getID().isNull() ) { image = LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT_AVATAR); } @@ -980,6 +920,7 @@ void LLPanelEditWearable::updatePanelPickerControls(LLWearableType::EType type) return; bool is_modifiable = false; + bool is_complete = false; bool is_copyable = false; if(mWearableItem) @@ -987,15 +928,17 @@ void LLPanelEditWearable::updatePanelPickerControls(LLWearableType::EType type) const LLPermissions& perm = mWearableItem->getPermissions(); is_modifiable = perm.allowModifyBy(gAgent.getID(), gAgent.getGroupID()); is_copyable = perm.allowCopyBy(gAgent.getID(), gAgent.getGroupID()); + is_complete = mWearableItem->isFinished(); } - if (is_modifiable) + if (is_modifiable && is_complete) { // Update picker controls for_each_picker_ctrl_entry <LLColorSwatchCtrl> (panel, type, boost::bind(update_color_swatch_ctrl, this, _1, _2)); for_each_picker_ctrl_entry <LLTextureCtrl> (panel, type, boost::bind(update_texture_ctrl, this, _1, _2)); } - else + + if (!is_modifiable || !is_complete || !is_copyable) { // Disable controls for_each_picker_ctrl_entry <LLColorSwatchCtrl> (panel, type, boost::bind(set_enabled_color_swatch_ctrl, false, _1, _2)); @@ -1003,7 +946,7 @@ void LLPanelEditWearable::updatePanelPickerControls(LLWearableType::EType type) } } -void LLPanelEditWearable::saveChanges(bool force_save_as) +void LLPanelEditWearable::saveChanges() { if (!mWearablePtr || !isDirty()) { @@ -1012,18 +955,15 @@ void LLPanelEditWearable::saveChanges(bool force_save_as) } U32 index = gAgentWearables.getWearableIndex(mWearablePtr); - - std::string new_name = mNameEditor->getText(); - if (force_save_as) + + if (mWearablePtr->getName().compare(mTextEditor->getText()) != 0) { // the name of the wearable has changed, re-save wearable with new name - LLAppearanceMgr::instance().removeCOFItemLinks(mWearablePtr->getItemID(),false); - gAgentWearables.saveWearableAs(mWearablePtr->getType(), index, new_name, FALSE); - mNameEditor->setText(mWearableItem->getName()); + gAgentWearables.saveWearableAs(mWearablePtr->getType(), index, mTextEditor->getText(), FALSE); } else { - gAgentWearables.saveWearable(mWearablePtr->getType(), index, TRUE, new_name); + gAgentWearables.saveWearable(mWearablePtr->getType(), index); } } @@ -1036,10 +976,7 @@ void LLPanelEditWearable::revertChanges() } mWearablePtr->revertValues(); - mNameEditor->setText(mWearableItem->getName()); - updatePanelPickerControls(mWearablePtr->getType()); - updateTypeSpecificControls(mWearablePtr->getType()); - gAgentAvatarp->wearableUpdated(mWearablePtr->getType(), FALSE); + mTextEditor->setText(mWearablePtr->getName()); } void LLPanelEditWearable::showWearable(LLWearable* wearable, BOOL show) @@ -1078,11 +1015,10 @@ void LLPanelEditWearable::showWearable(LLWearable* wearable, BOOL show) if (show) { mPanelTitle->setText(title); - mPanelTitle->setToolTip(title); mDescTitle->setText(description_title); // set name - mNameEditor->setText(mWearableItem->getName()); + mTextEditor->setText(wearable->getName()); updatePanelPickerControls(type); updateTypeSpecificControls(type); @@ -1190,6 +1126,7 @@ void LLPanelEditWearable::changeCamera(U8 subpart) } // Update the camera + gMorphView->setCameraDistToDefault(); gMorphView->setCameraTargetJoint( gAgentAvatarp->getJoint( subpart_entry->mTargetJoint ) ); gMorphView->setCameraTargetOffset( subpart_entry->mTargetOffset ); gMorphView->setCameraOffset( subpart_entry->mCameraOffset ); @@ -1365,8 +1302,8 @@ void LLPanelEditWearable::getSortedParams(value_map_t &sorted_params, const std: { LLViewerVisualParam *param = (LLViewerVisualParam*) *iter; - if (param->getID() == -1 - || !param->isTweakable() + if (param->getID() == -1 + || param->getGroup() != VISUAL_PARAM_GROUP_TWEAKABLE || param->getEditGroup() != edit_group || !(param->getSex() & avatar_sex)) { @@ -1420,28 +1357,6 @@ void LLPanelEditWearable::updateVerbs() gSavedSettings.setU32("AvatarSex", (gAgentAvatarp->getSex() == SEX_MALE) ); } - // update back button and title according to dirty state. - static BOOL was_dirty = FALSE; - if (was_dirty != is_dirty) // to avoid redundant changes because this method is called from draw - { - static S32 label_width = mBtnBack->getFont()->getWidth(mBackBtnLabel); - const std::string& label = is_dirty ? mBackBtnLabel : LLStringUtil::null; - const S32 delta_width = is_dirty ? label_width : -label_width; - - mBtnBack->setLabel(label); - - // update rect according to label width - LLRect rect = mBtnBack->getRect(); - rect.mRight += delta_width; - mBtnBack->setShape(rect); - - // update title rect according to back button width - rect = mPanelTitle->getRect(); - rect.mLeft += delta_width; - mPanelTitle->setShape(rect); - - was_dirty = is_dirty; - } } void LLPanelEditWearable::configureAlphaCheckbox(LLVOAvatarDefines::ETextureIndex te, const std::string& name) |