[Scummvm-cvs-logs] CVS: scummvm/gui ScrollBarWidget.cpp,1.2,1.3
Max Horn
fingolfin at users.sourceforge.net
Tue Oct 1 15:43:32 CEST 2002
Update of /cvsroot/scummvm/scummvm/gui
In directory usw-pr-cvs1:/tmp/cvs-serv16089
Modified Files:
ScrollBarWidget.cpp
Log Message:
fixed scrollbar drawing/response when there are less items than fit on one page
Index: ScrollBarWidget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/ScrollBarWidget.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- ScrollBarWidget.cpp 8 Sep 2002 16:00:12 -0000 1.2
+++ ScrollBarWidget.cpp 1 Oct 2002 22:39:55 -0000 1.3
@@ -74,6 +74,10 @@
{
int old_pos = _currentPos;
+ // Do nothing if there are less items than fit on one page
+ if (_numEntries < _entriesPerPage)
+ return;
+
if (y <= UP_DOWN_BOX_HEIGHT) {
// Up arrow
_currentPos--;
@@ -97,12 +101,15 @@
void ScrollBarWidget::handleMouseUp(int x, int y, int button, int clickCount)
{
- if (_draggingPart != kNoPart)
- _draggingPart = kNoPart;
+ _draggingPart = kNoPart;
}
void ScrollBarWidget::handleMouseMoved(int x, int y, int button)
{
+ // Do nothing if there are less items than fit on one page
+ if (_numEntries < _entriesPerPage)
+ return;
+
if (_draggingPart == kSliderPart) {
int old_pos = _currentPos;
_sliderPos = y - _sliderDeltaMouseDownPos;
@@ -158,10 +165,10 @@
void ScrollBarWidget::checkBounds(int old_pos)
{
- if (_currentPos > _numEntries - _entriesPerPage)
- _currentPos = _numEntries - _entriesPerPage;
- else if (_currentPos < 0)
+ if (_numEntries < _entriesPerPage || _currentPos < 0)
_currentPos = 0;
+ else if (_currentPos > _numEntries - _entriesPerPage)
+ _currentPos = _numEntries - _entriesPerPage;
if (old_pos != _currentPos) {
recalc();
@@ -187,6 +194,7 @@
{
NewGui *gui = _boss->getGui();
int bottomY = _y + _h;
+ bool isSinglePage = (_numEntries < _entriesPerPage);
gui->frameRect(_x, _y, _w, _h, gui->_shadowcolor);
@@ -196,15 +204,19 @@
// Up arrow
gui->frameRect(_x, _y, _w, UP_DOWN_BOX_HEIGHT, gui->_color);
gui->drawBitmap(up_arrow, _x, _y,
- (hilite && _part == kUpArrowPart) ? gui->_textcolorhi : gui->_textcolor);
+ isSinglePage ? gui->_color :
+ (hilite && _part == kUpArrowPart) ? gui->_textcolorhi : gui->_textcolor);
// Down arrow
gui->frameRect(_x, bottomY - UP_DOWN_BOX_HEIGHT, _w, UP_DOWN_BOX_HEIGHT, gui->_color);
gui->drawBitmap(down_arrow, _x, bottomY - UP_DOWN_BOX_HEIGHT,
- (hilite && _part == kDownArrowPart) ? gui->_textcolorhi : gui->_textcolor);
+ isSinglePage ? gui->_color :
+ (hilite && _part == kDownArrowPart) ? gui->_textcolorhi : gui->_textcolor);
// Slider
- gui->checkerRect(_x, _y + _sliderPos, _w, _sliderHeight,
- (hilite && _part == kSliderPart) ? gui->_textcolorhi : gui->_textcolor);
- gui->frameRect(_x, _y + _sliderPos, _w, _sliderHeight, gui->_color);
+ if (!isSinglePage) {
+ gui->checkerRect(_x, _y + _sliderPos, _w, _sliderHeight,
+ (hilite && _part == kSliderPart) ? gui->_textcolorhi : gui->_textcolor);
+ gui->frameRect(_x, _y + _sliderPos, _w, _sliderHeight, gui->_color);
+ }
}
More information about the Scummvm-git-logs
mailing list