diff options
| author | Dmitry Oleshko <doleshko@productengine.com> | 2009-12-18 15:58:37 +0200 | 
|---|---|---|
| committer | Dmitry Oleshko <doleshko@productengine.com> | 2009-12-18 15:58:37 +0200 | 
| commit | f3a92bfc17762c7f0ade6b93f27d7a499031e463 (patch) | |
| tree | 6b2af8ad271edc643b629559d0b81ca2f4abede2 | |
| parent | 55ff23cdad73882fdbf0a4959c1ca8fbf6ada315 (diff) | |
implemented major task (EXT-3354) Add "unread message" counters for IM sessions in the IM well window
- IM Well Window's chiclets now have counters and count IMs from 1 to "99+"
- IM Well Window's items can resize on appearance of chiclet's counter or speaker indicator
--HG--
branch : product-engine
| -rw-r--r-- | indra/newview/llchiclet.cpp | 125 | ||||
| -rw-r--r-- | indra/newview/llchiclet.h | 59 | ||||
| -rw-r--r-- | indra/newview/llsyswellwindow.cpp | 12 | ||||
| -rw-r--r-- | indra/newview/llsyswellwindow.h | 2 | ||||
| -rw-r--r-- | indra/newview/skins/default/xui/en/panel_activeim_row.xml | 4 | 
5 files changed, 147 insertions, 55 deletions
| diff --git a/indra/newview/llchiclet.cpp b/indra/newview/llchiclet.cpp index 5695f7cac1..1bdbdb6b82 100644 --- a/indra/newview/llchiclet.cpp +++ b/indra/newview/llchiclet.cpp @@ -66,7 +66,8 @@ static LLDefaultChildRegistry::Register<LLInvOfferChiclet> t7("chiclet_offer");  static const LLRect CHICLET_RECT(0, 25, 25, 0);  static const LLRect CHICLET_ICON_RECT(0, 22, 22, 0); -static const LLRect VOICE_INDICATOR_RECT(25, 25, 45, 0); +static const LLRect VOICE_INDICATOR_RECT(50, 25, 70, 0); +static const LLRect COUNTER_RECT(25, 25, 50, 0);  static const S32	OVERLAY_ICON_SHIFT = 2;	// used for shifting of an overlay icon for new massages in a chiclet  // static @@ -170,6 +171,7 @@ LLSysWellChiclet::~LLSysWellChiclet()  void LLSysWellChiclet::setCounter(S32 counter)  { +	// note same code in LLChicletNotificationCounterCtrl::setCounter(S32 counter)  	std::string s_count;  	if(counter != 0)  	{ @@ -427,7 +429,7 @@ LLIMChiclet::LLIMChiclet(const LLIMChiclet::Params& p)  	// shift an icon a little bit to the right and up corner of a chiclet  	overlay_icon_rect.translate(OVERLAY_ICON_SHIFT, OVERLAY_ICON_SHIFT); -	setShowCounter(false); +	enableCounterControl(false);  }  void LLIMChiclet::setShowSpeaker(bool show) @@ -440,30 +442,87 @@ void LLIMChiclet::setShowSpeaker(bool show)  		onChicletSizeChanged();		  	}  } + +void LLIMChiclet::enableCounterControl(bool enable)  +{ +	mCounterEnabled = enable; +	if(!enable) +	{ +		LLChiclet::setShowCounter(false); +	} +} + +void LLIMChiclet::setShowCounter(bool show) +{ +	if(!mCounterEnabled) +	{ +		return; +	} + +	bool needs_resize = getShowCounter() != show; +	if(needs_resize) +	{		 +		LLChiclet::setShowCounter(show); +		toggleCounterControl(); +		onChicletSizeChanged();		 +	} +} +  void LLIMChiclet::initSpeakerControl()  {  	// virtual  } -void LLIMChiclet::toggleSpeakerControl() +void LLIMChiclet::setRequiredWidth()  { -	LLRect speaker_rect = mSpeakerCtrl->getRect(); -	S32 required_width = getRect().getWidth(); +	bool show_speaker = getShowSpeaker(); +	bool show_counter = getShowCounter(); +	S32 required_width = CHICLET_RECT.getWidth(); -	if(getShowSpeaker()) +	if (show_counter)  	{ -		required_width = required_width + speaker_rect.getWidth(); -		initSpeakerControl();		 +		required_width += COUNTER_RECT.getWidth();  	} -	else +	if (show_speaker)  	{ -		required_width = required_width - speaker_rect.getWidth(); -	} -	 +		required_width += VOICE_INDICATOR_RECT.getWidth(); +	}  +  	reshape(required_width, getRect().getHeight()); +} + +void LLIMChiclet::toggleSpeakerControl() +{ +	if(getShowSpeaker()) +	{ +		if(getShowCounter()) +		{ +			mSpeakerCtrl->setRect(VOICE_INDICATOR_RECT); +		} +		else +		{ +			mSpeakerCtrl->setRect(COUNTER_RECT); +		} +		initSpeakerControl();		 +	} + +	setRequiredWidth();  	mSpeakerCtrl->setVisible(getShowSpeaker());  } +void LLIMChiclet::setCounter(S32 counter) +{ +	mCounterCtrl->setCounter(counter); +	setShowCounter(counter); +	setShowNewMessagesIcon(counter); +} + +void LLIMChiclet::toggleCounterControl() +{ +	setRequiredWidth(); +	mCounterCtrl->setVisible(getShowCounter()); +} +  void LLIMChiclet::setShowNewMessagesIcon(bool show)  {  	if(mNewMessagesIcon) @@ -564,6 +623,7 @@ LLIMP2PChiclet::Params::Params()  	unread_notifications.v_pad(5);  	unread_notifications.text_color(LLColor4::white);  	unread_notifications.mouse_opaque(false); +	unread_notifications.rect(COUNTER_RECT);  	unread_notifications.visible(false);  	speaker.name("speaker"); @@ -602,12 +662,6 @@ LLIMP2PChiclet::LLIMP2PChiclet(const Params& p)  	mSpeakerCtrl->setVisible(getShowSpeaker());  } -void LLIMP2PChiclet::setCounter(S32 counter) -{ -	mCounterCtrl->setCounter(counter); -	setShowNewMessagesIcon(counter); -} -  void LLIMP2PChiclet::initSpeakerControl()  {  	mSpeakerCtrl->setSpeakerId(getOtherParticipantId()); @@ -720,6 +774,7 @@ LLAdHocChiclet::Params::Params()  	unread_notifications.v_pad(5);  	unread_notifications.text_color(LLColor4::white);  	unread_notifications.mouse_opaque(false); +	unread_notifications.rect(COUNTER_RECT);  	unread_notifications.visible(false); @@ -794,12 +849,6 @@ void LLAdHocChiclet::switchToCurrentSpeaker()  	mSpeakerCtrl->setSpeakerId(speaker_id);  } -void LLAdHocChiclet::setCounter(S32 counter) -{ -	mCounterCtrl->setCounter(counter); -	setShowNewMessagesIcon(counter); -} -  void LLAdHocChiclet::createPopupMenu()  {  	if(mPopupMenu) @@ -871,6 +920,7 @@ LLIMGroupChiclet::Params::Params()  	unread_notifications.font_halign(LLFontGL::HCENTER);  	unread_notifications.v_pad(5);  	unread_notifications.text_color(LLColor4::white); +	unread_notifications.rect(COUNTER_RECT);  	unread_notifications.visible(false);  	speaker.name("speaker"); @@ -911,12 +961,6 @@ LLIMGroupChiclet::~LLIMGroupChiclet()  	LLGroupMgr::getInstance()->removeObserver(this);  } -void LLIMGroupChiclet::setCounter(S32 counter) -{ -	mCounterCtrl->setCounter(counter); -	setShowNewMessagesIcon(counter); -} -  void LLIMGroupChiclet::draw()  {  	switchToCurrentSpeaker(); @@ -1608,11 +1652,16 @@ S32 LLChicletPanel::getTotalUnreadIMCount()  //////////////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////////////  ////////////////////////////////////////////////////////////////////////// +LLChicletNotificationCounterCtrl::Params::Params() +: max_displayed_count("max_displayed_count", MAX_DISPLAYED_COUNT) +{ +}  LLChicletNotificationCounterCtrl::LLChicletNotificationCounterCtrl(const Params& p)   : LLTextBox(p)   , mCounter(0)   , mInitialWidth(0) + , mMaxDisplayedCount(p.max_displayed_count)  {  	mInitialWidth = getRect().getWidth();  } @@ -1621,11 +1670,21 @@ void LLChicletNotificationCounterCtrl::setCounter(S32 counter)  {  	mCounter = counter; -	std::stringstream stream; -	stream << getCounter(); +	// note same code in LLSysWellChiclet::setCounter(S32 counter) +	std::string s_count; +	if(counter != 0) +	{ +		static std::string more_messages_exist("+"); +		std::string more_messages(counter > mMaxDisplayedCount ? more_messages_exist : ""); +		s_count = llformat("%d%s" +			, llmin(counter, mMaxDisplayedCount) +			, more_messages.c_str() +			); +	} +  	if(mCounter != 0)  	{ -		setText(stream.str()); +		setText(s_count);  	}  	else  	{ diff --git a/indra/newview/llchiclet.h b/indra/newview/llchiclet.h index d8f641d0f9..529586abb3 100644 --- a/indra/newview/llchiclet.h +++ b/indra/newview/llchiclet.h @@ -52,10 +52,19 @@ class LLChicletNotificationCounterCtrl : public LLTextBox  {  public: +	static const S32 MAX_DISPLAYED_COUNT = 99; +  	struct Params :	public LLInitParam::Block<Params, LLTextBox::Params>  	{ -		Params() -		{}; +		/** +		* Contains maximum displayed count of unread messages. Default value is 9. +		* +		* If count is less than "max_unread_count" will be displayed as is. +		* Otherwise 9+ will be shown (for default value). +		*/ +		Optional<S32> max_displayed_count; + +		Params();  	};  	/** @@ -93,6 +102,7 @@ private:  	S32 mCounter;  	S32 mInitialWidth; +	S32 mMaxDisplayedCount;  };  /** @@ -359,6 +369,32 @@ public:  	virtual void toggleSpeakerControl();  	/** +	* Sets number of unread messages. Will update chiclet's width if number text  +	* exceeds size of counter and notify it's parent about size change. +	*/ +	virtual void setCounter(S32); + +	/** +	* Enables/disables the counter control for a chiclet. +	*/ +	virtual void enableCounterControl(bool enable); + +	/** +	* Sets show counter state. +	*/ +	virtual void setShowCounter(bool show); + +	/** +	* Shows/Hides for counter control for a chiclet. +	*/ +	virtual void toggleCounterControl(); + +	/** +	* Sets required width for a chiclet according to visible controls. +	*/ +	virtual void setRequiredWidth(); + +	/**  	 * Shows/hides overlay icon concerning new unread messages.  	 */  	virtual void setShowNewMessagesIcon(bool show); @@ -400,6 +436,7 @@ protected:  protected:  	bool mShowSpeaker; +	bool mCounterEnabled;  	LLIconCtrl* mNewMessagesIcon;  	LLChicletNotificationCounterCtrl* mCounterCtrl; @@ -453,12 +490,6 @@ public:  	/* virtual */ void setOtherParticipantId(const LLUUID& other_participant_id);  	/** -	 * Sets number of unread messages. Will update chiclet's width if number text  -	 * exceeds size of counter and notify it's parent about size change. -	 */ -	/*virtual*/ void setCounter(S32); - -	/**  	 * Init Speaker Control with speaker's ID  	 */  	/*virtual*/ void initSpeakerControl(); @@ -527,12 +558,6 @@ public:  	/*virtual*/ void setSessionId(const LLUUID& session_id);  	/** -	 * Sets number of unread messages. Will update chiclet's width if number text  -	 * exceeds size of counter and notify it's parent about size change. -	 */ -	/*virtual*/ void setCounter(S32); - -	/**  	 * Keep Speaker Control with actual speaker's ID  	 */  	/*virtual*/ void draw(); @@ -695,12 +720,6 @@ public:  	/*virtual*/ void changed(LLGroupChange gc);  	/** -	 * Sets number of unread messages. Will update chiclet's width if number text  -	 * exceeds size of counter and notify it's parent about size change. -	 */ -	/*virtual*/ void setCounter(S32); - -	/**  	 * Init Speaker Control with speaker's ID  	 */  	/*virtual*/ void initSpeakerControl(); diff --git a/indra/newview/llsyswellwindow.cpp b/indra/newview/llsyswellwindow.cpp index 7bff06e9a3..1aeafaea5a 100644 --- a/indra/newview/llsyswellwindow.cpp +++ b/indra/newview/llsyswellwindow.cpp @@ -350,6 +350,8 @@ LLIMWellWindow::RowPanel::RowPanel(const LLSysWellWindow* parent, const LLUUID&  	}  	// Initialize chiclet. +	mChiclet->setChicletSizeChangedCallback(boost::bind(&LLIMWellWindow::RowPanel::onChicletSizeChanged, this, mChiclet, _2)); +	mChiclet->enableCounterControl(true);  	mChiclet->setCounter(chicletCounter);  	mChiclet->setSessionId(sessionId);  	mChiclet->setIMSessionName(name); @@ -364,6 +366,16 @@ LLIMWellWindow::RowPanel::RowPanel(const LLSysWellWindow* parent, const LLUUID&  }  //--------------------------------------------------------------------------------- +void LLIMWellWindow::RowPanel::onChicletSizeChanged(LLChiclet* ctrl, const LLSD& param) +{ +	LLTextBox* text = getChild<LLTextBox>("contact_name"); +	S32 new_text_left = mChiclet->getRect().mRight + CHICLET_HPAD; +	LLRect text_rect = text->getRect();  +	text_rect.mLeft = new_text_left; +	text->setRect(text_rect); +} + +//---------------------------------------------------------------------------------  LLIMWellWindow::RowPanel::~RowPanel()  {  } diff --git a/indra/newview/llsyswellwindow.h b/indra/newview/llsyswellwindow.h index 5f2c2ba501..0b95c8decd 100644 --- a/indra/newview/llsyswellwindow.h +++ b/indra/newview/llsyswellwindow.h @@ -223,6 +223,8 @@ private:  		void onMouseLeave(S32 x, S32 y, MASK mask);  		BOOL handleMouseDown(S32 x, S32 y, MASK mask);  	private: +		static const S32 CHICLET_HPAD = 10; +		void onChicletSizeChanged(LLChiclet* ctrl, const LLSD& param);  		void onClosePanel();  	public:  		LLIMChiclet* mChiclet; diff --git a/indra/newview/skins/default/xui/en/panel_activeim_row.xml b/indra/newview/skins/default/xui/en/panel_activeim_row.xml index 3ed91cb48f..3416b2369d 100644 --- a/indra/newview/skins/default/xui/en/panel_activeim_row.xml +++ b/indra/newview/skins/default/xui/en/panel_activeim_row.xml @@ -69,9 +69,9 @@  		name="contact_name"  		layout="topleft"  		top="10" -		left_pad="20" +		left_pad="10"  		height="14" -		width="245" +		width="255"  		length="1"  		follows="right|left"  		use_ellipses="true" | 
