From a2955b102547ab37a7cf9b42ca0addeed82bb942 Mon Sep 17 00:00:00 2001 From: Borja Lorente Date: Fri, 29 Jul 2016 12:14:19 +0200 Subject: GRAPHICS: Add active/inactive borders to MacWindowBorders --- graphics/macgui/macwindow.cpp | 13 +++++++------ graphics/macgui/macwindow.h | 3 +-- graphics/macgui/macwindowborder.cpp | 2 ++ graphics/macgui/macwindowborder.h | 1 + 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/graphics/macgui/macwindow.cpp b/graphics/macgui/macwindow.cpp index 7ad5666866..3c9372a745 100644 --- a/graphics/macgui/macwindow.cpp +++ b/graphics/macgui/macwindow.cpp @@ -186,7 +186,7 @@ void MacWindow::drawBorder() { ManagedSurface *g = &_borderSurface; prepareBorderSurface(g); - if (_borders) + if (!_macBorder.empty()) drawBorderFromSurface(g); else drawSimpleBorder(g); @@ -203,12 +203,11 @@ void MacWindow::prepareBorderSurface(ManagedSurface *g) { } void MacWindow::drawBorderFromSurface(ManagedSurface *g) { - assert(_borders); TransparentSurface srf; srf.create(_borderSurface.w, _borderSurface.h, _borders->format); - _macBorder.blitBorderInto(_borderSurface, false); + _macBorder.blitBorderInto(_borderSurface, _active); _borderSurface.transBlitFrom(srf, _borderSurface.format.ARGBToColor(0, 255, 255, 255)); } @@ -302,10 +301,12 @@ void MacWindow::setHighlight(WindowClick highlightedPart) { _borderIsDirty = true; } - void MacWindow::setBorders(TransparentSurface *source) { + void MacWindow::setBorder(TransparentSurface *source, bool active) { _borders = new TransparentSurface(*source); - if (_borders) - _macBorder.addInactiveBorder(_borders); + if (active) + _macBorder.addActiveBorder(_borders); + else + _macBorder.addInactiveBorder(_borders); } diff --git a/graphics/macgui/macwindow.h b/graphics/macgui/macwindow.h index 1181190300..bffeaf7104 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 setBorders(TransparentSurface *source); + void setBorder(TransparentSurface *source, bool active); private: void drawBorder(); @@ -155,7 +155,6 @@ private: ManagedSurface _borderSurface; ManagedSurface _composeSurface; - NinePatchBitmap *_bmp; TransparentSurface *_borders; MacWindowBorder _macBorder; diff --git a/graphics/macgui/macwindowborder.cpp b/graphics/macgui/macwindowborder.cpp index 7e64f1d87c..cbb2ef0571 100644 --- a/graphics/macgui/macwindowborder.cpp +++ b/graphics/macgui/macwindowborder.cpp @@ -15,6 +15,8 @@ MacWindowBorder::~MacWindowBorder() { delete _inactiveBorder; } +bool MacWindowBorder::empty() { return !(_activeBorder || _inactiveBorder); } + void MacWindowBorder::addActiveBorder(TransparentSurface *source) { // Assumes NinePatchBitmap invariants hold _activeBorder = new NinePatchBitmap(source, false); diff --git a/graphics/macgui/macwindowborder.h b/graphics/macgui/macwindowborder.h index c956add76d..0c98e23156 100644 --- a/graphics/macgui/macwindowborder.h +++ b/graphics/macgui/macwindowborder.h @@ -62,6 +62,7 @@ public: MacWindowBorder(); ~MacWindowBorder(); + bool empty(); void addActiveBorder(TransparentSurface *source); void addInactiveBorder(TransparentSurface *source); void blitBorderInto(ManagedSurface &destination, bool active); -- cgit v1.2.3