aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sandulenko2016-04-28 16:45:07 +0200
committerEugene Sandulenko2016-04-28 16:45:07 +0200
commit8b41a507664eb077cdc233dfe1d6a31aa5ab8de3 (patch)
tree807f40c50f9a773d815cabf3b3bbe31eb0a2af85
parent859cd9d1f953f3c4263996ad84c541d7d9f1580a (diff)
downloadscummvm-rg350-8b41a507664eb077cdc233dfe1d6a31aa5ab8de3.tar.gz
scummvm-rg350-8b41a507664eb077cdc233dfe1d6a31aa5ab8de3.tar.bz2
scummvm-rg350-8b41a507664eb077cdc233dfe1d6a31aa5ab8de3.zip
WAGE: Compose MacMenu instead of screen copying.
This completes making Mac* classes engine-agnostic.
-rw-r--r--engines/wage/gui.cpp2
-rw-r--r--engines/wage/macmenu.cpp31
-rw-r--r--engines/wage/macmenu.h4
-rw-r--r--engines/wage/macwindowmanager.cpp4
-rw-r--r--engines/wage/macwindowmanager.h4
5 files changed, 23 insertions, 22 deletions
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 0ddae88f2d..310e5734b7 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -143,7 +143,7 @@ Gui::Gui(WageEngine *engine) {
g_system->getTimerManager()->installTimerProc(&cursorTimerHandler, 200000, this, "wageCursor");
- _menu = _wm.addMenu(this);
+ _menu = _wm.addMenu();
_menu->setCommandsCallback(menuCommandsCallback, this);
diff --git a/engines/wage/macmenu.cpp b/engines/wage/macmenu.cpp
index 19deffd5cb..bed9dd42f4 100644
--- a/engines/wage/macmenu.cpp
+++ b/engines/wage/macmenu.cpp
@@ -49,9 +49,10 @@
#include "common/keyboard.h"
#include "graphics/primitives.h"
+#include "graphics/font.h"
-#include "wage/gui.h"
#include "wage/macwindowmanager.h"
+#include "wage/macwindow.h"
#include "wage/macmenu.h"
namespace Wage {
@@ -88,8 +89,8 @@ struct MenuItem {
MenuItem(const char *n) : name(n) {}
};
-Menu::Menu(int id, const Common::Rect &bounds, MacWindowManager *wm, Gui *gui)
- : BaseMacWindow(id, false, wm), _gui(gui) {
+Menu::Menu(int id, const Common::Rect &bounds, MacWindowManager *wm)
+ : BaseMacWindow(id, false, wm) {
_font = getMenuFont();
_screen.create(bounds.width(), bounds.height(), Graphics::PixelFormat::createFormatCLUT8());
@@ -103,7 +104,6 @@ Menu::Menu(int id, const Common::Rect &bounds, MacWindowManager *wm, Gui *gui)
_activeItem = -1;
_activeSubItem = -1;
- _screenCopy.create(_screen.w, _screen.h, Graphics::PixelFormat::createFormatCLUT8());
_tempSurface.create(_screen.w, _font->getFontHeight(), Graphics::PixelFormat::createFormatCLUT8());
}
@@ -307,10 +307,12 @@ static void drawFilledRoundRect(Graphics::ManagedSurface *surface, Common::Rect
bool Menu::draw(Graphics::ManagedSurface *g, bool forceRedraw) {
Common::Rect r(_bbox);
- if (!_contentIsDirty)
+ if (!_contentIsDirty && !forceRedraw)
return false;
- _contentIsDirty = true;
+ _contentIsDirty = false;
+
+ _screen.clear(kColorGreen);
drawFilledRoundRect(&_screen, r, kDesktopArc, kColorWhite);
r.top = 7;
@@ -339,7 +341,9 @@ bool Menu::draw(Graphics::ManagedSurface *g, bool forceRedraw) {
_font->drawString(&_screen, it->name, it->bbox.left + kMenuLeftMargin, it->bbox.top + (_wm->hasBuiltInFonts() ? 2 : 1), it->bbox.width(), color);
}
- g_system->copyRectToScreen(_screen.getPixels(), _screen.pitch, 0, 0, _screen.w, kMenuHeight);
+ g->transBlitFrom(_screen, kColorGreen);
+
+ g_system->copyRectToScreen(g->getPixels(), g->pitch, 0, 0, g->w, g->h);
return true;
}
@@ -416,7 +420,8 @@ void Menu::renderSubmenu(MenuItem *menu) {
y += kMenuDropdownItemHeight;
}
- g_system->copyRectToScreen(_screen.getBasePtr(r->left, r->top), _screen.pitch, r->left, r->top, r->width() + 2, r->height() + 2);
+ _contentIsDirty = true;
+ //g_system->copyRectToScreen(_screen.getBasePtr(r->left, r->top), _screen.pitch, r->left, r->top, r->width() + 2, r->height() + 2);
}
bool Menu::processEvent(Common::Event &event) {
@@ -449,9 +454,6 @@ bool Menu::keyEvent(Common::Event &event) {
bool Menu::mouseClick(int x, int y) {
if (_bbox.contains(x, y)) {
- if (!_menuActivated)
- _screenCopy.copyFrom(_gui->_screen);
-
for (uint i = 0; i < _items.size(); i++)
if (_items[i]->bbox.contains(x, y)) {
if ((uint)_activeItem == i)
@@ -462,14 +464,15 @@ bool Menu::mouseClick(int x, int y) {
r.right += 3;
r.bottom += 3;
- _screen.copyRectToSurface(_screenCopy, r.left, r.top, r);
- g_system->copyRectToScreen(_screen.getBasePtr(r.left, r.top), _screen.pitch, r.left, r.top, r.width(), r.height());
+ _wm->setFullRefresh(true);
}
_activeItem = i;
_activeSubItem = -1;
_menuActivated = true;
+ _contentIsDirty = true;
+
return true;
}
} else if (_menuActivated && _items[_activeItem]->subbbox.contains(x, y)) {
@@ -480,11 +483,13 @@ bool Menu::mouseClick(int x, int y) {
_activeSubItem = numSubItem;
renderSubmenu(_items[_activeItem]);
+ _contentIsDirty = true;
}
} else if (_menuActivated && _activeItem != -1) {
_activeSubItem = -1;
renderSubmenu(_items[_activeItem]);
+ _contentIsDirty = true;
}
return false;
diff --git a/engines/wage/macmenu.h b/engines/wage/macmenu.h
index 929ce76dc5..e73e4c48a9 100644
--- a/engines/wage/macmenu.h
+++ b/engines/wage/macmenu.h
@@ -101,7 +101,7 @@ struct MenuData {
class Menu : public BaseMacWindow {
public:
- Menu(int id, const Common::Rect &bounds, MacWindowManager *wm, Gui *gui);
+ Menu(int id, const Common::Rect &bounds, MacWindowManager *wm);
~Menu();
void setCommandsCallback(void (*callback)(int, Common::String &, void *), void *data) { _ccallback = callback; _cdata = data; }
@@ -126,9 +126,7 @@ public:
Common::Rect _bbox;
private:
- Gui *_gui;
Graphics::ManagedSurface _screen;
- Graphics::ManagedSurface _screenCopy;
Graphics::ManagedSurface _tempSurface;
private:
diff --git a/engines/wage/macwindowmanager.cpp b/engines/wage/macwindowmanager.cpp
index 9913a36feb..3bebd865ef 100644
--- a/engines/wage/macwindowmanager.cpp
+++ b/engines/wage/macwindowmanager.cpp
@@ -157,8 +157,8 @@ MacWindow *MacWindowManager::addWindow(bool scrollable, bool resizable, bool edi
return w;
}
-Menu *MacWindowManager::addMenu(Gui *g) {
- _menu = new Menu(_lastId, _screen->getBounds(), this, g);
+Menu *MacWindowManager::addMenu() {
+ _menu = new Menu(_lastId, _screen->getBounds(), this);
_windows.push_back(_menu);
diff --git a/engines/wage/macwindowmanager.h b/engines/wage/macwindowmanager.h
index 53db0d65d0..2d03c9b11d 100644
--- a/engines/wage/macwindowmanager.h
+++ b/engines/wage/macwindowmanager.h
@@ -61,8 +61,6 @@ class ManagedSurface;
namespace Wage {
-class Gui; // FIXME
-
enum {
kDesktopArc = 7
};
@@ -98,7 +96,7 @@ public:
const Graphics::Font *getFont(const char *name, Graphics::FontManager::FontUsage fallback);
MacWindow *addWindow(bool scrollable, bool resizable, bool editable);
- Menu *addMenu(Gui *gui);
+ Menu *addMenu();
void setActive(int id);
void setFullRefresh(bool redraw) { _fullRefresh = true; }