aboutsummaryrefslogtreecommitdiff
path: root/graphics/macgui
diff options
context:
space:
mode:
authorTorbjörn Andersson2016-09-04 00:33:38 +0200
committerTorbjörn Andersson2016-09-04 08:31:39 +0200
commit40c65540fac262fbd70478eb8017f260780fb1a4 (patch)
tree9866418945598f4b4c7e355d43969b30bc2303df /graphics/macgui
parent29535c0a55410684a263b493b1c75112f352bab6 (diff)
downloadscummvm-rg350-40c65540fac262fbd70478eb8017f260780fb1a4.tar.gz
scummvm-rg350-40c65540fac262fbd70478eb8017f260780fb1a4.tar.bz2
scummvm-rg350-40c65540fac262fbd70478eb8017f260780fb1a4.zip
GRAPHICS: Add setBackgroundPattern() to MacWindow
Set a background pattern for the window surface. For instance, the exits window in the MacVenture engine should have a light gray background, rather than a white one, and this will allow it to get one without having to draw it by itself.
Diffstat (limited to 'graphics/macgui')
-rw-r--r--graphics/macgui/macwindow.cpp27
-rw-r--r--graphics/macgui/macwindow.h10
-rw-r--r--graphics/macgui/macwindowmanager.cpp4
-rw-r--r--graphics/macgui/macwindowmanager.h4
4 files changed, 43 insertions, 2 deletions
diff --git a/graphics/macgui/macwindow.cpp b/graphics/macgui/macwindow.cpp
index ea9a0a141d..2a6e191ded 100644
--- a/graphics/macgui/macwindow.cpp
+++ b/graphics/macgui/macwindow.cpp
@@ -44,6 +44,9 @@ MacWindow::MacWindow(int id, bool scrollable, bool resizable, bool editable, Mac
_active = false;
_borderIsDirty = true;
+ _pattern = 0;
+ _hasPattern = false;
+
_highlightedPart = kBorderNone;
_scrollPos = _scrollSize = 0.0;
@@ -83,6 +86,10 @@ void MacWindow::resize(int w, int h) {
_surface.free();
_surface.create(w, h, PixelFormat::createFormatCLUT8());
+
+ if (_hasPattern)
+ drawPattern();
+
_borderSurface.free();
_borderSurface.create(w, h, PixelFormat::createFormatCLUT8());
_composeSurface.free();
@@ -115,6 +122,13 @@ void MacWindow::setDimensions(const Common::Rect &r) {
_contentIsDirty = true;
}
+void MacWindow::setBackgroundPattern(int pattern) {
+ _pattern = pattern;
+ _hasPattern = true;
+ drawPattern();
+ _contentIsDirty = true;
+}
+
bool MacWindow::draw(ManagedSurface *g, bool forceRedraw) {
if (!_borderIsDirty && !_contentIsDirty && !forceRedraw)
return false;
@@ -273,6 +287,19 @@ void MacWindow::drawSimpleBorder(ManagedSurface *g) {
}
}
+void MacWindow::drawPattern() {
+ byte *pat = _wm->getPatterns()[_pattern - 1];
+ for (int y = 0; y < _surface.h; y++) {
+ for (int x = 0; x < _surface.w; x++) {
+ byte *dst = (byte *)_surface.getBasePtr(x, y);
+ if (pat[y % 8] & (1 << (7 - (x % 8))))
+ *dst = kColorBlack;
+ else
+ *dst = kColorWhite;
+ }
+ }
+}
+
void MacWindow::setHighlight(WindowClick highlightedPart) {
if (_highlightedPart == highlightedPart)
return;
diff --git a/graphics/macgui/macwindow.h b/graphics/macgui/macwindow.h
index ee25a9e7e3..5d06da383d 100644
--- a/graphics/macgui/macwindow.h
+++ b/graphics/macgui/macwindow.h
@@ -216,6 +216,12 @@ public:
const Common::Rect &getInnerDimensions() { return _innerDims; }
/**
+ * Set a background pattern for the window.
+ * @param pattern
+ */
+ void setBackgroundPattern(int pattern);
+
+ /**
* Similar to that described in BaseMacWindow.
* @param g See BaseMacWindow.
* @param forceRedraw If true, the borders are guarranteed to redraw.
@@ -282,6 +288,7 @@ private:
void prepareBorderSurface(ManagedSurface *g);
void drawSimpleBorder(ManagedSurface *g);
void drawBorderFromSurface(ManagedSurface *g);
+ void drawPattern();
void drawBox(ManagedSurface *g, int x, int y, int w, int h);
void fillRect(ManagedSurface *g, int x, int y, int w, int h, int color);
const Font *getTitleFont();
@@ -298,6 +305,9 @@ private:
MacWindowBorder _macBorder;
+ int _pattern;
+ bool _hasPattern;
+
bool _scrollable;
bool _resizable;
bool _active;
diff --git a/graphics/macgui/macwindowmanager.cpp b/graphics/macgui/macwindowmanager.cpp
index 6c51a2f5ef..9e40c368dc 100644
--- a/graphics/macgui/macwindowmanager.cpp
+++ b/graphics/macgui/macwindowmanager.cpp
@@ -48,7 +48,9 @@ static const byte palette[] = {
static byte fillPatterns[][8] = { { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, // kPatternSolid
{ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55 }, // kPatternStripes
{ 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55 }, // kPatternCheckers
- { 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa } // kPatternCheckers2
+ { 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa }, // kPatternCheckers2
+ { 0x88, 0x22, 0x88, 0x22, 0x88, 0x22, 0x88, 0x22 }, // kPatternLightGray
+ { 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd } // kPatternDarkGray
};
static const byte macCursorArrow[] = {
diff --git a/graphics/macgui/macwindowmanager.h b/graphics/macgui/macwindowmanager.h
index c5a179aeab..96cc1e73a5 100644
--- a/graphics/macgui/macwindowmanager.h
+++ b/graphics/macgui/macwindowmanager.h
@@ -51,7 +51,9 @@ enum {
kPatternSolid = 1,
kPatternStripes = 2,
kPatternCheckers = 3,
- kPatternCheckers2 = 4
+ kPatternCheckers2 = 4,
+ kPatternLightGray = 5,
+ kPatternDarkGray = 6
};
}
using namespace MacGUIConstants;