summaryrefslogtreecommitdiff
path: root/indra/newview/lltexturectrl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/lltexturectrl.cpp')
-rw-r--r--indra/newview/lltexturectrl.cpp117
1 files changed, 86 insertions, 31 deletions
diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp
index 0ce82a1297..21bb855704 100644
--- a/indra/newview/lltexturectrl.cpp
+++ b/indra/newview/lltexturectrl.cpp
@@ -176,6 +176,8 @@ LLFloaterTexturePicker::LLFloaterTexturePicker(
mSelectedItemPinned( FALSE ),
mCanApply(true),
mCanPreview(true),
+ mMaxDim(S32_MAX),
+ mMinDim(0),
mPreviewSettingChanged(false),
mOnFloaterCommitCallback(NULL),
mOnFloaterCloseCallback(NULL),
@@ -270,19 +272,36 @@ void LLFloaterTexturePicker::stopUsingPipette()
}
}
-void LLFloaterTexturePicker::updateImageStats()
+bool LLFloaterTexturePicker::updateImageStats()
{
+ bool result = true;
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 (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
{
@@ -293,6 +312,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
@@ -410,11 +444,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));
childSetCommitCallback("show_folders_check", onShowFolders, this);
@@ -481,10 +526,6 @@ BOOL LLFloaterTexturePicker::postBuild()
getChildView("show_folders_check")->setEnabled(FALSE);
}
- getChild<LLUICtrl>("Pipette")->setCommitCallback( boost::bind(&LLFloaterTexturePicker::onBtnPipette, this));
- childSetAction("Cancel", LLFloaterTexturePicker::onBtnCancel,this);
- childSetAction("Select", LLFloaterTexturePicker::onBtnSelect,this);
-
// update permission filter once UI is fully initialized
updateFilterPermMask();
mSavedFolderState.setApply(FALSE);
@@ -504,13 +545,13 @@ void LLFloaterTexturePicker::draw()
static LLCachedControl<F32> max_opacity(gSavedSettings, "PickerContextOpacity", 0.4f);
drawConeToOwner(mContextConeOpacity, max_opacity, mOwner);
- updateImageStats();
+ bool valid_dims = updateImageStats();
// if we're inactive, gray out "apply immediate" checkbox
getChildView("show_folders_check")->setEnabled(mActive && mCanApplyImmediately && !mNoCopyTextureSelected);
- getChildView("Select")->setEnabled(mActive && mCanApply);
- getChildView("Pipette")->setEnabled(mActive);
- getChild<LLUICtrl>("Pipette")->setValue(LLToolMgr::getInstance()->getCurrentTool() == LLToolPipette::getInstance());
+ mSelectBtn->setEnabled(mActive && mCanApply && valid_dims);
+ mPipetteBtn->setEnabled(mActive);
+ mPipetteBtn->setValue(LLToolMgr::getInstance()->getCurrentTool() == LLToolPipette::getInstance());
//BOOL allow_copy = FALSE;
if( mOwner )
@@ -544,9 +585,9 @@ void LLFloaterTexturePicker::draw()
mTentativeLabel->setVisible( FALSE );
}
- getChildView("Default")->setEnabled(mImageAssetID != mDefaultImageAssetID || mTentative);
- getChildView("Blank")->setEnabled(mImageAssetID != mBlankImageAssetID || mTentative);
- getChildView("None")->setEnabled(mAllowNoTexture && (!mImageAssetID.isNull() || mTentative));
+ mDefaultBtn->setEnabled(mImageAssetID != mDefaultImageAssetID || mTentative);
+ mBlankBtn->setEnabled(mImageAssetID != mBlankImageAssetID || mTentative);
+ mNoneBtn->setEnabled(mAllowNoTexture && (!mImageAssetID.isNull() || mTentative));
LLFloater::draw();
@@ -820,10 +861,10 @@ 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<LLButton>("Pipette")->setVisible(index == 0 ? TRUE : FALSE);
+ self->mDefaultBtn->setVisible(index == 0 ? TRUE : FALSE);
+ self->mBlankBtn->setVisible(index == 0 ? TRUE : FALSE);
+ self->mNoneBtn->setVisible(index == 0 ? TRUE : FALSE);
+ self->mPipetteBtn->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);
@@ -1098,10 +1139,10 @@ void LLFloaterTexturePicker::updateFilterPermMask()
//mInventoryPanel->setFilterPermMask( getFilterPermMask() ); Commented out due to no-copy texture loss.
}
-void LLFloaterTexturePicker::setCanApply(bool can_preview, bool can_apply)
+void LLFloaterTexturePicker::setCanApply(bool can_preview, bool can_apply, bool inworld_image)
{
- 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;
@@ -1109,6 +1150,17 @@ void LLFloaterTexturePicker::setCanApply(bool can_preview, bool can_apply)
mPreviewSettingChanged = true;
}
+void LLFloaterTexturePicker::setDimentionsLimits(S32 max_dim, S32 min_dim)
+{
+ mMaxDim = max_dim;
+ mMinDim = min_dim;
+
+ std::string formatted_dims = llformat("%dx%d", mMinDim, mMinDim);
+ mResolutionWarning->setTextArg("[MINTEXDIM]", formatted_dims);
+ formatted_dims = llformat("%dx%d", mMaxDim, mMaxDim);
+ mResolutionWarning->setTextArg("[MAXTEXDIM]", formatted_dims);
+}
+
void LLFloaterTexturePicker::onFilterEdit(const std::string& search_string )
{
std::string upper_case_search_string = search_string;
@@ -1478,8 +1530,11 @@ BOOL LLTextureCtrl::handleMouseDown(S32 x, S32 y, MASK mask)
showPicker(FALSE);
//grab textures first...
LLInventoryModelBackgroundFetch::instance().start(gInventory.findCategoryUUIDForType(LLFolderType::FT_TEXTURE));
- //...then start full inventory fetch.
- LLInventoryModelBackgroundFetch::instance().start();
+ //...then start full inventory fetch (should have been done on startup, but just in case.
+ if (!LLInventoryModelBackgroundFetch::instance().inventoryFetchStarted())
+ {
+ LLInventoryModelBackgroundFetch::instance().start();
+ }
handled = TRUE;
}
else