fixed scrollbar drawing/response when there are less items than fit on one page
svn-id: r5066
This commit is contained in:
parent
a1f749994f
commit
273e4b4740
1 changed files with 22 additions and 10 deletions
|
@ -74,6 +74,10 @@ void ScrollBarWidget::handleMouseDown(int x, int y, int button, int clickCount)
|
||||||
{
|
{
|
||||||
int old_pos = _currentPos;
|
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) {
|
if (y <= UP_DOWN_BOX_HEIGHT) {
|
||||||
// Up arrow
|
// Up arrow
|
||||||
_currentPos--;
|
_currentPos--;
|
||||||
|
@ -97,12 +101,15 @@ void ScrollBarWidget::handleMouseDown(int x, int y, int button, int clickCount)
|
||||||
|
|
||||||
void ScrollBarWidget::handleMouseUp(int x, int y, int button, int clickCount)
|
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)
|
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) {
|
if (_draggingPart == kSliderPart) {
|
||||||
int old_pos = _currentPos;
|
int old_pos = _currentPos;
|
||||||
_sliderPos = y - _sliderDeltaMouseDownPos;
|
_sliderPos = y - _sliderDeltaMouseDownPos;
|
||||||
|
@ -158,10 +165,10 @@ void ScrollBarWidget::handleTickle()
|
||||||
|
|
||||||
void ScrollBarWidget::checkBounds(int old_pos)
|
void ScrollBarWidget::checkBounds(int old_pos)
|
||||||
{
|
{
|
||||||
if (_currentPos > _numEntries - _entriesPerPage)
|
if (_numEntries < _entriesPerPage || _currentPos < 0)
|
||||||
_currentPos = _numEntries - _entriesPerPage;
|
|
||||||
else if (_currentPos < 0)
|
|
||||||
_currentPos = 0;
|
_currentPos = 0;
|
||||||
|
else if (_currentPos > _numEntries - _entriesPerPage)
|
||||||
|
_currentPos = _numEntries - _entriesPerPage;
|
||||||
|
|
||||||
if (old_pos != _currentPos) {
|
if (old_pos != _currentPos) {
|
||||||
recalc();
|
recalc();
|
||||||
|
@ -187,6 +194,7 @@ void ScrollBarWidget::drawWidget(bool hilite)
|
||||||
{
|
{
|
||||||
NewGui *gui = _boss->getGui();
|
NewGui *gui = _boss->getGui();
|
||||||
int bottomY = _y + _h;
|
int bottomY = _y + _h;
|
||||||
|
bool isSinglePage = (_numEntries < _entriesPerPage);
|
||||||
|
|
||||||
gui->frameRect(_x, _y, _w, _h, gui->_shadowcolor);
|
gui->frameRect(_x, _y, _w, _h, gui->_shadowcolor);
|
||||||
|
|
||||||
|
@ -196,15 +204,19 @@ void ScrollBarWidget::drawWidget(bool hilite)
|
||||||
// Up arrow
|
// Up arrow
|
||||||
gui->frameRect(_x, _y, _w, UP_DOWN_BOX_HEIGHT, gui->_color);
|
gui->frameRect(_x, _y, _w, UP_DOWN_BOX_HEIGHT, gui->_color);
|
||||||
gui->drawBitmap(up_arrow, _x, _y,
|
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
|
// Down arrow
|
||||||
gui->frameRect(_x, bottomY - UP_DOWN_BOX_HEIGHT, _w, UP_DOWN_BOX_HEIGHT, gui->_color);
|
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,
|
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
|
// Slider
|
||||||
gui->checkerRect(_x, _y + _sliderPos, _w, _sliderHeight,
|
if (!isSinglePage) {
|
||||||
(hilite && _part == kSliderPart) ? gui->_textcolorhi : gui->_textcolor);
|
gui->checkerRect(_x, _y + _sliderPos, _w, _sliderHeight,
|
||||||
gui->frameRect(_x, _y + _sliderPos, _w, _sliderHeight, gui->_color);
|
(hilite && _part == kSliderPart) ? gui->_textcolorhi : gui->_textcolor);
|
||||||
|
gui->frameRect(_x, _y + _sliderPos, _w, _sliderHeight, gui->_color);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue