From 92dae33631e5b2f43c280aa6b05861a4f2aa25e2 Mon Sep 17 00:00:00 2001 From: Maximilian Philipps Date: Thu, 30 Jul 2009 21:50:15 +0200 Subject: patch for ticket #767 bigger "hold here to drag" area for the chatbox and a scroll lock for resize --- src/gui/chat.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/gui/chat.cpp') 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) { -- cgit v1.2.3-70-g09d2