diff options
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/macgui/macwindow.cpp | 20 | ||||
-rw-r--r-- | graphics/macgui/macwindow.h | 4 | ||||
-rw-r--r-- | graphics/macgui/macwindowborder.cpp | 21 | ||||
-rw-r--r-- | graphics/macgui/macwindowborder.h | 9 |
4 files changed, 25 insertions, 29 deletions
diff --git a/graphics/macgui/macwindow.cpp b/graphics/macgui/macwindow.cpp index 3c9372a745..96139b2508 100644 --- a/graphics/macgui/macwindow.cpp +++ b/graphics/macgui/macwindow.cpp @@ -78,9 +78,6 @@ MacWindow::MacWindow(int id, bool scrollable, bool resizable, bool editable, Mac _draggedX = _draggedY = 0; _type = kWindowWindow; - - _borders = nullptr; - } MacWindow::~MacWindow() { @@ -186,7 +183,7 @@ void MacWindow::drawBorder() { ManagedSurface *g = &_borderSurface; prepareBorderSurface(g); - if (!_macBorder.empty()) + if (_macBorder.hasBorder(_active)) drawBorderFromSurface(g); else drawSimpleBorder(g); @@ -203,12 +200,7 @@ void MacWindow::prepareBorderSurface(ManagedSurface *g) { } void MacWindow::drawBorderFromSurface(ManagedSurface *g) { - - TransparentSurface srf; - srf.create(_borderSurface.w, _borderSurface.h, _borders->format); - _macBorder.blitBorderInto(_borderSurface, _active); - _borderSurface.transBlitFrom(srf, _borderSurface.format.ARGBToColor(0, 255, 255, 255)); } void MacWindow::drawSimpleBorder(ManagedSurface *g) { @@ -301,15 +293,13 @@ void MacWindow::setHighlight(WindowClick highlightedPart) { _borderIsDirty = true; } - void MacWindow::setBorder(TransparentSurface *source, bool active) { - _borders = new TransparentSurface(*source); + void MacWindow::setBorder(TransparentSurface &border, bool active) { if (active) - _macBorder.addActiveBorder(_borders); - else - _macBorder.addInactiveBorder(_borders); + _macBorder.addActiveBorder(border); + else + _macBorder.addInactiveBorder(border); } - void MacWindow::drawBox(ManagedSurface *g, int x, int y, int w, int h) { Common::Rect r(x, y, x + w + 1, y + h + 1); diff --git a/graphics/macgui/macwindow.h b/graphics/macgui/macwindow.h index bffeaf7104..e9e2ffd34c 100644 --- a/graphics/macgui/macwindow.h +++ b/graphics/macgui/macwindow.h @@ -138,7 +138,7 @@ public: bool processEvent(Common::Event &event); bool hasAllFocus() { return _beingDragged || _beingResized; } - void setBorder(TransparentSurface *source, bool active); + void setBorder(TransparentSurface &border, bool active); private: void drawBorder(); @@ -155,8 +155,6 @@ private: ManagedSurface _borderSurface; ManagedSurface _composeSurface; - TransparentSurface *_borders; - MacWindowBorder _macBorder; bool _scrollable; diff --git a/graphics/macgui/macwindowborder.cpp b/graphics/macgui/macwindowborder.cpp index cbb2ef0571..761e1b6853 100644 --- a/graphics/macgui/macwindowborder.cpp +++ b/graphics/macgui/macwindowborder.cpp @@ -2,9 +2,9 @@ namespace Graphics { -MacWindowBorder::MacWindowBorder() { +MacWindowBorder::MacWindowBorder() : _activeInitialized(false), _inactiveInitialized(false) { _activeBorder = nullptr; - _inactiveBorder = nullptr; + _inactiveBorder = nullptr; } @@ -15,15 +15,20 @@ MacWindowBorder::~MacWindowBorder() { delete _inactiveBorder; } -bool MacWindowBorder::empty() { return !(_activeBorder || _inactiveBorder); } +bool MacWindowBorder::hasBorder(bool active) { + return active ? _activeInitialized : _inactiveInitialized; +} -void MacWindowBorder::addActiveBorder(TransparentSurface *source) { - // Assumes NinePatchBitmap invariants hold - _activeBorder = new NinePatchBitmap(source, false); +void MacWindowBorder::addActiveBorder(TransparentSurface &source) { + assert(!_activeBorder); + _activeBorder = new NinePatchBitmap(&source, false); + _activeInitialized = true; } -void MacWindowBorder::addInactiveBorder(TransparentSurface *source) { - _inactiveBorder = new NinePatchBitmap(source, false); +void MacWindowBorder::addInactiveBorder(TransparentSurface &source) { + assert(!_inactiveBorder); + _inactiveBorder = new NinePatchBitmap(&source, false); + _inactiveInitialized = true; } void MacWindowBorder::blitBorderInto(ManagedSurface &destination, bool active) { diff --git a/graphics/macgui/macwindowborder.h b/graphics/macgui/macwindowborder.h index 0c98e23156..1e46e1a017 100644 --- a/graphics/macgui/macwindowborder.h +++ b/graphics/macgui/macwindowborder.h @@ -62,9 +62,9 @@ public: MacWindowBorder(); ~MacWindowBorder(); - bool empty(); - void addActiveBorder(TransparentSurface *source); - void addInactiveBorder(TransparentSurface *source); + bool hasBorder(bool active); + void addActiveBorder(TransparentSurface &source); + void addInactiveBorder(TransparentSurface &source); void blitBorderInto(ManagedSurface &destination, bool active); private: @@ -72,6 +72,9 @@ private: NinePatchBitmap *_activeBorder; NinePatchBitmap *_inactiveBorder; + bool _activeInitialized; + bool _inactiveInitialized; + }; } // End of namespace Graphics |