mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-14 13:50:13 +00:00
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.
This commit is contained in:
parent
29535c0a55
commit
40c65540fa
@ -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;
|
||||
|
@ -215,6 +215,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.
|
||||
@ -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;
|
||||
|
@ -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[] = {
|
||||
|
@ -51,7 +51,9 @@ enum {
|
||||
kPatternSolid = 1,
|
||||
kPatternStripes = 2,
|
||||
kPatternCheckers = 3,
|
||||
kPatternCheckers2 = 4
|
||||
kPatternCheckers2 = 4,
|
||||
kPatternLightGray = 5,
|
||||
kPatternDarkGray = 6
|
||||
};
|
||||
}
|
||||
using namespace MacGUIConstants;
|
||||
|
Loading…
Reference in New Issue
Block a user