diff options
Diffstat (limited to 'indra/newview/llsyswellwindow.cpp')
-rw-r--r-- | indra/newview/llsyswellwindow.cpp | 217 |
1 files changed, 202 insertions, 15 deletions
diff --git a/indra/newview/llsyswellwindow.cpp b/indra/newview/llsyswellwindow.cpp index 2bbb5a2767..15d77dbf88 100644 --- a/indra/newview/llsyswellwindow.cpp +++ b/indra/newview/llsyswellwindow.cpp @@ -40,29 +40,36 @@ //--------------------------------------------------------------------------------- LLSysWellWindow::LLSysWellWindow(const LLSD& key) : LLFloater(LLSD()), + mSysWell(NULL), mChannel(NULL), mScrollContainer(NULL), mNotificationList(NULL) { + LLIMMgr::getInstance()->addSessionObserver(this); + LLIMChiclet::sFindChicletsSignal.connect(boost::bind(&LLSysWellWindow::findIMChiclet, this, _1)); } //--------------------------------------------------------------------------------- BOOL LLSysWellWindow::postBuild() { mScrollContainer = getChild<LLScrollContainer>("notification_list_container"); + mTwinListPanel = getChild<LLPanel>("twin_list_panel"); mNotificationList = getChild<LLScrollingPanelList>("notification_list"); + mIMRowList = getChild<LLScrollingPanelList>("im_row_panel_list"); gViewerWindow->setOnBottomTrayWidthChanged(boost::bind(&LLSysWellWindow::adjustWindowPosition, this)); // *TODO: won't be necessary after docking is realized mScrollContainer->setBorderVisible(FALSE); mDockTongue = LLUI::getUIImage("windows/Flyout_Pointer.png"); + return TRUE; } //--------------------------------------------------------------------------------- LLSysWellWindow::~LLSysWellWindow() { + LLIMMgr::getInstance()->removeSessionObserver(this); } //--------------------------------------------------------------------------------- @@ -121,10 +128,9 @@ void LLSysWellWindow::removeItemByID(const LLUUID& id) reshapeWindow(); adjustWindowPosition(); // *TODO: won't be necessary after docking is realized + // hide chiclet window if there are no items left - S32 items_left = mNotificationList->getPanelList().size(); - if(items_left == 0) - setVisible(FALSE); + setVisible(!isWindowEmpty()); } //--------------------------------------------------------------------------------- @@ -177,6 +183,7 @@ void LLSysWellWindow::adjustWindowPosition() // *TODO: won't be necessary after LLRect this_rect = getRect(); setOrigin(btm_rect.mRight - this_rect.getWidth() - WINDOW_MARGIN, WINDOW_MARGIN); } + //--------------------------------------------------------------------------------- void LLSysWellWindow::reshapeWindow() { @@ -184,30 +191,210 @@ void LLSysWellWindow::reshapeWindow() const LLUICachedControl<S32> SCROLLBAR_SIZE("UIScrollbarSize", 0); const LLUICachedControl<S32> HEADER_SIZE("UIFloaterHeaderSize", 0); - // Get item list - const LLScrollingPanelList::panel_list_t list = mNotificationList->getPanelList(); + LLRect notif_list_rect = mNotificationList->getRect(); + LLRect im_list_rect = mIMRowList->getRect(); + LLRect panel_rect = mTwinListPanel->getRect(); + + S32 notif_list_height = notif_list_rect.getHeight(); + S32 im_list_height = im_list_rect.getHeight(); - // Get height for a scrolling panel list - S32 list_height = mNotificationList->getRect().getHeight(); + S32 new_panel_height = notif_list_height + LLScrollingPanelList::GAP_BETWEEN_PANELS + im_list_height; + S32 new_window_height = new_panel_height + LLScrollingPanelList::GAP_BETWEEN_PANELS + HEADER_SIZE; - // Check that the floater doesn't exceed its parent view limits after reshape - S32 new_height = list_height + LLScrollingPanelList::GAP_BETWEEN_PANELS + HEADER_SIZE; + U32 twinListWidth = 0; - if(new_height > MAX_WINDOW_HEIGHT) + if (new_window_height > MAX_WINDOW_HEIGHT) { - reshape(MIN_WINDOW_WIDTH, MAX_WINDOW_HEIGHT, FALSE); - mNotificationList->reshape(MIN_PANELLIST_WIDTH - SCROLLBAR_SIZE, list_height, TRUE); + twinListWidth = MIN_PANELLIST_WIDTH - SCROLLBAR_SIZE; + new_window_height = MAX_WINDOW_HEIGHT; } else { - reshape(MIN_WINDOW_WIDTH, new_height, FALSE); - mNotificationList->reshape(MIN_PANELLIST_WIDTH, list_height, TRUE); + twinListWidth = MIN_PANELLIST_WIDTH; } - + + reshape(MIN_WINDOW_WIDTH, new_window_height, FALSE); + mTwinListPanel->reshape(twinListWidth, new_panel_height, TRUE); + mNotificationList->reshape(twinListWidth, notif_list_height, TRUE); + mIMRowList->reshape(twinListWidth, im_list_height, TRUE); + + // arrange panel and lists + // move panel + panel_rect.setLeftTopAndSize(1, new_panel_height, twinListWidth, new_panel_height); + mTwinListPanel->setRect(panel_rect); + // move notif list panel + notif_list_rect.setLeftTopAndSize(notif_list_rect.mLeft, new_panel_height, twinListWidth, notif_list_height); + mNotificationList->setRect(notif_list_rect); + // move IM list panel + im_list_rect.setLeftTopAndSize(im_list_rect.mLeft, notif_list_rect.mBottom - LLScrollingPanelList::GAP_BETWEEN_PANELS, twinListWidth, im_list_height); + mIMRowList->setRect(im_list_rect); + mNotificationList->updatePanels(TRUE); + mIMRowList->updatePanels(TRUE); +} + +//--------------------------------------------------------------------------------- +LLSysWellWindow::RowPanel * LLSysWellWindow::findIMRow(const LLUUID& sessionId) +{ + RowPanel * res = NULL; + const LLScrollingPanelList::panel_list_t &list = mIMRowList->getPanelList(); + if (!list.empty()) + { + for (LLScrollingPanelList::panel_list_t::const_iterator iter = list.begin(); iter != list.end(); ++iter) + { + RowPanel *panel = static_cast<RowPanel*> (*iter); + if (panel->mChiclet->getSessionId() == sessionId) + { + res = panel; + break; + } + } + } + return res; +} + +//--------------------------------------------------------------------------------- +LLChiclet* LLSysWellWindow::findIMChiclet(const LLUUID& sessionId) +{ + LLChiclet* res = NULL; + RowPanel* panel = findIMRow(sessionId); + if (panel != NULL) + { + res = panel->mChiclet; + } + + return res; +} + +//--------------------------------------------------------------------------------- +void LLSysWellWindow::addIMRow(const LLUUID& sessionId, S32 chicletCounter, + const std::string& name, const LLUUID& otherParticipantId) +{ + + mIMRowList->addPanel(new RowPanel(this, sessionId, chicletCounter, name, otherParticipantId)); + adjustWindowPosition(); // *TODO: won't be necessary after docking is realized +} + +//--------------------------------------------------------------------------------- +void LLSysWellWindow::delIMRow(const LLUUID& sessionId) +{ + RowPanel *panel = findIMRow(sessionId); + if (panel != NULL) + { + mIMRowList->removePanel(panel); + } + + // hide chiclet window if there are no items left + setVisible(!isWindowEmpty()); + + adjustWindowPosition(); // *TODO: won't be necessary after docking is realized +} + +//--------------------------------------------------------------------------------- +bool LLSysWellWindow::isWindowEmpty() +{ + if(mIMRowList->getPanelList().size() == 0 && mNotificationList->getPanelList().size() == 0) + { + return true; + } + else + { + return false; + } +} + +//--------------------------------------------------------------------------------- +//virtual +void LLSysWellWindow::sessionAdded(const LLUUID& sessionId, + const std::string& name, const LLUUID& otherParticipantId) +{ + if (findIMRow(sessionId) == NULL) + { + S32 chicletCounter = 0; + LLIMModel::LLIMSession* session = get_if_there(LLIMModel::sSessionsMap, + sessionId, (LLIMModel::LLIMSession*) NULL); + if (session != NULL) + { + chicletCounter = session->mNumUnread; + } + addIMRow(sessionId, chicletCounter, name, otherParticipantId); + reshapeWindow(); + } +} + +//--------------------------------------------------------------------------------- +//virtual +void LLSysWellWindow::sessionRemoved(const LLUUID& sessionId) +{ + delIMRow(sessionId); + reshapeWindow(); + mSysWell->updateUreadIMNotifications(); +} + +//--------------------------------------------------------------------------------- +LLSysWellWindow::RowPanel::RowPanel(const LLSysWellWindow* parent, const LLUUID& sessionId, + S32 chicletCounter, const std::string& name, const LLUUID& otherParticipantId) : + LLScrollingPanel(LLPanel::Params()), mParent(parent) +{ + LLUICtrlFactory::getInstance()->buildPanel(this, "panel_activeim_row.xml", NULL); + + mChiclet = getChild<LLIMChiclet>("chiclet"); + mChiclet->setCounter(chicletCounter); + mChiclet->setSessionId(sessionId); + mChiclet->setIMSessionName(name); + mChiclet->setOtherParticipantId(otherParticipantId); + + LLTextBox* contactName = getChild<LLTextBox>("contact_name"); + contactName->setValue(name); + + mCloseBtn = getChild<LLButton>("hide_btn"); + mCloseBtn->setCommitCallback(boost::bind(&LLSysWellWindow::RowPanel::onClose, this)); +} + +//--------------------------------------------------------------------------------- +LLSysWellWindow::RowPanel::~RowPanel() +{ +} + +//--------------------------------------------------------------------------------- +void LLSysWellWindow::RowPanel::onClose() +{ + mParent->mIMRowList->removePanel(this); + gIMMgr->removeSession(mChiclet->getSessionId()); +} + +//--------------------------------------------------------------------------------- +void LLSysWellWindow::RowPanel::onMouseEnter(S32 x, S32 y, MASK mask) +{ + setTransparentColor(LLUIColorTable::instance().getColor("SysWellItemSelected")); +} + +//--------------------------------------------------------------------------------- +void LLSysWellWindow::RowPanel::onMouseLeave(S32 x, S32 y, MASK mask) +{ + setTransparentColor(LLUIColorTable::instance().getColor("SysWellItemUnselected")); } //--------------------------------------------------------------------------------- +// virtual +BOOL LLSysWellWindow::RowPanel::handleMouseDown(S32 x, S32 y, MASK mask) +{ + // Pass the mouse down event to the chiclet (EXT-596). + if (!mChiclet->pointInView(x, y) && !mCloseBtn->getRect().pointInRect(x, y)) // prevent double call of LLIMChiclet::onMouseDown() + mChiclet->onMouseDown(); + return LLPanel::handleMouseDown(x, y, mask); +} + +//--------------------------------------------------------------------------------- +void LLSysWellWindow::RowPanel::updatePanel(BOOL allow_modify) +{ + S32 parent_width = getParent()->getRect().getWidth(); + S32 panel_height = getRect().getHeight(); + + reshape(parent_width, panel_height, TRUE); +} + +//--------------------------------------------------------------------------------- |