From e2a7280918665222db3357a4d7566dbdc5d959f2 Mon Sep 17 00:00:00 2001
From: Merov Linden <merov@lindenlab.com>
Date: Mon, 24 Jun 2013 17:01:10 -0700
Subject: ACME-582 : Checkin feature: Implement the loading and displaying of
 map tiles in the LLIconCtrl

---
 indra/newview/llfloatersocial.cpp                  |  51 +++++++++++++++------
 indra/newview/llfloatersocial.h                    |  10 ++--
 .../default/textures/icons/map_placeholder.jpg     | Bin 15526 -> 25641 bytes
 3 files changed, 44 insertions(+), 17 deletions(-)

diff --git a/indra/newview/llfloatersocial.cpp b/indra/newview/llfloatersocial.cpp
index 361d54f696..b14098eb77 100644
--- a/indra/newview/llfloatersocial.cpp
+++ b/indra/newview/llfloatersocial.cpp
@@ -33,6 +33,7 @@
 #include "llagentui.h"
 #include "llfacebookconnect.h"
 #include "llfloaterreg.h"
+#include "lliconctrl.h"
 #include "llslurl.h"
 #include "llviewerregion.h"
 #include "llviewercontrol.h"
@@ -78,22 +79,11 @@ void LLSocialPhotoPanel::onSend()
 }
 
 
-LLSocialCheckinPanel::LLSocialCheckinPanel() :
-    mMapUrl("")
+LLSocialCheckinPanel::LLSocialCheckinPanel()
 {
 	mCommitCallbackRegistrar.add("SocialSharing.SendCheckin", boost::bind(&LLSocialCheckinPanel::onSend, this));
 }
 
-/*virtual*/
-void LLSocialCheckinPanel::setVisible(BOOL visible)
-{
-    if (visible)
-    {
-        mMapUrl = get_map_url();
-    }
-    LLPanel::setVisible(visible);
-}
-
 void LLSocialCheckinPanel::onSend()
 {
 	// Get the location SLURL
@@ -110,7 +100,7 @@ void LLSocialCheckinPanel::onSend()
     
 	// Optionally add the region map view
 	bool add_map_view = getChild<LLUICtrl>("add_place_view_cb")->getValue().asBoolean();
-    std::string map_url = (add_map_view ? mMapUrl : "");
+    std::string map_url = (add_map_view ? get_map_url() : "");
     
 	// Get the caption
 	std::string caption = getChild<LLUICtrl>("place_caption")->getValue().asString();
@@ -127,7 +117,9 @@ void LLSocialCheckinPanel::onSend()
 }
 
 
-LLFloaterSocial::LLFloaterSocial(const LLSD& key) : LLFloater(key)
+LLFloaterSocial::LLFloaterSocial(const LLSD& key) : LLFloater(key),
+    mMapUrl(""),
+    mReloadingMapTexture(false)
 {
 	mCommitCallbackRegistrar.add("SocialSharing.Cancel", boost::bind(&LLFloaterSocial::onCancel, this));
 }
@@ -139,5 +131,36 @@ void LLFloaterSocial::onCancel()
 
 BOOL LLFloaterSocial::postBuild()
 {
+    // Keep a pointer to the map tile placeholder texture
+    mMapPlaceholder = getChild<LLIconCtrl>("map_placeholder")->getImage();
 	return LLFloater::postBuild();
 }
+
+/*virtual*/
+void LLFloaterSocial::draw()
+{
+    std::string map_url = get_map_url();
+    // Did we change location?
+    if (map_url != mMapUrl)
+    {
+        mMapUrl = map_url;
+        // Load the map tile
+        mMapTexture = LLViewerTextureManager::getFetchedTextureFromUrl(mMapUrl, FTT_MAP_TILE, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE);
+        mMapTexture->setBoostLevel(LLGLTexture::BOOST_MAP);
+        mReloadingMapTexture = true;
+        // In the meantime, put back the "loading" placeholder in the map widget
+        getChild<LLIconCtrl>("map_placeholder")->setImage(mMapPlaceholder);
+    }
+    // Are we done loading the map tile?
+    if (mReloadingMapTexture && mMapTexture->isFullyLoaded())
+    {
+        // Don't do it again next time around
+        mReloadingMapTexture = false;
+        // Convert the map texture to the appropriate image object
+        LLPointer<LLUIImage> ui_image = new LLUIImage(mMapUrl, mMapTexture);
+        // Point map widget to correct map tile
+        getChild<LLIconCtrl>("map_placeholder")->setImage(ui_image);
+    }
+    LLFloater::draw();
+}
+
diff --git a/indra/newview/llfloatersocial.h b/indra/newview/llfloatersocial.h
index aee7f2f060..2f3ff3ccdc 100644
--- a/indra/newview/llfloatersocial.h
+++ b/indra/newview/llfloatersocial.h
@@ -28,6 +28,7 @@
 #define LL_LLFLOATERSOCIAL_H
 
 #include "llfloater.h"
+#include "llviewertexture.h"
 
 class LLSocialPhotoPanel : public LLPanel
 {
@@ -41,9 +42,6 @@ class LLSocialCheckinPanel : public LLPanel
 public:
     LLSocialCheckinPanel();
     void onSend();
-	/*virtual*/ void setVisible(BOOL visible);
-private:
-    std::string mMapUrl;
 };
 
 class LLFloaterSocial : public LLFloater
@@ -52,6 +50,12 @@ public:
 	LLFloaterSocial(const LLSD& key);
 	BOOL postBuild();
 	void onCancel();
+	/*virtual*/ void draw();
+private:
+    std::string mMapUrl;
+    LLPointer<LLViewerFetchedTexture> mMapTexture;
+	LLPointer<LLUIImage> mMapPlaceholder;
+    bool mReloadingMapTexture;
 };
 
 #endif // LL_LLFLOATERSOCIAL_H
diff --git a/indra/newview/skins/default/textures/icons/map_placeholder.jpg b/indra/newview/skins/default/textures/icons/map_placeholder.jpg
index 89f4eb88df..0cb86c58d3 100644
Binary files a/indra/newview/skins/default/textures/icons/map_placeholder.jpg and b/indra/newview/skins/default/textures/icons/map_placeholder.jpg differ
-- 
cgit v1.2.3