From 99278b2f6259cd6e7b48dfbccb2528d428f83ec6 Mon Sep 17 00:00:00 2001
From: Andrey Kleshchev <andreykproductengine@lindenlab.com>
Date: Fri, 5 Feb 2021 11:15:06 +0200
Subject: [PATCH] SL-14797 Normalize right-click menus on Landmarks & Picks
 Part#1

---
 indra/newview/llpanellandmarks.cpp            | 37 +++++++++++
 indra/newview/llpanelplaces.cpp               |  2 +-
 .../xui/en/menu_places_gear_folder.xml        |  3 +
 .../xui/en/menu_places_gear_landmark.xml      | 62 ++++++++-----------
 4 files changed, 67 insertions(+), 37 deletions(-)

diff --git a/indra/newview/llpanellandmarks.cpp b/indra/newview/llpanellandmarks.cpp
index ccd84974845..578485c9676 100644
--- a/indra/newview/llpanellandmarks.cpp
+++ b/indra/newview/llpanellandmarks.cpp
@@ -40,6 +40,7 @@
 #include "llagent.h"
 #include "llagentpicksinfo.h"
 #include "llagentui.h"
+#include "llavataractions.h"
 #include "llcallbacklist.h"
 #include "lldndbutton.h"
 #include "llfloatersidepanelcontainer.h"
@@ -1051,6 +1052,38 @@ bool LLLandmarksPanel::isActionEnabled(const LLSD& userdata) const
 		}
 		return false;
 	}
