diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-02-10 16:27:16 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-02-10 16:55:22 +0300 |
commit | f6482585eb8d9fd514b38dd214d83acd3985dc76 (patch) | |
tree | b70094dd1886f2a842364c9f2940b7b81acace79 /src/guichan/widgets/scrollarea.cpp | |
parent | 9b84665e4d2a3c069179cde38f32ce023b37542a (diff) | |
download | manaverse-f6482585eb8d9fd514b38dd214d83acd3985dc76.tar.gz manaverse-f6482585eb8d9fd514b38dd214d83acd3985dc76.tar.bz2 manaverse-f6482585eb8d9fd514b38dd214d83acd3985dc76.tar.xz manaverse-f6482585eb8d9fd514b38dd214d83acd3985dc76.zip |
Add theme option to hide scrollbar buttons.
Also improve scrollbar speed.
Diffstat (limited to 'src/guichan/widgets/scrollarea.cpp')
-rw-r--r-- | src/guichan/widgets/scrollarea.cpp | 316 |
1 files changed, 0 insertions, 316 deletions
diff --git a/src/guichan/widgets/scrollarea.cpp b/src/guichan/widgets/scrollarea.cpp index c286d26e6..67154fbad 100644 --- a/src/guichan/widgets/scrollarea.cpp +++ b/src/guichan/widgets/scrollarea.cpp @@ -287,77 +287,6 @@ namespace gcn return mScrollbarWidth; } - void ScrollArea::mousePressed(MouseEvent& mouseEvent) - { - const int x = mouseEvent.getX(); - const int y = mouseEvent.getY(); - - if (getUpButtonDimension().isPointInRect(x, y)) - { - setVerticalScrollAmount(getVerticalScrollAmount() - - mUpButtonScrollAmount); - mUpButtonPressed = true; - } - else if (getDownButtonDimension().isPointInRect(x, y)) - { - setVerticalScrollAmount(getVerticalScrollAmount() - + mDownButtonScrollAmount); - mDownButtonPressed = true; - } - else if (getLeftButtonDimension().isPointInRect(x, y)) - { - setHorizontalScrollAmount(getHorizontalScrollAmount() - - mLeftButtonScrollAmount); - mLeftButtonPressed = true; - } - else if (getRightButtonDimension().isPointInRect(x, y)) - { - setHorizontalScrollAmount(getHorizontalScrollAmount() - + mRightButtonScrollAmount); - mRightButtonPressed = true; - } - else if (getVerticalMarkerDimension().isPointInRect(x, y)) - { - mIsHorizontalMarkerDragged = false; - mIsVerticalMarkerDragged = true; - - mVerticalMarkerDragOffset = y - getVerticalMarkerDimension().y; - } - else if (getVerticalBarDimension().isPointInRect(x, y)) - { - if (y < getVerticalMarkerDimension().y) - { - setVerticalScrollAmount(getVerticalScrollAmount() - - static_cast<int>(getChildrenArea().height * 0.95)); - } - else - { - setVerticalScrollAmount(getVerticalScrollAmount() - + static_cast<int>(getChildrenArea().height * 0.95)); - } - } - else if (getHorizontalMarkerDimension().isPointInRect(x, y)) - { - mIsHorizontalMarkerDragged = true; - mIsVerticalMarkerDragged = false; - - mHorizontalMarkerDragOffset = x - getHorizontalMarkerDimension().x; - } - else if (getHorizontalBarDimension().isPointInRect(x, y)) - { - if (x < getHorizontalMarkerDimension().x) - { - setHorizontalScrollAmount(getHorizontalScrollAmount() - - static_cast<int>(getChildrenArea().width * 0.95)); - } - else - { - setHorizontalScrollAmount(getHorizontalScrollAmount() - + static_cast<int>(getChildrenArea().width * 0.95)); - } - } - } - void ScrollArea::mouseReleased(MouseEvent& mouseEvent) { mUpButtonPressed = false; @@ -370,49 +299,6 @@ namespace gcn mouseEvent.consume(); } - void ScrollArea::mouseDragged(MouseEvent& mouseEvent) - { - if (mIsVerticalMarkerDragged) - { - const Rectangle barDim = getVerticalBarDimension(); - - const int pos = mouseEvent.getY() - barDim.y - - mVerticalMarkerDragOffset; - const int length = getVerticalMarkerDimension().height; - - if ((barDim.height - length) > 0) - { - setVerticalScrollAmount((getVerticalMaxScroll() * pos) - / (barDim.height - length)); - } - else - { - setVerticalScrollAmount(0); - } - } - - if (mIsHorizontalMarkerDragged) - { - const Rectangle barDim = getHorizontalBarDimension(); - - const int pos = mouseEvent.getX() - barDim.x - - mHorizontalMarkerDragOffset; - const int length = getHorizontalMarkerDimension().width; - - if ((barDim.width - length) > 0) - { - setHorizontalScrollAmount((getHorizontalMaxScroll() * pos) - / (barDim.width - length)); - } - else - { - setHorizontalScrollAmount(0); - } - } - - mouseEvent.consume(); - } - void ScrollArea::draw(Graphics *graphics A_UNUSED) { } @@ -565,62 +451,6 @@ namespace gcn } } - Rectangle ScrollArea::getUpButtonDimension() const - { - if (!mVBarVisible) - return Rectangle(0, 0, 0, 0); - - return Rectangle(getWidth() - mScrollbarWidth, 0, - mScrollbarWidth, mScrollbarWidth); - } - - Rectangle ScrollArea::getDownButtonDimension() const - { - if (!mVBarVisible) - return Rectangle(0, 0, 0, 0); - - if (mVBarVisible && mHBarVisible) - { - return Rectangle(getWidth() - mScrollbarWidth, - getHeight() - mScrollbarWidth*2, - mScrollbarWidth, - mScrollbarWidth); - } - - return Rectangle(getWidth() - mScrollbarWidth, - getHeight() - mScrollbarWidth, - mScrollbarWidth, - mScrollbarWidth); - } - - Rectangle ScrollArea::getLeftButtonDimension() const - { - if (!mHBarVisible) - return Rectangle(0, 0, 0, 0); - - return Rectangle(0, getHeight() - mScrollbarWidth, - mScrollbarWidth, mScrollbarWidth); - } - - Rectangle ScrollArea::getRightButtonDimension() const - { - if (!mHBarVisible) - return Rectangle(0, 0, 0, 0); - - if (mVBarVisible && mHBarVisible) - { - return Rectangle(getWidth() - mScrollbarWidth*2, - getHeight() - mScrollbarWidth, - mScrollbarWidth, - mScrollbarWidth); - } - - return Rectangle(getWidth() - mScrollbarWidth, - getHeight() - mScrollbarWidth, - mScrollbarWidth, - mScrollbarWidth); - } - Rectangle ScrollArea::getChildrenArea() { const Rectangle area = Rectangle(0, 0, @@ -633,152 +463,6 @@ namespace gcn return area; } - Rectangle ScrollArea::getVerticalBarDimension() const - { - if (!mVBarVisible) - return Rectangle(0, 0, 0, 0); - - if (mHBarVisible) - { - return Rectangle(getWidth() - mScrollbarWidth, - getUpButtonDimension().height, - mScrollbarWidth, - getHeight() - - getUpButtonDimension().height - - getDownButtonDimension().height - - mScrollbarWidth); - } - - return Rectangle(getWidth() - mScrollbarWidth, - getUpButtonDimension().height, - mScrollbarWidth, - getHeight() - - getUpButtonDimension().height - - getDownButtonDimension().height); - } - - Rectangle ScrollArea::getHorizontalBarDimension() const - { - if (!mHBarVisible) - return Rectangle(0, 0, 0, 0); - - if (mVBarVisible) - { - return Rectangle(getLeftButtonDimension().width, - getHeight() - mScrollbarWidth, - getWidth() - - getLeftButtonDimension().width - - getRightButtonDimension().width - - mScrollbarWidth, - mScrollbarWidth); - } - - return Rectangle(getLeftButtonDimension().width, - getHeight() - mScrollbarWidth, - getWidth() - - getLeftButtonDimension().width - - getRightButtonDimension().width, - mScrollbarWidth); - } - - Rectangle ScrollArea::getVerticalMarkerDimension() - { - if (!mVBarVisible) - return Rectangle(0, 0, 0, 0); - - int length, pos; - int height; - - if (mHBarVisible) - { - height = getHeight() - getUpButtonDimension().height - - getDownButtonDimension().height - mScrollbarWidth; - } - else - { - height = getHeight() - getUpButtonDimension().height - - getDownButtonDimension().height; - } - - if (getContent() && getContent()->getHeight() != 0) - { - length = (height * getChildrenArea().height) - / getContent()->getHeight(); - } - else - { - length = height; - } - - if (length < mScrollbarWidth) - length = mScrollbarWidth; - - if (length > height) - length = height; - - if (getVerticalMaxScroll() != 0) - { - pos = ((height - length) * getVerticalScrollAmount()) - / getVerticalMaxScroll(); - } - else - { - pos = 0; - } - - return Rectangle(getWidth() - mScrollbarWidth, - getUpButtonDimension().height + pos, mScrollbarWidth, length); - } - - Rectangle ScrollArea::getHorizontalMarkerDimension() - { - if (!mHBarVisible) - return Rectangle(0, 0, 0, 0); - - int length, pos; - int width; - - if (mVBarVisible) - { - width = getWidth() - getLeftButtonDimension().width - - getRightButtonDimension().width - mScrollbarWidth; - } - else - { - width = getWidth() - getLeftButtonDimension().width - - getRightButtonDimension().width; - } - - if (getContent() && getContent()->getWidth() != 0) - { - length = (width * getChildrenArea().width) - / getContent()->getWidth(); - } - else - { - length = width; - } - - if (length < mScrollbarWidth) - length = mScrollbarWidth; - - if (length > width) - length = width; - - if (getHorizontalMaxScroll() != 0) - { - pos = ((width - length) * getHorizontalScrollAmount()) - / getHorizontalMaxScroll(); - } - else - { - pos = 0; - } - - return Rectangle(getLeftButtonDimension().width + pos, - getHeight() - mScrollbarWidth, length, mScrollbarWidth); - } - void ScrollArea::showWidgetPart(Widget* widget, Rectangle area) { if (widget != getContent()) |