diff options
author | Steven Bennetts <steve@lindenlab.com> | 2009-10-22 00:21:18 +0000 |
---|---|---|
committer | Steven Bennetts <steve@lindenlab.com> | 2009-10-22 00:21:18 +0000 |
commit | 0041d485b1c5a1b18c9d5b2ae016f2c1e5ea6b8e (patch) | |
tree | e69610d38613885aa123c2744dd07db581a810d2 /indra/newview/llnearbychat.cpp | |
parent | 67c4555a3793850ca8a8142b1e3e72c90d5001f4 (diff) |
Merging revisions 2129-2144 of https://svn.aws.productengine.com/secondlife/pe/stable-2 into P:\svn\viewer-2.0.0-3, respecting ancestry
* Bugs: EXT-1293 EXT-1611 EXT-1613 EXT-1176 EXT-1724 EXT-1186 EXT-1662 EXT-1760 EXT-1720
* Dev: EXT-1575 EXT-1770 EXT-1232 EXT-1234
Diffstat (limited to 'indra/newview/llnearbychat.cpp')
-rw-r--r-- | indra/newview/llnearbychat.cpp | 269 |
1 files changed, 32 insertions, 237 deletions
diff --git a/indra/newview/llnearbychat.cpp b/indra/newview/llnearbychat.cpp index 7160cce5cb..6e90d22d89 100644 --- a/indra/newview/llnearbychat.cpp +++ b/indra/newview/llnearbychat.cpp @@ -54,17 +54,15 @@ #include "llstylemap.h" #include "lldraghandle.h" - +#include "lltrans.h" static const S32 RESIZE_BAR_THICKNESS = 3; LLNearbyChat::LLNearbyChat(const LLSD& key) : - LLFloater(key), - mEChatTearofState(CHAT_PINNED), - mChatCaptionPanel(NULL), - mChatHistory(NULL) + LLFloater(key) + ,mChatHistory(NULL) { - m_isDirty = false; + } LLNearbyChat::~LLNearbyChat() @@ -73,25 +71,6 @@ LLNearbyChat::~LLNearbyChat() BOOL LLNearbyChat::postBuild() { - //resize bars - setCanResize(true); - - mResizeBar[LLResizeBar::BOTTOM]->setVisible(false); - mResizeBar[LLResizeBar::LEFT]->setVisible(false); - mResizeBar[LLResizeBar::RIGHT]->setVisible(false); - - mResizeBar[LLResizeBar::BOTTOM]->setResizeLimits(120,500); - mResizeBar[LLResizeBar::TOP]->setResizeLimits(120,500); - mResizeBar[LLResizeBar::LEFT]->setResizeLimits(220,600); - mResizeBar[LLResizeBar::RIGHT]->setResizeLimits(220,600); - - mResizeHandle[0]->setVisible(false); - mResizeHandle[1]->setVisible(false); - mResizeHandle[2]->setVisible(false); - mResizeHandle[3]->setVisible(false); - - getDragHandle()->setVisible(false); - //menu LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar; LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable_registrar; @@ -101,17 +80,15 @@ BOOL LLNearbyChat::postBuild() LLMenuGL* menu = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>("menu_nearby_chat.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); - if(menu) mPopupMenuHandle = menu->getHandle(); gSavedSettings.declareS32("nearbychat_showicons_and_names",2,"NearByChat header settings",true); - mChatCaptionPanel = getChild<LLPanel>("chat_caption", false); mChatHistory = getChild<LLChatHistory>("chat_history"); - reshape(getRect().getWidth(), getRect().getHeight(), FALSE); - + setCanResize(true); + return LLFloater::postBuild(); } @@ -181,6 +158,22 @@ LLColor4 nearbychat_get_text_color(const LLChat& chat) return text_color; } +std::string formatCurrentTime() +{ + time_t utc_time; + utc_time = time_corrected(); + std::string timeStr ="["+ LLTrans::getString("TimeHour")+"]:[" + +LLTrans::getString("TimeMin")+"] "; + + LLSD substitution; + + substitution["datetime"] = (S32) utc_time; + LLStringUtil::format (timeStr, substitution); + + return timeStr; +} + + void LLNearbyChat::add_timestamped_line(const LLChat& chat, const LLColor4& color) { S32 font_size = gSavedSettings.getS32("ChatFontSize"); @@ -205,7 +198,7 @@ void LLNearbyChat::add_timestamped_line(const LLChat& chat, const LLColor4& colo style_params.font(fontp); LLUUID uuid = chat.mFromID; std::string from = chat.mFromName; - std::string time = ""; + std::string time = formatCurrentTime(); std::string message = chat.mText; mChatHistory->appendWidgetMessage(uuid, from, time, message, style_params); } @@ -239,193 +232,6 @@ void LLNearbyChat::onNearbySpeakers() LLSideTray::getInstance()->showPanel("panel_people",param); } -void LLNearbyChat::onTearOff() -{ - if(mEChatTearofState == CHAT_PINNED) - float_panel(); - else - pinn_panel(); -} - -void LLNearbyChat::reshape(S32 width, S32 height, BOOL called_from_parent) -{ - - LLFloater::reshape(width, height, called_from_parent); - - LLRect resize_rect; - resize_rect.setLeftTopAndSize( 0, height, width, RESIZE_BAR_THICKNESS); - if (mResizeBar[LLResizeBar::TOP]) - { - mResizeBar[LLResizeBar::TOP]->reshape(width,RESIZE_BAR_THICKNESS); - mResizeBar[LLResizeBar::TOP]->setRect(resize_rect); - } - - resize_rect.setLeftTopAndSize( 0, RESIZE_BAR_THICKNESS, width, RESIZE_BAR_THICKNESS); - if (mResizeBar[LLResizeBar::BOTTOM]) - { - mResizeBar[LLResizeBar::BOTTOM]->reshape(width,RESIZE_BAR_THICKNESS); - mResizeBar[LLResizeBar::BOTTOM]->setRect(resize_rect); - } - - resize_rect.setLeftTopAndSize( 0, height, RESIZE_BAR_THICKNESS, height); - if (mResizeBar[LLResizeBar::LEFT]) - { - mResizeBar[LLResizeBar::LEFT]->reshape(RESIZE_BAR_THICKNESS,height); - mResizeBar[LLResizeBar::LEFT]->setRect(resize_rect); - } - - resize_rect.setLeftTopAndSize( width - RESIZE_BAR_THICKNESS, height, RESIZE_BAR_THICKNESS, height); - if (mResizeBar[LLResizeBar::RIGHT]) - { - mResizeBar[LLResizeBar::RIGHT]->reshape(RESIZE_BAR_THICKNESS,height); - mResizeBar[LLResizeBar::RIGHT]->setRect(resize_rect); - } - - // *NOTE: we must check mChatCaptionPanel and mChatHistory against NULL because reshape is called from the - // LLView::initFromParams BEFORE postBuild is called and child controls are not exist yet - LLRect caption_rect; - if (NULL != mChatCaptionPanel) - { - caption_rect = mChatCaptionPanel->getRect(); - caption_rect.setLeftTopAndSize( 2, height - RESIZE_BAR_THICKNESS, width - 4, caption_rect.getHeight()); - mChatCaptionPanel->reshape( width - 4, caption_rect.getHeight(), 1); - mChatCaptionPanel->setRect(caption_rect); - } - - if (NULL != mChatHistory) - { - LLRect scroll_rect = mChatHistory->getRect(); - scroll_rect.setLeftTopAndSize( 2, height - caption_rect.getHeight() - RESIZE_BAR_THICKNESS, width - 4, height - caption_rect.getHeight() - RESIZE_BAR_THICKNESS*2); - mChatHistory->reshape( width - 4, height - caption_rect.getHeight() - RESIZE_BAR_THICKNESS*2, 1); - mChatHistory->setRect(scroll_rect); - } - - // - if(mEChatTearofState == CHAT_PINNED) - { - const LLRect& parent_rect = gViewerWindow->getRootView()->getRect(); - - LLRect panel_rect; - panel_rect.setLeftTopAndSize( parent_rect.mLeft+2, parent_rect.mBottom+height+4, width, height); - setRect(panel_rect); - } - else - { - LLRect panel_rect; - panel_rect.setLeftTopAndSize( getRect().mLeft, getRect().mTop, width, height); - setRect(panel_rect); - } - -} - -BOOL LLNearbyChat::handleMouseDown (S32 x, S32 y, MASK mask) -{ - LLUICtrl* nearby_speakers_btn = mChatCaptionPanel->getChild<LLUICtrl>("nearby_speakers_btn"); - LLUICtrl* tearoff_btn = mChatCaptionPanel->getChild<LLUICtrl>("tearoff_btn"); - LLUICtrl* close_btn = mChatCaptionPanel->getChild<LLUICtrl>("close_btn"); - - S32 caption_local_x = x - mChatCaptionPanel->getRect().mLeft; - S32 caption_local_y = y - mChatCaptionPanel->getRect().mBottom; - - S32 local_x = caption_local_x - nearby_speakers_btn->getRect().mLeft; - S32 local_y = caption_local_y - nearby_speakers_btn->getRect().mBottom; - if(nearby_speakers_btn->pointInView(local_x, local_y)) - { - - onNearbySpeakers(); - bringToFront( x, y ); - return true; - } - local_x = caption_local_x - tearoff_btn->getRect().mLeft; - local_y = caption_local_y- tearoff_btn->getRect().mBottom; - if(tearoff_btn->pointInView(local_x, local_y)) - { - onTearOff(); - bringToFront( x, y ); - return true; - } - - local_x = caption_local_x - close_btn->getRect().mLeft; - local_y = caption_local_y - close_btn->getRect().mBottom; - if(close_btn->pointInView(local_x, local_y)) - { - setVisible(false); - bringToFront( x, y ); - return true; - } - - if(mEChatTearofState == CHAT_UNPINNED && mChatCaptionPanel->pointInView(caption_local_x, caption_local_y) ) - { - //start draggind - gFocusMgr.setMouseCapture(this); - mStart_Y = y; - mStart_X = x; - bringToFront( x, y ); - return true; - } - - return LLFloater::handleMouseDown(x,y,mask); -} - -BOOL LLNearbyChat::handleMouseUp(S32 x, S32 y, MASK mask) -{ - if( hasMouseCapture() ) - { - // Release the mouse - gFocusMgr.setMouseCapture( NULL ); - mStart_X = 0; - mStart_Y = 0; - return true; - } - - return LLFloater::handleMouseUp(x,y,mask); -} - -BOOL LLNearbyChat::handleHover(S32 x, S32 y, MASK mask) -{ - if( hasMouseCapture() ) - { - translate(x-mStart_X,y-mStart_Y); - return true; - } - return LLFloater::handleHover(x,y,mask); -} - -void LLNearbyChat::pinn_panel() -{ - mEChatTearofState = CHAT_PINNED; - LLIconCtrl* tearoff_btn = mChatCaptionPanel->getChild<LLIconCtrl>("tearoff_btn",false); - - tearoff_btn->setValue("Inv_Landmark"); - - const LLRect& parent_rect = gViewerWindow->getRootView()->getRect(); - - LLRect panel_rect; - panel_rect.setLeftTopAndSize( parent_rect.mLeft+2, parent_rect.mBottom+getRect().getHeight()+4, getRect().getWidth(), getRect().getHeight()); - setRect(panel_rect); - - mResizeBar[LLResizeBar::BOTTOM]->setVisible(false); - mResizeBar[LLResizeBar::LEFT]->setVisible(false); - mResizeBar[LLResizeBar::RIGHT]->setVisible(false); - - getDragHandle()->setVisible(false); - -} - -void LLNearbyChat::float_panel() -{ - mEChatTearofState = CHAT_UNPINNED; - LLIconCtrl* tearoff_btn = mChatCaptionPanel->getChild<LLIconCtrl>("tearoff_btn", false); - - tearoff_btn->setValue("Inv_Landmark"); - mResizeBar[LLResizeBar::BOTTOM]->setVisible(true); - mResizeBar[LLResizeBar::LEFT]->setVisible(true); - mResizeBar[LLResizeBar::RIGHT]->setVisible(true); - - getDragHandle()->setVisible(true); - - translate(4,4); -} void LLNearbyChat::onNearbyChatContextMenuItemClicked(const LLSD& userdata) { @@ -438,23 +244,6 @@ bool LLNearbyChat::onNearbyChatCheckContextMenuItem(const LLSD& userdata) return false; } -BOOL LLNearbyChat::handleRightMouseDown(S32 x, S32 y, MASK mask) -{ - if(mChatCaptionPanel->pointInView(x - mChatCaptionPanel->getRect().mLeft, y - mChatCaptionPanel->getRect().mBottom) ) - { - LLMenuGL* menu = (LLMenuGL*)mPopupMenuHandle.get(); - - if(menu) - { - menu->buildDrawLabels(); - menu->updateParent(LLMenuGL::sMenuContainer); - LLMenuGL::showPopup(this, menu, x, y); - } - return true; - } - return LLFloater::handleRightMouseDown(x, y, mask); -} - void LLNearbyChat::onOpen(const LLSD& key ) { LLNotificationsUI::LLScreenChannelBase* chat_channel = LLNotificationsUI::LLChannelManager::getInstance()->findChannelByID(LLUUID(gSavedSettings.getString("NearByChatChannelUUID"))); @@ -464,9 +253,15 @@ void LLNearbyChat::onOpen(const LLSD& key ) } } -void LLNearbyChat::draw () +void LLNearbyChat::setDocked (bool docked, bool pop_on_undock) { - LLFloater::draw(); -} + LLFloater::setDocked(docked, pop_on_undock); + if(docked) + { + //move nearby_chat to right bottom + LLRect rect = gFloaterView->getRect(); + setRect(LLRect(rect.mLeft,getRect().getHeight(),rect.mLeft+getRect().getWidth(),0)); + } +} |