summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorDmitry Zaporozhan <dzaporozhan@productengine.com>2010-03-03 16:22:51 +0200
committerDmitry Zaporozhan <dzaporozhan@productengine.com>2010-03-03 16:22:51 +0200
commit7b5ef7053f0e00282faa47138497b6937756faeb (patch)
tree9ca0caa7dd7fe5628d0ecac1b6ffcc689a7f9d4e /indra
parentc01c2ec86f1918d4830365965010d45ad120d425 (diff)
Implemented major sub task EXT-5858 - Assigned picture is stretched in the Classified Info panel.
Reshape snapshot control to max possible size maintaining aspect ratio. --HG-- branch : product-engine
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/llpanelclassified.cpp55
-rw-r--r--indra/newview/llpanelclassified.h7
-rw-r--r--indra/newview/lltexturectrl.h2
3 files changed, 64 insertions, 0 deletions
diff --git a/indra/newview/llpanelclassified.cpp b/indra/newview/llpanelclassified.cpp
index 7cf27d9141..24cdcadb7c 100644
--- a/indra/newview/llpanelclassified.cpp
+++ b/indra/newview/llpanelclassified.cpp
@@ -1157,6 +1157,7 @@ LLPanelClassifiedInfo::LLPanelClassifiedInfo()
, mScrollContainer(NULL)
, mScrollingPanelMinHeight(0)
, mScrollingPanelWidth(0)
+ , mSnapshotStreched(false)
{
}
@@ -1184,6 +1185,8 @@ BOOL LLPanelClassifiedInfo::postBuild()
mScrollingPanelMinHeight = mScrollContainer->getScrolledViewRect().getHeight();
mScrollingPanelWidth = mScrollingPanel->getRect().getWidth();
+ mSnapshotRect = getChild<LLUICtrl>("classified_snapshot")->getRect();
+
return TRUE;
}
@@ -1215,6 +1218,8 @@ void LLPanelClassifiedInfo::reshape(S32 width, S32 height, BOOL called_from_pare
{
mScrollingPanel->reshape(mScrollingPanelWidth + scrollbar_size, scroll_height);
}
+
+ mSnapshotRect = getChild<LLUICtrl>("classified_snapshot")->getRect();
}
void LLPanelClassifiedInfo::onOpen(const LLSD& key)
@@ -1325,6 +1330,21 @@ void LLPanelClassifiedInfo::setClassifiedLocation(const std::string& location)
void LLPanelClassifiedInfo::setSnapshotId(const LLUUID& id)
{
childSetValue("classified_snapshot", id);
+ if(!mSnapshotStreched)
+ {
+ LLUICtrl* snapshot = getChild<LLUICtrl>("classified_snapshot");
+ snapshot->setRect(mSnapshotRect);
+ }
+ mSnapshotStreched = false;
+}
+
+void LLPanelClassifiedInfo::draw()
+{
+ LLPanel::draw();
+
+ // Stretch in draw because it takes some time to load a texture,
+ // going to try to stretch snapshot until texture is loaded
+ stretchSnapshot();
}
LLUUID LLPanelClassifiedInfo::getSnapshotId()
@@ -1363,6 +1383,41 @@ std::string LLPanelClassifiedInfo::createLocationText(
return location_text;
}
+void LLPanelClassifiedInfo::stretchSnapshot()
+{
+ // *NOTE dzaporozhan
+ // Could be moved to LLTextureCtrl
+
+ LLTextureCtrl* texture_ctrl = getChild<LLTextureCtrl>("classified_snapshot");
+ LLViewerFetchedTexture* texture = texture_ctrl->getTexture();
+
+ if(!texture || mSnapshotStreched)
+ {
+ return;
+ }
+
+ if(0 == texture->getOriginalWidth() || 0 == texture->getOriginalHeight())
+ {
+ // looks like texture is not loaded yet
+ llinfos << "Missing image size" << llendl;
+ return;
+ }
+
+ LLRect rc = mSnapshotRect;
+ F32 t_width = texture->getFullWidth();
+ F32 t_height = texture->getFullHeight();
+
+ F32 ratio = llmin<F32>( (rc.getWidth() / t_width), (rc.getHeight() / t_height) );
+
+ t_width *= ratio;
+ t_height *= ratio;
+
+ rc.setCenterAndSize(rc.getCenterX(), rc.getCenterY(), t_width, t_height);
+ texture_ctrl->setRect(rc);
+
+ mSnapshotStreched = true;
+}
+
void LLPanelClassifiedInfo::onMapClick()
{
LLFloaterWorldMap::getInstance()->trackLocation(getPosGlobal());
diff --git a/indra/newview/llpanelclassified.h b/indra/newview/llpanelclassified.h
index 9e33e55b88..1942eb5365 100644
--- a/indra/newview/llpanelclassified.h
+++ b/indra/newview/llpanelclassified.h
@@ -256,6 +256,8 @@ public:
/*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
+ /*virtual*/ void draw();
+
protected:
LLPanelClassifiedInfo();
@@ -269,6 +271,8 @@ protected:
const std::string& sim_name,
const LLVector3d& pos_global);
+ void stretchSnapshot();
+
void onMapClick();
void onTeleportClick();
void onExit();
@@ -281,6 +285,9 @@ private:
LLUUID mParcelId;
bool mInfoLoaded;
+ bool mSnapshotStreched;
+ LLRect mSnapshotRect;
+
LLScrollContainer* mScrollContainer;
LLPanel* mScrollingPanel;
diff --git a/indra/newview/lltexturectrl.h b/indra/newview/lltexturectrl.h
index 8ca92c3d87..837f837430 100644
--- a/indra/newview/lltexturectrl.h
+++ b/indra/newview/lltexturectrl.h
@@ -183,6 +183,8 @@ public:
void setShowLoadingPlaceholder(BOOL showLoadingPlaceholder);
+ LLViewerFetchedTexture* getTexture() { return mTexturep; }
+
private:
BOOL allowDrop(LLInventoryItem* item);
BOOL doDrop(LLInventoryItem* item);