diff options
author | Torbjörn Andersson | 2016-09-04 00:33:38 +0200 |
---|---|---|
committer | Torbjörn Andersson | 2016-09-04 08:31:39 +0200 |
commit | 40c65540fac262fbd70478eb8017f260780fb1a4 (patch) | |
tree | 9866418945598f4b4c7e355d43969b30bc2303df /graphics/macgui/macwindow.cpp | |
parent | 29535c0a55410684a263b493b1c75112f352bab6 (diff) | |
download | scummvm-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/macwindow.cpp')
-rw-r--r-- | graphics/macgui/macwindow.cpp | 27 |
1 files changed, 27 insertions, 0 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; |