summaryrefslogtreecommitdiff
path: root/src/gui/widgets/scrollarea.cpp
diff options
context:
space:
mode:
authorMaximilian Philipps <Turmfalke2007@web.de>2009-08-02 20:15:38 +0200
committerChuck Miller <shadowmil@gmail.com>2009-08-05 15:19:32 -0400
commit1eda598ab8d34e8d2fd3ecf990fcb64d49f518f8 (patch)
tree098001f83da97cc77cb234dc40bc23dae6d8fe95 /src/gui/widgets/scrollarea.cpp
parent5c578f9d64bfcc0dbd81d9c6bad549a65bd1ad32 (diff)
downloadmana-1eda598ab8d34e8d2fd3ecf990fcb64d49f518f8.tar.gz
mana-1eda598ab8d34e8d2fd3ecf990fcb64d49f518f8.tar.bz2
mana-1eda598ab8d34e8d2fd3ecf990fcb64d49f518f8.tar.xz
mana-1eda598ab8d34e8d2fd3ecf990fcb64d49f518f8.zip
patch for #813, adds mouse over highlight for
radio buttons, tabs, checkboxes, slider and scrollbars
Diffstat (limited to 'src/gui/widgets/scrollarea.cpp')
-rw-r--r--src/gui/widgets/scrollarea.cpp47
1 files changed, 43 insertions, 4 deletions
diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp
index ff3a23d1..a5ea43a8 100644
--- a/src/gui/widgets/scrollarea.cpp
+++ b/src/gui/widgets/scrollarea.cpp
@@ -33,10 +33,13 @@ int ScrollArea::instances = 0;
float ScrollArea::mAlpha = 1.0;
ImageRect ScrollArea::background;
ImageRect ScrollArea::vMarker;
+ImageRect ScrollArea::vMarkerHi;
Image *ScrollArea::buttons[4][2];
ScrollArea::ScrollArea():
gcn::ScrollArea(),
+ mX(0),
+ mY(0),
mOpaque(true)
{
init();
@@ -44,6 +47,7 @@ ScrollArea::ScrollArea():
ScrollArea::ScrollArea(gcn::Widget *widget):
gcn::ScrollArea(widget),
+ mHasMouse(false),
mOpaque(true)
{
init();
@@ -60,6 +64,7 @@ ScrollArea::~ScrollArea()
{
for_each(background.grid, background.grid + 9, dtor<Image*>());
for_each(vMarker.grid, vMarker.grid + 9, dtor<Image*>());
+ for_each(vMarkerHi.grid, vMarker.grid + 9, dtor<Image*>());
buttons[UP][0]->decRef();
buttons[UP][1]->decRef();
@@ -103,6 +108,8 @@ void ScrollArea::init()
// Load vertical scrollbar skin
Image *vscroll = resman->getImage("graphics/gui/vscroll_grey.png");
+ Image *vscrollHi = resman->getImage("graphics/gui/vscroll_highlight.png");
+
int vsgridx[4] = {0, 4, 7, 11};
int vsgridy[4] = {0, 4, 15, 19};
a = 0;
@@ -115,12 +122,18 @@ void ScrollArea::init()
vsgridx[x], vsgridy[y],
vsgridx[x + 1] - vsgridx[x],
vsgridy[y + 1] - vsgridy[y]);
+ vMarkerHi.grid[a] = vscrollHi->getSubImage(
+ vsgridx[x], vsgridy[y],
+ vsgridx[x + 1] - vsgridx[x],
+ vsgridy[y + 1] - vsgridy[y]);
vMarker.grid[a]->setAlpha(config.getValue("guialpha", 0.8));
+ vMarkerHi.grid[a]->setAlpha(config.getValue("guialpha", 0.8));
a++;
}
}
vscroll->decRef();
+ vscrollHi->decRef();
buttons[UP][0] =
resman->getImage("graphics/gui/vscroll_up_default.png");
@@ -202,6 +215,7 @@ void ScrollArea::draw(gcn::Graphics *graphics)
{
background.grid[a]->setAlpha(mAlpha);
vMarker.grid[a]->setAlpha(mAlpha);
+ vMarkerHi.grid[a]->setAlpha(mAlpha);
}
}
@@ -296,14 +310,39 @@ void ScrollArea::drawVMarker(gcn::Graphics *graphics)
{
gcn::Rectangle dim = getVerticalMarkerDimension();
- static_cast<Graphics*>(graphics)->
- drawImageRect(dim.x, dim.y, dim.width, dim.height, vMarker);
+ if ((mHasMouse) && (mX > (getWidth() - getScrollbarWidth())))
+ static_cast<Graphics*>(graphics)->
+ drawImageRect(dim.x, dim.y, dim.width, dim.height, vMarkerHi);
+ else
+ static_cast<Graphics*>(graphics)->
+ drawImageRect(dim.x, dim.y, dim.width, dim.height,vMarker);
}
void ScrollArea::drawHMarker(gcn::Graphics *graphics)
{
gcn::Rectangle dim = getHorizontalMarkerDimension();
- static_cast<Graphics*>(graphics)->
- drawImageRect(dim.x, dim.y, dim.width, dim.height, vMarker);
+ if ((mHasMouse) && (mY > (getHeight() - getScrollbarWidth())))
+ static_cast<Graphics*>(graphics)->
+ drawImageRect(dim.x, dim.y, dim.width, dim.height, vMarkerHi);
+ else
+ static_cast<Graphics*>(graphics)->
+ drawImageRect(dim.x, dim.y, dim.width, dim.height, vMarker);
}
+
+void ScrollArea::mouseMoved(gcn::MouseEvent& event)
+{
+mX = event.getX();
+mY = event.getY();
+}
+
+void ScrollArea::mouseEntered(gcn::MouseEvent& event)
+{
+ mHasMouse = true;
+}
+
+void ScrollArea::mouseExited(gcn::MouseEvent& event)
+{
+ mHasMouse = false;
+}
+