aboutsummaryrefslogtreecommitdiff
path: root/graphics/macgui
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/macgui')
-rw-r--r--graphics/macgui/macwindow.cpp31
-rw-r--r--graphics/macgui/macwindow.h2
-rw-r--r--graphics/macgui/macwindowborder.cpp28
-rw-r--r--graphics/macgui/macwindowborder.h13
4 files changed, 40 insertions, 34 deletions
diff --git a/graphics/macgui/macwindow.cpp b/graphics/macgui/macwindow.cpp
index 08343c0f98..f41378bd9e 100644
--- a/graphics/macgui/macwindow.cpp
+++ b/graphics/macgui/macwindow.cpp
@@ -177,10 +177,10 @@ void MacWindow::updateInnerDims() {
if (_macBorder.hasBorder(_active) && _macBorder.hasOffsets()) {
_innerDims = Common::Rect(
- _dims.left + _macBorder.getOffset(kBorderOffsetLeft),
- _dims.top + _macBorder.getOffset(kBorderOffsetTop),
- _dims.right - _macBorder.getOffset(kBorderOffsetRight),
- _dims.bottom - _macBorder.getOffset(kBorderOffsetBottom));
+ _dims.left + _macBorder.getOffset().left,
+ _dims.top + _macBorder.getOffset().top,
+ _dims.right - _macBorder.getOffset().right,
+ _dims.bottom - _macBorder.getOffset().bottom);
} else {
_innerDims = _dims;
_innerDims.grow(-kBorderWidth);
@@ -212,7 +212,7 @@ void MacWindow::prepareBorderSurface(ManagedSurface *g) {
void MacWindow::drawBorderFromSurface(ManagedSurface *g) {
g->clear(kColorGreen2);
Common::Rect inside = _innerDims;
- inside.moveTo(_macBorder.getOffset(kBorderOffsetLeft), _macBorder.getOffset(kBorderOffsetTop));
+ inside.moveTo(_macBorder.getOffset().left, _macBorder.getOffset().top);
g->fillRect(inside, kColorGreen);
_macBorder.blitBorderInto(_borderSurface, _active);
@@ -343,8 +343,11 @@ void MacWindow::loadBorder(Common::SeekableReadStream &file, bool active, int lo
else
_macBorder.addInactiveBorder(surface);
- if (!_macBorder.hasOffsets())
- _macBorder.setOffsets(lo, ro, to, bo);
+ if (!_macBorder.hasOffsets()) {
+ if (lo + ro + to + bo > -4) { // Checking against default -1
+ _macBorder.setOffsets(lo, ro, to, bo);
+ }
+ }
updateInnerDims();
source->free();
@@ -389,8 +392,8 @@ bool MacWindow::isInCloseButton(int x, int y) {
int bLeft = kBorderWidth;
int bTop = kBorderWidth;
if (_macBorder.hasOffsets()) {
- bLeft = _macBorder.getOffset(kBorderOffsetLeft);
- bTop = _macBorder.getOffset(kBorderOffsetTop);
+ bLeft = _macBorder.getOffset().left;
+ bTop = _macBorder.getOffset().top;
}
return (x >= _innerDims.left - bLeft && x < _innerDims.left && y >= _innerDims.top - bTop && y < _innerDims.top);
}
@@ -399,8 +402,8 @@ bool MacWindow::isInResizeButton(int x, int y) {
int bRight = kBorderWidth;
int bBottom = kBorderWidth;
if (_macBorder.hasOffsets()) {
- bRight = _macBorder.getOffset(kBorderOffsetRight);
- bBottom = _macBorder.getOffset(kBorderOffsetBottom);
+ bRight = _macBorder.getOffset().right;
+ bBottom = _macBorder.getOffset().bottom;
}
return (x >= _innerDims.right && x < _innerDims.right + bRight && y >= _innerDims.bottom && y < _innerDims.bottom + bBottom);
}
@@ -410,9 +413,9 @@ WindowClick MacWindow::isInScroll(int x, int y) {
int bRight = kBorderWidth;
int bBottom = kBorderWidth;
if (_macBorder.hasOffsets()) {
- bTop = _macBorder.getOffset(kBorderOffsetTop);
- bRight = _macBorder.getOffset(kBorderOffsetRight);
- bBottom = _macBorder.getOffset(kBorderOffsetBottom);
+ bTop = _macBorder.getOffset().top;
+ bRight = _macBorder.getOffset().right;
+ bBottom = _macBorder.getOffset().bottom;
}
if (x >= _innerDims.right && x < _innerDims.right + bRight) {
diff --git a/graphics/macgui/macwindow.h b/graphics/macgui/macwindow.h
index f1e0cac7f3..fdf750c50a 100644
--- a/graphics/macgui/macwindow.h
+++ b/graphics/macgui/macwindow.h
@@ -276,7 +276,7 @@ public:
* @param to Width of the top side of the border, in pixels.
* @param bo Width of the bottom side of the border, in pixels.
*/
- void loadBorder(Common::SeekableReadStream &file, bool active, int lo, int ro, int to, int bo);
+ void loadBorder(Common::SeekableReadStream &file, bool active, int lo = -1, int ro = -1, int to = -1, int bo = -1);
//void setBorder(TransparentSurface &border, bool active);
/**
diff --git a/graphics/macgui/macwindowborder.cpp b/graphics/macgui/macwindowborder.cpp
index 7dae697c19..50fccd3577 100644
--- a/graphics/macgui/macwindowborder.cpp
+++ b/graphics/macgui/macwindowborder.cpp
@@ -32,7 +32,8 @@ using namespace Graphics::MacGUIConstants;
MacWindowBorder::MacWindowBorder() : _activeInitialized(false), _inactiveInitialized(false) {
_activeBorder = nullptr;
_inactiveBorder = nullptr;
- _hasOffsets = false;
+
+ _borderOffsets.right = -1; // make invalid rect
}
MacWindowBorder::~MacWindowBorder() {
@@ -50,28 +51,37 @@ void MacWindowBorder::addActiveBorder(TransparentSurface *source) {
assert(!_activeBorder);
_activeBorder = new NinePatchBitmap(source, true);
_activeInitialized = true;
+
+ if (_activeBorder->getPadding().isValidRect())
+ setOffsets(_activeBorder->getPadding());
}
void MacWindowBorder::addInactiveBorder(TransparentSurface *source) {
assert(!_inactiveBorder);
_inactiveBorder = new NinePatchBitmap(source, true);
_inactiveInitialized = true;
+
+ if (!_inactiveBorder->getPadding().isValidRect())
+ setOffsets(_inactiveBorder->getPadding());
}
bool MacWindowBorder::hasOffsets() {
- return _hasOffsets;
+ return _borderOffsets.isValidRect();
}
void MacWindowBorder::setOffsets(int left, int right, int top, int bottom) {
- _borderOffsets[0] = left;
- _borderOffsets[1] = right;
- _borderOffsets[2] = top;
- _borderOffsets[3] = bottom;
- _hasOffsets = true;
+ _borderOffsets.left = left;
+ _borderOffsets.right = right;
+ _borderOffsets.top = top;
+ _borderOffsets.bottom = bottom;
+}
+
+void MacWindowBorder::setOffsets(Common::Rect &rect) {
+ _borderOffsets = rect;
}
-int MacWindowBorder::getOffset(MacBorderOffset offset) {
- return _borderOffsets[offset];
+Common::Rect &MacWindowBorder::getOffset() {
+ return _borderOffsets;
}
void MacWindowBorder::blitBorderInto(ManagedSurface &destination, bool active) {
diff --git a/graphics/macgui/macwindowborder.h b/graphics/macgui/macwindowborder.h
index 1500b9b847..330e407460 100644
--- a/graphics/macgui/macwindowborder.h
+++ b/graphics/macgui/macwindowborder.h
@@ -32,13 +32,6 @@
namespace Graphics {
-enum MacBorderOffset {
- kBorderOffsetLeft = 0,
- kBorderOffsetRight = 1,
- kBorderOffsetTop = 2,
- kBorderOffsetBottom = 3
-};
-
/**
* A representation of a custom border, which allows for arbitrary border offsets
* and nine-patch resizable displays for both active and inactive states.
@@ -89,6 +82,7 @@ public:
* @param bottom Thickness (in pixels) of the bottom side of the border.
*/
void setOffsets(int left, int right, int top, int bottom);
+ void setOffsets(Common::Rect &rect);
/**
* Accessor method to retrieve a given border.
@@ -97,7 +91,7 @@ public:
* @param offset The identifier of the offset wanted.
* @return The desired offset in pixels.
*/
- int getOffset(MacBorderOffset offset);
+ Common::Rect &getOffset();
/**
* Blit the desired border (active or inactive) into a destination surface.
@@ -115,8 +109,7 @@ private:
bool _activeInitialized;
bool _inactiveInitialized;
- bool _hasOffsets;
- int _borderOffsets[4];
+ Common::Rect _borderOffsets;
};