diff options
author | callum <none@none> | 2009-12-28 13:45:57 -0800 |
---|---|---|
committer | callum <none@none> | 2009-12-28 13:45:57 -0800 |
commit | 3519435bbfeec4c838d5ffbe008d0ac7bbc085a8 (patch) | |
tree | 5d590d84a1fa6c8414adba0732a83a67a440dd37 /indra/newview/llchiclet.cpp | |
parent | dd1fb1568e85a8e3622372cae21bcd3205051718 (diff) | |
parent | 6008bf61b2d0475a274ad2b851b61e69496b5bf8 (diff) |
Merge with (specific revision) and head
Diffstat (limited to 'indra/newview/llchiclet.cpp')
-rw-r--r-- | indra/newview/llchiclet.cpp | 247 |
1 files changed, 96 insertions, 151 deletions
diff --git a/indra/newview/llchiclet.cpp b/indra/newview/llchiclet.cpp index 17ef1f41a4..c01202bb82 100644 --- a/indra/newview/llchiclet.cpp +++ b/indra/newview/llchiclet.cpp @@ -64,18 +64,6 @@ static LLDefaultChildRegistry::Register<LLAdHocChiclet> t5("chiclet_im_adhoc"); static LLDefaultChildRegistry::Register<LLScriptChiclet> t6("chiclet_script"); 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(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 const S32 SCROLL_BUTTON_PAD = 5; - -// static -const S32 LLChicletPanel::s_scroll_ratio = 10; -const S32 LLChicletNotificationCounterCtrl::MAX_DISPLAYED_COUNT = 99; - - boost::signals2::signal<LLChiclet* (const LLUUID&), LLIMChiclet::CollectChicletCombiner<std::list<LLChiclet*> > > LLIMChiclet::sFindChicletsSignal; @@ -173,6 +161,9 @@ LLSysWellChiclet::~LLSysWellChiclet() void LLSysWellChiclet::setCounter(S32 counter) { + // do nothing if the same counter is coming. EXT-3678. + if (counter == mCounter) return; + // note same code in LLChicletNotificationCounterCtrl::setCounter(S32 counter) std::string s_count; if(counter != 0) @@ -388,9 +379,9 @@ void LLNotificationChiclet::createMenu() ////////////////////////////////////////////////////////////////////////// LLChiclet::Params::Params() - : show_counter("show_counter") + : show_counter("show_counter", true) + , enable_counter("enable_counter", false) { - show_counter = true; } LLChiclet::LLChiclet(const Params& p) @@ -448,26 +439,12 @@ void LLChiclet::setValue(const LLSD& value) LLIMChiclet::LLIMChiclet(const LLIMChiclet::Params& p) : LLChiclet(p) , mShowSpeaker(false) +, mDefaultWidth(p.rect().getWidth()) , mNewMessagesIcon(NULL) , mSpeakerCtrl(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); - addChild(mNewMessagesIcon); - - // adjust size and position of an icon - LLRect chiclet_rect = p.rect; - LLRect overlay_icon_rect = LLRect(chiclet_rect.getWidth()/2, chiclet_rect.getHeight(), chiclet_rect.getWidth(), chiclet_rect.getHeight()/2); - mNewMessagesIcon->setRect(overlay_icon_rect); - - // 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); - - enableCounterControl(false); + enableCounterControl(p.enable_counter); } void LLIMChiclet::setShowSpeaker(bool show) @@ -477,7 +454,6 @@ void LLIMChiclet::setShowSpeaker(bool show) { mShowSpeaker = show; toggleSpeakerControl(); - onChicletSizeChanged(); } } @@ -502,7 +478,6 @@ void LLIMChiclet::setShowCounter(bool show) { LLChiclet::setShowCounter(show); toggleCounterControl(); - onChicletSizeChanged(); } } @@ -515,32 +490,37 @@ void LLIMChiclet::setRequiredWidth() { bool show_speaker = getShowSpeaker(); bool show_counter = getShowCounter(); - S32 required_width = CHICLET_RECT.getWidth(); + S32 required_width = mDefaultWidth; if (show_counter) { - required_width += COUNTER_RECT.getWidth(); + required_width += mCounterCtrl->getRect().getWidth(); } if (show_speaker) { - required_width += VOICE_INDICATOR_RECT.getWidth(); + required_width += mSpeakerCtrl->getRect().getWidth(); } reshape(required_width, getRect().getHeight()); + + onChicletSizeChanged(); } void LLIMChiclet::toggleSpeakerControl() { if(getShowSpeaker()) { + // move speaker to the right of chiclet icon + LLRect speaker_rc = mSpeakerCtrl->getRect(); + speaker_rc.setLeftTopAndSize(mDefaultWidth, speaker_rc.mTop, speaker_rc.getWidth(), speaker_rc.getHeight()); + mSpeakerCtrl->setRect(speaker_rc); + if(getShowCounter()) { - mSpeakerCtrl->setRect(VOICE_INDICATOR_RECT); - } - else - { - mSpeakerCtrl->setRect(COUNTER_RECT); + // move speaker to the right of counter + mSpeakerCtrl->translate(mCounterCtrl->getRect().getWidth(), 0); } + initSpeakerControl(); } @@ -567,6 +547,7 @@ void LLIMChiclet::setShowNewMessagesIcon(bool show) { mNewMessagesIcon->setVisible(show); } + setRequiredWidth(); } bool LLIMChiclet::getShowNewMessagesIcon() @@ -640,36 +621,9 @@ LLIMP2PChiclet::Params::Params() : avatar_icon("avatar_icon") , unread_notifications("unread_notifications") , speaker("speaker") +, new_message_icon("new_message_icon") , show_speaker("show_speaker") { - // *TODO Vadim: Get rid of hardcoded values. - rect(CHICLET_RECT); - - avatar_icon.name("avatar_icon"); - avatar_icon.follows.flags(FOLLOWS_LEFT | FOLLOWS_TOP | FOLLOWS_BOTTOM); - - // *NOTE dzaporozhan - // Changed icon height from 25 to 24 to fix ticket EXT-794. - // In some cases(after changing UI scale) 25 pixel height icon was - // drawn incorrectly, i'm not sure why. - avatar_icon.rect(CHICLET_ICON_RECT); - avatar_icon.mouse_opaque(false); - - unread_notifications.name("unread"); - unread_notifications.font(LLFontGL::getFontSansSerif()); - unread_notifications.font_halign(LLFontGL::HCENTER); - 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"); - speaker.rect(VOICE_INDICATOR_RECT); - speaker.auto_update(true); - speaker.draw_border(false); - - show_speaker = false; } LLIMP2PChiclet::LLIMP2PChiclet(const Params& p) @@ -677,6 +631,10 @@ LLIMP2PChiclet::LLIMP2PChiclet(const Params& p) , mChicletIconCtrl(NULL) , mPopupMenu(NULL) { + LLIconCtrl::Params new_msg_params = p.new_message_icon; + mNewMessagesIcon = LLUICtrlFactory::create<LLIconCtrl>(new_msg_params); + addChild(mNewMessagesIcon); + LLChicletAvatarIconCtrl::Params avatar_params = p.avatar_icon; mChicletIconCtrl = LLUICtrlFactory::create<LLChicletAvatarIconCtrl>(avatar_params); addChild(mChicletIconCtrl); @@ -694,10 +652,6 @@ LLIMP2PChiclet::LLIMP2PChiclet(const Params& p) sendChildToFront(mNewMessagesIcon); setShowSpeaker(p.show_speaker); - - //since mShowSpeaker initialized with false - //setShowSpeaker(false) will not hide mSpeakerCtrl - mSpeakerCtrl->setVisible(getShowSpeaker()); } void LLIMP2PChiclet::initSpeakerControl() @@ -718,8 +672,11 @@ void LLIMP2PChiclet::updateMenuItems() if(getSessionId().isNull()) return; + LLIMFloater* open_im_floater = LLIMFloater::findInstance(getSessionId()); + bool open_window_exists = open_im_floater && open_im_floater->getVisible(); + mPopupMenu->getChild<LLUICtrl>("Send IM")->setEnabled(!open_window_exists); + bool is_friend = LLAvatarActions::isFriend(getOtherParticipantId()); - mPopupMenu->getChild<LLUICtrl>("Add Friend")->setEnabled(!is_friend); } @@ -790,38 +747,10 @@ LLAdHocChiclet::Params::Params() : avatar_icon("avatar_icon") , unread_notifications("unread_notifications") , speaker("speaker") +, new_message_icon("new_message_icon") , show_speaker("show_speaker") , avatar_icon_color("avatar_icon_color", LLColor4::green) { - // *TODO Vadim: Get rid of hardcoded values. - rect(CHICLET_RECT); - - avatar_icon.name("avatar_icon"); - avatar_icon.follows.flags(FOLLOWS_LEFT | FOLLOWS_TOP | FOLLOWS_BOTTOM); - - // *NOTE dzaporozhan - // Changed icon height from 25 to 24 to fix ticket EXT-794. - // In some cases(after changing UI scale) 25 pixel height icon was - // drawn incorrectly, i'm not sure why. - avatar_icon.rect(CHICLET_ICON_RECT); - avatar_icon.mouse_opaque(false); - - unread_notifications.name("unread"); - unread_notifications.font(LLFontGL::getFontSansSerif()); - unread_notifications.font_halign(LLFontGL::HCENTER); - 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"); - speaker.rect(VOICE_INDICATOR_RECT); - speaker.auto_update(true); - speaker.draw_border(false); - - show_speaker = false; } LLAdHocChiclet::LLAdHocChiclet(const Params& p) @@ -829,6 +758,10 @@ LLAdHocChiclet::LLAdHocChiclet(const Params& p) , mChicletIconCtrl(NULL) , mPopupMenu(NULL) { + LLIconCtrl::Params new_msg_params = p.new_message_icon; + mNewMessagesIcon = LLUICtrlFactory::create<LLIconCtrl>(new_msg_params); + addChild(mNewMessagesIcon); + LLChicletAvatarIconCtrl::Params avatar_params = p.avatar_icon; mChicletIconCtrl = LLUICtrlFactory::create<LLChicletAvatarIconCtrl>(avatar_params); //Make the avatar modified @@ -941,32 +874,9 @@ LLIMGroupChiclet::Params::Params() : group_icon("group_icon") , unread_notifications("unread_notifications") , speaker("speaker") +, new_message_icon("new_message_icon") , show_speaker("show_speaker") { - rect(CHICLET_RECT); - - group_icon.name("group_icon"); - - // *NOTE dzaporozhan - // Changed icon height from 25 to 24 to fix ticket EXT-794. - // In some cases(after changing UI scale) 25 pixel height icon was - // drawn incorrectly, i'm not sure why. - group_icon.rect(CHICLET_ICON_RECT); - - unread_notifications.name("unread"); - unread_notifications.font(LLFontGL::getFontSansSerif()); - 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"); - speaker.rect(VOICE_INDICATOR_RECT); - speaker.auto_update(true); - speaker.draw_border(false); - - show_speaker = false; } LLIMGroupChiclet::LLIMGroupChiclet(const Params& p) @@ -975,6 +885,10 @@ LLIMGroupChiclet::LLIMGroupChiclet(const Params& p) , mChicletIconCtrl(NULL) , mPopupMenu(NULL) { + LLIconCtrl::Params new_msg_params = p.new_message_icon; + mNewMessagesIcon = LLUICtrlFactory::create<LLIconCtrl>(new_msg_params); + addChild(mNewMessagesIcon); + LLChicletGroupIconCtrl::Params avatar_params = p.group_icon; mChicletIconCtrl = LLUICtrlFactory::create<LLChicletGroupIconCtrl>(avatar_params); addChild(mChicletIconCtrl); @@ -1063,6 +977,18 @@ void LLIMGroupChiclet::changed(LLGroupChange gc) } } +void LLIMGroupChiclet::updateMenuItems() +{ + if(!mPopupMenu) + return; + if(getSessionId().isNull()) + return; + + LLIMFloater* open_im_floater = LLIMFloater::findInstance(getSessionId()); + bool open_window_exists = open_im_floater && open_im_floater->getVisible(); + mPopupMenu->getChild<LLUICtrl>("Chat")->setEnabled(!open_window_exists); +} + BOOL LLIMGroupChiclet::handleRightMouseDown(S32 x, S32 y, MASK mask) { if(!mPopupMenu) @@ -1072,6 +998,7 @@ BOOL LLIMGroupChiclet::handleRightMouseDown(S32 x, S32 y, MASK mask) if (mPopupMenu) { + updateMenuItems(); mPopupMenu->arrangeAndClear(); LLMenuGL::showPopup(this, mPopupMenu, x, y); } @@ -1125,16 +1052,10 @@ void LLIMGroupChiclet::onMenuItemClicked(const LLSD& user_data) LLChicletPanel::Params::Params() : chiclet_padding("chiclet_padding") , scrolling_offset("scrolling_offset") +, scroll_button_hpad("scroll_button_hpad") +, scroll_ratio("scroll_ratio") , min_width("min_width") { - chiclet_padding = 3; - scrolling_offset = 40; - - if (!min_width.isProvided()) - { - // min_width = 4 chiclets + 3 paddings - min_width = 180 + 3*chiclet_padding; - } }; LLChicletPanel::LLChicletPanel(const Params&p) @@ -1144,6 +1065,8 @@ LLChicletPanel::LLChicletPanel(const Params&p) , mRightScrollButton(NULL) , mChicletPadding(p.chiclet_padding) , mScrollingOffset(p.scrolling_offset) +, mScrollButtonHPad(p.scroll_button_hpad) +, mScrollRatio(p.scroll_ratio) , mMinWidth(p.min_width) , mShowControls(true) { @@ -1445,8 +1368,8 @@ void LLChicletPanel::reshape(S32 width, S32 height, BOOL called_from_parent ) bool need_show_scroll = needShowScroll(); if(need_show_scroll) { - mScrollArea->setRect(LLRect(scroll_button_rect.getWidth() + SCROLL_BUTTON_PAD, - height, width - scroll_button_rect.getWidth() - SCROLL_BUTTON_PAD, 0)); + mScrollArea->setRect(LLRect(scroll_button_rect.getWidth() + mScrollButtonHPad, + height, width - scroll_button_rect.getWidth() - mScrollButtonHPad, 0)); } else { @@ -1462,6 +1385,20 @@ void LLChicletPanel::reshape(S32 width, S32 height, BOOL called_from_parent ) } +S32 LLChicletPanel::notifyParent(const LLSD& info) +{ + if(info.has("notification")) + { + std::string str_notification = info["notification"]; + if(str_notification == "size_changes") + { + arrange(); + return 1; + } + } + return LLPanel::notifyParent(info); +} + void LLChicletPanel::arrange() { if(mChicletList.empty()) @@ -1490,8 +1427,8 @@ void LLChicletPanel::arrange() bool need_show_scroll = needShowScroll(); if(need_show_scroll) { - mScrollArea->setRect(LLRect(scroll_button_rect.getWidth() + SCROLL_BUTTON_PAD, - rect.getHeight(), rect.getWidth() - scroll_button_rect.getWidth() - SCROLL_BUTTON_PAD, 0)); + mScrollArea->setRect(LLRect(scroll_button_rect.getWidth() + mScrollButtonHPad, + rect.getHeight(), rect.getWidth() - scroll_button_rect.getWidth() - mScrollButtonHPad, 0)); } else { @@ -1655,7 +1592,7 @@ void LLChicletPanel::onRightScrollClick() void LLChicletPanel::onLeftScrollHeldDown() { S32 offset = mScrollingOffset; - mScrollingOffset = mScrollingOffset / s_scroll_ratio; + mScrollingOffset = mScrollingOffset / mScrollRatio; scrollLeft(); mScrollingOffset = offset; } @@ -1663,7 +1600,7 @@ void LLChicletPanel::onLeftScrollHeldDown() void LLChicletPanel::onRightScrollHeldDown() { S32 offset = mScrollingOffset; - mScrollingOffset = mScrollingOffset / s_scroll_ratio; + mScrollingOffset = mScrollingOffset / mScrollRatio; scrollRight(); mScrollingOffset = offset; } @@ -1725,7 +1662,7 @@ S32 LLChicletPanel::getTotalUnreadIMCount() ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// LLChicletNotificationCounterCtrl::Params::Params() -: max_displayed_count("max_displayed_count", MAX_DISPLAYED_COUNT) +: max_displayed_count("max_displayed_count", 99) { } @@ -1802,6 +1739,7 @@ LLChicletGroupIconCtrl::LLChicletGroupIconCtrl(const Params& p) : LLIconCtrl(p) , mDefaultIcon(p.default_icon) { + setValue(LLUUID::null); } void LLChicletGroupIconCtrl::setValue(const LLSD& value ) @@ -1853,20 +1791,23 @@ LLChicletSpeakerCtrl::LLChicletSpeakerCtrl(const Params&p) LLScriptChiclet::Params::Params() : icon("icon") + , new_message_icon("new_message_icon") { - // *TODO Vadim: Get rid of hardcoded values. - rect(CHICLET_RECT); - icon.rect(CHICLET_ICON_RECT); } LLScriptChiclet::LLScriptChiclet(const Params&p) : LLIMChiclet(p) , mChicletIconCtrl(NULL) { + LLIconCtrl::Params new_msg_params = p.new_message_icon; + mNewMessagesIcon = LLUICtrlFactory::create<LLIconCtrl>(new_msg_params); + addChild(mNewMessagesIcon); + LLIconCtrl::Params icon_params = p.icon; mChicletIconCtrl = LLUICtrlFactory::create<LLIconCtrl>(icon_params); - // Let "new message" icon be on top, else it will be hidden behind chiclet icon. - addChildInBack(mChicletIconCtrl); + addChild(mChicletIconCtrl); + + sendChildToFront(mNewMessagesIcon); } void LLScriptChiclet::setSessionId(const LLUUID& session_id) @@ -1905,20 +1846,24 @@ BOOL LLScriptChiclet::handleMouseDown(S32 x, S32 y, MASK mask) static const std::string INVENTORY_USER_OFFER ("UserGiveItem"); LLInvOfferChiclet::Params::Params() + : icon("icon") + , new_message_icon("new_message_icon") { - // *TODO Vadim: Get rid of hardcoded values. - rect(CHICLET_RECT); - icon.rect(CHICLET_ICON_RECT); } LLInvOfferChiclet::LLInvOfferChiclet(const Params&p) : LLIMChiclet(p) , mChicletIconCtrl(NULL) { + LLIconCtrl::Params new_msg_params = p.new_message_icon; + mNewMessagesIcon = LLUICtrlFactory::create<LLIconCtrl>(new_msg_params); + addChild(mNewMessagesIcon); + LLChicletInvOfferIconCtrl::Params icon_params = p.icon; mChicletIconCtrl = LLUICtrlFactory::create<LLChicletInvOfferIconCtrl>(icon_params); - // Let "new message" icon be on top, else it will be hidden behind chiclet icon. - addChildInBack(mChicletIconCtrl); + addChild(mChicletIconCtrl); + + sendChildToFront(mNewMessagesIcon); } void LLInvOfferChiclet::setSessionId(const LLUUID& session_id) |