summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-02-10 23:02:26 +0300
committerAndrei Karas <akaras@inbox.ru>2013-02-10 23:02:26 +0300
commit4d236566cc8132fdbcb901668c3291f7cf3279af (patch)
tree80c732be5592689f64851fec8f869368eb6b000a
parent6781809c3ae40507d86573f06c296706eff60e9a (diff)
downloadplus-4d236566cc8132fdbcb901668c3291f7cf3279af.tar.gz
plus-4d236566cc8132fdbcb901668c3291f7cf3279af.tar.bz2
plus-4d236566cc8132fdbcb901668c3291f7cf3279af.tar.xz
plus-4d236566cc8132fdbcb901668c3291f7cf3279af.zip
Add option to scrollbuttons.xml to set scroll marker size.
New theme option: markersize - set market scroll size. Default is 0 (auto count).
-rw-r--r--data/themes/jewelry/scrollbuttons.xml1
-rw-r--r--src/gui/widgets/scrollarea.cpp100
-rw-r--r--src/gui/widgets/scrollarea.h1
3 files changed, 66 insertions, 36 deletions
diff --git a/data/themes/jewelry/scrollbuttons.xml b/data/themes/jewelry/scrollbuttons.xml
index 9ffd91348..6a42d7dba 100644
--- a/data/themes/jewelry/scrollbuttons.xml
+++ b/data/themes/jewelry/scrollbuttons.xml
@@ -2,6 +2,7 @@
<skinset name="Default" image="window.png">
<widget type="Window" xpos="41" ypos="100">
<option name="showbuttons" value="0" />
+ <option name="markersize" value="0" />
<part type="left" xpos="0" ypos="0" width="12" height="12" />
<part type="right" xpos="0" ypos="16" width="12" height="12" />
<part type="down" xpos="0" ypos="32" width="12" height="12" />
diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp
index 4e3404aa8..e865839ab 100644
--- a/src/gui/widgets/scrollarea.cpp
+++ b/src/gui/widgets/scrollarea.cpp
@@ -33,6 +33,7 @@
int ScrollArea::instances = 0;
float ScrollArea::mAlpha = 1.0;
bool ScrollArea::mShowButtons = true;
+int ScrollArea::mMarkerSize = 0;
ImageRect ScrollArea::background;
ImageRect ScrollArea::vMarker;
ImageRect ScrollArea::vMarkerHi;
@@ -168,7 +169,10 @@ void ScrollArea::init(std::string skinName)
buttons[f][i] = rect.grid[f];
}
if (i == 0)
+ {
mShowButtons = (skin->getOption("showbuttons", 1) == 1);
+ mMarkerSize = skin->getOption("markersize", 0);
+ }
}
else
{
@@ -864,7 +868,8 @@ gcn::Rectangle ScrollArea::getVerticalMarkerDimension()
int length, pos;
int height;
- const int h2 = (mVBarVisible && mShowButtons) ? mScrollbarWidth : 0;
+ const int h2 = (mVBarVisible && mShowButtons)
+ ? mScrollbarWidth : mMarkerSize / 2;
const gcn::Widget *content;
if (!mWidgets.empty())
content = *mWidgets.begin();
@@ -876,30 +881,42 @@ gcn::Rectangle ScrollArea::getVerticalMarkerDimension()
else
height = mDimension.height - 2 * h2;
- if (content && content->getHeight() != 0)
+ const int maxV = getVerticalMaxScroll();
+ if (mMarkerSize && maxV)
{
- length = (height * getChildrenArea().height)
- / content->getHeight();
+ pos = (mVScroll * height / maxV - mMarkerSize / 2);
+ length = mMarkerSize;
}
else
{
- length = height;
- }
+ if (content)
+ {
+ const int h3 = content->getHeight();
+ if (h3)
+ length = (height * getChildrenArea().height) / h3;
+ else
+ length = height;
+ }
+ else
+ {
+ length = height;
+ }
- if (length < mScrollbarWidth)
- length = mScrollbarWidth;
+ if (length < mScrollbarWidth)
+ length = mScrollbarWidth;
- if (length > height)
- length = height;
+ if (length > height)
+ length = height;
- if (getVerticalMaxScroll() != 0)
- {
- pos = ((height - length) * mVScroll)
- / getVerticalMaxScroll();
- }
- else
- {
- pos = 0;
+ if (getVerticalMaxScroll() != 0)
+ {
+ pos = ((height - length) * mVScroll)
+ / getVerticalMaxScroll();
+ }
+ else
+ {
+ pos = 0;
+ }
}
return gcn::Rectangle(mDimension.width - mScrollbarWidth, h2 + pos,
@@ -913,7 +930,8 @@ gcn::Rectangle ScrollArea::getHorizontalMarkerDimension()
int length, pos;
int width;
- const int w2 = (mHBarVisible && mShowButtons) ? mScrollbarWidth : 0;
+ const int w2 = (mHBarVisible && mShowButtons)
+ ? mScrollbarWidth : mMarkerSize / 2;
const gcn::Widget *content;
if (!mWidgets.empty())
content = *mWidgets.begin();
@@ -925,30 +943,40 @@ gcn::Rectangle ScrollArea::getHorizontalMarkerDimension()
else
width = mDimension.width - w2 - mScrollbarWidth;
- if (content && content->getWidth() != 0)
+ const int maxH = getHorizontalMaxScroll();
+ if (mMarkerSize && maxH)
{
- length = (width * getChildrenArea().width)
- / content->getWidth();
+ pos = (getHorizontalScrollAmount() * width / maxH - mMarkerSize / 2);
+ length = mMarkerSize;
}
else
{
- length = width;
- }
+ if (content)
+ {
+ const int w3 = content->getWidth();
+ if (w3)
+ length = (width * getChildrenArea().width) / w3;
+ }
+ else
+ {
+ length = width;
+ }
- if (length < mScrollbarWidth)
- length = mScrollbarWidth;
+ if (length < mScrollbarWidth)
+ length = mScrollbarWidth;
- if (length > width)
- length = width;
+ if (length > width)
+ length = width;
- if (getHorizontalMaxScroll() != 0)
- {
- pos = ((width - length) * getHorizontalScrollAmount())
- / getHorizontalMaxScroll();
- }
- else
- {
- pos = 0;
+ if (getHorizontalMaxScroll() != 0)
+ {
+ pos = ((width - length) * getHorizontalScrollAmount())
+ / getHorizontalMaxScroll();
+ }
+ else
+ {
+ pos = 0;
+ }
}
return gcn::Rectangle(w2 + pos, mDimension.height - mScrollbarWidth,
diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h
index 3a552ee75..3c391e4ae 100644
--- a/src/gui/widgets/scrollarea.h
+++ b/src/gui/widgets/scrollarea.h
@@ -174,6 +174,7 @@ class ScrollArea final : public gcn::ScrollArea,
static int instances;
static float mAlpha;
static bool mShowButtons;
+ static int mMarkerSize;
static ImageRect background;
static ImageRect vMarker;
static ImageRect vMarkerHi;