summaryrefslogtreecommitdiff
path: root/indra/newview/lltexturectrl.cpp
diff options
context:
space:
mode:
authorAndrey Kleshchev <andreykproductengine@lindenlab.com>2023-10-03 19:00:33 +0300
committerAndrey Kleshchev <andreykproductengine@lindenlab.com>2023-10-03 19:00:33 +0300
commit7d50a5143411d5b975173e62de65e530c5dd0f00 (patch)
treec1a4111c8db0d39ef9cc66ad8be29b5d4dc4fd10 /indra/newview/lltexturectrl.cpp
parent41433fdb08b50e4721b2285a045cc8f14e82433c (diff)
parent2465470817957c8378e81ec1a7e32551fbac7b26 (diff)
Merge branch 'main' (DRTVWR-567) into DRTVWR-559
# Conflicts: # indra/newview/CMakeLists.txt # indra/newview/VIEWER_VERSION.txt # indra/newview/llagent.cpp # indra/newview/llfloaternewfeaturenotification.cpp # indra/newview/llinventorybridge.cpp # indra/newview/llinventorymodel.cpp # indra/newview/lloutfitgallery.cpp # indra/newview/llpanelmaininventory.cpp # indra/newview/llpanelmaininventory.h # indra/newview/llsidepaneltaskinfo.cpp # indra/newview/llsidepaneltaskinfo.h # indra/newview/lltexturectrl.cpp # indra/newview/lltexturectrl.h # indra/newview/llviewerinventory.cpp # indra/newview/llviewerobject.cpp # indra/newview/llviewertexturelist.cpp # indra/newview/llviewertexturelist.h # indra/newview/skins/default/xui/en/floater_new_feature_notification.xml # indra/newview/skins/default/xui/en/menu_inventory.xml
Diffstat (limited to 'indra/newview/lltexturectrl.cpp')
-rw-r--r--indra/newview/lltexturectrl.cpp257
1 files changed, 202 insertions, 55 deletions
diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp
index bbacec843b..796753955b 100644
--- a/indra/newview/lltexturectrl.cpp
+++ b/indra/newview/lltexturectrl.cpp
@@ -170,6 +170,9 @@ LLFloaterTexturePicker::LLFloaterTexturePicker(
mSelectedItemPinned( FALSE ),
mCanApply(true),
mCanPreview(true),
+ mLimitsSet(false),
+ mMaxDim(S32_MAX),
+ mMinDim(0),
mPreviewSettingChanged(false),
mOnFloaterCommitCallback(NULL),
mOnFloaterCloseCallback(NULL),
@@ -272,8 +275,9 @@ void LLFloaterTexturePicker::stopUsingPipette()
}
}
-void LLFloaterTexturePicker::updateImageStats()
+bool LLFloaterTexturePicker::updateImageStats()
{
+ bool result = true;
if (mGLTFMaterial.notNull())
{
S32 width = 0;
@@ -329,14 +333,31 @@ void LLFloaterTexturePicker::updateImageStats()
else if (mTexturep.notNull())
{
//RN: have we received header data for this image?
- if (mTexturep->getFullWidth() > 0 && mTexturep->getFullHeight() > 0)
+ S32 width = mTexturep->getFullWidth();
+ S32 height = mTexturep->getFullHeight();
+ if (width > 0 && height > 0)
{
- std::string formatted_dims = llformat("%d x %d", mTexturep->getFullWidth(),mTexturep->getFullHeight());
- mResolutionLabel->setTextArg("[DIMENSIONS]", formatted_dims);
- if (mOnUpdateImageStatsCallback)
- {
- mOnUpdateImageStatsCallback(mTexturep);
- }
+ if ((mLimitsSet && (width != height))
+ || width < mMinDim
+ || width > mMaxDim
+ || height < mMinDim
+ || height > mMaxDim
+ )
+ {
+ std::string formatted_dims = llformat("%dx%d", width, height);
+ mResolutionWarning->setTextArg("[TEXDIM]", formatted_dims);
+ result = false;
+ }
+ else
+ {
+ std::string formatted_dims = llformat("%d x %d", width, height);
+ mResolutionLabel->setTextArg("[DIMENSIONS]", formatted_dims);
+ }
+
+ if (mOnUpdateImageStatsCallback)
+ {
+ mOnUpdateImageStatsCallback(mTexturep);
+ }
}
else
{
@@ -347,6 +368,21 @@ void LLFloaterTexturePicker::updateImageStats()
{
mResolutionLabel->setTextArg("[DIMENSIONS]", std::string(""));
}
+ mResolutionLabel->setVisible(result);
+ mResolutionWarning->setVisible(!result);
+
+ // Hide buttons and pipete to make space for mResolutionWarning
+ // Hiding buttons is suboptimal, but at the moment limited to inventory thumbnails
+ // may be this should be an info/warning icon with a tooltip?
+ S32 index = mModeSelector->getValue().asInteger();
+ if (index == 0)
+ {
+ mDefaultBtn->setVisible(result);
+ mNoneBtn->setVisible(result);
+ mBlankBtn->setVisible(result);
+ mPipetteBtn->setVisible(result);
+ }
+ return result;
}
// virtual
@@ -479,11 +515,22 @@ BOOL LLFloaterTexturePicker::postBuild()
mTentativeLabel = getChild<LLTextBox>("Multiple");
mResolutionLabel = getChild<LLTextBox>("size_lbl");
+ mResolutionWarning = getChild<LLTextBox>("over_limit_lbl");
+
+ mDefaultBtn = getChild<LLButton>("Default");
+ mNoneBtn = getChild<LLButton>("None");
+ mBlankBtn = getChild<LLButton>("Blank");
+ mPipetteBtn = getChild<LLButton>("Pipette");
+ mSelectBtn = getChild<LLButton>("Select");
+ mCancelBtn = getChild<LLButton>("Cancel");
- childSetAction("Default",LLFloaterTexturePicker::onBtnSetToDefault,this);
- childSetAction("None", LLFloaterTexturePicker::onBtnNone,this);
- childSetAction("Blank", LLFloaterTexturePicker::onBtnBlank,this);
+ mDefaultBtn->setClickedCallback(boost::bind(LLFloaterTexturePicker::onBtnSetToDefault,this));
+ mNoneBtn->setClickedCallback(boost::bind(LLFloaterTexturePicker::onBtnNone, this));
+ mBlankBtn->setClickedCallback(boost::bind(LLFloaterTexturePicker::onBtnBlank, this));
+ mPipetteBtn->setCommitCallback(boost::bind(&LLFloaterTexturePicker::onBtnPipette, this));
+ mSelectBtn->setClickedCallback(boost::bind(LLFloaterTexturePicker::onBtnSelect, this));
+ mCancelBtn->setClickedCallback(boost::bind(LLFloaterTexturePicker::onBtnCancel, this));
mFilterEdit = getChild<LLFilterEditor>("inventory search editor");
mFilterEdit->setCommitCallback(boost::bind(&LLFloaterTexturePicker::onFilterEdit, this, _2));
@@ -546,6 +593,8 @@ BOOL LLFloaterTexturePicker::postBuild()
childSetAction("Cancel", LLFloaterTexturePicker::onBtnCancel,this);
childSetAction("Select", LLFloaterTexturePicker::onBtnSelect,this);
+ // update permission filter once UI is fully initialized
+ updateFilterPermMask();
mSavedFolderState.setApply(FALSE);
LLToolPipette::getInstance()->setToolSelectCallback(boost::bind(&LLFloaterTexturePicker::onTextureSelect, this, _1));
@@ -564,12 +613,13 @@ void LLFloaterTexturePicker::draw()
// This is going to spam mOnUpdateImageStatsCallback,
// either move elsewhere or fix to cause update once per image
- updateImageStats();
+ bool valid_dims = updateImageStats();
// if we're inactive, gray out "apply immediate" checkbox
- getChildView("Select")->setEnabled(mActive && mCanApply);
- getChildView("Pipette")->setEnabled(mActive);
- getChild<LLUICtrl>("Pipette")->setValue(LLToolMgr::getInstance()->getCurrentTool() == LLToolPipette::getInstance());
+ getChildView("show_folders_check")->setEnabled(mActive && mCanApplyImmediately && !mNoCopyTextureSelected);
+ mSelectBtn->setEnabled(mActive && mCanApply && valid_dims);
+ mPipetteBtn->setEnabled(mActive);
+ mPipetteBtn->setValue(LLToolMgr::getInstance()->getCurrentTool() == LLToolPipette::getInstance());
//BOOL allow_copy = FALSE;
if( mOwner )
@@ -614,9 +664,9 @@ void LLFloaterTexturePicker::draw()
mTentativeLabel->setVisible( FALSE );
}
- getChildView("Default")->setEnabled(mImageAssetID != mDefaultImageAssetID || mTentative);
- getChildView("Blank")->setEnabled((mImageAssetID != mBlankImageAssetID && mBlankImageAssetID.notNull()) || mTentative);
- getChildView("None")->setEnabled(mAllowNoTexture && (!mImageAssetID.isNull() || mTentative));
+ mDefaultBtn->setEnabled(mImageAssetID != mDefaultImageAssetID || mTentative);
+ mBlankBtn->setEnabled((mImageAssetID != mBlankImageAssetID && mBlankImageAssetID.notNull()) || mTentative);
+ mNoneBtn->setEnabled(mAllowNoTexture && (!mImageAssetID.isNull() || mTentative));
LLFloater::draw();
@@ -741,17 +791,76 @@ const LLUUID& LLFloaterTexturePicker::findItemID(const LLUUID& asset_id, BOOL co
void LLFloaterTexturePicker::commitIfImmediateSet()
{
- if (!mNoCopyTextureSelected && mOnFloaterCommitCallback && mCanApply)
+ if (!mNoCopyTextureSelected && mCanApply)
{
- mOnFloaterCommitCallback(LLTextureCtrl::TEXTURE_CHANGE, LLUUID::null);
+ commitCallback(LLTextureCtrl::TEXTURE_CHANGE);
}
}
+void LLFloaterTexturePicker::commitCallback(LLTextureCtrl::ETexturePickOp op)
+{
+ if (!mOnFloaterCommitCallback)
+ {
+ return;
+ }
+ LLUUID asset_id = mImageAssetID;
+ LLUUID inventory_id;
+ LLPickerSource mode = (LLPickerSource)mModeSelector->getValue().asInteger();
+
+ switch (mode)
+ {
+ case PICKER_INVENTORY:
+ {
+ LLFolderView* root_folder = mInventoryPanel->getRootFolder();
+ if (root_folder && root_folder->getCurSelectedItem())
+ {
+ LLFolderViewItem* last_selected = root_folder->getCurSelectedItem();
+ LLFolderViewModelItemInventory* inv_view = static_cast<LLFolderViewModelItemInventory*>(last_selected->getViewModelItem());
+
+ LLInventoryItem* itemp = gInventory.getItem(inv_view->getUUID());
+ if (itemp && itemp->getAssetUUID() == mImageAssetID)
+ {
+ inventory_id = inv_view->getUUID();
+ }
+ else
+ {
+ mode = PICKER_UNKNOWN; // source of id unknown
+ }
+ }
+ else
+ {
+ mode = PICKER_UNKNOWN; // source of id unknown
+ }
+ break;
+ }
+ case PICKER_LOCAL:
+ {
+ if (!mLocalScrollCtrl->getAllSelected().empty())
+ {
+ LLUUID temp_id = mLocalScrollCtrl->getFirstSelected()->getColumn(LOCAL_TRACKING_ID_COLUMN)->getValue().asUUID();
+ asset_id = LLLocalBitmapMgr::getInstance()->getWorldID(temp_id);
+ }
+ else
+ {
+ asset_id = mImageAssetID;
+ mode = PICKER_UNKNOWN; // source of id unknown
+ }
+ break;
+ }
+ case PICKER_BAKE:
+ break;
+ default:
+ mode = PICKER_UNKNOWN; // source of id unknown
+ break;
+ }
+
+ mOnFloaterCommitCallback(op, mode, asset_id, inventory_id);
+}
void LLFloaterTexturePicker::commitCancel()
{
if (!mNoCopyTextureSelected && mOnFloaterCommitCallback && mCanApply)
{
- mOnFloaterCommitCallback(LLTextureCtrl::TEXTURE_CANCEL, LLUUID::null);
+ mOnFloaterCommitCallback(LLTextureCtrl::TEXTURE_CANCEL, PICKER_UNKNOWN, mOriginalImageAssetID, LLUUID::null);
}
}
@@ -805,7 +914,7 @@ void LLFloaterTexturePicker::onBtnCancel(void* userdata)
self->setImageID( self->mOriginalImageAssetID );
if (self->mOnFloaterCommitCallback)
{
- self->mOnFloaterCommitCallback(LLTextureCtrl::TEXTURE_CANCEL, LLUUID::null);
+ self->mOnFloaterCommitCallback(LLTextureCtrl::TEXTURE_CANCEL, PICKER_UNKNOWN, self->mOriginalImageAssetID, LLUUID::null);
}
self->mViewModel->resetDirty();
self->closeFloater();
@@ -837,7 +946,7 @@ void LLFloaterTexturePicker::onBtnSelect(void* userdata)
if (self->mOnFloaterCommitCallback)
{
- self->mOnFloaterCommitCallback(LLTextureCtrl::TEXTURE_SELECT, local_id);
+ self->commitCallback(LLTextureCtrl::TEXTURE_SELECT, local_id);
}
self->closeFloater();
}
@@ -900,24 +1009,28 @@ void LLFloaterTexturePicker::onModeSelect(LLUICtrl* ctrl, void *userdata)
LLFloaterTexturePicker* self = (LLFloaterTexturePicker*) userdata;
int index = self->mModeSelector->getValue().asInteger();
- self->getChild<LLButton>("Default")->setVisible(index == 0 ? TRUE : FALSE);
- self->getChild<LLButton>("Blank")->setVisible(index == 0 ? TRUE : FALSE);
- self->getChild<LLButton>("None")->setVisible(index == 0 ? TRUE : FALSE);
- self->getChild<LLFilterEditor>("inventory search editor")->setVisible(index == 0 ? TRUE : FALSE);
- self->getChild<LLInventoryPanel>("inventory panel")->setVisible(index == 0 ? TRUE : FALSE);
+ self->mDefaultBtn->setVisible(index == PICKER_INVENTORY ? TRUE : FALSE);
+ self->mBlankBtn->setVisible(index == PICKER_INVENTORY ? TRUE : FALSE);
+ self->mNoneBtn->setVisible(index == PICKER_INVENTORY ? TRUE : FALSE);
+ self->getChild<LLFilterEditor>("inventory search editor")->setVisible(index == PICKER_INVENTORY ? TRUE : FALSE);
+ self->getChild<LLInventoryPanel>("inventory panel")->setVisible(index == PICKER_INVENTORY ? TRUE : FALSE);
- self->getChild<LLButton>("l_add_btn")->setVisible(index == 1 ? TRUE : FALSE);
- self->getChild<LLButton>("l_rem_btn")->setVisible(index == 1 ? TRUE : FALSE);
- self->getChild<LLButton>("l_upl_btn")->setVisible(index == 1 ? TRUE : FALSE);
- self->getChild<LLScrollListCtrl>("l_name_list")->setVisible(index == 1 ? TRUE : FALSE);
+ /*self->getChild<LLCheckBox>("show_folders_check")->setVisible(mode);
+ no idea under which conditions the above is even shown, needs testing. */
- self->getChild<LLComboBox>("l_bake_use_texture_combo_box")->setVisible(index == 2 ? TRUE : FALSE);
+ self->getChild<LLButton>("l_add_btn")->setVisible(index == PICKER_LOCAL ? TRUE : FALSE);
+ self->getChild<LLButton>("l_rem_btn")->setVisible(index == PICKER_LOCAL ? TRUE : FALSE);
+ self->getChild<LLButton>("l_upl_btn")->setVisible(index == PICKER_LOCAL ? TRUE : FALSE);
+ self->getChild<LLScrollListCtrl>("l_name_list")->setVisible(index == PICKER_LOCAL ? TRUE : FALSE);
- bool pipette_visible = (index == 0)
+ self->getChild<LLComboBox>("l_bake_use_texture_combo_box")->setVisible(index == PICKER_BAKE ? TRUE : FALSE);
+ self->getChild<LLCheckBoxCtrl>("hide_base_mesh_region")->setVisible(FALSE);// index == 2 ? TRUE : FALSE);
+
+ bool pipette_visible = (index == PICKER_INVENTORY)
&& (self->mInventoryPickType != LLTextureCtrl::PICK_MATERIAL);
- self->getChild<LLButton>("Pipette")->setVisible(pipette_visible);
+ self->mPipetteBtn->setVisible(pipette_visible);
- if (index == 2)
+ if (index == PICKER_BAKE)
{
self->stopUsingPipette();
@@ -1103,7 +1216,7 @@ void LLFloaterTexturePicker::onLocalScrollCommit(LLUICtrl* ctrl, void* userdata)
{
if (self->mOnFloaterCommitCallback)
{
- self->mOnFloaterCommitCallback(LLTextureCtrl::TEXTURE_CHANGE, inworld_id);
+ self->mOnFloaterCommitCallback(LLTextureCtrl::TEXTURE_CHANGE, PICKER_LOCAL, inworld_id, LLUUID::null);
}
}
}
@@ -1193,10 +1306,22 @@ void LLFloaterTexturePicker::onBakeTextureSelect(LLUICtrl* ctrl, void *user_data
}
}
+//static
+void LLFloaterTexturePicker::onHideBaseMeshRegionCheck(LLUICtrl* ctrl, void *user_data)
+{
+ //LLFloaterTexturePicker* picker = (LLFloaterTexturePicker*)user_data;
+ //LLCheckBoxCtrl* check_box = (LLCheckBoxCtrl*)ctrl;
+}
+
+void LLFloaterTexturePicker::updateFilterPermMask()
+{
+ //mInventoryPanel->setFilterPermMask( getFilterPermMask() ); Commented out due to no-copy texture loss.
+}
+
void LLFloaterTexturePicker::setCanApply(bool can_preview, bool can_apply)
{
- getChildRef<LLUICtrl>("Select").setEnabled(can_apply);
- getChildRef<LLUICtrl>("preview_disabled").setVisible(!can_preview);
+ mSelectBtn->setEnabled(can_apply);
+ getChildRef<LLUICtrl>("preview_disabled").setVisible(!can_preview && inworld_image);
getChildRef<LLUICtrl>("apply_immediate_check").setVisible(can_preview);
mCanApply = can_apply;
@@ -1204,6 +1329,15 @@ void LLFloaterTexturePicker::setCanApply(bool can_preview, bool can_apply)
mPreviewSettingChanged = true;
}
+void LLFloaterTexturePicker::setMinDimentionsLimits(S32 min_dim)
+{
+ mMinDim = min_dim;
+ mLimitsSet = true;
+
+ std::string formatted_dims = llformat("%dx%d", mMinDim, mMinDim);
+ mResolutionWarning->setTextArg("[MINTEXDIM]", formatted_dims);
+}
+
void LLFloaterTexturePicker::onFilterEdit(const std::string& search_string )
{
std::string upper_case_search_string = search_string;
@@ -1643,7 +1777,10 @@ void LLTextureCtrl::showPicker(BOOL take_focus)
}
if (texture_floaterp)
{
- texture_floaterp->setOnFloaterCommitCallback(boost::bind(&LLTextureCtrl::onFloaterCommit, this, _1, _2));
+ texture_floaterp->setOnFloaterCommitCallback(boost::bind(&LLTextureCtrl::onFloaterCommit, this, _1, _2, _3, _4));
+ }
+ if (texture_floaterp)
+ {
texture_floaterp->setSetImageAssetIDCallback(boost::bind(&LLTextureCtrl::setImageAssetID, this, _1));
texture_floaterp->setBakeTextureEnabled(mBakeTextureEnabled);
@@ -1721,7 +1858,10 @@ BOOL LLTextureCtrl::handleMouseDown(S32 x, S32 y, MASK mask)
LLInventoryModelBackgroundFetch::instance().start(gInventory.findCategoryUUIDForType(LLFolderType::FT_TEXTURE));
}
//...then start full inventory fetch.
- LLInventoryModelBackgroundFetch::instance().start();
+ if (!LLInventoryModelBackgroundFetch::instance().inventoryFetchStarted())
+ {
+ LLInventoryModelBackgroundFetch::instance().start();
+ }
handled = TRUE;
}
else
@@ -1761,7 +1901,7 @@ void LLTextureCtrl::onFloaterClose()
mFloaterHandle.markDead();
}
-void LLTextureCtrl::onFloaterCommit(ETexturePickOp op, LLUUID id)
+void LLTextureCtrl::onFloaterCommit(ETexturePickOp op, LLPickerSource source, const LLUUID& asset_id, const LLUUID& inv_id)
{
LLFloaterTexturePicker* floaterp = (LLFloaterTexturePicker*)mFloaterHandle.get();
@@ -1775,22 +1915,29 @@ void LLTextureCtrl::onFloaterCommit(ETexturePickOp op, LLUUID id)
else if (mCommitOnSelection || op == TEXTURE_SELECT)
mViewModel->setDirty(); // *TODO: shouldn't we be using setValue() here?
- if(floaterp->isDirty() || id.notNull()) // mModelView->setDirty does not work.
+ if(floaterp->isDirty() || asset_id.notNull()) // mModelView->setDirty does not work.
{
setTentative( FALSE );
- if (id.notNull())
- {
- mImageItemID = id;
- mImageAssetID = id;
- }
- else
- {
- mImageItemID = floaterp->findItemID(floaterp->getAssetID(), FALSE);
- LL_DEBUGS() << "mImageItemID: " << mImageItemID << LL_ENDL;
- mImageAssetID = floaterp->getAssetID();
- LL_DEBUGS() << "mImageAssetID: " << mImageAssetID << LL_ENDL;
- }
+ switch(source)
+ {
+ case PICKER_INVENTORY:
+ mImageItemID = inv_id;
+ mImageAssetID = asset_id;
+ break;
+ case PICKER_BAKE:
+ case PICKER_LOCAL:
+ mImageItemID = LLUUID::null;
+ mImageAssetID = asset_id;
+ break;
+ case PICKER_UNKNOWN:
+ default:
+ mImageItemID = floaterp->findItemID(asset_id, FALSE);
+ mImageAssetID = asset_id;
+ break;
+ }
+
+ LL_DEBUGS() << "mImageAssetID: " << mImageAssetID << ", mImageItemID: " << mImageItemID << LL_ENDL;
if (op == TEXTURE_SELECT && mOnSelectCallback)
{