From caf3cad2da9945e48fc2104404460f639c71a6b0 Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Mon, 30 Mar 2009 18:33:00 -0600 Subject: Hilight chat tabs when appropriate --- src/gui/widgets/chattab.cpp | 2 ++ src/gui/widgets/chattab.h | 2 ++ src/gui/widgets/tab.h | 6 ++++++ src/gui/widgets/tabbedarea.cpp | 10 ++++++++++ src/gui/widgets/tabbedarea.h | 5 +++++ 5 files changed, 25 insertions(+) (limited to 'src') diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index 4a63bbcd..43248e8b 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -207,6 +207,8 @@ void ChatTab::chatLog(std::string line, int own, bool ignoreRecord) mScrollArea->logic(); chatWindow->mRecorder->record(line.substr(3)); + if (this != getTabbedArea()->getSelectedTab()) + setHighlighted(true); } void ChatTab::chatLog(const std::string &nick, const std::string &msg) diff --git a/src/gui/widgets/chattab.h b/src/gui/widgets/chattab.h index 76b33011..88443aa3 100644 --- a/src/gui/widgets/chattab.h +++ b/src/gui/widgets/chattab.h @@ -110,6 +110,8 @@ class ChatTab : public Tab friend class ChatWindow; friend class WhisperWindow; + virtual void setCurrent() { setHighlighted(false); } + virtual void handleInput(const std::string &msg); virtual void handleCommand(std::string msg); diff --git a/src/gui/widgets/tab.h b/src/gui/widgets/tab.h index 64e76d4c..efdc8d26 100644 --- a/src/gui/widgets/tab.h +++ b/src/gui/widgets/tab.h @@ -23,8 +23,10 @@ #define TAB_H #include +#include class ImageRect; +class TabbedArea; /** * A tab, the same as the guichan tab in 0.8, but extended to allow transparancy @@ -57,6 +59,10 @@ class Tab : public gcn::Tab */ void setHighlighted(bool high); + protected: + friend class TabbedArea; + virtual void setCurrent() {} + private: /** Load images if no other instances exist yet */ void init(); diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index 8e93d394..0d7cf155 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -146,4 +146,14 @@ void TabbedArea::removeTab(Tab *tab) void TabbedArea::logic() { logicChildren(); + +} +void TabbedArea::setSelectedTab(gcn::Tab *tab) +{ + gcn::TabbedArea::setSelectedTab(tab); + + Tab *newTab = dynamic_cast(tab); + + if (newTab) + newTab->setCurrent(); } diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h index dffbd36b..b4fc1ded 100644 --- a/src/gui/widgets/tabbedarea.h +++ b/src/gui/widgets/tabbedarea.h @@ -87,6 +87,11 @@ class TabbedArea : public gcn::TabbedArea int getContainerHeight() { return mWidgetContainer->getHeight(); } + void setSelectedTab(unsigned int index) + { gcn::TabbedArea::setSelectedTab(index); } + + void setSelectedTab(gcn::Tab *tab); + private: typedef std::vector< std::pair > TabContainer; }; -- cgit v1.2.3-60-g2f50