summaryrefslogtreecommitdiff
path: root/indra/newview/llpanelpick.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llpanelpick.cpp')
-rw-r--r--indra/newview/llpanelpick.cpp200
1 files changed, 137 insertions, 63 deletions
diff --git a/indra/newview/llpanelpick.cpp b/indra/newview/llpanelpick.cpp
index e725479abb..f0dc493ebe 100644
--- a/indra/newview/llpanelpick.cpp
+++ b/indra/newview/llpanelpick.cpp
@@ -35,23 +35,30 @@
// profile.
#include "llviewerprecompiledheaders.h"
-#include "llpanel.h"
+
+#include "llpanelpick.h"
+
#include "message.h"
-#include "llagent.h"
-#include "llagentpicksinfo.h"
+
+#include "llparcel.h"
+
#include "llbutton.h"
+#include "llfloaterreg.h"
+#include "lliconctrl.h"
#include "lllineeditor.h"
-#include "llparcel.h"
-#include "llviewerparcelmgr.h"
+#include "llpanel.h"
+#include "llscrollcontainer.h"
#include "lltexteditor.h"
+
+#include "llagent.h"
+#include "llagentpicksinfo.h"
+#include "llavatarpropertiesprocessor.h"
+#include "llfloaterworldmap.h"
#include "lltexturectrl.h"
#include "lluiconstants.h"
+#include "llviewerparcelmgr.h"
#include "llviewerregion.h"
#include "llworldmap.h"
-#include "llfloaterworldmap.h"
-#include "llfloaterreg.h"
-#include "llavatarpropertiesprocessor.h"
-#include "llpanelpick.h"
#define XML_PANEL_EDIT_PICK "panel_edit_pick.xml"
@@ -62,14 +69,9 @@
#define XML_SNAPSHOT "pick_snapshot"
#define XML_LOCATION "pick_location"
+#define XML_BTN_ON_TXTR "edit_icon"
#define XML_BTN_SAVE "save_changes_btn"
-#define SAVE_BTN_LABEL "[WHAT]"
-#define LABEL_PICK = "Pick"
-#define LABEL_CHANGES = "Changes"
-
-std::string SET_LOCATION_NOTICE("(will update after save)");
-
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
@@ -89,12 +91,23 @@ LLPanelPickInfo::LLPanelPickInfo()
, mAvatarId(LLUUID::null)
, mSnapshotCtrl(NULL)
, mPickId(LLUUID::null)
+ , mParcelId(LLUUID::null)
+ , mRequestedId(LLUUID::null)
+ , mScrollingPanelMinHeight(0)
+ , mScrollingPanelWidth(0)
+ , mScrollingPanel(NULL)
+ , mScrollContainer(NULL)
{
}
LLPanelPickInfo::~LLPanelPickInfo()
{
LLAvatarPropertiesProcessor::getInstance()->removeObserver(getAvatarId(), this);
+
+ if (mParcelId.notNull())
+ {
+ LLRemoteParcelInfoProcessor::getInstance()->removeObserver(mParcelId, this);
+ }
}
void LLPanelPickInfo::onOpen(const LLSD& key)
@@ -131,15 +144,39 @@ BOOL LLPanelPickInfo::postBuild()
{
mSnapshotCtrl = getChild<LLTextureCtrl>(XML_SNAPSHOT);
- childSetLabelArg(XML_BTN_SAVE, SAVE_BTN_LABEL, std::string("Pick"));
-
childSetAction("teleport_btn", boost::bind(&LLPanelPickInfo::onClickTeleport, this));
childSetAction("show_on_map_btn", boost::bind(&LLPanelPickInfo::onClickMap, this));
childSetAction("back_btn", boost::bind(&LLPanelPickInfo::onClickBack, this));
+ mScrollingPanel = getChild<LLPanel>("scroll_content_panel");
+ mScrollContainer = getChild<LLScrollContainer>("profile_scroll");
+
+ mScrollingPanelMinHeight = mScrollContainer->getScrolledViewRect().getHeight();
+ mScrollingPanelWidth = mScrollingPanel->getRect().getWidth();
+
return TRUE;
}
+void LLPanelPickInfo::reshape(S32 width, S32 height, BOOL called_from_parent)
+{
+ LLPanel::reshape(width, height, called_from_parent);
+
+ if (!mScrollContainer || !mScrollingPanel)
+ return;
+
+ static LLUICachedControl<S32> scrollbar_size ("UIScrollbarSize", 0);
+
+ S32 scroll_height = mScrollContainer->getRect().getHeight();
+ if (mScrollingPanelMinHeight >= scroll_height)
+ {
+ mScrollingPanel->reshape(mScrollingPanelWidth, mScrollingPanelMinHeight);
+ }
+ else
+ {
+ mScrollingPanel->reshape(mScrollingPanelWidth + scrollbar_size, scroll_height);
+ }
+}
+
void LLPanelPickInfo::processProperties(void* data, EAvatarProcessorType type)
{
if(APT_PICK_INFO != type)
@@ -154,12 +191,14 @@ void LLPanelPickInfo::processProperties(void* data, EAvatarProcessorType type)
return;
}
+ mParcelId = pick_info->parcel_id;
setSnapshotId(pick_info->snapshot_id);
setPickName(pick_info->name);
setPickDesc(pick_info->desc);
setPosGlobal(pick_info->pos_global);
- setPickLocation(createLocationText(pick_info->user_name, pick_info->original_name,
- pick_info->sim_name, pick_info->pos_global));
+
+ // Send remote parcel info request to get parcel name and sim (region) name.
+ sendParcelInfoRequest();
// *NOTE dzaporozhan
// We want to keep listening to APT_PICK_INFO because user may
@@ -167,6 +206,17 @@ void LLPanelPickInfo::processProperties(void* data, EAvatarProcessorType type)
// revomeObserver is called from onClickBack
}
+void LLPanelPickInfo::sendParcelInfoRequest()
+{
+ if (mParcelId != mRequestedId)
+ {
+ LLRemoteParcelInfoProcessor::getInstance()->addObserver(mParcelId, this);
+ LLRemoteParcelInfoProcessor::getInstance()->sendParcelInfoRequest(mParcelId);
+
+ mRequestedId = mParcelId;
+ }
+}
+
void LLPanelPickInfo::setExitCallback(const commit_callback_t& cb)
{
getChild<LLButton>("back_btn")->setClickedCallback(cb);
@@ -174,21 +224,16 @@ void LLPanelPickInfo::setExitCallback(const commit_callback_t& cb)
void LLPanelPickInfo::processParcelInfo(const LLParcelData& parcel_data)
{
- // HACK: Flag 0x2 == adult region,
- // Flag 0x1 == mature region, otherwise assume PG
- std::string rating_icon = "icon_event.tga";
- if (parcel_data.flags & 0x2)
- {
- rating_icon = "icon_event_adult.tga";
- }
- else if (parcel_data.flags & 0x1)
- {
- rating_icon = "icon_event_mature.tga";
- }
+ setPickLocation(createLocationText(LLStringUtil::null, parcel_data.name,
+ parcel_data.sim_name, getPosGlobal()));
- childSetValue("maturity", rating_icon);
+ // We have received parcel info for the requested ID so clear it now.
+ mRequestedId.setNull();
- //*NOTE we don't removeObserver(...) ourselves cause LLRemoveParcelProcessor does it for us
+ if (mParcelId.notNull())
+ {
+ LLRemoteParcelInfoProcessor::getInstance()->removeObserver(mParcelId, this);
+ }
}
void LLPanelPickInfo::setEditPickCallback(const commit_callback_t& cb)
@@ -220,7 +265,8 @@ void LLPanelPickInfo::resetData()
setPickId(LLUUID::null);
setSnapshotId(LLUUID::null);
mPosGlobal.clearVec();
- childSetValue("maturity", LLStringUtil::null);
+ mParcelId.setNull();
+ mRequestedId.setNull();
}
// static
@@ -271,9 +317,6 @@ void LLPanelPickInfo::setPickDesc(const std::string& desc)
void LLPanelPickInfo::setPickLocation(const std::string& location)
{
childSetValue(XML_LOCATION, location);
-
- //preserving non-wrapped text for info/edit modes switching
- mLocation = location;
}
void LLPanelPickInfo::onClickMap()
@@ -338,7 +381,7 @@ void LLPanelPickEdit::onOpen(const LLSD& key)
setPosGlobal(gAgent.getPositionGlobal());
LLUUID parcel_id = LLUUID::null, snapshot_id = LLUUID::null;
- std::string pick_name, pick_desc;
+ std::string pick_name, pick_desc, region_name;
LLParcel* parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();
if(parcel)
@@ -349,21 +392,17 @@ void LLPanelPickEdit::onOpen(const LLSD& key)
snapshot_id = parcel->getSnapshotID();
}
- if(pick_name.empty())
+ LLViewerRegion* region = gAgent.getRegion();
+ if(region)
{
- LLViewerRegion* region = gAgent.getRegion();
- if(region)
- {
- pick_name = region->getName();
- }
+ region_name = region->getName();
}
setParcelID(parcel_id);
- childSetValue("pick_name", pick_name);
+ childSetValue("pick_name", pick_name.empty() ? region_name : pick_name);
childSetValue("pick_desc", pick_desc);
setSnapshotId(snapshot_id);
- setPickLocation(createLocationText(LLStringUtil::null, SET_LOCATION_NOTICE,
- pick_name, getPosGlobal()));
+ setPickLocation(createLocationText(getLocationNotice(), pick_name, region_name, getPosGlobal()));
enableSaveButton(true);
}
@@ -392,17 +431,16 @@ void LLPanelPickEdit::setPickData(const LLPickData* pick_data)
childSetValue("pick_name", pick_data->name);
childSetValue("pick_desc", pick_data->desc);
setSnapshotId(pick_data->snapshot_id);
- setPickLocation(createLocationText(pick_data->user_name, pick_data->original_name, /*pick_data->sim_name,*/
- pick_data->name, pick_data->pos_global));
+ setPosGlobal(pick_data->pos_global);
+ setPickLocation(createLocationText(LLStringUtil::null, pick_data->name,
+ pick_data->sim_name, pick_data->pos_global));
}
BOOL LLPanelPickEdit::postBuild()
{
LLPanelPickInfo::postBuild();
- mSnapshotCtrl->setOnSelectCallback(boost::bind(&LLPanelPickEdit::onPickChanged, this, _1));
- mSnapshotCtrl->setMouseEnterCallback(boost::bind(&LLPanelPickEdit::childSetVisible, this, "edit_icon", true));
- mSnapshotCtrl->setMouseLeaveCallback(boost::bind(&LLPanelPickEdit::childSetVisible, this, "edit_icon", false));
+ mSnapshotCtrl->setCommitCallback(boost::bind(&LLPanelPickEdit::onSnapshotChanged, this));
LLLineEditor* line_edit = getChild<LLLineEditor>("pick_name");
line_edit->setKeystrokeCallback(boost::bind(&LLPanelPickEdit::onPickChanged, this, _1), NULL);
@@ -413,6 +451,8 @@ BOOL LLPanelPickEdit::postBuild()
childSetAction(XML_BTN_SAVE, boost::bind(&LLPanelPickEdit::onClickSave, this));
childSetAction("set_to_curr_location_btn", boost::bind(&LLPanelPickEdit::onClickSetLocation, this));
+ initTexturePickerMouseEvents();
+
return TRUE;
}
@@ -438,7 +478,8 @@ void LLPanelPickEdit::resetDirty()
BOOL LLPanelPickEdit::isDirty() const
{
- if( LLPanelPickInfo::isDirty()
+ if( mNewPick
+ || LLPanelPickInfo::isDirty()
|| mLocationChanged
|| mSnapshotCtrl->isDirty()
|| getChild<LLLineEditor>("pick_name")->isDirty()
@@ -488,16 +529,14 @@ void LLPanelPickEdit::sendUpdate()
}
}
+void LLPanelPickEdit::onSnapshotChanged()
+{
+ enableSaveButton(true);
+}
+
void LLPanelPickEdit::onPickChanged(LLUICtrl* ctrl)
{
- if(isDirty())
- {
- enableSaveButton(true);
- }
- else
- {
- enableSaveButton(false);
- }
+ enableSaveButton(isDirty());
}
void LLPanelPickEdit::resetData()
@@ -516,14 +555,22 @@ void LLPanelPickEdit::onClickSetLocation()
// Save location for later use.
setPosGlobal(gAgent.getPositionGlobal());
+ std::string parcel_name, region_name;
+
LLParcel* parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();
if (parcel)
{
mParcelId = parcel->getID();
- mSimName = parcel->getName();
+ parcel_name = parcel->getName();
}
- setPickLocation(createLocationText(
- LLStringUtil::null, SET_LOCATION_NOTICE, mSimName, getPosGlobal()));
+
+ LLViewerRegion* region = gAgent.getRegion();
+ if(region)
+ {
+ region_name = region->getName();
+ }
+
+ setPickLocation(createLocationText(getLocationNotice(), parcel_name, region_name, getPosGlobal()));
mLocationChanged = true;
enableSaveButton(TRUE);
@@ -540,6 +587,12 @@ void LLPanelPickEdit::onClickSave()
notifyParent(params);
}
+std::string LLPanelPickEdit::getLocationNotice()
+{
+ static std::string notice = getString("location_notice");
+ return notice;
+}
+
void LLPanelPickEdit::processProperties(void* data, EAvatarProcessorType type)
{
if(mNeedData)
@@ -547,3 +600,24 @@ void LLPanelPickEdit::processProperties(void* data, EAvatarProcessorType type)
LLPanelPickInfo::processProperties(data, type);
}
}
+
+// PRIVATE AREA
+
+void LLPanelPickEdit::initTexturePickerMouseEvents()
+{
+ text_icon = getChild<LLIconCtrl>(XML_BTN_ON_TXTR);
+ mSnapshotCtrl->setMouseEnterCallback(boost::bind(&LLPanelPickEdit::onTexturePickerMouseEnter, this, _1));
+ mSnapshotCtrl->setMouseLeaveCallback(boost::bind(&LLPanelPickEdit::onTexturePickerMouseLeave, this, _1));
+
+ text_icon->setVisible(FALSE);
+}
+
+void LLPanelPickEdit::onTexturePickerMouseEnter(LLUICtrl* ctrl)
+{
+ text_icon->setVisible(TRUE);
+}
+
+void LLPanelPickEdit::onTexturePickerMouseLeave(LLUICtrl* ctrl)
+{
+ text_icon->setVisible(FALSE);
+}