diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/chat.cpp | 34 | ||||
-rw-r--r-- | src/gui/chat.h | 5 |
2 files changed, 39 insertions, 0 deletions
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 1d06edd1..1561002a 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -141,9 +141,14 @@ void ChatWindow::adjustTabSize() ChatTab *tab = getFocused(); if (tab) { gcn::Widget *content = tab->mScrollArea; + bool scrollLock = false; + if(tab->mScrollArea->getVerticalMaxScroll() == tab->mScrollArea->getVerticalScrollAmount()) + scrollLock = true; content->setSize(mChatTabs->getWidth() - 2 * content->getFrameSize(), mChatTabs->getContainerHeight() - 2 * content->getFrameSize()); content->logic(); + if(scrollLock) + tab->mScrollArea->setVerticalScrollAmount(tab->mScrollArea->getVerticalMaxScroll()); } } @@ -362,6 +367,35 @@ void ChatWindow::scroll(int amount) if (tab) tab->scroll(amount); } +void ChatWindow::mousePressed(gcn::MouseEvent &event) +{ +Window::mousePressed(event); + +if(event.isConsumed()) +return; + +mMoved = event.getY() <= mCurrentTab->getHeight(); +mDragOffsetX = event.getX(); +mDragOffsetY = event.getY(); + +} +void ChatWindow::mouseDragged(gcn::MouseEvent &event) +{ +Window::mouseDragged(event); + +if(event.isConsumed()) +return; + +if(isMovable() && mMoved) +{ + int newX = std::max(0, getX() + event.getX() - mDragOffsetX); + int newY = std::max(0, getY() + event.getY() - mDragOffsetY); + newX = std::min(graphics->getWidth() - getWidth(), newX); + newY = std::min(graphics->getHeight() - getHeight(), newY); + setPosition(newX, newY); +} +} + void ChatWindow::keyPressed(gcn::KeyEvent &event) { diff --git a/src/gui/chat.h b/src/gui/chat.h index 7080392e..2de3a634 100644 --- a/src/gui/chat.h +++ b/src/gui/chat.h @@ -150,6 +150,11 @@ class ChatWindow : public Window, /** Override to reset mTmpVisible */ void setVisible(bool visible); + + void mousePressed(gcn::MouseEvent &event); + void mouseDragged(gcn::MouseEvent &event); + + /** * Scrolls the chat window * |