From a3a7733728fb463d911fdb7218d6db27f629d877 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 18 Jun 2024 13:34:31 +0300 Subject: viewer-private#242 Last used picker mode can force picker into a disabled mode --- indra/newview/lltexturectrl.cpp | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'indra/newview/lltexturectrl.cpp') diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp index 4744edd5a3..2773f538cc 100644 --- a/indra/newview/lltexturectrl.cpp +++ b/indra/newview/lltexturectrl.cpp @@ -185,6 +185,7 @@ LLFloaterTexturePicker::LLFloaterTexturePicker( mSetImageAssetIDCallback(NULL), mOnUpdateImageStatsCallback(NULL), mBakeTextureEnabled(FALSE), + mLocalTextureEnabled(false), mInventoryPickType(pick_type) { mCanApplyImmediately = can_apply_immediately; @@ -524,6 +525,8 @@ BOOL LLFloaterTexturePicker::handleKeyHere(KEY key, MASK mask) void LLFloaterTexturePicker::onOpen(const LLSD& key) { if (sLastPickerMode != 0 + && (mLocalTextureEnabled || sLastPickerMode != 1) + && (mBakeTextureEnabled || sLastPickerMode != 2) && mModeSelector->selectByValue(sLastPickerMode)) { changeMode(); @@ -1490,7 +1493,13 @@ void LLFloaterTexturePicker::refreshInventoryFilter() void LLFloaterTexturePicker::setLocalTextureEnabled(BOOL enabled) { + mLocalTextureEnabled = enabled; mModeSelector->setEnabledByValue(1, enabled); + if (!enabled && (mModeSelector->getValue().asInteger() == 2)) + { + mModeSelector->selectByValue(0); + onModeSelect(0, this); + } } void LLFloaterTexturePicker::setBakeTextureEnabled(BOOL enabled) @@ -1877,11 +1886,9 @@ void LLTextureCtrl::showPicker(BOOL take_focus) if (texture_floaterp) { texture_floaterp->setOnFloaterCommitCallback(boost::bind(&LLTextureCtrl::onFloaterCommit, this, _1, _2, _3, _4, _5)); - } - if (texture_floaterp) - { texture_floaterp->setSetImageAssetIDCallback(boost::bind(&LLTextureCtrl::setImageAssetID, this, _1)); + texture_floaterp->setLocalTextureEnabled(mAllowLocalTexture); texture_floaterp->setBakeTextureEnabled(mBakeTextureEnabled); } @@ -1891,12 +1898,6 @@ void LLTextureCtrl::showPicker(BOOL take_focus) floaterp->openFloater(); } - LLFloaterTexturePicker* picker_floater = dynamic_cast(floaterp); - if (picker_floater) - { - picker_floater->setLocalTextureEnabled(mAllowLocalTexture); - } - if (take_focus) { floaterp->setFocus(TRUE); @@ -2076,6 +2077,16 @@ void LLTextureCtrl::setOnTextureSelectedCallback(texture_selected_callback cb) } } +void LLTextureCtrl::setAllowLocalTexture(BOOL b) +{ + mAllowLocalTexture = b; + LLFloaterTexturePicker* picker_floater = dynamic_cast(mFloaterHandle.get()); + if (picker_floater) + { + picker_floater->setLocalTextureEnabled(mAllowLocalTexture); + } +} + void LLTextureCtrl::setImageAssetName(const std::string& name) { LLPointer imagep = LLUI::getUIImage(name); -- cgit v1.2.3 From 3bddaeab845c970e9ac5bdb241312673250f28ff Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 29 Apr 2025 22:16:11 +0300 Subject: p#428 Fix texture picker's tentative behavior --- indra/newview/lltexturectrl.cpp | 47 +++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 20 deletions(-) (limited to 'indra/newview/lltexturectrl.cpp') diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp index ff01e537ee..d3c553fe50 100644 --- a/indra/newview/lltexturectrl.cpp +++ b/indra/newview/lltexturectrl.cpp @@ -163,7 +163,6 @@ LLFloaterTexturePicker::LLFloaterTexturePicker( mFallbackImage(fallback_image), mDefaultImageAssetID(default_image_asset_id), mBlankImageAssetID(blank_image_asset_id), - mTentative(tentative), mAllowNoTexture(allow_no_texture), mLabel(label), mTentativeLabel(NULL), @@ -188,6 +187,7 @@ LLFloaterTexturePicker::LLFloaterTexturePicker( mLocalTextureEnabled(false), mInventoryPickType(pick_type) { + setTentative(tentative); mCanApplyImmediately = can_apply_immediately; buildFromFile("floater_texture_ctrl.xml"); setCanMinimize(false); @@ -199,7 +199,7 @@ LLFloaterTexturePicker::~LLFloaterTexturePicker() void LLFloaterTexturePicker::setImageID(const LLUUID& image_id, bool set_selection /*=true*/) { - if( ((mImageAssetID != image_id) || mTentative) && mActive) + if( ((mImageAssetID != image_id) || getTentative()) && mActive) { mNoCopyTextureSelected = false; mViewModel->setDirty(); // *TODO: shouldn't we be using setValue() here? @@ -277,6 +277,7 @@ void LLFloaterTexturePicker::setImageIDFromItem(const LLInventoryItem* itemp, bo asset_id = BLANK_MATERIAL_ASSET_ID; } setImageID(asset_id, set_selection); + setTentative(false); } void LLFloaterTexturePicker::setActive( bool active ) @@ -657,7 +658,7 @@ void LLFloaterTexturePicker::draw() bool valid_dims = updateImageStats(); // if we're inactive, gray out "apply immediate" checkbox - mSelectBtn->setEnabled(mActive && mCanApply && valid_dims); + mSelectBtn->setEnabled(mActive && mCanApply && valid_dims && !getTentative()); mPipetteBtn->setEnabled(mActive); mPipetteBtn->setValue(LLToolMgr::getInstance()->getCurrentTool() == LLToolPipette::getInstance()); @@ -722,9 +723,9 @@ void LLFloaterTexturePicker::draw() mTentativeLabel->setVisible( false ); } - mDefaultBtn->setEnabled(mImageAssetID != mDefaultImageAssetID || mTentative); - mBlankBtn->setEnabled((mImageAssetID != mBlankImageAssetID && mBlankImageAssetID.notNull()) || mTentative); - mNoneBtn->setEnabled(mAllowNoTexture && (!mImageAssetID.isNull() || mTentative)); + mDefaultBtn->setEnabled(mImageAssetID != mDefaultImageAssetID || getTentative()); + mBlankBtn->setEnabled((mImageAssetID != mBlankImageAssetID && mBlankImageAssetID.notNull()) || getTentative()); + mNoneBtn->setEnabled(mAllowNoTexture && (!mImageAssetID.isNull() || getTentative())); LLFloater::draw(); @@ -777,7 +778,7 @@ void LLFloaterTexturePicker::draw() } // Draw Tentative Label over the image - if( mTentative && !mViewModel->isDirty() ) + if( getTentative() && !mViewModel->isDirty() ) { mTentativeLabel->setVisible( true ); drawChild(mTentativeLabel); @@ -980,6 +981,7 @@ void LLFloaterTexturePicker::onBtnSetToDefault(void* userdata) if (self->mOwner) { self->setImageID( self->getDefaultImageAssetID() ); + self->setTentative(false); } self->commitIfImmediateSet(); } @@ -990,6 +992,7 @@ void LLFloaterTexturePicker::onBtnBlank(void* userdata) LLFloaterTexturePicker* self = (LLFloaterTexturePicker*) userdata; self->setCanApply(true, true); self->setImageID( self->getBlankImageAssetID() ); + self->setTentative(false); self->commitIfImmediateSet(); } @@ -1000,21 +1003,10 @@ void LLFloaterTexturePicker::onBtnNone(void* userdata) LLFloaterTexturePicker* self = (LLFloaterTexturePicker*) userdata; self->setCanApply(true, true); self->setImageID( LLUUID::null ); + self->setTentative(false); self->commitIfImmediateSet(); } -/* -// static -void LLFloaterTexturePicker::onBtnRevert(void* userdata) -{ - LLFloaterTexturePicker* self = (LLFloaterTexturePicker*) userdata; - self->setImageID( self->mOriginalImageAssetID ); - // TODO: Change this to tell the owner to cancel. It needs to be - // smart enough to restore multi-texture selections. - self->mOwner->onFloaterCommit(); - self->mViewModel->resetDirty(); -}*/ - // static void LLFloaterTexturePicker::onBtnCancel(void* userdata) { @@ -1221,6 +1213,7 @@ void LLFloaterTexturePicker::onLocalScrollCommit(LLUICtrl* ctrl, void* userdata) if (self->mSetImageAssetIDCallback) { self->mSetImageAssetIDCallback(inworld_id); + self->setTentative(false); } if (self->childGetValue("apply_immediate_check").asBoolean()) @@ -1299,6 +1292,7 @@ void LLFloaterTexturePicker::onBakeTextureSelect(LLUICtrl* ctrl, void *user_data } self->setImageID(imageID); + self->setTentative(false); self->mViewModel->setDirty(); // *TODO: shouldn't we be using setValue() here? if (!self->mPreviewSettingChanged) @@ -1319,7 +1313,7 @@ void LLFloaterTexturePicker::onBakeTextureSelect(LLUICtrl* ctrl, void *user_data void LLFloaterTexturePicker::setCanApply(bool can_preview, bool can_apply, bool inworld_image) { - mSelectBtn->setEnabled(can_apply); + mSelectBtn->setEnabled(can_apply && !getTentative()); // will be updated on draw getChildRef("preview_disabled").setVisible(!can_preview && inworld_image); getChildRef("apply_immediate_check").setVisible(can_preview); @@ -1626,6 +1620,7 @@ void LLFloaterTexturePicker::onTextureSelect( const LLTextureEntry& te ) else { setImageID(te.getID()); + setTentative(false); } mNoCopyTextureSelected = false; @@ -1839,6 +1834,17 @@ void LLTextureCtrl::clear() setImageAssetID(LLUUID::null); } +void LLTextureCtrl::setTentative(bool tentative) +{ + LLFloater* floaterp = mFloaterHandle.get(); + + if (floaterp) + { + floaterp->setTentative(tentative); + } + LLUICtrl::setTentative(tentative); +} + void LLTextureCtrl::setLabel(const std::string& label) { mLabel = label; @@ -2112,6 +2118,7 @@ void LLTextureCtrl::setImageAssetID( const LLUUID& asset_id ) if( floaterp && getEnabled() ) { floaterp->setImageID( asset_id ); + floaterp->setTentative(getTentative()); floaterp->resetDirty(); } } -- cgit v1.2.3