GRAPHICS: Add active/inactive borders to MacWindowBorders

This commit is contained in:
Borja Lorente 2016-07-29 12:14:19 +02:00
parent 4ab02530ae
commit a2955b1025
4 changed files with 11 additions and 8 deletions

View file

@ -186,7 +186,7 @@ void MacWindow::drawBorder() {
ManagedSurface *g = &_borderSurface; ManagedSurface *g = &_borderSurface;
prepareBorderSurface(g); prepareBorderSurface(g);
if (_borders) if (!_macBorder.empty())
drawBorderFromSurface(g); drawBorderFromSurface(g);
else else
drawSimpleBorder(g); drawSimpleBorder(g);
@ -203,12 +203,11 @@ void MacWindow::prepareBorderSurface(ManagedSurface *g) {
} }
void MacWindow::drawBorderFromSurface(ManagedSurface *g) { void MacWindow::drawBorderFromSurface(ManagedSurface *g) {
assert(_borders);
TransparentSurface srf; TransparentSurface srf;
srf.create(_borderSurface.w, _borderSurface.h, _borders->format); 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)); _borderSurface.transBlitFrom(srf, _borderSurface.format.ARGBToColor(0, 255, 255, 255));
} }
@ -302,10 +301,12 @@ void MacWindow::setHighlight(WindowClick highlightedPart) {
_borderIsDirty = true; _borderIsDirty = true;
} }
void MacWindow::setBorders(TransparentSurface *source) { void MacWindow::setBorder(TransparentSurface *source, bool active) {
_borders = new TransparentSurface(*source); _borders = new TransparentSurface(*source);
if (_borders) if (active)
_macBorder.addInactiveBorder(_borders); _macBorder.addActiveBorder(_borders);
else
_macBorder.addInactiveBorder(_borders);
} }

View file

@ -138,7 +138,7 @@ public:
bool processEvent(Common::Event &event); bool processEvent(Common::Event &event);
bool hasAllFocus() { return _beingDragged || _beingResized; } bool hasAllFocus() { return _beingDragged || _beingResized; }
void setBorders(TransparentSurface *source); void setBorder(TransparentSurface *source, bool active);
private: private:
void drawBorder(); void drawBorder();
@ -155,7 +155,6 @@ private:
ManagedSurface _borderSurface; ManagedSurface _borderSurface;
ManagedSurface _composeSurface; ManagedSurface _composeSurface;
NinePatchBitmap *_bmp;
TransparentSurface *_borders; TransparentSurface *_borders;
MacWindowBorder _macBorder; MacWindowBorder _macBorder;

View file

@ -15,6 +15,8 @@ MacWindowBorder::~MacWindowBorder() {
delete _inactiveBorder; delete _inactiveBorder;
} }
bool MacWindowBorder::empty() { return !(_activeBorder || _inactiveBorder); }
void MacWindowBorder::addActiveBorder(TransparentSurface *source) { void MacWindowBorder::addActiveBorder(TransparentSurface *source) {
// Assumes NinePatchBitmap invariants hold // Assumes NinePatchBitmap invariants hold
_activeBorder = new NinePatchBitmap(source, false); _activeBorder = new NinePatchBitmap(source, false);

View file

@ -62,6 +62,7 @@ public:
MacWindowBorder(); MacWindowBorder();
~MacWindowBorder(); ~MacWindowBorder();
bool empty();
void addActiveBorder(TransparentSurface *source); void addActiveBorder(TransparentSurface *source);
void addInactiveBorder(TransparentSurface *source); void addInactiveBorder(TransparentSurface *source);
void blitBorderInto(ManagedSurface &destination, bool active); void blitBorderInto(ManagedSurface &destination, bool active);