Skip to content

Commit

Permalink
SCUMM: Cleanup Mac slider widget
Browse files Browse the repository at this point in the history
  • Loading branch information
Torbjörn Andersson committed Nov 8, 2023
1 parent 732c999 commit a4b8277
Showing 1 changed file with 17 additions and 29 deletions.
46 changes: 17 additions & 29 deletions engines/scumm/gfx_mac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,8 @@ bool MacGui::MacSlider::findWidget(int x, int y) const {

Common::Rect bounds = _bounds;

// While dragging the handle, you'r allowed to go outside the slider.

if (_grabOffset >= 0) {
bounds.left -= 25;
bounds.right += 25;
Expand Down Expand Up @@ -1252,20 +1254,6 @@ void MacGui::MacSlider::handleMouseMove(Common::Event &event) {
int x = event.mouse.x;
int y = event.mouse.y;

if (!findWidget(x, y)) {
if (_upArrowPressed) {
_upArrowPressed = false;
drawUpArrow(true);
}

if (_downArrowPressed) {
_downArrowPressed = false;
drawDownArrow(true);
}

return;
}

if (_grabOffset >= 0) {
Common::Rect r;

Expand Down Expand Up @@ -1404,6 +1392,21 @@ bool MacGui::MacPictureSlider::findWidget(int x, int y) const {
return _bounds.contains(x, y);
}

void MacGui::MacPictureSlider::draw(bool drawFocused) {
if (!_redraw && !_fullRedraw)
return;

debug(1, "MacGui::MacPictureSlider: Drawing slider %d (_fullRedraw = %d, drawFocused = %d, _value = %d)", _id, _fullRedraw, drawFocused, _value);

if (_fullRedraw) {
_window->drawSprite(_background->getPicture(), _bounds.left, _bounds.top);
drawHandle();
}

_redraw = false;
_fullRedraw = false;
}

void MacGui::MacPictureSlider::eraseHandle() {
Common::Rect r = _handle->getBounds();
int y = r.top - _bounds.top;
Expand All @@ -1422,21 +1425,6 @@ void MacGui::MacPictureSlider::drawHandle() {
_window->drawSprite(sprite, _bounds.left + _handlePos, r.top);
}

void MacGui::MacPictureSlider::draw(bool drawFocused) {
if (!_redraw && !_fullRedraw)
return;

debug(1, "MacGui::MacPictureSlider: Drawing slider %d (_fullRedraw = %d, drawFocused = %d, _value = %d)", _id, _fullRedraw, drawFocused, _value);

if (_fullRedraw) {
_window->drawSprite(_background->getPicture(), _bounds.left, _bounds.top);
drawHandle();
}

_redraw = false;
_fullRedraw = false;
}

void MacGui::MacPictureSlider::handleMouseDown(Common::Event &event) {
int mouseX = event.mouse.x;
int handleWidth = _handle->getBounds().width();
Expand Down

0 comments on commit a4b8277

Please sign in to comment.