From 649beed53bd44ae5b06cd36f40897ed561fe48ab Mon Sep 17 00:00:00 2001
From: Vadim ProductEngine <vsavchuk@productengine.com>
Date: Fri, 18 Nov 2011 22:23:09 +0200
Subject: [PATCH] EXP-1577 FIX Made agent profile position and size persistent.

Enable My Profile to use saved_rect.
Value of the "WebProfileRect" setting is ignored in this case.
---
 indra/newview/llavataractions.cpp             | 31 +++++++--
 indra/newview/llviewerfloaterreg.cpp          |  1 +
 indra/newview/llviewermenu.cpp                |  2 +-
 .../default/xui/en/floater_my_web_profile.xml |  9 +++
 .../default/xui/en/panel_snapshot_local.xml   | 65 +++++++++++++++++++
 5 files changed, 101 insertions(+), 7 deletions(-)
 create mode 100644 indra/newview/skins/default/xui/en/floater_my_web_profile.xml

diff --git a/indra/newview/llavataractions.cpp b/indra/newview/llavataractions.cpp
index 10fd6b739e6..7f6abb09375 100755
--- a/indra/newview/llavataractions.cpp
+++ b/indra/newview/llavataractions.cpp
@@ -302,6 +302,25 @@ void LLAvatarActions::startConference(const uuid_vec_t& ids)
 	make_ui_sound("UISndStartIM");
 }
 
