Skip to content

Commit

Permalink
WAGE: Draw drop-down menu shadow
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Jan 13, 2016
1 parent a45c66b commit a6cf968
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
12 changes: 12 additions & 0 deletions engines/wage/design.cpp
Expand Up @@ -661,6 +661,12 @@ void Design::drawEllipse(int x0, int y0, int x1, int y1, bool filled, void (*plo
}
}

void Design::drawHLine(Graphics::Surface *surface, int x1, int x2, int y, int thickness, int color, Patterns &patterns, byte fillType) {
plotData pd(surface, &patterns, fillType, thickness);

drawHLine(x1, x2, y, color, drawPixel, &pd);
}

void Design::drawHLine(int x1, int x2, int y, int color, void (*plotProc)(int, int, int, void *), void *data) {
if (x1 > x2)
SWAP(x1, x2);
Expand All @@ -669,6 +675,12 @@ void Design::drawHLine(int x1, int x2, int y, int color, void (*plotProc)(int, i
(*plotProc)(x, y, color, data);
}

void Design::drawVLine(Graphics::Surface *surface, int x, int y1, int y2, int thickness, int color, Patterns &patterns, byte fillType) {
plotData pd(surface, &patterns, fillType, thickness);

drawVLine(x, y1, y2, color, drawPixel, &pd);
}

void Design::drawVLine(int x, int y1, int y2, int color, void (*plotProc)(int, int, int, void *), void *data) {
if (y1 > y2)
SWAP(y1, y2);
Expand Down
2 changes: 2 additions & 0 deletions engines/wage/design.h
Expand Up @@ -72,6 +72,8 @@ class Design {
static void drawRect(Graphics::Surface *surface, Common::Rect &rect, int thickness, int color, Patterns &patterns, byte fillType);
static void drawFilledRect(Graphics::Surface *surface, Common::Rect &rect, int color, Patterns &patterns, byte fillType);
static void drawFilledRoundRect(Graphics::Surface *surface, Common::Rect &rect, int arc, int color, Patterns &patterns, byte fillType);
static void drawHLine(Graphics::Surface *surface, int x1, int x2, int y, int thickness, int color, Patterns &patterns, byte fillType);
static void drawVLine(Graphics::Surface *surface, int x, int y1, int y2, int thickness, int color, Patterns &patterns, byte fillType);


private:
Expand Down
16 changes: 11 additions & 5 deletions engines/wage/menu.cpp
Expand Up @@ -274,6 +274,10 @@ void Menu::renderSubmenu(MenuItem *menu) {

Design::drawFilledRect(&_gui->_screen, *r, kColorWhite, _patterns, 1);
Design::drawRect(&_gui->_screen, *r, 1, kColorBlack, _patterns, 1);
Design::drawVLine(&_gui->_screen, r->right + 1, r->top + 2, r->bottom + 2, 1, kColorBlack, _patterns, 1);
Design::drawVLine(&_gui->_screen, r->right + 2, r->top + 2, r->bottom + 2, 1, kColorBlack, _patterns, 1);
Design::drawHLine(&_gui->_screen, r->left + 3, r->right + 2, r->bottom + 1, 1, kColorBlack, _patterns, 1);
Design::drawHLine(&_gui->_screen, r->left + 3, r->right + 2, r->bottom + 2, 1, kColorBlack, _patterns, 1);

int x = r->left + kMenuDropdownPadding;
int y = r->top;
Expand All @@ -283,7 +287,7 @@ void Menu::renderSubmenu(MenuItem *menu) {
y += kMenuDropdownItemHeight;
}

g_system->copyRectToScreen(_gui->_screen.getBasePtr(r->left, r->top), _gui->_screen.pitch, r->left, r->top, r->width() + 1, r->height() + 1);
g_system->copyRectToScreen(_gui->_screen.getBasePtr(r->left, r->top), _gui->_screen.pitch, r->left, r->top, r->width() + 3, r->height() + 3);
}

bool Menu::mouseClick(int x, int y) {
Expand All @@ -296,11 +300,13 @@ bool Menu::mouseClick(int x, int y) {
if (_activeItem == i)
return false;

if (_activeItem != -1) {
Common::Rect *r = &_items[_activeItem]->subbbox;
if (_activeItem != -1) { // Restore background
Common::Rect r(_items[_activeItem]->subbbox);
r.right += 3;
r.bottom += 3;

_gui->_screen.copyRectToSurface(_screenCopy, r->left, r->top, *r);
g_system->copyRectToScreen(_gui->_screen.getBasePtr(r->left, r->top), _gui->_screen.pitch, r->left, r->top, r->width() + 1, r->height() + 1);
_gui->_screen.copyRectToSurface(_screenCopy, r.left, r.top, r);
g_system->copyRectToScreen(_gui->_screen.getBasePtr(r.left, r.top), _gui->_screen.pitch, r.left, r.top, r.width() + 1, r.height() + 1);
}

_activeItem = i;
Expand Down

0 comments on commit a6cf968

Please sign in to comment.