diff options
author | Maximilian Philipps <Turmfalke2007@web.de> | 2009-07-30 21:50:15 +0200 |
---|---|---|
committer | Bertram <bertram@cegetel.net> | 2009-07-31 00:14:39 +0200 |
commit | 92dae33631e5b2f43c280aa6b05861a4f2aa25e2 (patch) | |
tree | 7c004cdf207870dcb8155902ab61c623742a0cc1 /src/gui | |
parent | 256391f7bff25440218e7b10e445fe91f232f6a9 (diff) | |
download | mana-client-92dae33631e5b2f43c280aa6b05861a4f2aa25e2.tar.gz mana-client-92dae33631e5b2f43c280aa6b05861a4f2aa25e2.tar.bz2 mana-client-92dae33631e5b2f43c280aa6b05861a4f2aa25e2.tar.xz mana-client-92dae33631e5b2f43c280aa6b05861a4f2aa25e2.zip |
patch for ticket #767
bigger "hold here to drag" area for the chatbox and a scroll lock for resize
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 * |