From c0848751cc4c2e66426d6061f489e7b1d6afe1f7 Mon Sep 17 00:00:00 2001 From: Rye Mutt <rye@alchemyviewer.org> Date: Thu, 28 Dec 2023 23:04:25 -0500 Subject: [PATCH] Fix pipette tool in texture and color picker --- indra/newview/llfloatercolorpicker.cpp | 11 +++-- indra/newview/llfloatercolorpicker.h | 4 +- indra/newview/llfloatertexturepicker.cpp | 59 ++++++++++++------------ indra/newview/llfloatertexturepicker.h | 4 +- 4 files changed, 38 insertions(+), 40 deletions(-) diff --git a/indra/newview/llfloatercolorpicker.cpp b/indra/newview/llfloatercolorpicker.cpp index 607a8866e3b..c4b167a487e 100644 --- a/indra/newview/llfloatercolorpicker.cpp +++ b/indra/newview/llfloatercolorpicker.cpp @@ -435,7 +435,7 @@ void LLFloaterColorPicker::onClickPipette( ) if (pipette_active) { LLToolMgr::getInstance()->clearTransientTool(); - LLToolPipette::getInstance()->setToolSelectCallback(boost::bind(&LLFloaterColorPicker::onColorSelect, this, _2, _3)); + LLToolPipette::getInstance()->setToolSelectCallback(boost::bind(&LLFloaterColorPicker::onColorSelect, this, _1, _3)); LLToolMgr::getInstance()->setTransientTool(LLToolPipette::getInstance()); } else @@ -471,10 +471,13 @@ void LLFloaterColorPicker::onImmediateCheck( LLUICtrl* ctrl, void* data) } } -void LLFloaterColorPicker::onColorSelect(LLViewerObject* obj, const LLTextureEntry& te) +void LLFloaterColorPicker::onColorSelect(bool success, const LLTextureEntry& te) { // Pipete - selectCurRgb(te.getColor().mV[VRED], te.getColor().mV[VGREEN], te.getColor().mV[VBLUE]); + if (success) + { + selectCurRgb(te.getColor().mV[VRED], te.getColor().mV[VGREEN], te.getColor().mV[VBLUE]); + } } void LLFloaterColorPicker::onMouseCaptureLost() @@ -1152,8 +1155,6 @@ void LLFloaterColorPicker::setActive(BOOL active) void LLFloaterColorPicker::stopUsingPipette() { - if (mPipetteConnection.connected()) mPipetteConnection.disconnect(); - if (LLToolMgr::getInstance()->getCurrentTool() == LLToolPipette::getInstance()) { LLToolMgr::getInstance()->clearTransientTool(); diff --git a/indra/newview/llfloatercolorpicker.h b/indra/newview/llfloatercolorpicker.h index a8a3a8af5dc..2938952b6db 100644 --- a/indra/newview/llfloatercolorpicker.h +++ b/indra/newview/llfloatercolorpicker.h @@ -122,7 +122,7 @@ class LLFloaterColorPicker final void onClickPipette ( ); static void onTextCommit ( LLUICtrl* ctrl, void* data ); static void onImmediateCheck ( LLUICtrl* ctrl, void* data ); - void onColorSelect(class LLViewerObject* obj, const class LLTextureEntry& te); + void onColorSelect(bool success, const class LLTextureEntry& te); void menuDoToSelected(const LLSD& userdata); private: // mutators for color values, can raise event to preview changes at object @@ -197,8 +197,6 @@ class LLFloaterColorPicker final F32 mContextConeInAlpha; F32 mContextConeOutAlpha; F32 mContextConeFadeTime; - - boost::signals2::scoped_connection mPipetteConnection; }; #endif // LL_LLFLOATERCOLORPICKER_H diff --git a/indra/newview/llfloatertexturepicker.cpp b/indra/newview/llfloatertexturepicker.cpp index a32477d1df3..5efe06dd291 100644 --- a/indra/newview/llfloatertexturepicker.cpp +++ b/indra/newview/llfloatertexturepicker.cpp @@ -935,7 +935,7 @@ void LLFloaterTexturePicker::onBtnPipette() if (pipette_active) { LLToolMgr::getInstance()->clearTransientTool(); - LLToolPipette::getInstance()->setToolSelectCallback(boost::bind(&LLFloaterTexturePicker::onTextureSelect, this, _2, _3)); + LLToolPipette::getInstance()->setToolSelectCallback(boost::bind(&LLFloaterTexturePicker::onTextureSelect, this, _1, _3)); LLToolMgr::getInstance()->setTransientTool(LLToolPipette::getInstance()); } else @@ -1504,39 +1504,40 @@ void LLFloaterTexturePicker::onPickerCallback(const std::vector<std::string>& fi } } -void LLFloaterTexturePicker::onTextureSelect( LLViewerObject* obj, const LLTextureEntry& te ) +void LLFloaterTexturePicker::onTextureSelect(bool success, const LLTextureEntry& te ) { - if (mPipetteConnection.connected()) mPipetteConnection.disconnect(); - - LLUUID inventory_item_id = findItemID(te.getID(), TRUE); - if (inventory_item_id.notNull()) + if (success) { - LLToolPipette::getInstance()->setResult(TRUE, ""); - if (mInventoryPickType == LLTextureCtrl::PICK_MATERIAL) - { - // tes have no data about material ids - // Plus gltf materials are layered with overrides, - // which mean that end result might have no id. - LL_WARNS() << "tes have no data about material ids" << LL_ENDL; - } - else - { - setImageID(te.getID()); - } + LLUUID inventory_item_id = findItemID(te.getID(), TRUE); + if (inventory_item_id.notNull()) + { + LLToolPipette::getInstance()->setResult(TRUE, ""); + if (mInventoryPickType == LLTextureCtrl::PICK_MATERIAL) + { + // tes have no data about material ids + // Plus gltf materials are layered with overrides, + // which mean that end result might have no id. + LL_WARNS() << "tes have no data about material ids" << LL_ENDL; + } + else + { + setImageID(te.getID()); + } - mNoCopyTextureSelected = FALSE; - LLInventoryItem* itemp = gInventory.getItem(inventory_item_id); + mNoCopyTextureSelected = FALSE; + LLInventoryItem* itemp = gInventory.getItem(inventory_item_id); + + if (itemp && !itemp->getPermissions().allowCopyBy(gAgent.getID())) + { + // no copy texture + mNoCopyTextureSelected = TRUE; + } - if (itemp && !itemp->getPermissions().allowCopyBy(gAgent.getID())) + commitIfImmediateSet(); + } + else { - // no copy texture - mNoCopyTextureSelected = TRUE; + LLToolPipette::getInstance()->setResult(FALSE, LLTrans::getString("InventoryNoTexture")); } - - commitIfImmediateSet(); - } - else - { - LLToolPipette::getInstance()->setResult(FALSE, LLTrans::getString("InventoryNoTexture")); } } diff --git a/indra/newview/llfloatertexturepicker.h b/indra/newview/llfloatertexturepicker.h index 7c808253a2c..229d6b3c08f 100644 --- a/indra/newview/llfloatertexturepicker.h +++ b/indra/newview/llfloatertexturepicker.h @@ -114,7 +114,7 @@ class LLFloaterTexturePicker final : public LLFloater static void onApplyUUID(void* userdata); void onSelectionChange(const std::deque<LLFolderViewItem*> &items, BOOL user_action); static void onApplyImmediateCheck(LLUICtrl* ctrl, void* userdata); - void onTextureSelect(LLViewerObject* obj, const LLTextureEntry& te); + void onTextureSelect(bool success, const LLTextureEntry& te); static void onModeSelect(LLUICtrl* ctrl, void *userdata); static void onBtnAdd(void* userdata); @@ -196,8 +196,6 @@ class LLFloaterTexturePicker final : public LLFloater set_image_asset_id_callback mSetImageAssetIDCallback; set_on_update_image_stats_callback mOnUpdateImageStatsCallback; - boost::signals2::scoped_connection mPipetteConnection; - BOOL mBakeTextureEnabled; static S32 sLastPickerMode; -- GitLab