From ec09ce526b477869aa76dddaa8e11eecca57989d Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Tue, 25 Jun 2013 15:49:39 -0700 Subject: ACME-612 : Implemented a loading indicator for the map tile when it's loading, also disable the checkbox during that time --- indra/newview/llfloatersocial.cpp | 14 +++++++++-- indra/newview/llfloatersocial.h | 1 + .../skins/default/xui/en/floater_social.xml | 27 ++++++++++++++-------- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/indra/newview/llfloatersocial.cpp b/indra/newview/llfloatersocial.cpp index 92a291e51c..e164ea8155 100644 --- a/indra/newview/llfloatersocial.cpp +++ b/indra/newview/llfloatersocial.cpp @@ -34,6 +34,7 @@ #include "llfacebookconnect.h" #include "llfloaterreg.h" #include "lliconctrl.h" +#include "llloadingindicator.h" #include "llslurl.h" #include "llviewerregion.h" #include "llviewercontrol.h" @@ -453,8 +454,12 @@ void LLFloaterSocial::draw() mMapTexture->setBoostLevel(LLGLTexture::BOOST_MAP); mReloadingMapTexture = true; // In the meantime, put back the "loading" placeholder in the map widget - getChild("map_placeholder")->setImage(mMapPlaceholder); - } + getChild("map_loading_indicator")->setVisible(true); + getChild("map_placeholder")->setVisible(false); + mMapCheckBoxValue = getChild("add_place_view_cb")->get(); + getChild("add_place_view_cb")->set(false); + getChild("add_place_view_cb")->setEnabled(false); + } // Are we done loading the map tile? if (mReloadingMapTexture && mMapTexture->isFullyLoaded()) { @@ -464,6 +469,11 @@ void LLFloaterSocial::draw() LLPointer ui_image = new LLUIImage(mMapUrl, mMapTexture); // Point map widget to correct map tile getChild("map_placeholder")->setImage(ui_image); + // Switch visibility + getChild("map_loading_indicator")->setVisible(false); + getChild("map_placeholder")->setVisible(true); + getChild("add_place_view_cb")->setEnabled(true); + getChild("add_place_view_cb")->set(mMapCheckBoxValue); } LLFloater::draw(); } diff --git a/indra/newview/llfloatersocial.h b/indra/newview/llfloatersocial.h index 1e28e3cb7e..8b51d5ca9b 100644 --- a/indra/newview/llfloatersocial.h +++ b/indra/newview/llfloatersocial.h @@ -103,6 +103,7 @@ private: LLPointer mMapTexture; LLPointer mMapPlaceholder; bool mReloadingMapTexture; + bool mMapCheckBoxValue; }; #endif // LL_LLFLOATERSOCIAL_H diff --git a/indra/newview/skins/default/xui/en/floater_social.xml b/indra/newview/skins/default/xui/en/floater_social.xml index 76c15b9624..960f883595 100644 --- a/indra/newview/skins/default/xui/en/floater_social.xml +++ b/indra/newview/skins/default/xui/en/floater_social.xml @@ -379,16 +379,25 @@ - - + height="24" + width="24" + name="map_loading_indicator" + top="57" + left="61" + visible="true"/> + + Date: Tue, 25 Jun 2013 16:49:15 -0700 Subject: ACME-497 : Refactor the LLSocialCheckinPanel code a bit to make it more maintainable --- indra/newview/llfloatersocial.cpp | 87 +++++++++++++++++++++++---------------- indra/newview/llfloatersocial.h | 15 ++++--- 2 files changed, 61 insertions(+), 41 deletions(-) diff --git a/indra/newview/llfloatersocial.cpp b/indra/newview/llfloatersocial.cpp index 2859b19b19..c9f7283640 100644 --- a/indra/newview/llfloatersocial.cpp +++ b/indra/newview/llfloatersocial.cpp @@ -392,11 +392,61 @@ void LLSocialPhotoPanel::onSend() } -LLSocialCheckinPanel::LLSocialCheckinPanel() +LLSocialCheckinPanel::LLSocialCheckinPanel() : + mMapUrl(""), + mReloadingMapTexture(false) { mCommitCallbackRegistrar.add("SocialSharing.SendCheckin", boost::bind(&LLSocialCheckinPanel::onSend, this)); } +BOOL LLSocialCheckinPanel::postBuild() +{ + // Keep pointers to widgets so we don't traverse the UI hierarchy too often + mMapLoadingIndicator = getChild("map_loading_indicator"); + mMapPlaceholder = getChild("map_placeholder"); + mMapCheckBox = getChild("add_place_view_cb"); + mMapCheckBoxValue = mMapCheckBox->get(); + + return LLPanel::postBuild(); +} + +void LLSocialCheckinPanel::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 the "loading" indicator on, hide the tile map and disable the checkbox + mMapLoadingIndicator->setVisible(true); + mMapPlaceholder->setVisible(false); + mMapCheckBoxValue = mMapCheckBox->get(); + mMapCheckBox->set(false); + mMapCheckBox->setEnabled(false); + } + // 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 ui_image = new LLUIImage(mMapUrl, mMapTexture); + // Load the map widget with the correct map tile image + mMapPlaceholder->setImage(ui_image); + // Now hide the loading indicator, bring the tile in view and reenable the checkbox with its previous value + mMapLoadingIndicator->setVisible(false); + mMapPlaceholder->setVisible(true); + mMapCheckBox->setEnabled(true); + mMapCheckBox->set(mMapCheckBoxValue); + } + + LLPanel::draw(); +} + void LLSocialCheckinPanel::onSend() { // Get the location SLURL @@ -431,8 +481,6 @@ void LLSocialCheckinPanel::onSend() LLFloaterSocial::LLFloaterSocial(const LLSD& key) : LLFloater(key), - mMapUrl(""), - mReloadingMapTexture(false), mSocialPhotoPanel(NULL) { mCommitCallbackRegistrar.add("SocialSharing.Cancel", boost::bind(&LLFloaterSocial::onCancel, this)); @@ -446,45 +494,12 @@ void LLFloaterSocial::onCancel() BOOL LLFloaterSocial::postBuild() { mSocialPhotoPanel = static_cast(getChild("social_photo_tab")); - // Keep a pointer to the map tile placeholder texture - mMapPlaceholder = getChild("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("map_loading_indicator")->setVisible(true); - getChild("map_placeholder")->setVisible(false); - mMapCheckBoxValue = getChild("add_place_view_cb")->get(); - getChild("add_place_view_cb")->set(false); - getChild("add_place_view_cb")->setEnabled(false); - } - // 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 ui_image = new LLUIImage(mMapUrl, mMapTexture); - // Point map widget to correct map tile - getChild("map_placeholder")->setImage(ui_image); - // Switch visibility - getChild("map_loading_indicator")->setVisible(false); - getChild("map_placeholder")->setVisible(true); - getChild("add_place_view_cb")->setEnabled(true); - getChild("add_place_view_cb")->set(mMapCheckBoxValue); - } LLFloater::draw(); } diff --git a/indra/newview/llfloatersocial.h b/indra/newview/llfloatersocial.h index 8b51d5ca9b..b7792e10c1 100644 --- a/indra/newview/llfloatersocial.h +++ b/indra/newview/llfloatersocial.h @@ -81,7 +81,17 @@ class LLSocialCheckinPanel : public LLPanel { public: LLSocialCheckinPanel(); + BOOL postBuild(); + void draw(); void onSend(); +private: + std::string mMapUrl; + LLPointer mMapTexture; + LLUICtrl* mMapLoadingIndicator; + LLIconCtrl* mMapPlaceholder; + LLCheckBoxCtrl* mMapCheckBox; + bool mReloadingMapTexture; + bool mMapCheckBoxValue; }; class LLFloaterSocial : public LLFloater @@ -99,11 +109,6 @@ public: private: LLSocialPhotoPanel * mSocialPhotoPanel; - std::string mMapUrl; - LLPointer mMapTexture; - LLPointer mMapPlaceholder; - bool mReloadingMapTexture; - bool mMapCheckBoxValue; }; #endif // LL_LLFLOATERSOCIAL_H -- cgit v1.2.3