+    else if ("add_landmark" == command_name)
+    {
+        bool is_single_selection = root_folder_view && root_folder_view->getSelectedCount() == 1;
+        if (!is_single_selection)
+        {
+            return false;
+        }
+        LLFolderViewModelItemInventory* view_model = getCurSelectedViewModelItem();
+        if (!view_model || view_model->getInventoryType() != LLInventoryType::IT_CATEGORY)
+        {
+            return false;
+        }
+        LLViewerInventoryItem* landmark = LLLandmarkActions::findLandmarkForAgentPos();
+        if (landmark)
+        {
+            //already exists
+            return false;
+        }
+        return true;
+    }
+    else if ("share" == command_name)
+    {
+        if (!mCurrentSelectedList)
+        {
+            return false;
+        }
+        if (!LLAvatarActions::canShareSelectedItems(mCurrentSelectedList))
+        {
+            return false;
+        }
+        return true;
+    }
 	else
 	{
 		LL_WARNS() << "Unprocessed command has come: " << command_name << LL_ENDL;
@@ -1078,6 +1111,10 @@ void LLLandmarksPanel::onCustomAction(const LLSD& userdata)
 	{
 		doActionOnCurSelectedLandmark(boost::bind(&LLLandmarksPanel::doCreatePick, this, _1));
 	}
+    else if ("share" == command_name && mCurrentSelectedList)
+    {
+        LLAvatarActions::shareWithAvatars(mCurrentSelectedList);
+    }
 	else if ("restore" == command_name && mCurrentSelectedList)
 	{
 		mCurrentSelectedList->doToSelected(userdata);
diff --git a/indra/newview/llpanelplaces.cpp b/indra/newview/llpanelplaces.cpp
index 53870fb5c74..abec3ba733f 100644
--- a/indra/newview/llpanelplaces.cpp
+++ b/indra/newview/llpanelplaces.cpp
@@ -388,7 +388,7 @@ void LLPanelPlaces::onOpen(const LLSD& key)
 			// Update the buttons at the bottom of the panel
 			updateVerbs();
 		}
-		else
+		else // "create_landmark"
 		{
 			mFilterEditor->clear();
 			onFilterEdit("", false);
diff --git a/indra/newview/skins/default/xui/en/menu_places_gear_folder.xml b/indra/newview/skins/default/xui/en/menu_places_gear_folder.xml
index 1aeb166e015..4d59ab06317 100644
--- a/indra/newview/skins/default/xui/en/menu_places_gear_folder.xml
+++ b/indra/newview/skins/default/xui/en/menu_places_gear_folder.xml
@@ -13,6 +13,9 @@
         <on_click
          function="Places.LandmarksGear.Add.Action"
          parameter="add_landmark" />
+        <on_enable
+         function="Places.LandmarksGear.Enable"
+         parameter="add_landmark" />
     </menu_item_call>
     <menu_item_call
      label="Add Folder"
diff --git a/indra/newview/skins/default/xui/en/menu_places_gear_landmark.xml b/indra/newview/skins/default/xui/en/menu_places_gear_landmark.xml
index ff5fdd37953..b8249b621b7 100644
--- a/indra/newview/skins/default/xui/en/menu_places_gear_landmark.xml
+++ b/indra/newview/skins/default/xui/en/menu_places_gear_landmark.xml
@@ -18,7 +18,18 @@
          parameter="teleport" />
     </menu_item_call>
     <menu_item_call
-     label="More Information"
+     label="Share"
+     layout="topleft"
+     name="share">
+        <on_click
+         function="Places.LandmarksGear.Custom.Action"
+         parameter="share" />
+        <on_enable
+         function="Places.LandmarksGear.Enable"
+         parameter="share" />
+    </menu_item_call>
+    <menu_item_call
+     label="View/Edit Landmark"
      layout="topleft"
      name="more_info">
         <on_click
@@ -39,26 +50,27 @@
          function="Places.LandmarksGear.Enable"
          parameter="show_on_map" />
     </menu_item_call>
-    <menu_item_separator
-     layout="topleft" />
     <menu_item_call
-     label="Add Landmark"
+     label="Copy SLurl"
      layout="topleft"
-     name="add_landmark">
+     name="copy_slurl">
         <on_click
-         function="Places.LandmarksGear.Add.Action"
-         parameter="add_landmark" />
-    </menu_item_call>
+         function="Places.LandmarksGear.CopyPaste.Action"
+         parameter="copy_slurl" />
+        <on_enable
+         function="Places.LandmarksGear.Enable"
+         parameter="copy_slurl" />
+    </menu_item_call> 
     <menu_item_call
-     label="Add Folder"
+     label="Create Pick"
      layout="topleft"
-     name="add_folder">
+     name="create_pick">
         <on_click
-         function="Places.LandmarksGear.Add.Action"
-         parameter="category" />
+         function="Places.LandmarksGear.Custom.Action"
+         parameter="create_pick" />
         <on_enable
          function="Places.LandmarksGear.Enable"
-         parameter="category" />
+         parameter="create_pick" />
     </menu_item_call>
     <menu_item_call
      label="Restore Item"
@@ -82,24 +94,13 @@
          parameter="cut" />
     </menu_item_call>
     <menu_item_call
-     label="Copy Landmark"
+     label="Copy"
      layout="topleft"
      name="copy_landmark">
         <on_click
          function="Places.LandmarksGear.CopyPaste.Action"
          parameter="copy" />
     </menu_item_call>
-    <menu_item_call
-     label="Copy SLurl"
-     layout="topleft"
-     name="copy_slurl">
-        <on_click
-         function="Places.LandmarksGear.CopyPaste.Action"
-         parameter="copy_slurl" />
-        <on_enable
-         function="Places.LandmarksGear.Enable"
-         parameter="copy_slurl" />
-    </menu_item_call>
     <menu_item_call
      label="Paste"
      layout="topleft"
@@ -171,15 +172,4 @@
          function="Places.LandmarksGear.Enable"
          parameter="sort_by_date" />
     </menu_item_check>
-    <menu_item_call
-     label="Create Pick"
-     layout="topleft"
-     name="create_pick">
-        <on_click
-         function="Places.LandmarksGear.Custom.Action"
-         parameter="create_pick" />
-        <on_enable
-         function="Places.LandmarksGear.Enable"
-         parameter="create_pick" />
-    </menu_item_call>
 </toggleable_menu>
-- 
GitLab