From 59c586d0c635fc4fa308170fe5532dd2bb3f529b Mon Sep 17 00:00:00 2001
From: Mnikolenko Productengine <mnikolenko@productengine.com>
Date: Thu, 7 Jul 2022 18:14:49 +0300
Subject: SL-17666 Allow Map sidebar UI to be hidden

---
 indra/newview/llfloaterworldmap.cpp                |  19 +++++
 indra/newview/llfloaterworldmap.h                  |   2 +
 .../default/textures/map_ui_collapse_icon.png      | Bin 0 -> 300 bytes
 .../skins/default/textures/map_ui_expand_icon.png  | Bin 0 -> 284 bytes
 indra/newview/skins/default/textures/textures.xml  |   2 +
 .../skins/default/xui/en/floater_world_map.xml     |  90 +++++++++++++++++----
 6 files changed, 97 insertions(+), 16 deletions(-)
 create mode 100644 indra/newview/skins/default/textures/map_ui_collapse_icon.png
 create mode 100644 indra/newview/skins/default/textures/map_ui_expand_icon.png

diff --git a/indra/newview/llfloaterworldmap.cpp b/indra/newview/llfloaterworldmap.cpp
index 2c84cd1f93..09235d8fb2 100644
--- a/indra/newview/llfloaterworldmap.cpp
+++ b/indra/newview/llfloaterworldmap.cpp
@@ -45,6 +45,7 @@
 //#include "llfirstuse.h"
 #include "llfloaterreg.h"		// getTypedInstance()
 #include "llfocusmgr.h"
+#include "lliconctrl.h"
 #include "llinventoryfunctions.h"
 #include "llinventorymodel.h"
 #include "llinventorymodelbackgroundfetch.h"
@@ -307,6 +308,8 @@ BOOL LLFloaterWorldMap::postBuild()
 	
 	mCurZoomVal = log(LLWorldMapView::sMapScale/256.f)/log(2.f);
 	getChild<LLUICtrl>("zoom slider")->setValue(mCurZoomVal);
+
+    getChild<LLPanel>("expand_btn_panel")->setMouseDownCallback(boost::bind(&LLFloaterWorldMap::onExpandCollapseBtn, this));
 	
 	setDefaultBtn(NULL);
 	
@@ -1315,6 +1318,22 @@ void LLFloaterWorldMap::onCopySLURL()
 	LLNotificationsUtil::add("CopySLURL", args);
 }
 