+static const LLRect& get_preferred_profile_rect(const LLUUID& avatar_id)
+{
+	if (avatar_id == gAgentID)
+	{
+		return LLRect::null; // no preference
+	}
+
+	// Preferred size for all residents' profiles except our own,
+	// for which saved_rect will be used.
+	static LLCachedControl<LLRect> profile_rect(gSavedSettings, "WebProfileRect");
+	return profile_rect;
+}
+
+static const char* get_profile_floater_name(const LLUUID& avatar_id)
+{
+	// Use different floater XML for our profile to be able to save its rect.
+	return avatar_id == gAgentID ? "my_profile" : "profile";
+}
+
 static void on_avatar_name_show_profile(const LLUUID& agent_id, const LLAvatarName& av_name)
 {
 	std::string username = av_name.mUsername;
@@ -315,14 +334,13 @@ static void on_avatar_name_show_profile(const LLUUID& agent_id, const LLAvatarNa
 
 	// PROFILES: open in webkit window
 	const bool show_chrome = false;
-	static LLCachedControl<LLRect> profile_rect(gSavedSettings, "WebProfileRect");
 	LLFloaterWebContent::Params p;
 	p.url(url).
 		id(agent_id.asString()).
 		show_chrome(show_chrome).
 		window_class("profile").
-		preferred_media_size(profile_rect);
-	LLFloaterReg::showInstance("profile", p);
+		preferred_media_size(get_preferred_profile_rect(agent_id));
+	LLFloaterReg::showInstance(get_profile_floater_name(agent_id), p);
 }
 
 // static
@@ -339,14 +357,15 @@ bool LLAvatarActions::profileVisible(const LLUUID& id)
 {
 	LLSD sd;
 	sd["id"] = id;
-	LLFloaterWebContent *browser = dynamic_cast<LLFloaterWebContent*> (LLFloaterReg::findInstance("profile", sd));
+	LLFloater* browser = getProfileFloater(id);
 	return browser && browser->isShown();
 }
 
 //static
 LLFloater* LLAvatarActions::getProfileFloater(const LLUUID& id)
 {
-	LLFloaterWebContent *browser = dynamic_cast<LLFloaterWebContent*> (LLFloaterReg::findInstance("profile", LLSD().with("id", id)));
+	LLFloaterWebContent *browser = dynamic_cast<LLFloaterWebContent*>
+		(LLFloaterReg::findInstance(get_profile_floater_name(id), LLSD().with("id", id)));
 	return browser;
 }
 
@@ -355,7 +374,7 @@ void LLAvatarActions::hideProfile(const LLUUID& id)
 {
 	LLSD sd;
 	sd["id"] = id;
-	LLFloaterWebContent *browser = dynamic_cast<LLFloaterWebContent*> (LLFloaterReg::findInstance("profile", sd));
+	LLFloater* browser = getProfileFloater(id);
 	if (browser)
 	{
 		browser->closeFloater();
diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp
index 273bf822bcf..0ec8cc1d4ea 100644
--- a/indra/newview/llviewerfloaterreg.cpp
+++ b/indra/newview/llviewerfloaterreg.cpp
@@ -285,6 +285,7 @@ void LLViewerFloaterReg::registerFloaters()
 	LLFloaterReg::add("stop_queue", "floater_script_queue.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterNotRunQueue>);
 	LLFloaterReg::add("snapshot", "floater_snapshot.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSnapshot>);
 	LLFloaterReg::add("search", "floater_search.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSearch>);
+	LLFloaterReg::add("my_profile", "floater_my_web_profile.xml", (LLFloaterBuildFunc)&LLFloaterWebContent::create);
 	LLFloaterReg::add("profile", "floater_web_profile.xml", (LLFloaterBuildFunc)&LLFloaterWebContent::create);	
 	LLFloaterReg::add("how_to", "floater_how_to.xml", (LLFloaterBuildFunc)&LLFloaterWebContent::create);	
 
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index 22d95563d86..81311b03f54 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -3122,7 +3122,7 @@ void handle_avatar_eject(const LLSD& avatar_id)
 
 bool my_profile_visible()
 {
-	LLFloater* floaterp = LLFloaterReg::findInstance("profile", LLSD().with("id", gAgent.getID()));
+	LLFloater* floaterp = LLAvatarActions::getProfileFloater(gAgentID);
 	return floaterp && floaterp->isInVisibleChain();
 }
 
diff --git a/indra/newview/skins/default/xui/en/floater_my_web_profile.xml b/indra/newview/skins/default/xui/en/floater_my_web_profile.xml
new file mode 100644
index 00000000000..df46fc198f2
--- /dev/null
+++ b/indra/newview/skins/default/xui/en/floater_my_web_profile.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<floater name="floater_my_web_profile"
+         help_topic="web_profile"
+         width="780"
+         height="775"
+         save_rect="true"
+         single_instance="true"
+         reuse_instance="false"
+         filename="floater_web_content.xml"/>
\ No newline at end of file
diff --git a/indra/newview/skins/default/xui/en/panel_snapshot_local.xml b/indra/newview/skins/default/xui/en/panel_snapshot_local.xml
index 4d6c4bcdfac..a9b373430ab 100644
--- a/indra/newview/skins/default/xui/en/panel_snapshot_local.xml
+++ b/indra/newview/skins/default/xui/en/panel_snapshot_local.xml
@@ -80,6 +80,7 @@
          name="Custom"
          value="[i-1,i-1]" />
     </combo_box>
+<!--
     <spinner
      allow_text_entry="false"
      decimal_digits="0"
@@ -167,6 +168,70 @@
      width="60">
        ([QLVL])
     </text>
+ -->
+    <layout_stack
+     follows="all"
+     height="275"
+     layout="bottomleft"
+     name="edit_panel_ls"
+     left_delta="0"
+     orientation="vertical"
+     top_pad="10"
+     right="-10">
+        <layout_panel
+         follows="top|left|right"
+         height="23"
+         layout="topleft"
+         left="0"
+         name="size_controls_lp"
+         user_resize="false" 
+         auto_resize="false"
+         top="0"
+         right="-1"
+         visible="true">
+            <button
+             follows="top|left|right"
+             height="23"
+             label="Info"
+             layout="topleft"
+             name="info_btn"
+             tab_stop="false"
+             tool_tip="Show pick information"
+             right="-1" />
+        </layout_panel>
+        <layout_panel
+         follows="top|left|right"
+         height="23"
+         layout="topleft"
+         left="0"
+         name="test_lp"
+         user_resize="false" 
+         auto_resize="true"
+         top="0"
+         right="-1"
+         visible="true">
+            <button
+             follows="top|left|right"
+             height="23"
+             label="Test"
+             layout="topleft"
+             name="test_btn"
+             tab_stop="false"
+             tool_tip="Show pick information"
+             right="-1" />
+        </layout_panel>
+        <layout_panel
+         follows="top|left|right"
+         height="28"
+         layout="topleft"
+         left="0"
+         name="spacer_lp"
+         user_resize="false" 
+         auto_resize="true"
+         top="0"
+         right="-1"
+         visible="true" />
+    </layout_stack>
     <button
      follows="right|bottom"
      height="23"
-- 
GitLab