aboutsummaryrefslogtreecommitdiff
path: root/graphics
diff options
context:
space:
mode:
authorBorja Lorente2016-07-29 12:13:31 +0200
committerBorja Lorente2016-07-31 14:44:48 +0200
commit26238ee6f987a1ffe5836145f3b937cfd38d28cf (patch)
tree53ee9a6d106c63998a363ca5e5c1aebfbc049456 /graphics
parentd49d573edc7e7c4698dac2d7748365a6e9dcef0c (diff)
downloadscummvm-rg350-26238ee6f987a1ffe5836145f3b937cfd38d28cf.tar.gz
scummvm-rg350-26238ee6f987a1ffe5836145f3b937cfd38d28cf.tar.bz2
scummvm-rg350-26238ee6f987a1ffe5836145f3b937cfd38d28cf.zip
GRAPHICS: Fix border loading
Diffstat (limited to 'graphics')
-rw-r--r--graphics/macgui/macwindow.cpp54
-rw-r--r--graphics/macgui/macwindow.h5
2 files changed, 37 insertions, 22 deletions
diff --git a/graphics/macgui/macwindow.cpp b/graphics/macgui/macwindow.cpp
index dfb1c07f86..226037ef56 100644
--- a/graphics/macgui/macwindow.cpp
+++ b/graphics/macgui/macwindow.cpp
@@ -145,19 +145,10 @@ bool MacWindow::draw(ManagedSurface *g, bool forceRedraw) {
_contentIsDirty = false;
-
// Compose
_composeSurface.blitFrom(_surface, Common::Rect(0, 0, _surface.w - 2, _surface.h - 2), Common::Point(2, 2));
_composeSurface.transBlitFrom(_borderSurface, kColorGreen);
- if (_borders) {
- TransparentSurface tr(*_borders);
- //tr.create(_composeSurface.w, _composeSurface.h, tr.getSupportedPixelFormat());
-
- //_bmp->blit(tr, 0, 0, tr.w, tr.h)
- _composeSurface.transBlitFrom(tr);
- }
-
g->transBlitFrom(_composeSurface, _composeSurface.getBounds(), Common::Point(_dims.left - 2, _dims.top - 2), kColorGreen2);
return true;
@@ -192,19 +183,43 @@ void MacWindow::updateInnerDims() {
void MacWindow::drawBorder() {
_borderIsDirty = false;
- bool active = _active, scrollable = _scrollable, closeable = _active, drawTitle = !_title.empty();
- const int size = kBorderWidth;
- int x = 0;
- int y = 0;
- int width = _borderSurface.w;
- int height = _borderSurface.h;
ManagedSurface *g = &_borderSurface;
+ prepareBorderSurface(g);
+
+ if (_borders)
+ drawBorderFromSurface(g);
+ else
+ drawSimpleBorder(g);
+}
+void MacWindow::prepareBorderSurface(ManagedSurface *g) {
// We draw rect with outer kColorGreen2 and inner kColorGreen, so on 2 passes we cut out
// scene by external shape of the border
int sz = kBorderWidth / 2;
+ int width = g->w;
+ int height = g->h;
g->clear(kColorGreen2);
g->fillRect(Common::Rect(sz, sz, width - sz, height - sz), kColorGreen);
+}
+
+void MacWindow::drawBorderFromSurface(ManagedSurface *g) {
+ TransparentSurface srf;
+ srf.create(_composeSurface.w, _composeSurface.h, _borders->format);
+
+ _bmp = new NinePatchBitmap(_borders, false);
+
+ _bmp->blit(srf, 0, 0, srf.w, srf.h);
+ _borderSurface.transBlitFrom(srf, _borderSurface.format.ARGBToColor(0, 255, 255, 255));
+}
+
+void MacWindow::drawSimpleBorder(ManagedSurface *g) {
+
+ bool active = _active, scrollable = _scrollable, closeable = _active, drawTitle = !_title.empty();
+ const int size = kBorderWidth;
+ int x = 0;
+ int y = 0;
+ int width = _borderSurface.w;
+ int height = _borderSurface.h;
drawBox(g, x, y, size, size);
drawBox(g, x + width - size - 1, y, size, size);
@@ -215,8 +230,6 @@ void MacWindow::drawBorder() {
drawBox(g, x + 2, y + size, size - 4, height - 2 * size - 1);
drawBox(g, x + width - size + 1, y + size, size - 4, height - 2 * size - 1);
-
-
if (active) {
fillRect(g, x + size, y + 5, width - 2 * size - 1, 8, kColorBlack);
fillRect(g, x + size, y + height - 13, width - 2 * size - 1, 8, kColorBlack);
@@ -247,7 +260,7 @@ void MacWindow::drawBorder() {
int ry2 = ry1 + _dims.height() * _scrollSize;
Common::Rect rr(rx1, ry1, rx2, ry2);
- drawFilledRect(rr, kColorBlack, drawPixelInverted, g);
+ Graphics::drawFilledRect(rr, kColorBlack, drawPixelInverted, g);
}
}
if (closeable) {
@@ -260,7 +273,7 @@ void MacWindow::drawBorder() {
}
if (drawTitle) {
- const Font *font = getTitleFont();
+ const Graphics::Font *font = getTitleFont();
int yOff = _wm->hasBuiltInFonts() ? 3 : 1;
int w = font->getStringWidth(_title) + 10;
@@ -269,7 +282,7 @@ void MacWindow::drawBorder() {
w = maxWidth;
drawBox(g, x + (width - w) / 2, y, w, size);
font->drawString(g, _title, x + (width - w) / 2 + 5, y + yOff, w, kColorBlack);
- }
+ }
}
void MacWindow::setHighlight(WindowClick highlightedPart) {
@@ -290,7 +303,6 @@ void MacWindow::setHighlight(WindowClick highlightedPart) {
}
void MacWindow::setBorders(TransparentSurface *source) {
- _bmp = new NinePatchBitmap(source, true);
_borders = new TransparentSurface(*source);
}
diff --git a/graphics/macgui/macwindow.h b/graphics/macgui/macwindow.h
index 9c908f3912..6526e05876 100644
--- a/graphics/macgui/macwindow.h
+++ b/graphics/macgui/macwindow.h
@@ -139,6 +139,9 @@ public:
private:
void drawBorder();
+ void prepareBorderSurface(ManagedSurface *g);
+ void drawSimpleBorder(ManagedSurface *g);
+ void drawBorderFromSurface(ManagedSurface *g);
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();
@@ -150,7 +153,7 @@ private:
ManagedSurface _composeSurface;
NinePatchBitmap *_bmp;
- TransparentSurface *_borders = nullptr;
+ TransparentSurface *_borders;
bool _scrollable;
bool _resizable;