summaryrefslogtreecommitdiff
path: root/src/guichan
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-02-10 16:27:16 +0300
committerAndrei Karas <akaras@inbox.ru>2013-02-10 16:55:22 +0300
commitf6482585eb8d9fd514b38dd214d83acd3985dc76 (patch)
treeb70094dd1886f2a842364c9f2940b7b81acace79 /src/guichan
parent9b84665e4d2a3c069179cde38f32ce023b37542a (diff)
downloadmanaplus-f6482585eb8d9fd514b38dd214d83acd3985dc76.tar.gz
manaplus-f6482585eb8d9fd514b38dd214d83acd3985dc76.tar.bz2
manaplus-f6482585eb8d9fd514b38dd214d83acd3985dc76.tar.xz
manaplus-f6482585eb8d9fd514b38dd214d83acd3985dc76.zip
Add theme option to hide scrollbar buttons.
Also improve scrollbar speed.
Diffstat (limited to 'src/guichan')
-rw-r--r--src/guichan/include/guichan/widgets/scrollarea.hpp60
-rw-r--r--src/guichan/widgets/scrollarea.cpp316
2 files changed, 0 insertions, 376 deletions
diff --git a/src/guichan/include/guichan/widgets/scrollarea.hpp b/src/guichan/include/guichan/widgets/scrollarea.hpp
index 92f68000e..32a3f8f5b 100644
--- a/src/guichan/include/guichan/widgets/scrollarea.hpp
+++ b/src/guichan/include/guichan/widgets/scrollarea.hpp
@@ -351,12 +351,8 @@ namespace gcn
// Inherited from MouseListener
- virtual void mousePressed(MouseEvent& mouseEvent) override;
-
virtual void mouseReleased(MouseEvent& mouseEvent) override;
- virtual void mouseDragged(MouseEvent& mouseEvent) override;
-
virtual void mouseWheelMovedUp(MouseEvent& mouseEvent) override;
virtual void mouseWheelMovedDown(MouseEvent& mouseEvent) override;
@@ -432,62 +428,6 @@ namespace gcn
virtual void checkPolicies();
/**
- * Gets the up button dimension.
- *
- * @return the dimension of the up button.
- */
- Rectangle getUpButtonDimension() const;
-
- /**
- * Gets the down button dimension.
- *
- * @return the dimension of the down button.
- */
- Rectangle getDownButtonDimension() const;
-
- /**
- * Gets the left button dimension.
- *
- * @return the dimension of the left button.
- */
- Rectangle getLeftButtonDimension() const;
-
- /**
- * Gets the right button dimension.
- *
- * @return the dimension of the right button.
- */
- Rectangle getRightButtonDimension() const;
-
- /**
- * Gets the vertical scrollbar dimension.
- *
- * @return the dimension of the vertical scrollbar.
- */
- Rectangle getVerticalBarDimension() const;
-
- /**
- * Gets the horizontal scrollbar dimension.
- *
- * @return the dimension of the horizontal scrollbar.
- */
- Rectangle getHorizontalBarDimension() const;
-
- /**
- * Gets the vertical marker dimension.
- *
- * @return the dimension of the vertical marker.
- */
- Rectangle getVerticalMarkerDimension();
-
- /**
- * Gets the horizontal marker dimension.
- *
- * @return the dimension of the horizontal marker.
- */
- Rectangle getHorizontalMarkerDimension();
-
- /**
* Holds the vertical scroll amount.
*/
int mVScroll;
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())