From a8fffc7d172d3a786904e6d8e7e7c2943e6d54fc Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Tue, 30 May 2017 16:28:07 +0300 Subject: MAINT-731 Fixed Images Do Not Show at Proper Proportions --- indra/newview/llpreviewtexture.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'indra/newview/llpreviewtexture.cpp') diff --git a/indra/newview/llpreviewtexture.cpp b/indra/newview/llpreviewtexture.cpp index 645a77e42a..54eeebda28 100644 --- a/indra/newview/llpreviewtexture.cpp +++ b/indra/newview/llpreviewtexture.cpp @@ -52,6 +52,8 @@ #include "llviewerwindow.h" #include "lllineeditor.h" +#include + const S32 CLIENT_RECT_VPAD = 4; const F32 SECONDS_TO_SHOW_FILE_SAVED_MSG = 8.f; @@ -579,7 +581,11 @@ void LLPreviewTexture::adjustAspectRatio() std::vector::const_iterator found = std::find(mRatiosList.begin(), mRatiosList.end(), ratio.str()); if (found == mRatiosList.end()) { - combo->setCurrentByIndex(0); + // No existing ratio found, create an element that will show image at original ratio + std::string ratio = boost::lexical_cast(num)+":" + boost::lexical_cast(denom); + mRatiosList.push_back(ratio); + combo->add(ratio); + combo->setCurrentByIndex(mRatiosList.size()- 1); } else { @@ -587,6 +593,15 @@ void LLPreviewTexture::adjustAspectRatio() } } } + else + { + // Aspect ratio was set to unconstrained or was clamped + LLComboBox* combo = getChild("combo_aspect_ratio"); + if (combo) + { + combo->setCurrentByIndex(0); //unconstrained + } + } mUpdateDimensions = TRUE; } -- cgit v1.2.3 From 47ae78f8cfc9ca71bf9837b06618d34737b07fc4 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Wed, 7 Jun 2017 16:21:40 +0300 Subject: MAINT-7461 Fixed images not showing at correct proportions when opened for the first time --- indra/newview/llpreviewtexture.cpp | 64 ++++++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 23 deletions(-) (limited to 'indra/newview/llpreviewtexture.cpp') diff --git a/indra/newview/llpreviewtexture.cpp b/indra/newview/llpreviewtexture.cpp index 54eeebda28..12bcd89cb0 100644 --- a/indra/newview/llpreviewtexture.cpp +++ b/indra/newview/llpreviewtexture.cpp @@ -100,6 +100,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("combo_aspect_ratio"); + combo->removeall(); + + for (std::vector::const_iterator it = mRatiosList.begin(); it != mRatiosList.end(); ++it) + { + combo->add(*it); + } +} + // virtual BOOL LLPreviewTexture::postBuild() { @@ -140,27 +163,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("combo_aspect_ratio"); - combo->removeall(); - - for (std::vector::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("combo_aspect_ratio"); combo->setCurrentByIndex(0); return LLPreview::postBuild(); @@ -446,16 +454,25 @@ 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 - getChild("dimensions")->setTextArg("[WIDTH]", llformat("%d", mImage->getFullWidth())); - getChild("dimensions")->setTextArg("[HEIGHT]", llformat("%d", mImage->getFullHeight())); + getChild("dimensions")->setTextArg("[WIDTH]", llformat("%d", img_width)); + getChild("dimensions")->setTextArg("[HEIGHT]", llformat("%d", img_height)); + + mLastHeight = img_height; + mLastWidth = img_width; // Reshape the floater only when required if (mUpdateDimensions) @@ -582,6 +599,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(num)+":" + boost::lexical_cast(denom); mRatiosList.push_back(ratio); combo->add(ratio); -- cgit v1.2.3