MAINT-7461 Fixed images not showing at correct proportions when opened for the first time
parent
dbad1e3a5d
commit
0c7ed286bb
|
|
@ -103,11 +103,7 @@ LLPreviewTexture::LLPreviewTexture(const LLSD& key)
|
|||
mImageOldBoostLevel(LLGLTexture::BOOST_NONE),
|
||||
mShowingButtons(false),
|
||||
mDisplayNameCallback(false),
|
||||
mAvatarNameCallbackConnection(),
|
||||
// <FS:Ansariel> Performance improvement
|
||||
mCurrentImageWidth(0),
|
||||
mCurrentImageHeight(0)
|
||||
// </FS:Ansariel>
|
||||
mAvatarNameCallbackConnection()
|
||||
{
|
||||
updateImageID();
|
||||
if (key.has("save_as"))
|
||||
|
|
@ -151,6 +147,29 @@ LLPreviewTexture::~LLPreviewTexture()
|
|||
}
|
||||
}
|
||||
|
||||
void LLPreviewTexture::populateRatioList()
|
||||
{
|
||||
// Fill in ratios list with common aspect ratio values
|
||||
mRatiosList.clear();
|
||||
mRatiosList.push_back(LLTrans::getString("Unconstrained"));
|
||||
mRatiosList.push_back("1:1");
|
||||
mRatiosList.push_back("4:3");
|
||||
mRatiosList.push_back("10:7");
|
||||
mRatiosList.push_back("3:2");
|
||||
mRatiosList.push_back("16:10");
|
||||
mRatiosList.push_back("16:9");
|
||||
mRatiosList.push_back("2:1");
|
||||
|
||||
// Now fill combo box with provided list
|
||||
LLComboBox* combo = getChild<LLComboBox>("combo_aspect_ratio");
|
||||
combo->removeall();
|
||||
|
||||
for (std::vector<std::string>::const_iterator it = mRatiosList.begin(); it != mRatiosList.end(); ++it)
|
||||
{
|
||||
combo->add(*it);
|
||||
}
|
||||
}
|
||||
|
||||
// virtual
|
||||
BOOL LLPreviewTexture::postBuild()
|
||||
{
|
||||
|
|
@ -191,27 +210,12 @@ BOOL LLPreviewTexture::postBuild()
|
|||
}
|
||||
}
|
||||
|
||||
// Fill in ratios list with common aspect ratio values
|
||||
mRatiosList.clear();
|
||||
mRatiosList.push_back(LLTrans::getString("Unconstrained"));
|
||||
mRatiosList.push_back("1:1");
|
||||
mRatiosList.push_back("4:3");
|
||||
mRatiosList.push_back("10:7");
|
||||
mRatiosList.push_back("3:2");
|
||||
mRatiosList.push_back("16:10");
|
||||
mRatiosList.push_back("16:9");
|
||||
mRatiosList.push_back("2:1");
|
||||
|
||||
// Now fill combo box with provided list
|
||||
LLComboBox* combo = getChild<LLComboBox>("combo_aspect_ratio");
|
||||
combo->removeall();
|
||||
|
||||
for (std::vector<std::string>::const_iterator it = mRatiosList.begin(); it != mRatiosList.end(); ++it)
|
||||
{
|
||||
combo->add(*it);
|
||||
}
|
||||
// Fill in ratios list and combo box with common aspect ratio values
|
||||
populateRatioList();
|
||||
|
||||
childSetCommitCallback("combo_aspect_ratio", onAspectRatioCommit, this);
|
||||
|
||||
LLComboBox* combo = getChild<LLComboBox>("combo_aspect_ratio");
|
||||
combo->setCurrentByIndex(0);
|
||||
|
||||
// <FS:Techwolf Lupindo> texture comment metadata reader
|
||||
|
|
@ -665,28 +669,35 @@ void LLPreviewTexture::updateDimensions()
|
|||
return;
|
||||
}
|
||||
|
||||
if (mAssetStatus != PREVIEW_ASSET_LOADED)
|
||||
S32 img_width = mImage->getFullWidth();
|
||||
S32 img_height = mImage->getFullHeight();
|
||||
|
||||
if (mAssetStatus != PREVIEW_ASSET_LOADED
|
||||
|| mLastWidth != img_width
|
||||
|| mLastHeight != img_height)
|
||||
{
|
||||
mAssetStatus = PREVIEW_ASSET_LOADED;
|
||||
// Asset has been fully loaded, adjust aspect ratio
|
||||
adjustAspectRatio();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Update the width/height display every time
|
||||
// <FS:Ansariel> Performance improvement
|
||||
//getChild<LLUICtrl>("dimensions")->setTextArg("[WIDTH]", llformat("%d", mImage->getFullWidth()));
|
||||
//getChild<LLUICtrl>("dimensions")->setTextArg("[HEIGHT]", llformat("%d", mImage->getFullHeight()));
|
||||
if (mCurrentImageWidth != mImage->getFullWidth())
|
||||
//getChild<LLUICtrl>("dimensions")->setTextArg("[WIDTH]", llformat("%d", img_width));
|
||||
//getChild<LLUICtrl>("dimensions")->setTextArg("[HEIGHT]", llformat("%d", img_height));
|
||||
if (img_width != mLastWidth)
|
||||
{
|
||||
mDimensionsCtrl->setTextArg("[WIDTH]", llformat("%d", mImage->getFullWidth()));
|
||||
mCurrentImageWidth = mImage->getFullWidth();
|
||||
mDimensionsCtrl->setTextArg("[WIDTH]", llformat("%d", img_width));
|
||||
}
|
||||
if (mCurrentImageHeight != mImage->getFullHeight())
|
||||
if (img_height != mLastHeight)
|
||||
{
|
||||
mDimensionsCtrl->setTextArg("[HEIGHT]", llformat("%d", mImage->getFullHeight()));
|
||||
mCurrentImageHeight = mImage->getFullHeight();
|
||||
mDimensionsCtrl->setTextArg("[HEIGHT]", llformat("%d", img_height));
|
||||
}
|
||||
// </FS:Ansariel>
|
||||
// </FS:Ansariel> Performance improvement
|
||||
|
||||
mLastHeight = img_height;
|
||||
mLastWidth = img_width;
|
||||
|
||||
// Reshape the floater only when required
|
||||
if (mUpdateDimensions)
|
||||
|
|
@ -1040,6 +1051,7 @@ void LLPreviewTexture::adjustAspectRatio()
|
|||
if (found == mRatiosList.end())
|
||||
{
|
||||
// No existing ratio found, create an element that will show image at original ratio
|
||||
populateRatioList(); // makes sure previous custom ratio is cleared
|
||||
std::string ratio = boost::lexical_cast<std::string>(num)+":" + boost::lexical_cast<std::string>(denom);
|
||||
mRatiosList.push_back(ratio);
|
||||
combo->add(ratio);
|
||||
|
|
|
|||
|
|
@ -100,6 +100,7 @@ public:
|
|||
|
||||
protected:
|
||||
void init();
|
||||
void populateRatioList();
|
||||
/* virtual */ BOOL postBuild();
|
||||
bool setAspectRatio(const F32 width, const F32 height);
|
||||
static void onAspectRatioCommit(LLUICtrl*,void* userdata);
|
||||
|
|
@ -136,9 +137,6 @@ private:
|
|||
|
||||
// <FS:Ansariel> Performance improvement
|
||||
LLUICtrl* mDimensionsCtrl;
|
||||
S32 mCurrentImageWidth;
|
||||
S32 mCurrentImageHeight;
|
||||
// </FS:Ansariel>
|
||||
|
||||
LLLoadedCallbackEntry::source_callback_list_t mCallbackTextureList ;
|
||||
std::vector<std::string> mRatiosList;
|
||||
|
|
|
|||
Loading…
Reference in New Issue