From 116bd660b65cfad64c6f9635db165cff5b3eda36 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 31 Aug 2022 23:39:36 +0300 Subject: SL-17653 Finalized texure picker's local filtering --- indra/newview/llpanelface.cpp | 1 + indra/newview/lltexturectrl.cpp | 126 +++++++++++++++++---- indra/newview/lltexturectrl.h | 19 +++- .../skins/default/xui/en/floater_texture_ctrl.xml | 118 +++++++++++-------- 4 files changed, 194 insertions(+), 70 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 795a93c3fe..9300b161f4 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -213,6 +213,7 @@ BOOL LLPanelFace::postBuild() pbr_ctrl->setImmediateFilterPermMask(PERM_NONE); pbr_ctrl->setDnDFilterPermMask(PERM_COPY | PERM_TRANSFER); pbr_ctrl->setBakeTextureEnabled(false); + pbr_ctrl->setInventoryPickType(LLTextureCtrl::PICK_MATERIAL); } mTextureCtrl = getChild("texture control"); diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp index 580fd7936e..87c05c162a 100644 --- a/indra/newview/lltexturectrl.cpp +++ b/indra/newview/lltexturectrl.cpp @@ -177,7 +177,8 @@ LLFloaterTexturePicker::LLFloaterTexturePicker( mOnFloaterCloseCallback(NULL), mSetImageAssetIDCallback(NULL), mOnUpdateImageStatsCallback(NULL), - mBakeTextureEnabled(FALSE) + mBakeTextureEnabled(FALSE), + mInventoryPickType(LLTextureCtrl::PICK_TEXTURE) { mCanApplyImmediately = can_apply_immediately; buildFromFile("floater_texture_ctrl.xml"); @@ -466,8 +467,20 @@ BOOL LLFloaterTexturePicker::postBuild() mLocalScrollCtrl = getChild("l_name_list"); mLocalScrollCtrl->setCommitCallback(onLocalScrollCommit, this); mLocalScrollCtrl->clearRows(); - LLLocalBitmapMgr::getInstance()->feedScrollList(mLocalScrollCtrl); - LLLocalGLTFMaterialMgr::getInstance()->feedScrollList(mLocalScrollCtrl); + + if (mInventoryPickType == LLTextureCtrl::PICK_TEXTURE_MATERIAL) + { + LLLocalBitmapMgr::getInstance()->feedScrollList(mLocalScrollCtrl); + LLLocalGLTFMaterialMgr::getInstance()->feedScrollList(mLocalScrollCtrl); + } + else if (mInventoryPickType == LLTextureCtrl::PICK_TEXTURE) + { + LLLocalBitmapMgr::getInstance()->feedScrollList(mLocalScrollCtrl); + } + else if (mInventoryPickType == LLTextureCtrl::PICK_MATERIAL) + { + LLLocalGLTFMaterialMgr::getInstance()->feedScrollList(mLocalScrollCtrl); + } mNoCopyTextureSelected = FALSE; @@ -901,11 +914,18 @@ void LLFloaterTexturePicker::onBtnAdd(void* userdata) { LLFloaterTexturePicker* self = (LLFloaterTexturePicker*)userdata; - // todo: there will be changes to texture picker to forbid - // selection of materials in some cases, like landmarks, once - // it gets implemented, update code to select FLOAD_* filter - // based on picker's material/texture mode. - LLFilePickerReplyThread::startPicker(boost::bind(&onPickerCallback, _1, self->getHandle()), LLFilePicker::FFLOAD_MATERIAL_TEXTURE, true); + if (self->mInventoryPickType == LLTextureCtrl::PICK_TEXTURE_MATERIAL) + { + LLFilePickerReplyThread::startPicker(boost::bind(&onPickerCallback, _1, self->getHandle()), LLFilePicker::FFLOAD_MATERIAL_TEXTURE, true); + } + else if (self->mInventoryPickType == LLTextureCtrl::PICK_TEXTURE) + { + LLFilePickerReplyThread::startPicker(boost::bind(&onPickerCallback, _1, self->getHandle()), LLFilePicker::FFLOAD_IMAGE, true); + } + else if (self->mInventoryPickType == LLTextureCtrl::PICK_MATERIAL) + { + LLFilePickerReplyThread::startPicker(boost::bind(&onPickerCallback, _1, self->getHandle()), LLFilePicker::FFLOAD_MATERIAL, true); + } } // static @@ -941,8 +961,20 @@ void LLFloaterTexturePicker::onBtnRemove(void* userdata) self->getChild("l_rem_btn")->setEnabled(false); self->getChild("l_upl_btn")->setEnabled(false); self->mLocalScrollCtrl->clearRows(); - LLLocalBitmapMgr::getInstance()->feedScrollList(self->mLocalScrollCtrl); - LLLocalGLTFMaterialMgr::getInstance()->feedScrollList(self->mLocalScrollCtrl); + + if (self->mInventoryPickType == LLTextureCtrl::PICK_TEXTURE_MATERIAL) + { + LLLocalBitmapMgr::getInstance()->feedScrollList(self->mLocalScrollCtrl); + LLLocalGLTFMaterialMgr::getInstance()->feedScrollList(self->mLocalScrollCtrl); + } + else if (self->mInventoryPickType == LLTextureCtrl::PICK_TEXTURE) + { + LLLocalBitmapMgr::getInstance()->feedScrollList(self->mLocalScrollCtrl); + } + else if (self->mInventoryPickType == LLTextureCtrl::PICK_MATERIAL) + { + LLLocalGLTFMaterialMgr::getInstance()->feedScrollList(self->mLocalScrollCtrl); + } } } @@ -1183,18 +1215,23 @@ void LLFloaterTexturePicker::onSelectTextureMaterials(LLUICtrl* ctrl, void *user U32 filter_types = 0x0; - if (index == textures_and_materials) + if (self->mInventoryPickType != LLTextureCtrl::PICK_TEXTURE_MATERIAL) + { + index = self->mInventoryPickType; + } + + if (index == LLTextureCtrl::PICK_TEXTURE_MATERIAL) { filter_types |= 0x1 << LLInventoryType::IT_TEXTURE; filter_types |= 0x1 << LLInventoryType::IT_SNAPSHOT; filter_types |= 0x1 << LLInventoryType::IT_MATERIAL; } - else if (index == textures_only) + else if (index == LLTextureCtrl::PICK_TEXTURE) { filter_types |= 0x1 << LLInventoryType::IT_TEXTURE; filter_types |= 0x1 << LLInventoryType::IT_SNAPSHOT; } - else if (index == materials_only) + else if (index == LLTextureCtrl::PICK_MATERIAL) { filter_types |= 0x1 << LLInventoryType::IT_MATERIAL; } @@ -1229,6 +1266,28 @@ void LLFloaterTexturePicker::setBakeTextureEnabled(BOOL enabled) onModeSelect(0, this); } +void LLFloaterTexturePicker::setInventoryPickType(LLTextureCtrl::EPickInventoryType type) +{ + mInventoryPickType = type; + + mLocalScrollCtrl->clearRows(); + if (mInventoryPickType == LLTextureCtrl::PICK_TEXTURE_MATERIAL) + { + LLLocalBitmapMgr::getInstance()->feedScrollList(mLocalScrollCtrl); + LLLocalGLTFMaterialMgr::getInstance()->feedScrollList(mLocalScrollCtrl); + } + else if (mInventoryPickType == LLTextureCtrl::PICK_TEXTURE) + { + LLLocalBitmapMgr::getInstance()->feedScrollList(mLocalScrollCtrl); + } + else if (mInventoryPickType == LLTextureCtrl::PICK_MATERIAL) + { + LLLocalGLTFMaterialMgr::getInstance()->feedScrollList(mLocalScrollCtrl); + } + + onSelectTextureMaterials(0, this); +} + void LLFloaterTexturePicker::onPickerCallback(const std::vector& filenames, LLHandle handle) { std::vector::const_iterator iter = filenames.begin(); @@ -1254,8 +1313,20 @@ void LLFloaterTexturePicker::onPickerCallback(const std::vector& fi { LLFloaterTexturePicker* self = (LLFloaterTexturePicker*)handle.get(); self->mLocalScrollCtrl->clearRows(); - LLLocalBitmapMgr::getInstance()->feedScrollList(self->mLocalScrollCtrl); - LLLocalGLTFMaterialMgr::getInstance()->feedScrollList(self->mLocalScrollCtrl); + + if (self->mInventoryPickType == LLTextureCtrl::PICK_TEXTURE_MATERIAL) + { + LLLocalBitmapMgr::getInstance()->feedScrollList(self->mLocalScrollCtrl); + LLLocalGLTFMaterialMgr::getInstance()->feedScrollList(self->mLocalScrollCtrl); + } + else if (self->mInventoryPickType == LLTextureCtrl::PICK_TEXTURE) + { + LLLocalBitmapMgr::getInstance()->feedScrollList(self->mLocalScrollCtrl); + } + else if (self->mInventoryPickType == LLTextureCtrl::PICK_MATERIAL) + { + LLLocalGLTFMaterialMgr::getInstance()->feedScrollList(self->mLocalScrollCtrl); + } } } @@ -1306,6 +1377,8 @@ LLTextureCtrl::LLTextureCtrl(const LLTextureCtrl::Params& p) mValid( TRUE ), mShowLoadingPlaceholder( TRUE ), mOpenTexPreview(false), + mBakeTextureEnabled(true), + mInventoryPickType(PICK_TEXTURE), mImageAssetID(p.image_id), mDefaultImageAssetID(p.default_image_id), mDefaultImageName(p.default_image_name), @@ -1495,14 +1568,10 @@ void LLTextureCtrl::showPicker(BOOL take_focus) if (texture_floaterp) { texture_floaterp->setOnFloaterCommitCallback(boost::bind(&LLTextureCtrl::onFloaterCommit, this, _1, _2)); - } - if (texture_floaterp) - { texture_floaterp->setSetImageAssetIDCallback(boost::bind(&LLTextureCtrl::setImageAssetID, this, _1)); - } - if (texture_floaterp) - { - texture_floaterp->setBakeTextureEnabled(TRUE); + + texture_floaterp->setBakeTextureEnabled(mBakeTextureEnabled); + texture_floaterp->setInventoryPickType(mInventoryPickType); } LLFloater* root_floater = gFloaterView->getParentFloater(this); @@ -1749,8 +1818,9 @@ void LLTextureCtrl::setImageAssetID( const LLUUID& asset_id ) } } -void LLTextureCtrl::setBakeTextureEnabled(BOOL enabled) +void LLTextureCtrl::setBakeTextureEnabled(bool enabled) { + mBakeTextureEnabled = enabled; LLFloaterTexturePicker* floaterp = (LLFloaterTexturePicker*)mFloaterHandle.get(); if (floaterp) { @@ -1758,6 +1828,16 @@ void LLTextureCtrl::setBakeTextureEnabled(BOOL enabled) } } +void LLTextureCtrl::setInventoryPickType(EPickInventoryType type) +{ + mInventoryPickType = type; + LLFloaterTexturePicker* floaterp = (LLFloaterTexturePicker*)mFloaterHandle.get(); + if (floaterp) + { + floaterp->setInventoryPickType(type); + } +} + BOOL LLTextureCtrl::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, void *cargo_data, EAcceptance *accept, diff --git a/indra/newview/lltexturectrl.h b/indra/newview/lltexturectrl.h index 0325e09aa7..fb409af42b 100644 --- a/indra/newview/lltexturectrl.h +++ b/indra/newview/lltexturectrl.h @@ -78,6 +78,13 @@ public: TEXTURE_CANCEL } ETexturePickOp; + typedef enum e_pick_inventory_type + { + PICK_TEXTURE_MATERIAL = 0, + PICK_TEXTURE = 1, + PICK_MATERIAL = 2, + } EPickInventoryType; + public: struct Params : public LLInitParam::Block { @@ -212,7 +219,11 @@ public: LLViewerFetchedTexture* getTexture() { return mTexturep; } - void setBakeTextureEnabled(BOOL enabled); + void setBakeTextureEnabled(bool enabled); + bool getBakeTextureEnabled() const { return mBakeTextureEnabled; } + + void setInventoryPickType(EPickInventoryType type); + EPickInventoryType getInventoryPickType() { return mInventoryPickType; }; private: BOOL allowDrop(LLInventoryItem* item); @@ -251,7 +262,8 @@ private: std::string mLoadingPlaceholderString; S32 mLabelWidth; bool mOpenTexPreview; - BOOL mBakeTextureEnabled; + bool mBakeTextureEnabled; + LLTextureCtrl::EPickInventoryType mInventoryPickType; }; ////////////////////////////////////////////////////////////////////////////////////////// @@ -347,6 +359,8 @@ public: void setLocalTextureEnabled(BOOL enabled); void setBakeTextureEnabled(BOOL enabled); + void setInventoryPickType(LLTextureCtrl::EPickInventoryType type); + static void onPickerCallback(const std::vector& filenames, LLHandle handle); protected: @@ -389,6 +403,7 @@ private: bool mCanApply; bool mCanPreview; bool mPreviewSettingChanged; + LLTextureCtrl::EPickInventoryType mInventoryPickType; texture_selected_callback mTextureSelectedCallback; diff --git a/indra/newview/skins/default/xui/en/floater_texture_ctrl.xml b/indra/newview/skins/default/xui/en/floater_texture_ctrl.xml index 2a84fece03..b6a2aaf31b 100644 --- a/indra/newview/skins/default/xui/en/floater_texture_ctrl.xml +++ b/indra/newview/skins/default/xui/en/floater_texture_ctrl.xml @@ -137,51 +137,79 @@ value="Preview Disabled" word_wrap="true" visible="false" - width="87" /> - - - - - - - + width="87" /> + + + + + + + + + + + + + +