summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2012-02-05 13:50:11 +0100
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2012-02-05 16:11:23 +0100
commitc0721a0f5cf8694319c1f6849ea32864b31c825a (patch)
tree404fe5dbcdc64750c317c68e942f5686fec0243e /src
parent8b45afbbebeda5e4eef6d15a232f63ced0958135 (diff)
downloadmana-c0721a0f5cf8694319c1f6849ea32864b31c825a.tar.gz
mana-c0721a0f5cf8694319c1f6849ea32864b31c825a.tar.bz2
mana-c0721a0f5cf8694319c1f6849ea32864b31c825a.tar.xz
mana-c0721a0f5cf8694319c1f6849ea32864b31c825a.zip
Fixed some layout issues with the chat window
One pixel of the scroll bar wasn't visible since the mWidgetContainer is shifted by one pixel by gcn::TabbedArea::adjustSize, which wasn't being taken into account by our custom mWidgetContainer sizing code. Fixed that by just letting Guichan handle it. Another issue was that the tab scroll arrows were appearing before they were needed, since they took into account their own size when checking whether the tabs had enough space. Finally, a Layout has a default padding of 6 pixels but this is a little much for the chat window. I reduced it to 3 pixels now. Reviewed-by: Erik Schilling
Diffstat (limited to 'src')
-rw-r--r--src/gui/chatwindow.cpp4
-rw-r--r--src/gui/widgets/tabbedarea.cpp49
2 files changed, 22 insertions, 31 deletions
diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp
index 2f5108ff..0bf8d493 100644
--- a/src/gui/chatwindow.cpp
+++ b/src/gui/chatwindow.cpp
@@ -36,6 +36,7 @@
#include "gui/widgets/channeltab.h"
#include "gui/widgets/chattab.h"
#include "gui/widgets/itemlinkhandler.h"
+#include "gui/widgets/layout.h"
#include "gui/widgets/scrollarea.h"
#include "gui/widgets/tabbedarea.h"
#include "gui/widgets/textfield.h"
@@ -101,7 +102,7 @@ ChatWindow::ChatWindow():
setupWindow->registerWindowForReset(this);
// no title presented, title bar is padding so window can be moved.
- gcn::Window::setTitleBarHeight(gcn::Window::getPadding() + 4);
+ setTitleBarHeight(getPadding() + 4);
setShowTitle(false);
setResizable(true);
setDefaultVisible(true);
@@ -118,6 +119,7 @@ ChatWindow::ChatWindow():
mChatTabs = new TabbedArea;
+ getLayout().setPadding(3);
place(0, 0, mChatTabs, 3, 3);
place(0, 3, mChatInput, 3);
diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp
index a1125aaa..52690657 100644
--- a/src/gui/widgets/tabbedarea.cpp
+++ b/src/gui/widgets/tabbedarea.cpp
@@ -33,12 +33,10 @@ TabbedArea::TabbedArea() : gcn::TabbedArea(),
mWidgetContainer->setOpaque(false);
addWidgetListener(this);
- mArrowButton[0] = new Button("", "shift_left", this);
- mArrowButton[1] = new Button("", "shift_right", this);
- if (!mArrowButton[0]->setButtonIcon("tab_arrows_left.png"))
- mArrowButton[0]->setCaption("<");
- if (!mArrowButton[1]->setButtonIcon("tab_arrows_right.png"))
- mArrowButton[1]->setCaption(">");
+ mArrowButton[0] = new Button(std::string(), "shift_left", this);
+ mArrowButton[1] = new Button(std::string(), "shift_right", this);
+ mArrowButton[0]->setButtonIcon("tab_arrows_left.png");
+ mArrowButton[1]->setButtonIcon("tab_arrows_right.png");
add(mArrowButton[0]);
add(mArrowButton[1]);
@@ -88,21 +86,18 @@ gcn::Widget *TabbedArea::getWidget(const std::string &name) const
gcn::Widget *TabbedArea::getCurrentWidget()
{
- gcn::Tab *tab = getSelectedTab();
-
- if (tab)
+ if (gcn::Tab *tab = getSelectedTab())
return getWidget(tab->getCaption());
- else
- return NULL;
+
+ return NULL;
}
void TabbedArea::addTab(gcn::Tab* tab, gcn::Widget* widget)
{
gcn::TabbedArea::addTab(tab, widget);
- int width = getWidth() - 2 * getFrameSize();
- int height = getHeight() - 2 * getFrameSize() - mTabContainer->getHeight();
- widget->setSize(width, height);
+ widget->setSize(mWidgetContainer->getWidth(),
+ mWidgetContainer->getHeight());
updateTabsWidth();
updateArrowEnableState();
@@ -182,9 +177,7 @@ void TabbedArea::setSelectedTab(gcn::Tab *tab)
{
gcn::TabbedArea::setSelectedTab(tab);
- Tab *newTab = dynamic_cast<Tab*>(tab);
-
- if (newTab)
+ if (Tab *newTab = dynamic_cast<Tab*>(tab))
newTab->setCurrent();
widgetResized(NULL);
@@ -192,15 +185,13 @@ void TabbedArea::setSelectedTab(gcn::Tab *tab)
void TabbedArea::widgetResized(const gcn::Event &event)
{
- int width = getWidth() - 2 * getFrameSize()
- - 2 * mWidgetContainer->getFrameSize();
- int height = getHeight() - 2 * getFrameSize() - mWidgetContainer->getY()
- - 2 * mWidgetContainer->getFrameSize();
- mWidgetContainer->setSize(width, height);
+ adjustSize();
- gcn::Widget *w = getCurrentWidget();
- if (w)
- w->setSize(width, height);
+ if (gcn::Widget *w = getCurrentWidget())
+ {
+ w->setSize(mWidgetContainer->getWidth(),
+ mWidgetContainer->getHeight());
+ }
// Check whether there is room to show more tabs now.
int innerWidth = getWidth() - 4 - mArrowButton[0]->getWidth()
@@ -214,7 +205,7 @@ void TabbedArea::widgetResized(const gcn::Event &event)
}
// Move the right arrow to fit the windows content.
- mArrowButton[1]->setPosition(width - mArrowButton[1]->getWidth(), 0);
+ mArrowButton[1]->setPosition(getWidth() - mArrowButton[1]->getWidth(), 0);
updateArrowEnableState();
adjustTabPositions();
@@ -302,9 +293,7 @@ void TabbedArea::action(const gcn::ActionEvent& actionEvent)
void TabbedArea::updateArrowEnableState()
{
updateTabsWidth();
- if (mTabsWidth > getWidth() - 4
- - mArrowButton[0]->getWidth()
- - mArrowButton[1]->getWidth())
+ if (mTabsWidth > getWidth() - 2)
{
mArrowButton[0]->setVisible(true);
mArrowButton[1]->setVisible(true);
@@ -323,7 +312,7 @@ void TabbedArea::updateArrowEnableState()
mArrowButton[0]->setEnabled(true);
// Right arrow consistency check
- if (mVisibleTabsWidth < getWidth() - 4
+ if (mVisibleTabsWidth < getWidth() - 2
- mArrowButton[0]->getWidth()
- mArrowButton[1]->getWidth())
{