diff options
Diffstat (limited to 'indra/newview/lltexturectrl.cpp')
-rw-r--r-- | indra/newview/lltexturectrl.cpp | 102 |
1 files changed, 64 insertions, 38 deletions
diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp index fcb9deb20b..1625b4bafd 100644 --- a/indra/newview/lltexturectrl.cpp +++ b/indra/newview/lltexturectrl.cpp @@ -3,31 +3,25 @@ * @author Richard Nelson, James Cook * @brief LLTextureCtrl class implementation including related functions * - * $LicenseInfo:firstyear=2002&license=viewergpl$ - * - * Copyright (c) 2002-2009, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2002&license=viewerlgpl$ * 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 + * Copyright (C) 2010, Linden Research, Inc. * - * 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 + * 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. * - * 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. + * 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. * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * 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 + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -175,6 +169,8 @@ protected: BOOL mNoCopyTextureSelected; F32 mContextConeOpacity; LLSaveFolderState mSavedFolderState; + + BOOL mSelectedItemPinned; }; LLFloaterTexturePicker::LLFloaterTexturePicker( @@ -197,7 +193,8 @@ LLFloaterTexturePicker::LLFloaterTexturePicker( mFilterEdit(NULL), mImmediateFilterPermMask(immediate_filter_perm_mask), mNonImmediateFilterPermMask(non_immediate_filter_perm_mask), - mContextConeOpacity(0.f) + mContextConeOpacity(0.f), + mSelectedItemPinned( FALSE ) { mCanApplyImmediately = can_apply_immediately; LLUICtrlFactory::getInstance()->buildFloater(this,"floater_texture_ctrl.xml",NULL); @@ -226,7 +223,7 @@ void LLFloaterTexturePicker::setImageID(const LLUUID& image_id) if (itemp && !itemp->getPermissions().allowCopyBy(gAgent.getID())) { // no copy texture - childSetValue("apply_immediate_check", FALSE); + getChild<LLUICtrl>("apply_immediate_check")->setValue(FALSE); mNoCopyTextureSelected = TRUE; } mInventoryPanel->setSelection(item_id, TAKE_FOCUS_NO); @@ -236,7 +233,7 @@ void LLFloaterTexturePicker::setImageID(const LLUUID& image_id) void LLFloaterTexturePicker::setActive( BOOL active ) { - if (!active && childGetValue("Pipette").asBoolean()) + if (!active && getChild<LLUICtrl>("Pipette")->getValue().asBoolean()) { stopUsingPipette(); } @@ -248,7 +245,7 @@ void LLFloaterTexturePicker::setCanApplyImmediately(BOOL b) mCanApplyImmediately = b; if (!mCanApplyImmediately) { - childSetValue("apply_immediate_check", FALSE); + getChild<LLUICtrl>("apply_immediate_check")->setValue(FALSE); } updateFilterPermMask(); } @@ -403,7 +400,7 @@ BOOL LLFloaterTexturePicker::postBuild() childSetCommitCallback("show_folders_check", onShowFolders, this); - childSetVisible("show_folders_check", FALSE); + getChildView("show_folders_check")->setVisible( FALSE); mFilterEdit = getChild<LLFilterEditor>("inventory search editor"); mFilterEdit->setCommitCallback(boost::bind(&LLFloaterTexturePicker::onFilterEdit, this, _2)); @@ -423,6 +420,10 @@ BOOL LLFloaterTexturePicker::postBuild() mInventoryPanel->setShowFolderState(LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS); mInventoryPanel->setAllowMultiSelect(FALSE); + // Disable auto selecting first filtered item because it takes away + // selection from the item set by LLTextureCtrl owning this floater. + mInventoryPanel->getRootFolder()->setAutoSelectOverride(TRUE); + // Commented out to scroll to currently selected texture. See EXT-5403. // // store this filter as the default one // mInventoryPanel->getRootFolder()->getFilter()->markDefault(); @@ -438,12 +439,12 @@ BOOL LLFloaterTexturePicker::postBuild() mNoCopyTextureSelected = FALSE; - childSetValue("apply_immediate_check", gSavedSettings.getBOOL("ApplyTextureImmediately")); + getChild<LLUICtrl>("apply_immediate_check")->setValue(gSavedSettings.getBOOL("ApplyTextureImmediately")); childSetCommitCallback("apply_immediate_check", onApplyImmediateCheck, this); if (!mCanApplyImmediately) { - childSetEnabled("show_folders_check", FALSE); + getChildView("show_folders_check")->setEnabled(FALSE); } getChild<LLUICtrl>("Pipette")->setCommitCallback( boost::bind(&LLFloaterTexturePicker::onBtnPipette, this)); @@ -520,10 +521,10 @@ void LLFloaterTexturePicker::draw() updateImageStats(); // if we're inactive, gray out "apply immediate" checkbox - childSetEnabled("show_folders_check", mActive && mCanApplyImmediately && !mNoCopyTextureSelected); - childSetEnabled("Select", mActive); - childSetEnabled("Pipette", mActive); - childSetValue("Pipette", LLToolMgr::getInstance()->getCurrentTool() == LLToolPipette::getInstance()); + getChildView("show_folders_check")->setEnabled(mActive && mCanApplyImmediately && !mNoCopyTextureSelected); + getChildView("Select")->setEnabled(mActive); + getChildView("Pipette")->setEnabled(mActive); + getChild<LLUICtrl>("Pipette")->setValue(LLToolMgr::getInstance()->getCurrentTool() == LLToolPipette::getInstance()); //BOOL allow_copy = FALSE; if( mOwner ) @@ -540,9 +541,9 @@ void LLFloaterTexturePicker::draw() mTentativeLabel->setVisible( FALSE ); } - childSetEnabled("Default", mImageAssetID != mOwner->getDefaultImageAssetID()); - childSetEnabled("Blank", mImageAssetID != mWhiteImageAssetID ); - childSetEnabled("None", mOwner->getAllowNoTexture() && !mImageAssetID.isNull() ); + getChildView("Default")->setEnabled(mImageAssetID != mOwner->getDefaultImageAssetID()); + getChildView("Blank")->setEnabled(mImageAssetID != mWhiteImageAssetID ); + getChildView("None")->setEnabled(mOwner->getAllowNoTexture() && !mImageAssetID.isNull() ); LLFloater::draw(); @@ -593,6 +594,31 @@ void LLFloaterTexturePicker::draw() mTentativeLabel->setVisible( TRUE ); drawChild(mTentativeLabel); } + + if (mSelectedItemPinned) return; + + LLFolderView* folder_view = mInventoryPanel->getRootFolder(); + if (!folder_view) return; + + LLInventoryFilter* filter = folder_view->getFilter(); + if (!filter) return; + + bool is_filter_active = folder_view->getCompletedFilterGeneration() < filter->getCurrentGeneration() && + filter->isNotDefault(); + + // After inventory panel filter is applied we have to update + // constraint rect for the selected item because of folder view + // AutoSelectOverride set to TRUE. We force PinningSelectedItem + // flag to FALSE state and setting filter "dirty" to update + // scroll container to show selected item (see LLFolderView::doIdle()). + if (!is_filter_active && !mSelectedItemPinned) + { + folder_view->setPinningSelectedItem(mSelectedItemPinned); + folder_view->dirtyFilter(); + folder_view->arrangeFromRoot(); + + mSelectedItemPinned = TRUE; + } } } @@ -647,13 +673,13 @@ const LLUUID& LLFloaterTexturePicker::findItemID(const LLUUID& asset_id, BOOL co PermissionMask LLFloaterTexturePicker::getFilterPermMask() { - bool apply_immediate = childGetValue("apply_immediate_check").asBoolean(); + bool apply_immediate = getChild<LLUICtrl>("apply_immediate_check")->getValue().asBoolean(); return apply_immediate ? mImmediateFilterPermMask : mNonImmediateFilterPermMask; } void LLFloaterTexturePicker::commitIfImmediateSet() { - bool apply_immediate = childGetValue("apply_immediate_check").asBoolean(); + bool apply_immediate = getChild<LLUICtrl>("apply_immediate_check")->getValue().asBoolean(); if (!mNoCopyTextureSelected && apply_immediate && mOwner) { mOwner->onFloaterCommit(LLTextureCtrl::TEXTURE_CHANGE); @@ -726,7 +752,7 @@ void LLFloaterTexturePicker::onBtnSelect(void* userdata) void LLFloaterTexturePicker::onBtnPipette() { - BOOL pipette_active = childGetValue("Pipette").asBoolean(); + BOOL pipette_active = getChild<LLUICtrl>("Pipette")->getValue().asBoolean(); pipette_active = !pipette_active; if (pipette_active) { |