diff options
Diffstat (limited to 'indra/newview/llchiclet.cpp')
-rw-r--r-- | indra/newview/llchiclet.cpp | 111 |
1 files changed, 55 insertions, 56 deletions
diff --git a/indra/newview/llchiclet.cpp b/indra/newview/llchiclet.cpp index a3c0a17186..0f259b885c 100644 --- a/indra/newview/llchiclet.cpp +++ b/indra/newview/llchiclet.cpp @@ -197,9 +197,38 @@ void LLChiclet::setValue(const LLSD& value) ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// -LLIMChiclet::LLIMChiclet(const LLChiclet::Params& p) +LLIMChiclet::LLIMChiclet(const LLIMChiclet::Params& p) : LLChiclet(p) +, mNewMessagesIcon(NULL) +, mCounterCtrl(NULL) { + // initialize an overlay icon for new messages + LLIconCtrl::Params icon_params; + icon_params.visible = false; + icon_params.image = LLUI::getUIImage(p.new_messages_icon_name); + mNewMessagesIcon = LLUICtrlFactory::create<LLIconCtrl>(icon_params); + // adjust size and position of an icon + LLRect chiclet_rect = p.rect; + LLRect overlay_icon_rect = LLRect(chiclet_rect.getWidth()/2, chiclet_rect.mTop, chiclet_rect.mRight, chiclet_rect.getHeight()/2); + // shift an icon a little bit to the right and up corner of a chiclet + overlay_icon_rect.translate(overlay_icon_rect.getWidth()/4, overlay_icon_rect.getHeight()/4); + mNewMessagesIcon->setRect(overlay_icon_rect); + addChild(mNewMessagesIcon); + + setShowCounter(false); +} + +void LLIMChiclet::setShowNewMessagesIcon(bool show) +{ + if(mNewMessagesIcon) + { + mNewMessagesIcon->setVisible(show); + } +} + +bool LLIMChiclet::getShowNewMessagesIcon() +{ + return mNewMessagesIcon->getVisible(); } void LLIMChiclet::onMouseDown() @@ -273,7 +302,7 @@ LLIMP2PChiclet::Params::Params() , show_speaker("show_speaker") { // *TODO Vadim: Get rid of hardcoded values. - rect(LLRect(0, 25, 45, 0)); + rect(LLRect(0, 25, 25, 0)); avatar_icon.name("avatar_icon"); avatar_icon.follows.flags(FOLLOWS_LEFT | FOLLOWS_TOP | FOLLOWS_BOTTOM); @@ -292,6 +321,7 @@ LLIMP2PChiclet::Params::Params() unread_notifications.v_pad(5); unread_notifications.text_color(LLColor4::white); unread_notifications.mouse_opaque(false); + unread_notifications.visible(false); speaker.name("speaker"); speaker.rect(LLRect(45, 25, 65, 0)); @@ -302,7 +332,6 @@ LLIMP2PChiclet::Params::Params() LLIMP2PChiclet::LLIMP2PChiclet(const Params& p) : LLIMChiclet(p) , mChicletIconCtrl(NULL) -, mCounterCtrl(NULL) , mSpeakerCtrl(NULL) , mPopupMenu(NULL) { @@ -321,28 +350,14 @@ LLIMP2PChiclet::LLIMP2PChiclet(const Params& p) mSpeakerCtrl = LLUICtrlFactory::create<LLChicletSpeakerCtrl>(speaker_params); addChild(mSpeakerCtrl); + sendChildToFront(mNewMessagesIcon); setShowSpeaker(p.show_speaker); } void LLIMP2PChiclet::setCounter(S32 counter) { mCounterCtrl->setCounter(counter); - - if(getShowCounter()) - { - LLRect counter_rect = mCounterCtrl->getRect(); - LLRect required_rect = mCounterCtrl->getRequiredRect(); - bool needs_resize = required_rect.getWidth() != counter_rect.getWidth(); - - if(needs_resize) - { - counter_rect.mRight = counter_rect.mLeft + required_rect.getWidth(); - mCounterCtrl->reshape(counter_rect.getWidth(), counter_rect.getHeight()); - mCounterCtrl->setRect(counter_rect); - - onChicletSizeChanged(); - } - } + setShowNewMessagesIcon(counter); } LLRect LLIMP2PChiclet::getRequiredRect() @@ -454,9 +469,10 @@ LLAdHocChiclet::Params::Params() , unread_notifications("unread_notifications") , speaker("speaker") , show_speaker("show_speaker") +, avatar_icon_color("avatar_icon_color", LLColor4::green) { // *TODO Vadim: Get rid of hardcoded values. - rect(LLRect(0, 25, 45, 0)); + rect(LLRect(0, 25, 25, 0)); avatar_icon.name("avatar_icon"); avatar_icon.follows.flags(FOLLOWS_LEFT | FOLLOWS_TOP | FOLLOWS_BOTTOM); @@ -475,6 +491,8 @@ LLAdHocChiclet::Params::Params() unread_notifications.v_pad(5); unread_notifications.text_color(LLColor4::white); unread_notifications.mouse_opaque(false); + unread_notifications.visible(false); + speaker.name("speaker"); speaker.rect(LLRect(45, 25, 65, 0)); @@ -485,12 +503,13 @@ LLAdHocChiclet::Params::Params() LLAdHocChiclet::LLAdHocChiclet(const Params& p) : LLIMChiclet(p) , mChicletIconCtrl(NULL) -, mCounterCtrl(NULL) , mSpeakerCtrl(NULL) , mPopupMenu(NULL) { LLChicletAvatarIconCtrl::Params avatar_params = p.avatar_icon; mChicletIconCtrl = LLUICtrlFactory::create<LLChicletAvatarIconCtrl>(avatar_params); + //Make the avatar modified + mChicletIconCtrl->setColor(p.avatar_icon_color); addChild(mChicletIconCtrl); LLChicletNotificationCounterCtrl::Params unread_params = p.unread_notifications; @@ -504,6 +523,7 @@ LLAdHocChiclet::LLAdHocChiclet(const Params& p) mSpeakerCtrl = LLUICtrlFactory::create<LLChicletSpeakerCtrl>(speaker_params); addChild(mSpeakerCtrl); + sendChildToFront(mNewMessagesIcon); setShowSpeaker(p.show_speaker); } @@ -517,22 +537,7 @@ void LLAdHocChiclet::setSessionId(const LLUUID& session_id) void LLAdHocChiclet::setCounter(S32 counter) { mCounterCtrl->setCounter(counter); - - if(getShowCounter()) - { - LLRect counter_rect = mCounterCtrl->getRect(); - LLRect required_rect = mCounterCtrl->getRequiredRect(); - bool needs_resize = required_rect.getWidth() != counter_rect.getWidth(); - - if(needs_resize) - { - counter_rect.mRight = counter_rect.mLeft + required_rect.getWidth(); - mCounterCtrl->reshape(counter_rect.getWidth(), counter_rect.getHeight()); - mCounterCtrl->setRect(counter_rect); - - onChicletSizeChanged(); - } - } + setShowNewMessagesIcon(counter); } LLRect LLAdHocChiclet::getRequiredRect() @@ -561,7 +566,7 @@ BOOL LLAdHocChiclet::handleRightMouseDown(S32 x, S32 y, MASK mask) LLIMGroupChiclet::Params::Params() : group_icon("group_icon") { - rect(LLRect(0, 25, 45, 0)); + rect(LLRect(0, 25, 25, 0)); group_icon.name("group_icon"); @@ -577,6 +582,7 @@ LLIMGroupChiclet::Params::Params() unread_notifications.font_halign(LLFontGL::HCENTER); unread_notifications.v_pad(5); unread_notifications.text_color(LLColor4::white); + unread_notifications.visible(false); speaker.name("speaker"); speaker.rect(LLRect(45, 25, 65, 0)); @@ -588,7 +594,6 @@ LLIMGroupChiclet::LLIMGroupChiclet(const Params& p) : LLIMChiclet(p) , LLGroupMgrObserver(LLUUID::null) , mChicletIconCtrl(NULL) -, mCounterCtrl(NULL) , mSpeakerCtrl(NULL) , mPopupMenu(NULL) { @@ -607,6 +612,7 @@ LLIMGroupChiclet::LLIMGroupChiclet(const Params& p) mSpeakerCtrl = LLUICtrlFactory::create<LLChicletSpeakerCtrl>(speaker_params); addChild(mSpeakerCtrl); + sendChildToFront(mNewMessagesIcon); setShowSpeaker(p.show_speaker); } @@ -618,22 +624,7 @@ LLIMGroupChiclet::~LLIMGroupChiclet() void LLIMGroupChiclet::setCounter(S32 counter) { mCounterCtrl->setCounter(counter); - - if(getShowCounter()) - { - LLRect counter_rect = mCounterCtrl->getRect(); - LLRect required_rect = mCounterCtrl->getRequiredRect(); - bool needs_resize = required_rect.getWidth() != counter_rect.getWidth(); - - if(needs_resize) - { - counter_rect.mRight = counter_rect.mLeft + required_rect.getWidth(); - mCounterCtrl->reshape(counter_rect.getWidth(), counter_rect.getHeight()); - mCounterCtrl->setRect(counter_rect); - - onChicletSizeChanged(); - } - } + setShowNewMessagesIcon(counter); } LLRect LLIMGroupChiclet::getRequiredRect() @@ -829,13 +820,21 @@ LLChicletPanel::~LLChicletPanel() void im_chiclet_callback(LLChicletPanel* panel, const LLSD& data){ LLUUID session_id = data["session_id"].asUUID(); + S32 unread = data["num_unread"].asInteger(); + + LLIMFloater* im_floater = LLIMFloater::findInstance(session_id); + if (im_floater && im_floater->getVisible()) + { + unread = 0; + } + std::list<LLChiclet*> chiclets = LLIMChiclet::sFindChicletsSignal(session_id); std::list<LLChiclet *>::iterator iter; for (iter = chiclets.begin(); iter != chiclets.end(); iter++) { LLChiclet* chiclet = *iter; if (chiclet != NULL) { - chiclet->setCounter(data["num_unread"].asInteger()); + chiclet->setCounter(unread); } else { |