summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/chatwindow.cpp1
-rw-r--r--src/gui/widgets/tabbedarea.cpp35
-rw-r--r--src/gui/widgets/tabbedarea.h7
3 files changed, 37 insertions, 6 deletions
diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp
index c3e85bdac..1142636b4 100644
--- a/src/gui/chatwindow.cpp
+++ b/src/gui/chatwindow.cpp
@@ -175,6 +175,7 @@ ChatWindow::ChatWindow():
mChatTabs = new TabbedArea;
mChatTabs->enableScrollButtons(true);
+ mChatTabs->setFollowDownScroll(true);
mChatInput = new ChatInput(mChatTabs);
mChatInput->setActionEventId("chatinput");
diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp
index 6b90cb381..bd43e4dc7 100644
--- a/src/gui/widgets/tabbedarea.cpp
+++ b/src/gui/widgets/tabbedarea.cpp
@@ -22,18 +22,21 @@
#include "gui/widgets/tabbedarea.h"
+#include "gui/widgets/scrollarea.h"
#include "gui/widgets/tab.h"
#include "log.h"
#include <guichan/widgets/container.hpp>
-TabbedArea::TabbedArea() : gcn::TabbedArea(),
- mTabsWidth(0),
- mVisibleTabsWidth(0),
- mTabScrollIndex(0),
- mEnableScrollButtons(false),
- mRightMargin(0)
+TabbedArea::TabbedArea()
+ : gcn::TabbedArea(),
+ mTabsWidth(0),
+ mVisibleTabsWidth(0),
+ mTabScrollIndex(0),
+ mEnableScrollButtons(false),
+ mRightMargin(0),
+ mFollowDownScroll(false)
{
mWidgetContainer->setOpaque(false);
addWidgetListener(this);
@@ -246,7 +249,27 @@ void TabbedArea::widgetResized(const gcn::Event &event _UNUSED_)
gcn::Widget *w = getCurrentWidget();
if (w)
+ {
+ int newScroll = 0;
+ ScrollArea* scr = 0;
+ if (mFollowDownScroll && height != 0)
+ {
+ gcn::Rectangle rect = w->getDimension();
+ if (rect.height != 0 && rect.height > height)
+ {
+ scr = dynamic_cast<ScrollArea*>(w);
+ if (scr && scr->getVerticalScrollAmount()
+ == scr->getVerticalMaxScroll())
+ {
+ newScroll = scr->getVerticalScrollAmount()
+ + rect.height - height;
+ }
+ }
+ }
w->setSize(width, height);
+ if (scr && newScroll)
+ scr->setVerticalScrollAmount(newScroll);
+ }
if (mArrowButton[1])
{
diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h
index 0c2903777..b48f83240 100644
--- a/src/gui/widgets/tabbedarea.h
+++ b/src/gui/widgets/tabbedarea.h
@@ -139,6 +139,12 @@ class TabbedArea : public gcn::TabbedArea, public gcn::WidgetListener
int getRightMargin()
{ return mRightMargin; }
+ void setFollowDownScroll(bool n)
+ { mFollowDownScroll = n; }
+
+ bool getFollowDownScroll()
+ { return mFollowDownScroll; }
+
private:
typedef std::vector< std::pair<gcn::Tab*, gcn::Widget*> > TabContainer;
@@ -181,6 +187,7 @@ class TabbedArea : public gcn::TabbedArea, public gcn::WidgetListener
bool mEnableScrollButtons;
int mRightMargin;
+ bool mFollowDownScroll;
};
#endif