From 8a442d5edb9074fa76856fc739b362a7374bc1cf Mon Sep 17 00:00:00 2001
From: Paul ProductEngine <pguslisty@productengine.com>
Date: Fri, 25 Nov 2011 19:24:47 +0200
Subject: [PATCH] EXP-1463 FIXED (IM chiclets overlay Mini-Location bar)

- Now chiclet bar adjusts its width with Mini-Location bar
---
 indra/newview/llchicletbar.cpp      | 32 +++++++++++++++++++++++++++++
 indra/newview/llchicletbar.h        |  6 ++++++
 indra/newview/llpaneltopinfobar.cpp | 18 ++++++++++++++++
 indra/newview/llpaneltopinfobar.h   |  6 ++++++
 4 files changed, 62 insertions(+)

diff --git a/indra/newview/llchicletbar.cpp b/indra/newview/llchicletbar.cpp
index a17e1d13f57..1bd5a571a56 100644
--- a/indra/newview/llchicletbar.cpp
+++ b/indra/newview/llchicletbar.cpp
@@ -35,6 +35,7 @@
 // newview includes
 #include "llchiclet.h"
 #include "llimfloater.h" // for LLIMFloater
+#include "llpaneltopinfobar.h"
 #include "llsyswellwindow.h"
 
 namespace
@@ -181,6 +182,9 @@ BOOL LLChicletBar::postBuild()
 	showWellButton("im_well", !LLIMWellWindow::getInstance()->isWindowEmpty());
 	showWellButton("notification_well", !LLNotificationWellWindow::getInstance()->isWindowEmpty());
 
+	LLPanelTopInfoBar::instance().setResizeCallback(boost::bind(&LLChicletBar::fitWithTopInfoBar, this));
+	LLPanelTopInfoBar::instance().setVisibleCallback(boost::bind(&LLChicletBar::fitWithTopInfoBar, this));
+
 	return TRUE;
 }
 
@@ -338,3 +342,31 @@ S32 LLChicletBar::getChicletPanelShrinkHeadroom() const
 	llassert(shrink_headroom >= 0); // the panel cannot get narrower than the minimum
 	return shrink_headroom;
 }
+
+void LLChicletBar::fitWithTopInfoBar()
+{
+	LLPanelTopInfoBar& top_info_bar = LLPanelTopInfoBar::instance();
+
+	LLRect rect = getRect();
+	S32 width = rect.getWidth();
+
+	if (top_info_bar.getVisible())
+	{
+		S32 delta = top_info_bar.calcScreenRect().mRight - calcScreenRect().mLeft;
+		rect.setLeftTopAndSize(rect.mLeft + delta, rect.mTop, rect.getWidth(), rect.getHeight());
+		width = rect.getWidth() - delta;
+	}
+	else
+	{
+		LLView* parent = getParent();
+		if (parent)
+		{
+			LLRect parent_rect = parent->getRect();
+			rect.setLeftTopAndSize(0, rect.mTop, rect.getWidth(), rect.getHeight());
+			width = parent_rect.getWidth();
+		}
+	}
+
+	setRect(rect);
+	LLPanel::reshape(width, rect.getHeight(), false);
+}
diff --git a/indra/newview/llchicletbar.h b/indra/newview/llchicletbar.h
index 224dfbb6470..1427bf95e0f 100644
--- a/indra/newview/llchicletbar.h
+++ b/indra/newview/llchicletbar.h
@@ -89,6 +89,12 @@ class LLChicletBar
 	 */
 	S32 getChicletPanelShrinkHeadroom() const;
 
+	/**
+	 * function adjusts Chiclet bar width to prevent overlapping with Mini-Location bar
+	 * EXP-1463
+	 */
+	void fitWithTopInfoBar();
+
 protected:
 	LLChicletBar(const LLSD& key = LLSD());
 
