summaryrefslogtreecommitdiff
path: root/indra/newview/llchiclet.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llchiclet.cpp')
-rw-r--r--indra/newview/llchiclet.cpp125
1 files changed, 92 insertions, 33 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
{