diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-04-08 02:17:40 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-04-08 02:17:40 +0300 |
commit | be881476350ab5f4202e687ad4161099870fe5a4 (patch) | |
tree | 0758102d5203de8857be71b9d8ef6b3eeccff3fb /src/gui/chatwindow.cpp | |
parent | b65ec0190a8b5623052981b841ce2232b27760ef (diff) | |
download | mv-be881476350ab5f4202e687ad4161099870fe5a4.tar.gz mv-be881476350ab5f4202e687ad4161099870fe5a4.tar.bz2 mv-be881476350ab5f4202e687ad4161099870fe5a4.tar.xz mv-be881476350ab5f4202e687ad4161099870fe5a4.zip |
Now if chat input is hidden, it not using space in window.
Diffstat (limited to 'src/gui/chatwindow.cpp')
-rw-r--r-- | src/gui/chatwindow.cpp | 45 |
1 files changed, 34 insertions, 11 deletions
diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp index 0b9945370..c3e85bdac 100644 --- a/src/gui/chatwindow.cpp +++ b/src/gui/chatwindow.cpp @@ -71,8 +71,9 @@ class ChatInput : public TextField, public gcn::FocusListener { public: - ChatInput(): - TextField("", false) + ChatInput(TabbedArea *tabs): + TextField("", false), + mChatTabs(tabs) { setVisible(false); addFocusListener(this); @@ -84,8 +85,26 @@ class ChatInput : public TextField, public gcn::FocusListener */ void focusLost(const gcn::Event &event _UNUSED_) { - setVisible(false); + processVisible(false); + } + + void processVisible(bool n) + { + if (!mChatTabs || isVisible() == n) + return; + + if (config.getBoolValue("hideChatInput")) + { + if (n) + mChatTabs->setHeight(mChatTabs->getHeight() - getHeight()); + else + mChatTabs->setHeight(mChatTabs->getHeight() + getHeight()); + } + setVisible(n); } + + private: + TabbedArea *mChatTabs; }; const char *COLOR_NAME[14] = @@ -154,13 +173,13 @@ ChatWindow::ChatWindow(): mItemLinkHandler = new ItemLinkHandler; - mChatInput = new ChatInput; - mChatInput->setActionEventId("chatinput"); - mChatInput->addActionListener(this); - mChatTabs = new TabbedArea; mChatTabs->enableScrollButtons(true); + mChatInput = new ChatInput(mChatTabs); + mChatInput->setActionEventId("chatinput"); + mChatInput->addActionListener(this); + mChatColor = config.getIntValue("chatColor"); mColorListModel = new ColorListModel; mColorPicker = new DropDown(mColorListModel); @@ -282,8 +301,12 @@ void ChatWindow::adjustTabSize() mChatInput->setWidth(area.width - 2 * mChatInput->getFrameSize()); mChatTabs->setWidth(area.width - 2 * mChatTabs->getFrameSize()); - mChatTabs->setHeight(area.height - 2 * mChatTabs->getFrameSize() - - (mChatInput->getHeight() + mChatInput->getFrameSize() * 2)); + int height = area.height - 2 * mChatTabs->getFrameSize() - + (mChatInput->getHeight() + mChatInput->getFrameSize() * 2); + if (mChatInput->isVisible() || !config.getBoolValue("hideChatInput")) + mChatTabs->setHeight(height); + else + mChatTabs->setHeight(height + mChatInput->getHeight()); ChatTab *tab = getFocused(); if (tab) @@ -442,7 +465,7 @@ bool ChatWindow::requestChatFocus() return false; // Give focus to the chat input - mChatInput->setVisible(true); + mChatInput->processVisible(true); mChatInput->requestFocus(); return true; } @@ -684,7 +707,7 @@ void ChatWindow::keyPressed(gcn::KeyEvent &event) else if (keyboard.isKeyActive(keyboard.KEY_DEACTIVATE_CHAT) && mChatInput->isVisible()) { - mChatInput->setVisible(false); + mChatInput->processVisible(false); } else if (keyboard.isKeyActive(keyboard.KEY_CHAT_PREV_HISTORY) && mChatInput->isVisible()) |