summaryrefslogtreecommitdiff
path: root/indra/newview/llpanelme.cpp
diff options
context:
space:
mode:
authorVadim Savchuk <vsavchuk@productengine.com>2009-11-20 22:57:59 +0200
committerVadim Savchuk <vsavchuk@productengine.com>2009-11-20 22:57:59 +0200
commit70a0dbe8f8466438e12a45e70d0f901b9324f228 (patch)
tree6fa9a3e3ef2153b87129f286ed83652bedb0fc6e /indra/newview/llpanelme.cpp
parent0c468557b9e38ec4be201fa991499ed095a4d8c3 (diff)
Renamed classes and files for "Me" task panel for better readability.
Renamed files: - indra/newview/llpanelmeprofile.{cpp,h} to llpanelme.{cpp,h} - panel_me_profile.xml to panel_me.xml - panel_profile_user.xml to panel_my_profile.xml Renamed classes: - LLPanelAvatarMeProfile to LLPanelMyProfile - LLPanelMeProfile to LLPanelMe - LLPanelMeProfileEdit to LLPanelMyProfileEdit --HG-- branch : product-engine
Diffstat (limited to 'indra/newview/llpanelme.cpp')
-rw-r--r--indra/newview/llpanelme.cpp233
1 files changed, 233 insertions, 0 deletions
diff --git a/indra/newview/llpanelme.cpp b/indra/newview/llpanelme.cpp
new file mode 100644
index 0000000000..0c7da30b03
--- /dev/null
+++ b/indra/newview/llpanelme.cpp
@@ -0,0 +1,233 @@
+/**
+ * @file llpanelme.cpp
+ * @brief Side tray "Me" (My Profile) panel
+ *
+ * $LicenseInfo:firstyear=2009&license=viewergpl$
+ *
+ * Copyright (c) 2009, Linden Research, Inc.
+ *
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab. Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ *
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ *
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ *
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#include "llviewerprecompiledheaders.h"
+
+#include "llpanelprofile.h"
+#include "llavatarconstants.h"
+#include "llpanelme.h"
+#include "llagent.h"
+#include "llagentwearables.h"
+#include "lliconctrl.h"
+#include "lltabcontainer.h"
+#include "lltexturectrl.h"
+
+#define PICKER_SECOND_LIFE "2nd_life_pic"
+#define PICKER_FIRST_LIFE "real_world_pic"
+#define PANEL_PROFILE "panel_profile"
+
+static LLRegisterPanelClassWrapper<LLPanelMyProfileEdit> t_panel_me_profile_edit("edit_profile_panel");
+static LLRegisterPanelClassWrapper<LLPanelMe> t_panel_me_profile("panel_me_profile_view");
+
+LLPanelMe::LLPanelMe(void)
+ : LLPanelProfile()
+ , mEditPanel(NULL)
+{
+ setAvatarId(gAgent.getID());
+}
+
+BOOL LLPanelMe::postBuild()
+{
+ LLPanelProfile::postBuild();
+
+ getTabContainer()[PANEL_PROFILE]->childSetAction("edit_profile_btn", boost::bind(&LLPanelMe::onEditProfileClicked, this), this);
+ getTabContainer()[PANEL_PROFILE]->childSetAction("edit_appearance_btn", boost::bind(&LLPanelMe::onEditAppearanceClicked, this), this);
+
+ return TRUE;
+}
+
+void LLPanelMe::onOpen(const LLSD& key)
+{
+ LLPanelProfile::onOpen(key);
+}
+
+void LLPanelMe::buildEditPanel()
+{
+ if (NULL == mEditPanel)
+ {
+ mEditPanel = new LLPanelMyProfileEdit();
+ mEditPanel->childSetAction("save_btn", boost::bind(&LLPanelMe::onSaveChangesClicked, this), this);
+ mEditPanel->childSetAction("cancel_btn", boost::bind(&LLPanelMe::onCancelClicked, this), this);
+ }
+}
+
+
+void LLPanelMe::onEditProfileClicked()
+{
+ buildEditPanel();
+ togglePanel(mEditPanel);
+ mEditPanel->onOpen(getAvatarId());
+}
+
+void LLPanelMe::onEditAppearanceClicked()
+{
+ if (gAgentWearables.areWearablesLoaded())
+ {
+ gAgent.changeCameraToCustomizeAvatar();
+ }
+}
+
+void LLPanelMe::onSaveChangesClicked()
+{
+ LLAvatarData data = LLAvatarData();
+ data.avatar_id = gAgent.getID();
+ data.image_id = mEditPanel->getChild<LLTextureCtrl>(PICKER_SECOND_LIFE)->getImageAssetID();
+ data.fl_image_id = mEditPanel->getChild<LLTextureCtrl>(PICKER_FIRST_LIFE)->getImageAssetID();
+ data.about_text = mEditPanel->childGetValue("sl_description_edit").asString();
+ data.fl_about_text = mEditPanel->childGetValue("fl_description_edit").asString();
+ data.profile_url = mEditPanel->childGetValue("homepage_edit").asString();
+ data.allow_publish = mEditPanel->childGetValue("show_in_search_checkbox");
+
+ LLAvatarPropertiesProcessor::getInstance()->sendAvatarPropertiesUpdate(&data);
+ togglePanel(mEditPanel);
+ onOpen(getAvatarId());
+}
+
+void LLPanelMe::onCancelClicked()
+{
+ togglePanel(mEditPanel);
+}
+
+//////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////
+
+LLPanelMyProfileEdit::LLPanelMyProfileEdit()
+ : LLPanelMyProfile()
+{
+ LLUICtrlFactory::getInstance()->buildPanel(this, "panel_edit_profile.xml");
+
+ setAvatarId(gAgent.getID());
+}
+
+void LLPanelMyProfileEdit::onOpen(const LLSD& key)
+{
+ resetData();
+
+ // Disable editing until data is loaded, or edited fields will be overwritten when data
+ // is loaded.
+ enableEditing(false);
+ LLPanelMyProfile::onOpen(getAvatarId());
+}
+
+void LLPanelMyProfileEdit::processProperties(void* data, EAvatarProcessorType type)
+{
+ if(APT_PROPERTIES == type)
+ {
+ const LLAvatarData* avatar_data = static_cast<const LLAvatarData*>(data);
+ if(avatar_data && getAvatarId() == avatar_data->avatar_id)
+ {
+ // *TODO dzaporozhan
+ // Workaround for ticket EXT-1099, waiting for fix for ticket EXT-1128
+ enableEditing(true);
+ processProfileProperties(avatar_data);
+ LLAvatarPropertiesProcessor::getInstance()->removeObserver(getAvatarId(),this);
+ }
+ }
+}
+
+void LLPanelMyProfileEdit::processProfileProperties(const LLAvatarData* avatar_data)
+{
+ fillCommonData(avatar_data);
+
+ fillOnlineStatus(avatar_data);
+
+ fillPartnerData(avatar_data);
+
+ fillAccountStatus(avatar_data);
+
+ childSetValue("show_in_search_checkbox", (BOOL)(avatar_data->flags & AVATAR_ALLOW_PUBLISH));
+
+ std::string first, last;
+ BOOL found = gCacheName->getName(avatar_data->avatar_id, first, last);
+ if (found)
+ {
+ childSetTextArg("name_text", "[FIRST]", first);
+ childSetTextArg("name_text", "[LAST]", last);
+ }
+}
+
+BOOL LLPanelMyProfileEdit::postBuild()
+{
+ initTexturePickerMouseEvents();
+
+ childSetTextArg("partner_edit_link", "[URL]", getString("partner_edit_link_url"));
+
+ return LLPanelAvatarProfile::postBuild();
+}
+/**
+ * Inits map with texture picker and appropriate edit icon.
+ * Sets callbacks of Mouse Enter and Mouse Leave signals of Texture Pickers
+ */
+void LLPanelMyProfileEdit::initTexturePickerMouseEvents()
+{
+ LLTextureCtrl* text_pic = getChild<LLTextureCtrl>(PICKER_SECOND_LIFE);
+ LLIconCtrl* text_icon = getChild<LLIconCtrl>("2nd_life_edit_icon");
+ mTextureEditIconMap[text_pic->getName()] = text_icon;
+ text_pic->setMouseEnterCallback(boost::bind(&LLPanelMyProfileEdit::onTexturePickerMouseEnter, this, _1));
+ text_pic->setMouseLeaveCallback(boost::bind(&LLPanelMyProfileEdit::onTexturePickerMouseLeave, this, _1));
+ text_icon->setVisible(FALSE);
+
+ text_pic = getChild<LLTextureCtrl>(PICKER_FIRST_LIFE);
+ text_icon = getChild<LLIconCtrl>("real_world_edit_icon");
+ mTextureEditIconMap[text_pic->getName()] = text_icon;
+ text_pic->setMouseEnterCallback(boost::bind(&LLPanelMyProfileEdit::onTexturePickerMouseEnter, this, _1));
+ text_pic->setMouseLeaveCallback(boost::bind(&LLPanelMyProfileEdit::onTexturePickerMouseLeave, this, _1));
+ text_icon->setVisible(FALSE);
+}
+
+void LLPanelMyProfileEdit::resetData()
+{
+ LLPanelMyProfile::resetData();
+
+ childSetTextArg("name_text", "[FIRST]", LLStringUtil::null);
+ childSetTextArg("name_text", "[LAST]", LLStringUtil::null);
+}
+
+void LLPanelMyProfileEdit::onTexturePickerMouseEnter(LLUICtrl* ctrl)
+{
+ mTextureEditIconMap[ctrl->getName()]->setVisible(TRUE);
+}
+void LLPanelMyProfileEdit::onTexturePickerMouseLeave(LLUICtrl* ctrl)
+{
+ mTextureEditIconMap[ctrl->getName()]->setVisible(FALSE);
+}
+
+void LLPanelMyProfileEdit::enableEditing(bool enable)
+{
+ childSetEnabled("2nd_life_pic", enable);
+ childSetEnabled("real_world_pic", enable);
+ childSetEnabled("sl_description_edit", enable);
+ childSetEnabled("fl_description_edit", enable);
+ childSetEnabled("homepage_edit", enable);
+ childSetEnabled("show_in_search_checkbox", enable);
+}