diff options
Diffstat (limited to 'indra/newview/llpanelplaces.cpp')
-rw-r--r-- | indra/newview/llpanelplaces.cpp | 157 |
1 files changed, 116 insertions, 41 deletions
diff --git a/indra/newview/llpanelplaces.cpp b/indra/newview/llpanelplaces.cpp index 7461d150c8..41be268483 100644 --- a/indra/newview/llpanelplaces.cpp +++ b/indra/newview/llpanelplaces.cpp @@ -43,6 +43,7 @@ #include "lluictrlfactory.h" #include "llagent.h" +#include "lllandmarkactions.h" #include "lllandmarklist.h" #include "llfloaterworldmap.h" #include "llpanelplaces.h" @@ -50,14 +51,22 @@ #include "llpanelteleporthistory.h" #include "llsidetray.h" #include "lltoggleablemenu.h" +#include "llviewermenu.h" #include "llviewerparcelmgr.h" #include "llviewerregion.h" +static const std::string AGENT_INFO_TYPE = "agent"; +static const std::string CREATE_LANDMARK_INFO_TYPE = "create_landmark"; +static const std::string LANDMARK_INFO_TYPE = "landmark"; +static const std::string REMOTE_PLACE_INFO_TYPE = "remote_place"; +static const std::string TELEPORT_HISTORY_INFO_TYPE = "teleport_history"; + // Helper functions static bool cmp_folders(const folder_pair_t& left, const folder_pair_t& right); static std::string getFullFolderName(const LLViewerInventoryCategory* cat); static void collectLandmarkFolders(LLInventoryModel::cat_array_t& cats); static const LLVector3 get_pos_local_from_global(const LLVector3d &pos_global); +static void onSLURLBuilt(std::string& slurl); static LLRegisterPanelClassWrapper<LLPanelPlaces> t_places("panel_places"); @@ -68,6 +77,8 @@ LLPanelPlaces::LLPanelPlaces() mFilterEditor(NULL), mPlaceInfo(NULL), mItem(NULL), + mPlaceMenu(NULL), + mLandmarkMenu(NULL), mLandmarkFoldersMenuHandle(), mPosGlobal() { @@ -107,7 +118,23 @@ BOOL LLPanelPlaces::postBuild() mOverflowBtn = getChild<LLButton>("overflow_btn"); // *TODO: Assign the action to an appropriate event. - mOverflowBtn->setClickedCallback(boost::bind(&LLPanelPlaces::toggleMediaPanel, this)); + //mOverflowBtn->setClickedCallback(boost::bind(&LLPanelPlaces::toggleMediaPanel, this)); + mOverflowBtn->setClickedCallback(boost::bind(&LLPanelPlaces::onOverflowButtonClicked, this)); + + LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar; + registrar.add("Places.OverflowMenu.Action", boost::bind(&LLPanelPlaces::onOverflowMenuItemClicked, this, _2)); + + mPlaceMenu = LLUICtrlFactory::getInstance()->createFromFile<LLToggleableMenu>("menu_place.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); + if (!mPlaceMenu) + { + llwarns << "Error loading Place menu" << llendl; + } + + mLandmarkMenu = LLUICtrlFactory::getInstance()->createFromFile<LLToggleableMenu>("menu_landmark.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); + if (!mLandmarkMenu) + { + llwarns << "Error loading Landmark menu" << llendl; + } mTabContainer = getChild<LLTabContainer>("Places Tabs"); if (mTabContainer) @@ -147,21 +174,21 @@ void LLPanelPlaces::onOpen(const LLSD& key) togglePlaceInfoPanel(TRUE); updateVerbs(); - if (mPlaceInfoType == "agent") + if (mPlaceInfoType == AGENT_INFO_TYPE) { mPlaceInfo->setInfoType(LLPanelPlaceInfo::PLACE); mPlaceInfo->displayAgentParcelInfo(); mPosGlobal = gAgent.getPositionGlobal(); } - else if (mPlaceInfoType == "create_landmark") + else if (mPlaceInfoType == CREATE_LANDMARK_INFO_TYPE) { mPlaceInfo->setInfoType(LLPanelPlaceInfo::CREATE_LANDMARK); mPlaceInfo->displayAgentParcelInfo(); mPosGlobal = gAgent.getPositionGlobal(); } - else if (mPlaceInfoType == "landmark") + else if (mPlaceInfoType == LANDMARK_INFO_TYPE) { LLUUID item_uuid = key["id"].asUUID(); LLInventoryItem* item = gInventory.getItem(item_uuid); @@ -170,7 +197,7 @@ void LLPanelPlaces::onOpen(const LLSD& key) setItem(item); } - else if (mPlaceInfoType == "remote_place") + else if (mPlaceInfoType == REMOTE_PLACE_INFO_TYPE) { if (mPlaceInfo->isMediaPanelVisible()) { @@ -186,7 +213,7 @@ void LLPanelPlaces::onOpen(const LLSD& key) LLUUID(), mPosGlobal); } - else if (mPlaceInfoType == "teleport_history") + else if (mPlaceInfoType == TELEPORT_HISTORY_INFO_TYPE) { S32 index = key["id"].asInteger(); @@ -237,11 +264,10 @@ void LLPanelPlaces::onLandmarkLoaded(LLLandmark* landmark) LLUUID region_id; landmark->getRegionID(region_id); - LLVector3d pos_global; - landmark->getGlobalPos(pos_global); + landmark->getGlobalPos(mPosGlobal); mPlaceInfo->displayParcelInfo(landmark->getRegionPos(), region_id, - pos_global); + mPosGlobal); } void LLPanelPlaces::onFilterEdit(const std::string& search_string) @@ -273,12 +299,17 @@ void LLPanelPlaces::onShareButtonClicked() { // TODO: Launch the "Things" Share wizard } +*/ -void LLPanelPlaces::onCopySLURLButtonClicked() +void LLPanelPlaces::copySLURL() { - mActivePanel->onCopySLURL(); + LLLandmarkActions::getSLURLfromPosGlobal(mPosGlobal, boost::bind(&onSLURLBuilt, _1)); +} + +void LLPanelPlaces::deleteLandmark() +{ + gInventory.removeItem(mItem->getUUID()); } -*/ void LLPanelPlaces::onTeleportButtonClicked() { @@ -287,13 +318,13 @@ void LLPanelPlaces::onTeleportButtonClicked() if (mPlaceInfo->getVisible()) { - if (mPlaceInfoType == "landmark") + if (mPlaceInfoType == LANDMARK_INFO_TYPE) { LLSD payload; payload["asset_id"] = mItem->getAssetUUID(); LLNotifications::instance().add("TeleportFromLandmark", LLSD(), payload); } - else if (mPlaceInfoType == "remote_place" || mPlaceInfoType == "agent") + else if (mPlaceInfoType == AGENT_INFO_TYPE || mPlaceInfoType == REMOTE_PLACE_INFO_TYPE) { LLFloaterWorldMap* worldmap_instance = LLFloaterWorldMap::getInstance(); if (!mPosGlobal.isExactlyZero() && worldmap_instance) @@ -320,9 +351,9 @@ void LLPanelPlaces::onShowOnMapButtonClicked() if(!worldmap_instance) return; - if (mPlaceInfoType == "agent" || - mPlaceInfoType == "create_landmark" || - mPlaceInfoType == "remote_place") + if (mPlaceInfoType == AGENT_INFO_TYPE || + mPlaceInfoType == CREATE_LANDMARK_INFO_TYPE || + mPlaceInfoType == REMOTE_PLACE_INFO_TYPE) { if (!mPosGlobal.isExactlyZero()) { @@ -330,7 +361,7 @@ void LLPanelPlaces::onShowOnMapButtonClicked() LLFloaterReg::showInstance("world_map", "center"); } } - else if (mPlaceInfoType == "landmark") + else if (mPlaceInfoType == LANDMARK_INFO_TYPE) { LLLandmark* landmark = gLandmarkList.getAsset(mItem->getAssetUUID()); if (!landmark) @@ -353,6 +384,52 @@ void LLPanelPlaces::onShowOnMapButtonClicked() } } +void LLPanelPlaces::onOverflowButtonClicked() +{ + bool is_agent_place_info_visible = mPlaceInfoType == AGENT_INFO_TYPE; + bool is_landmark_info_visible = mPlaceInfoType == LANDMARK_INFO_TYPE; + + LLToggleableMenu* menu; + + if (is_agent_place_info_visible && mPlaceMenu != NULL) + { + menu = mPlaceMenu; + } + else if (is_landmark_info_visible && mLandmarkMenu != NULL) + { + menu = mLandmarkMenu; + } + else + { + return; + } + + if (!menu->toggleVisibility()) + return; + + menu->updateParent(LLMenuGL::sMenuContainer); + LLRect rect = mOverflowBtn->getRect(); + menu->setButtonRect(rect, this); + LLMenuGL::showPopup(this, menu, rect.mRight, rect.mTop); +} + +void LLPanelPlaces::onOverflowMenuItemClicked(const LLSD& param) +{ + std::string item = param.asString(); + if (item == "landmark") + { + onOpen(LLSD().insert("type", CREATE_LANDMARK_INFO_TYPE)); + } + else if (item == "copy") + { + copySLURL(); + } + else if (item == "delete") + { + deleteLandmark(); + } +} + void LLPanelPlaces::onCreateLandmarkButtonClicked(const LLUUID& folder_id) { if (!mPlaceInfo) @@ -380,11 +457,11 @@ void LLPanelPlaces::toggleMediaPanel() return; mPlaceInfo->toggleMediaPanel(!mPlaceInfo->isMediaPanelVisible()); - + // Refresh the current place info because // the media panel controls can't refer to // the remote parcel media. - onOpen(LLSD().insert("type", "agent")); + onOpen(LLSD().insert("type", AGENT_INFO_TYPE)); } void LLPanelPlaces::togglePlaceInfoPanel(BOOL visible) @@ -402,7 +479,7 @@ void LLPanelPlaces::togglePlaceInfoPanel(BOOL visible) LLRect rect = getRect(); LLRect new_rect = LLRect(rect.mLeft, rect.mTop, rect.mRight, mTabContainer->getRect().mBottom); - mPlaceInfo->reshape(new_rect.getWidth(),new_rect.getHeight()); + mPlaceInfo->reshape(new_rect.getWidth(),new_rect.getHeight()); } } @@ -450,13 +527,13 @@ void LLPanelPlaces::onAgentParcelChange() if (!mPlaceInfo) return; - if (mPlaceInfo->getVisible() && mPlaceInfoType == "create_landmark") + if (mPlaceInfo->getVisible() && mPlaceInfoType == CREATE_LANDMARK_INFO_TYPE) { onOpen(LLSD().insert("type", mPlaceInfoType)); } else if (mPlaceInfo->isMediaPanelVisible()) { - onOpen(LLSD().insert("type", "agent")); + onOpen(LLSD().insert("type", AGENT_INFO_TYPE)); } else { @@ -470,8 +547,8 @@ void LLPanelPlaces::updateVerbs() return; bool is_place_info_visible = mPlaceInfo->getVisible(); - bool is_agent_place_info_visible = mPlaceInfoType == "agent"; - bool is_create_landmark_visible = mPlaceInfoType == "create_landmark"; + bool is_agent_place_info_visible = mPlaceInfoType == AGENT_INFO_TYPE; + bool is_create_landmark_visible = mPlaceInfoType == CREATE_LANDMARK_INFO_TYPE; bool is_media_panel_visible = mPlaceInfo->isMediaPanelVisible(); mTeleportBtn->setVisible(!is_create_landmark_visible); @@ -479,9 +556,7 @@ void LLPanelPlaces::updateVerbs() mCreateLandmarkBtn->setVisible(is_create_landmark_visible); mFolderMenuBtn->setVisible(is_create_landmark_visible); - // Enable overflow button only when showing the information - // about agent's current location. - mOverflowBtn->setEnabled(is_agent_place_info_visible); + mOverflowBtn->setEnabled(is_place_info_visible && !is_media_panel_visible && !is_create_landmark_visible); if (is_place_info_visible) { @@ -493,7 +568,7 @@ void LLPanelPlaces::updateVerbs() !mPosGlobal.isExactlyZero() && !LLViewerParcelMgr::getInstance()->inAgentParcel(mPosGlobal)); } - else if (mPlaceInfoType == "landmark" || mPlaceInfoType == "remote_place") + else if (mPlaceInfoType == LANDMARK_INFO_TYPE || mPlaceInfoType == REMOTE_PLACE_INFO_TYPE) { mTeleportBtn->setEnabled(TRUE); } @@ -525,18 +600,8 @@ void LLPanelPlaces::showLandmarkFoldersMenu() if(!menu) return; - if (menu->getClosedByButtonClick()) - { - menu->resetClosedByButtonClick(); + if (!menu->toggleVisibility()) return; - } - - if (menu->getVisible()) - { - menu->setVisible(FALSE); - menu->resetClosedByButtonClick(); - return; - } // Collect all folders that can contain landmarks. LLInventoryModel::cat_array_t cats; @@ -705,7 +770,7 @@ static void collectLandmarkFolders(LLInventoryModel::cat_array_t& cats) } } -const LLVector3 get_pos_local_from_global(const LLVector3d &pos_global) +static const LLVector3 get_pos_local_from_global(const LLVector3d &pos_global) { F32 region_x = (F32)fmod( pos_global.mdV[VX], (F64)REGION_WIDTH_METERS ); F32 region_y = (F32)fmod( pos_global.mdV[VY], (F64)REGION_WIDTH_METERS ); @@ -713,3 +778,13 @@ const LLVector3 get_pos_local_from_global(const LLVector3d &pos_global) LLVector3 pos_local(region_x, region_y, (F32)pos_global.mdV[VZ]); return pos_local; } + +static void onSLURLBuilt(std::string& slurl) +{ + LLView::getWindow()->copyTextToClipboard(utf8str_to_wstring(slurl)); + + LLSD args; + args["SLURL"] = slurl; + + LLNotifications::instance().add("CopySLURL", args); +} |