aboutsummaryrefslogtreecommitdiff
path: root/graphics/macgui
diff options
context:
space:
mode:
authorBorja Lorente2016-07-29 12:16:08 +0200
committerBorja Lorente2016-07-31 14:47:19 +0200
commit3b1ba50c88931074184b63bc919cdaa47a749283 (patch)
treea5513918ff4241cfe646f16d04672d4af12db23d /graphics/macgui
parentfafd209d04f57680c141ea34f37f3a0f59080939 (diff)
downloadscummvm-rg350-3b1ba50c88931074184b63bc919cdaa47a749283.tar.gz
scummvm-rg350-3b1ba50c88931074184b63bc919cdaa47a749283.tar.bz2
scummvm-rg350-3b1ba50c88931074184b63bc919cdaa47a749283.zip
GRAPHICS: First approximation to custom border offsets
Diffstat (limited to 'graphics/macgui')
-rw-r--r--graphics/macgui/macwindow.cpp32
-rw-r--r--graphics/macgui/macwindow.h12
-rw-r--r--graphics/macgui/macwindowborder.cpp25
-rw-r--r--graphics/macgui/macwindowborder.h16
4 files changed, 67 insertions, 18 deletions
diff --git a/graphics/macgui/macwindow.cpp b/graphics/macgui/macwindow.cpp
index 96139b2508..350878446b 100644
--- a/graphics/macgui/macwindow.cpp
+++ b/graphics/macgui/macwindow.cpp
@@ -78,6 +78,10 @@ MacWindow::MacWindow(int id, bool scrollable, bool resizable, bool editable, Mac
_draggedX = _draggedY = 0;
_type = kWindowWindow;
+
+ _closeable = false;
+
+ _borderWidth = kBorderWidth;
}
MacWindow::~MacWindow() {
@@ -174,7 +178,14 @@ static void drawPixelInverted(int x, int y, int color, void *data) {
void MacWindow::updateInnerDims() {
_innerDims = _dims;
- _innerDims.grow(-kBorderWidth);
+ if (_macBorder.hasBorder(_active) && _macBorder.hasOffsets()) {
+ int maxW = _innerDims.width() - _macBorder.getBorderOffset(kBorderOffsetLeft) - _macBorder.getBorderOffset(kBorderOffsetRight);
+ int maxH = _innerDims.width() - _macBorder.getBorderOffset(kBorderOffsetTop) - _macBorder.getBorderOffset(kBorderOffsetBottom);
+ _innerDims.clip(maxW, maxH);
+ _innerDims.translate(_macBorder.getBorderOffset(kBorderOffsetLeft), _macBorder.getBorderOffset(kBorderOffsetTop));
+ } else {
+ _innerDims.grow(-kBorderWidth);
+ }
}
void MacWindow::drawBorder() {
@@ -293,11 +304,14 @@ void MacWindow::setHighlight(WindowClick highlightedPart) {
_borderIsDirty = true;
}
- void MacWindow::setBorder(TransparentSurface &border, bool active) {
+ void MacWindow::setBorder(TransparentSurface &border, bool active, int lo, int ro, int to, int bo) {
if (active)
_macBorder.addActiveBorder(border);
else
_macBorder.addInactiveBorder(border);
+
+ if (!_macBorder.hasOffsets())
+ _macBorder.setBorderOffsets(lo, ro, to, bo);
}
void MacWindow::drawBox(ManagedSurface *g, int x, int y, int w, int h) {
@@ -317,18 +331,18 @@ WindowClick MacWindow::isInBorder(int x, int y) {
if (_innerDims.contains(x, y))
return kBorderInner;
- if (x >= _innerDims.left - kBorderWidth && x < _innerDims.left && y >= _innerDims.top - kBorderWidth && y < _innerDims.top)
+ if (x >= _innerDims.left - _borderWidth && x < _innerDims.left && y >= _innerDims.top - _borderWidth && y < _innerDims.top)
return kBorderCloseButton;
if (_resizable)
- if (x >= _innerDims.right && x < _innerDims.right + kBorderWidth && y >= _innerDims.bottom && y < _innerDims.bottom + kBorderWidth)
+ if (x >= _innerDims.right && x < _innerDims.right + _borderWidth && y >= _innerDims.bottom && y < _innerDims.bottom + _borderWidth)
return kBorderResizeButton;
- if (_scrollable && x >= _innerDims.right && x < _innerDims.right + kBorderWidth) {
- if (y < _innerDims.top - kBorderWidth)
+ if (_scrollable && x >= _innerDims.right && x < _innerDims.right + _borderWidth) {
+ if (y < _innerDims.top - _borderWidth)
return kBorderBorder;
- if (y >= _innerDims.bottom + kBorderWidth)
+ if (y >= _innerDims.bottom + _borderWidth)
return kBorderBorder;
if (y >= _innerDims.top + _innerDims.height() / 2)
@@ -356,8 +370,8 @@ bool MacWindow::processEvent(Common::Event &event) {
}
if (_beingResized) {
- resize(MAX(kBorderWidth * 4, _dims.width() + event.mouse.x - _draggedX),
- MAX(kBorderWidth * 4, _dims.height() + event.mouse.y - _draggedY));
+ resize(MAX(_borderWidth * 4, _dims.width() + event.mouse.x - _draggedX),
+ MAX(_borderWidth * 4, _dims.height() + event.mouse.y - _draggedY));
_draggedX = event.mouse.x;
_draggedY = event.mouse.y;
diff --git a/graphics/macgui/macwindow.h b/graphics/macgui/macwindow.h
index e9e2ffd34c..ce5cd1a813 100644
--- a/graphics/macgui/macwindow.h
+++ b/graphics/macgui/macwindow.h
@@ -116,7 +116,7 @@ protected:
bool (*_callback)(WindowClick, Common::Event &, void *);
void *_dataPtr;
-
+
MacWindowManager *_wm;
};
@@ -130,7 +130,7 @@ public:
const Common::Rect &getInnerDimensions() { return _innerDims; }
bool draw(ManagedSurface *g, bool forceRedraw = false);
-
+
void setActive(bool active);
void setTitle(Common::String &title) { _title = title; }
void setHighlight(WindowClick highlightedPart);
@@ -138,7 +138,7 @@ public:
bool processEvent(Common::Event &event);
bool hasAllFocus() { return _beingDragged || _beingResized; }
- void setBorder(TransparentSurface &border, bool active);
+ void setBorder(TransparentSurface &border, bool active, int lo, int ro, int to, int bo);
private:
void drawBorder();
@@ -149,7 +149,7 @@ private:
void fillRect(ManagedSurface *g, int x, int y, int w, int h, int color);
const Font *getTitleFont();
void updateInnerDims();
- WindowClick isInBorder(int x, int y);
+ WindowClick isInBorder(int x, int y);
private:
ManagedSurface _borderSurface;
@@ -162,6 +162,10 @@ private:
bool _active;
bool _borderIsDirty;
+ bool _closeable;
+
+ int _borderWidth;
+
bool _beingDragged, _beingResized;
int _draggedX, _draggedY;
diff --git a/graphics/macgui/macwindowborder.cpp b/graphics/macgui/macwindowborder.cpp
index 761e1b6853..b5fdcc33bf 100644
--- a/graphics/macgui/macwindowborder.cpp
+++ b/graphics/macgui/macwindowborder.cpp
@@ -4,7 +4,8 @@ namespace Graphics {
MacWindowBorder::MacWindowBorder() : _activeInitialized(false), _inactiveInitialized(false) {
_activeBorder = nullptr;
- _inactiveBorder = nullptr;
+ _inactiveBorder = nullptr;
+ _hasOffsets = false;
}
@@ -15,13 +16,13 @@ MacWindowBorder::~MacWindowBorder() {
delete _inactiveBorder;
}
-bool MacWindowBorder::hasBorder(bool active) {
- return active ? _activeInitialized : _inactiveInitialized;
+bool MacWindowBorder::hasBorder(bool active) {
+ return active ? _activeInitialized : _inactiveInitialized;
}
void MacWindowBorder::addActiveBorder(TransparentSurface &source) {
assert(!_activeBorder);
- _activeBorder = new NinePatchBitmap(&source, false);
+ _activeBorder = new NinePatchBitmap(&source, false);
_activeInitialized = true;
}
@@ -31,6 +32,22 @@ void MacWindowBorder::addInactiveBorder(TransparentSurface &source) {
_inactiveInitialized = true;
}
+bool MacWindowBorder::hasOffsets() {
+ return _hasOffsets;
+}
+
+void MacWindowBorder::setBorderOffsets(int left, int right, int top, int bottom) {
+ _borderOffsets[0] = left;
+ _borderOffsets[1] = right;
+ _borderOffsets[2] = top;
+ _borderOffsets[3] = bottom;
+ _hasOffsets = true;
+}
+
+int MacWindowBorder::getBorderOffset(MacBorderOffset offset) {
+ return _borderOffsets[offset];
+}
+
void MacWindowBorder::blitBorderInto(ManagedSurface &destination, bool active) {
TransparentSurface srf;
diff --git a/graphics/macgui/macwindowborder.h b/graphics/macgui/macwindowborder.h
index 1e46e1a017..f1d0d2c81a 100644
--- a/graphics/macgui/macwindowborder.h
+++ b/graphics/macgui/macwindowborder.h
@@ -57,6 +57,13 @@
namespace Graphics {
+enum MacBorderOffset {
+ kBorderOffsetLeft = 0,
+ kBorderOffsetRight = 1,
+ kBorderOffsetTop = 2,
+ kBorderOffsetBottom = 3
+};
+
class MacWindowBorder {
public:
MacWindowBorder();
@@ -65,6 +72,11 @@ public:
bool hasBorder(bool active);
void addActiveBorder(TransparentSurface &source);
void addInactiveBorder(TransparentSurface &source);
+
+ bool hasOffsets();
+ void setBorderOffsets(int left, int right, int top, int bottom);
+ int getBorderOffset(MacBorderOffset offset);
+
void blitBorderInto(ManagedSurface &destination, bool active);
private:
@@ -75,8 +87,10 @@ private:
bool _activeInitialized;
bool _inactiveInitialized;
+ bool _hasOffsets;
+ int _borderOffsets[4];
+
};
} // End of namespace Graphics
#endif
-