summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-04-08 02:17:40 +0300
committerAndrei Karas <akaras@inbox.ru>2011-04-08 02:17:40 +0300
commitbe881476350ab5f4202e687ad4161099870fe5a4 (patch)
tree0758102d5203de8857be71b9d8ef6b3eeccff3fb /src
parentb65ec0190a8b5623052981b841ce2232b27760ef (diff)
downloadmv-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')
-rw-r--r--src/defaults.cpp1
-rw-r--r--src/gui/chatwindow.cpp45
-rw-r--r--src/gui/chatwindow.h4
-rw-r--r--src/gui/setup_chat.cpp17
-rw-r--r--src/gui/setup_chat.h3
5 files changed, 57 insertions, 13 deletions
diff --git a/src/defaults.cpp b/src/defaults.cpp
index aebf9ce2b..7f9c31204 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -195,6 +195,7 @@ DefaultsData* getConfigDefaults()
AddDEF(configData, "showJobExp", true);
AddDEF(configData, "showBeingPopup", true);
AddDEF(configData, "showExtMinimaps", false);
+ AddDEF(configData, "hideChatInput", true);
return configData;
}
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())
diff --git a/src/gui/chatwindow.h b/src/gui/chatwindow.h
index 1b10405d4..d8457d691 100644
--- a/src/gui/chatwindow.h
+++ b/src/gui/chatwindow.h
@@ -246,6 +246,8 @@ class ChatWindow : public Window,
std::string doReplace(const std::string &msg);
+ void adjustTabSize();
+
protected:
friend class ChatTab;
friend class WhisperTab;
@@ -261,8 +263,6 @@ class ChatWindow : public Window,
void removeWhisper(const std::string &nick);
- void adjustTabSize();
-
void autoComplete();
std::string addColors(std::string &msg);
diff --git a/src/gui/setup_chat.cpp b/src/gui/setup_chat.cpp
index f666284d6..a5b211d8f 100644
--- a/src/gui/setup_chat.cpp
+++ b/src/gui/setup_chat.cpp
@@ -54,6 +54,7 @@
#define ACTION_SHOW_CHAT_HISTORY "show chat history"
#define ACTION_ENABLE_BATTLE_TAB "show battle tab"
#define ACTION_SHOW_BATTLE_EVENTS "show battle events"
+#define ACTION_RESIZE_CHAT "resize chat"
Setup_Chat::Setup_Chat() :
mEditDialog(0)
@@ -127,6 +128,10 @@ Setup_Chat::Setup_Chat() :
mMaxLinesField = new IntTextField(maxLinesLimit, 0, 500, mMaxLines, 20);
+ mHideChatInput = config.getBoolValue("hideChatInput");
+ mHideChatInputCheckBox = new CheckBox(_("Resize chat tabs if need"),
+ mHideChatInput, this, ACTION_RESIZE_CHAT);
+
// Do the layout
LayoutHelper h(this);
ContainerPlacer place = h.getPlacer(0, 0);
@@ -148,6 +153,7 @@ Setup_Chat::Setup_Chat() :
place(0, 10, mShowChatHistoryCheckBox, 10);
place(0, 11, mEnableBattleTabCheckBox, 10);
place(0, 12, mShowBattleEventsCheckBox, 10);
+ place(0, 13, mHideChatInputCheckBox, 10);
place.getCell().matchColWidth(0, 0);
place = h.getPlacer(0, 1);
@@ -232,6 +238,10 @@ void Setup_Chat::action(const gcn::ActionEvent &event)
{
mShowBattleEvents = mShowBattleEventsCheckBox->isSelected();
}
+ else if (event.getId() == ACTION_RESIZE_CHAT)
+ {
+ mHideChatInput = mHideChatInputCheckBox->isSelected();
+ }
}
void Setup_Chat::cancel()
@@ -281,6 +291,9 @@ void Setup_Chat::cancel()
mShowBattleEvents = config.getBoolValue("showBattleEvents");
mShowBattleEventsCheckBox->setSelected(mShowBattleEvents);
+
+ mHideChatInput = config.getBoolValue("hideChatInput");
+ mHideChatInputCheckBox->setSelected(mHideChatInput);
}
void Setup_Chat::apply()
@@ -304,4 +317,8 @@ void Setup_Chat::apply()
config.setValue("showChatHistory", mShowChatHistory);
config.setValue("enableBattleTab", mEnableBattleTab);
config.setValue("showBattleEvents", mShowBattleEvents);
+
+ config.setValue("hideChatInput", mHideChatInput);
+ if (chatWindow)
+ chatWindow->adjustTabSize();
}
diff --git a/src/gui/setup_chat.h b/src/gui/setup_chat.h
index 30a59895a..2a6e5b183 100644
--- a/src/gui/setup_chat.h
+++ b/src/gui/setup_chat.h
@@ -86,6 +86,9 @@ class Setup_Chat : public SetupTab, public gcn::ActionListener
gcn::CheckBox *mShowBattleEventsCheckBox;
bool mShowBattleEvents;
+ gcn::CheckBox *mHideChatInputCheckBox;
+ bool mHideChatInput;
+
EditDialog *mEditDialog;
};