diff --git a/indra/newview/llpaneltopinfobar.cpp b/indra/newview/llpaneltopinfobar.cpp
index 5ed23d2f425..eb4c7572d43 100644
--- a/indra/newview/llpaneltopinfobar.cpp
+++ b/indra/newview/llpaneltopinfobar.cpp
@@ -203,6 +203,11 @@ void LLPanelTopInfoBar::onVisibilityChange(const LLSD& show)
 	gFloaterView->setMinimizePositionVerticalOffset(minimize_pos_offset);
 }
 
+boost::signals2::connection LLPanelTopInfoBar::setResizeCallback( const resize_signal_t::slot_type& cb )
+{
+	return mResizeSignal.connect(cb);
+}
+
 void LLPanelTopInfoBar::draw()
 {
 	updateParcelInfoText();
@@ -224,6 +229,7 @@ void LLPanelTopInfoBar::buildLocationString(std::string& loc_str, bool show_coor
 
 void LLPanelTopInfoBar::setParcelInfoText(const std::string& new_text)
 {
+	LLRect old_rect = getRect();
 	const LLFontGL* font = mParcelInfoText->getDefaultFont();
 	S32 new_text_width = font->getWidth(new_text);
 
@@ -235,6 +241,11 @@ void LLPanelTopInfoBar::setParcelInfoText(const std::string& new_text)
 	mParcelInfoText->reshape(rect.getWidth(), rect.getHeight(), TRUE);
 	mParcelInfoText->setRect(rect);
 	layoutParcelIcons();
+
+	if (old_rect != getRect())
+	{
+		mResizeSignal();
+	}
 }
 
 void LLPanelTopInfoBar::update()
@@ -342,6 +353,8 @@ void LLPanelTopInfoBar::updateHealth()
 
 void LLPanelTopInfoBar::layoutParcelIcons()
 {
+	LLRect old_rect = getRect();
+
 	// TODO: remove hard-coded values and read them as xml parameters
 	static const int FIRST_ICON_HPAD = 32;
 	static const int LAST_ICON_HPAD = 11;
@@ -358,6 +371,11 @@ void LLPanelTopInfoBar::layoutParcelIcons()
 	LLRect rect = getRect();
 	rect.set(rect.mLeft, rect.mTop, left + LAST_ICON_HPAD, rect.mBottom);
 	setRect(rect);
+
+	if (old_rect != getRect())
+	{
+		mResizeSignal();
+	}
 }
 
 S32 LLPanelTopInfoBar::layoutWidget(LLUICtrl* ctrl, S32 left)
diff --git a/indra/newview/llpaneltopinfobar.h b/indra/newview/llpaneltopinfobar.h
index e934b522bed..d58d95be900 100644
--- a/indra/newview/llpaneltopinfobar.h
+++ b/indra/newview/llpaneltopinfobar.h
@@ -41,6 +41,8 @@ class LLPanelTopInfoBar : public LLPanel, public LLSingleton<LLPanelTopInfoBar>,
 	friend class LLDestroyClass<LLPanelTopInfoBar>;
 
 public:
+	typedef boost::signals2::signal<void ()> resize_signal_t;
+
 	LLPanelTopInfoBar();
 	~LLPanelTopInfoBar();
 
@@ -57,6 +59,8 @@ class LLPanelTopInfoBar : public LLPanel, public LLSingleton<LLPanelTopInfoBar>,
 	 */
 	void onVisibilityChange(const LLSD& show);
 
+	boost::signals2::connection setResizeCallback( const resize_signal_t::slot_type& cb );
+
 private:
 	class LLParcelChangeObserver;
 
@@ -167,6 +171,8 @@ class LLPanelTopInfoBar : public LLPanel, public LLSingleton<LLPanelTopInfoBar>,
 	boost::signals2::connection	mParcelPropsCtrlConnection;
 	boost::signals2::connection	mShowCoordsCtrlConnection;
 	boost::signals2::connection	mParcelMgrConnection;
+
+	resize_signal_t mResizeSignal;
 };
 
 #endif /* LLPANELTOPINFOBAR_H_ */
-- 
GitLab