summaryrefslogtreecommitdiff
path: root/src/gui/chat.cpp
diff options
context:
space:
mode:
authorDavid Athay <ko2fan@gmail.com>2008-07-04 17:02:03 +0000
committerDavid Athay <ko2fan@gmail.com>2008-07-04 17:02:03 +0000
commit6423c8eda76babaa50c13525b0deb7df5f2d24bd (patch)
tree6a44f0fde271ad739a5d2f1521b86445bd99d0e8 /src/gui/chat.cpp
parentd22c6843a9b9f06a0f9e05bed268bfab90b75031 (diff)
downloadmana-client-6423c8eda76babaa50c13525b0deb7df5f2d24bd.tar.gz
mana-client-6423c8eda76babaa50c13525b0deb7df5f2d24bd.tar.bz2
mana-client-6423c8eda76babaa50c13525b0deb7df5f2d24bd.tar.xz
mana-client-6423c8eda76babaa50c13525b0deb7df5f2d24bd.zip
Ugly hack for chat scrolling.
Diffstat (limited to 'src/gui/chat.cpp')
-rw-r--r--src/gui/chat.cpp27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index ba9ef8ee..ad5e0c9b 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -71,6 +71,7 @@ ChatWindow::ChatWindow():
scrollArea->getFrameSize(), scrollArea->getFrameSize());
scrollArea->setScrollPolicy(
gcn::ScrollArea::SHOW_NEVER, gcn::ScrollArea::SHOW_ALWAYS);
+ scrollArea->setScrollAmount(0, 1);
scrollArea->setOpaque(false);
mChatTabs = new TabbedArea();
@@ -123,7 +124,24 @@ void ChatWindow::widgetResized(const gcn::Event &event)
mChatTabs->setWidth(area.width - 2 * mChatTabs->getFrameSize());
mChatTabs->setHeight(area.height - 2 * mChatTabs->getFrameSize());
- const std::string &channelName = mChatTabs->getSelectedTab()->getCaption();
+ const std::string &channelName = getFocused();
+ ChannelMap::const_iterator chan = mChannels.find(channelName);
+ if (chan != mChannels.end()) {
+ ScrollArea *scroll = chan->second.scroll;
+ scroll->setWidth(area.width - 2 * scroll->getFrameSize());
+ scroll->setHeight(area.height - 2 * scroll->getFrameSize() -
+ mChatInput->getHeight() - 5);
+ scroll->logic();
+ }
+}
+
+void ChatWindow::logic()
+{
+ Window::logic();
+
+ const gcn::Rectangle area = getChildrenArea();
+
+ const std::string &channelName = getFocused();
ChannelMap::const_iterator chan = mChannels.find(channelName);
if (chan != mChannels.end()) {
ScrollArea *scroll = chan->second.scroll;
@@ -139,7 +157,7 @@ ChatWindow::chatLog(std::string line, int own, std::string channelName)
{
if(channelName == "getFocused\"")
channelName = getFocused();
-
+
ChannelMap::const_iterator chan = mChannels.find(channelName);
if (chan == mChannels.end())
return;
@@ -210,7 +228,7 @@ ChatWindow::chatLog(std::string line, int own, std::string channelName)
// We look if the Vertical Scroll Bar is set at the max before
// adding a row, otherwise the max will always be a row higher
// at comparison.
- if (scroll->getVerticalScrollAmount() == scroll->getVerticalMaxScroll())
+ if (scroll->getVerticalScrollAmount() >= scroll->getVerticalMaxScroll())
{
output->addRow(line);
scroll->setVerticalScrollAmount(scroll->getVerticalMaxScroll());
@@ -289,7 +307,7 @@ void ChatWindow::chatSend(std::string const &msg)
if (msg.empty()) return;
// Prepare ordinary message
- if (msg[0] != '/')
+ if (msg[0] != '/')
{
if (getFocused() == "General")
{
@@ -330,6 +348,7 @@ ChatWindow::removeChannel(Channel *channel)
Tab *tab = mChatTabs->getTab(channel->getName());
if (!tab)
return;
+ clearTab(channel->getName());
mChatTabs->removeTab(tab);
mChannels.erase(channel->getName());
channelManager->removeChannel(channel);