+void LLFloaterWorldMap::onExpandCollapseBtn()
+{
+    LLLayoutStack* floater_stack = getChild<LLLayoutStack>("floater_map_stack");
+    LLLayoutPanel* controls_panel = getChild<LLLayoutPanel>("controls_lp");
+    
+    bool toggle_collapse = !controls_panel->isCollapsed();
+    floater_stack->collapsePanel(controls_panel, toggle_collapse);
+    floater_stack->updateLayout();
+   
+    std::string image_name = getString(toggle_collapse ? "expand_icon" : "collapse_icon");
+    std::string tooltip = getString(toggle_collapse ? "expand_tooltip" : "collapse_tooltip");
+    getChild<LLIconCtrl>("expand_collapse_icon")->setImage(LLUI::getUIImage(image_name));
+    getChild<LLIconCtrl>("expand_collapse_icon")->setToolTip(tooltip);
+    getChild<LLPanel>("expand_btn_panel")->setToolTip(tooltip);
+}
+
 // protected
 void LLFloaterWorldMap::centerOnTarget(BOOL animate)
 {
diff --git a/indra/newview/llfloaterworldmap.h b/indra/newview/llfloaterworldmap.h
index 14a9c26fb9..fcb55e9666 100644
--- a/indra/newview/llfloaterworldmap.h
+++ b/indra/newview/llfloaterworldmap.h
@@ -130,6 +130,8 @@ protected:
 	void			onShowAgentBtn();
 	void			onCopySLURL();
 
+    void            onExpandCollapseBtn();
+
 	void			centerOnTarget(BOOL animate);
 	void			updateLocation();
 
diff --git a/indra/newview/skins/default/textures/map_ui_collapse_icon.png b/indra/newview/skins/default/textures/map_ui_collapse_icon.png
new file mode 100644
index 0000000000..e4de49d4af
Binary files /dev/null and b/indra/newview/skins/default/textures/map_ui_collapse_icon.png differ
diff --git a/indra/newview/skins/default/textures/map_ui_expand_icon.png b/indra/newview/skins/default/textures/map_ui_expand_icon.png
new file mode 100644
index 0000000000..08734b4cc0
Binary files /dev/null and b/indra/newview/skins/default/textures/map_ui_expand_icon.png differ
diff --git a/indra/newview/skins/default/textures/textures.xml b/indra/newview/skins/default/textures/textures.xml
index a5ebfb3395..e9ef888a7f 100644
--- a/indra/newview/skins/default/textures/textures.xml
+++ b/indra/newview/skins/default/textures/textures.xml
@@ -810,6 +810,8 @@ with the same filename but different name
   <texture name="map_infohub.tga" />
   <texture name="map_telehub.tga" />
   <texture name="map_track_16.tga" />
+  <texture name="map_ui_collapse_icon.png" />
+  <texture name="map_ui_expand_icon.png" />
 
   <texture name="notify_caution_icon.tga" />
 
diff --git a/indra/newview/skins/default/xui/en/floater_world_map.xml b/indra/newview/skins/default/xui/en/floater_world_map.xml
index 83407069d2..45e11fc836 100644
--- a/indra/newview/skins/default/xui/en/floater_world_map.xml
+++ b/indra/newview/skins/default/xui/en/floater_world_map.xml
@@ -14,6 +14,31 @@
  single_instance="true"
  title="WORLD MAP"
  width="650">
+  <string
+   name="collapse_icon"
+   value="map_ui_collapse_icon.png"/>
+  <string
+   name="expand_icon"
+   value="map_ui_expand_icon.png"/>
+  <string
+   name="collapse_tooltip"
+   value="Hide map controls"/>
+  <string
+   name="expand_tooltip"
+   value="Show map controls"/>
+  <layout_stack
+   animate="false"
+   follows="all"
+   name="floater_map_stack"
+   tab_group="1"
+   top="16"
+   left="0"
+   right="-1"
+   bottom="-1">
+    <layout_panel
+     name="map_lp"
+     width="385"
+     height="575">
     <panel
      filename="panel_world_map.xml"
      follows="all"
@@ -21,17 +46,48 @@
      layout="topleft"
      left="10"
      name="objects_mapview"
-     top="25"
+     top="6"
      width="375" />
+      <panel
+       follows="top|right"
+       height="30"
+       layout="topleft"
+       left_pad="-29"
+       name="expand_btn_panel"
+       background_visible="true"
+       bg_opaque_color="FloaterFocusBackgroundColor"
+       bg_alpha_color="FloaterDefaultBackgroundColor"
+       background_opaque="true"
+       tool_tip="Hide map controls"
+       top="350"
+       width="30">
+        <icon
+         follows="top|right"
+         height="16"
+         width="16"
+         top="7"
+         left="7"
+         scale_image="false"
+         image_name="map_ui_collapse_icon.png"
+         layout="topleft"
+         mouse_opaque="true"
+         name="expand_collapse_icon"
+         tool_tip="Hide map controls" />
+      </panel>
+      </layout_panel>
+    <layout_panel
+      height="575"
+      width="265"
+      expanded_min_dim="265"
+      name="controls_lp">
      <panel
-     name="layout_panel_1"
-     height="22"
-     width="238"
-     follows="right|top"
-     top="25"
-     left_pad="5"
-  background_visible="true"
-  bg_alpha_color="DkGray2">
+      name="layout_panel_1"
+      height="22"
+      width="238"
+      follows="right|top"
+      top="6"     
+      background_visible="true"
+      bg_alpha_color="DkGray2">
     <text
      text_color="White"
      font="SansSerifLarge"
@@ -43,17 +99,17 @@
      layout="topleft"
      left="15"
      name="events_label"
-     top="3"
      width="215">
         Legend
     </text>
     </panel>
-<panel
- follows="right|top"
-  height="126"
-  top_pad="0"
-  width="238"
-  name="layout_panel_2">
+    <panel
+     follows="right|top"
+     height="126"
+     top_pad="4"
+     width="238"
+     left="1"
+     name="layout_panel_2">
 <button
      follows="right|top"
      height="22"
@@ -690,4 +746,6 @@
      show_text="false"
      width="200" />
      </panel>
+      </layout_panel>
+    </layout_stack>
 </floater>
-- 
cgit v1.2.3