Skip to content

Commit

Permalink
SCUMM: Preliminary work on Mac slider widget
Browse files Browse the repository at this point in the history
  • Loading branch information
Torbjörn Andersson committed Nov 6, 2023
1 parent 2798130 commit 94d8a40
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 3 deletions.
41 changes: 38 additions & 3 deletions engines/scumm/gfx_mac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,35 @@ void MacGui::MacPicture::draw(bool drawFocused) {
_fullRedraw = false;
}

// ---------------------------------------------------------------------------
// Standard slider widget
// ---------------------------------------------------------------------------

void MacGui::MacSlider::draw(bool drawFocused) {
if (!_visible)
return;

if (!_redraw && !_fullRedraw)
return;

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

Graphics::Surface *s = _window->innerSurface();

s->frameRect(_bounds, kBlack);

_redraw = false;
_fullRedraw = false;

_window->markRectAsDirty(_bounds);
}

void MacGui::MacSlider::handleMouseDown(Common::Event &event) {
}

void MacGui::MacSlider::handleMouseMove(Common::Event &event) {
}

// ---------------------------------------------------------------------------
// Picture slider widget. This is the custom slider widget used for the Loom
// and Indy 3 options dialogs. It consists of a background image and a slider
Expand Down Expand Up @@ -1020,7 +1049,7 @@ void MacGui::MacPictureSlider::draw(bool drawFocused) {
if (!_redraw && !_fullRedraw)
return;

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

Graphics::Surface *bgSprite = _background->getPicture();
Graphics::Surface *hSprite = _handle->getPicture();
Expand Down Expand Up @@ -1216,6 +1245,12 @@ MacGui::MacPicture *MacGui::MacDialogWindow::addPicture(Common::Rect bounds, int
return picture;
}

MacGui::MacSlider *MacGui::MacDialogWindow::addSlider(Common::Rect bounds, int minValue, int maxValue, int pageSize, bool enabled) {
MacGui::MacSlider *slider = new MacSlider(this, bounds, minValue, maxValue, pageSize, enabled);
_widgets.push_back(slider);
return slider;
}

MacGui::MacPictureSlider *MacGui::MacDialogWindow::addPictureSlider(int backgroundId, int handleId, bool enabled, int minX, int maxX, int minValue, int maxValue, int leftMargin, int rightMargin) {
MacPicture *background = (MacPicture *)_widgets[backgroundId];
MacPicture *handle = (MacPicture *)_widgets[handleId];
Expand Down Expand Up @@ -2699,11 +2734,11 @@ bool MacLoomGui::runOpenDialog() {
window->addButton(Common::Rect(254, 135, 334, 155), "Open", true);
window->addButton(Common::Rect(254, 104, 334, 124), "Cancel", true);
window->addButton(Common::Rect(254, 59, 334, 79), "Delete", true);
window->addSlider(Common::Rect(216, 13, 232, 159), 0, 50, 7, true);

Graphics::Surface *s = window->innerSurface();

s->frameRect(Common::Rect(14, 13, 217, 159), kBlack);
s->frameRect(Common::Rect(216, 13, 232, 159), kBlack);
s->hLine(253, 91, 334, kBlack);

window->setDefaultWidget(0);
Expand Down Expand Up @@ -2735,6 +2770,7 @@ bool MacLoomGui::runSaveDialog() {
window->addButton(Common::Rect(254, 159, 334, 179), "Save", true);
window->addButton(Common::Rect(254, 128, 334, 148), "Cancel", true);
window->addButton(Common::Rect(254, 83, 334, 103), "Delete", true);
window->addSlider(Common::Rect(216, 9, 232, 137), 0, 50, 7, true);

MacGui::MacEditText *editText = window->addEditText(Common::Rect(16, 164, 229, 180), "Game file", true);

Expand All @@ -2743,7 +2779,6 @@ bool MacLoomGui::runSaveDialog() {

s->frameRect(Common::Rect(14, 161, 232, 183), kBlack);
s->frameRect(Common::Rect(14, 9, 217, 137), kBlack);
s->frameRect(Common::Rect(216, 9, 232, 137), kBlack);

s->hLine(253, 115, 334, kBlack);

Expand Down
18 changes: 18 additions & 0 deletions engines/scumm/gfx_mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,23 @@ class MacGui {
void draw(bool drawFocused = false);
};

class MacSlider : public MacWidget {
private:
int _minValue;
int _maxValue;
int _pageSize;

public:
MacSlider(MacGui::MacDialogWindow *window, Common::Rect bounds, int minValue, int maxValue, int pageSize, bool enabled)
: MacWidget(window, bounds, "Slider", enabled),
_minValue(minValue), _maxValue(maxValue), _pageSize(pageSize) {}

void draw(bool drawFocued = false);

void handleMouseDown(Common::Event &event);
void handleMouseMove(Common::Event &event);
};

class MacPictureSlider : public MacWidget {
private:
MacPicture *_background;
Expand Down Expand Up @@ -400,6 +417,7 @@ class MacGui {
MacGui::MacStaticText *addStaticText(Common::Rect bounds, Common::String text, bool enabled);
MacGui::MacEditText *addEditText(Common::Rect bounds, Common::String text, bool enabled);
MacGui::MacPicture *addPicture(Common::Rect bounds, int id, bool enabled);
MacGui::MacSlider *addSlider(Common::Rect bounds, int minValue, int maxValue, int pageSize, bool enabled);
MacGui::MacPictureSlider *addPictureSlider(int backgroundId, int handleId, bool enabled, int minX, int maxX, int minValue, int maxValue, int leftMargin = 0, int rightMargin = 0);

void addSubstitution(Common::String text) { _substitutions.push_back(text); }
Expand Down

0 comments on commit 94d8a40

Please sign in to comment.