diff options
author | Borja Lorente | 2016-06-02 19:02:32 +0200 |
---|---|---|
committer | Borja Lorente | 2016-07-31 14:45:36 +0200 |
commit | 4ab02530ae8e6d32bf970973669b306a859b2805 (patch) | |
tree | 3f934efdc14fd7a8a9492d770873a5ba56c0211c /graphics | |
parent | 26238ee6f987a1ffe5836145f3b937cfd38d28cf (diff) | |
download | scummvm-rg350-4ab02530ae8e6d32bf970973669b306a859b2805.tar.gz scummvm-rg350-4ab02530ae8e6d32bf970973669b306a859b2805.tar.bz2 scummvm-rg350-4ab02530ae8e6d32bf970973669b306a859b2805.zip |
GRAPHICS: Add MacWindowBorder to abstract borders
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/macgui/macwindow.cpp | 10 | ||||
-rw-r--r-- | graphics/macgui/macwindow.h | 5 | ||||
-rw-r--r-- | graphics/macgui/macwindowborder.cpp | 38 | ||||
-rw-r--r-- | graphics/macgui/macwindowborder.h | 78 | ||||
-rw-r--r-- | graphics/module.mk | 3 | ||||
-rw-r--r-- | graphics/nine_patch.h | 1 |
6 files changed, 130 insertions, 5 deletions
diff --git a/graphics/macgui/macwindow.cpp b/graphics/macgui/macwindow.cpp index 226037ef56..7ad5666866 100644 --- a/graphics/macgui/macwindow.cpp +++ b/graphics/macgui/macwindow.cpp @@ -203,12 +203,12 @@ void MacWindow::prepareBorderSurface(ManagedSurface *g) { } void MacWindow::drawBorderFromSurface(ManagedSurface *g) { - TransparentSurface srf; - srf.create(_composeSurface.w, _composeSurface.h, _borders->format); + assert(_borders); - _bmp = new NinePatchBitmap(_borders, false); + TransparentSurface srf; + srf.create(_borderSurface.w, _borderSurface.h, _borders->format); - _bmp->blit(srf, 0, 0, srf.w, srf.h); + _macBorder.blitBorderInto(_borderSurface, false); _borderSurface.transBlitFrom(srf, _borderSurface.format.ARGBToColor(0, 255, 255, 255)); } @@ -304,6 +304,8 @@ void MacWindow::setHighlight(WindowClick highlightedPart) { void MacWindow::setBorders(TransparentSurface *source) { _borders = new TransparentSurface(*source); + if (_borders) + _macBorder.addInactiveBorder(_borders); } diff --git a/graphics/macgui/macwindow.h b/graphics/macgui/macwindow.h index 6526e05876..1181190300 100644 --- a/graphics/macgui/macwindow.h +++ b/graphics/macgui/macwindow.h @@ -53,9 +53,12 @@ #include "graphics/nine_patch.h" #include "graphics/palette.h" +#include "graphics/macgui/macwindowborder.h" + namespace Graphics { class MacWindowManager; +class MacWindowBorder; namespace MacWindowConstants { enum WindowType { @@ -155,6 +158,8 @@ private: NinePatchBitmap *_bmp; TransparentSurface *_borders; + MacWindowBorder _macBorder; + bool _scrollable; bool _resizable; bool _active; diff --git a/graphics/macgui/macwindowborder.cpp b/graphics/macgui/macwindowborder.cpp new file mode 100644 index 0000000000..7e64f1d87c --- /dev/null +++ b/graphics/macgui/macwindowborder.cpp @@ -0,0 +1,38 @@ +#include "macwindowborder.h" + +namespace Graphics { + +MacWindowBorder::MacWindowBorder() { + _activeBorder = nullptr; + _inactiveBorder = nullptr; +} + + +MacWindowBorder::~MacWindowBorder() { + if (_activeBorder) + delete _activeBorder; + if (_inactiveBorder) + delete _inactiveBorder; +} + +void MacWindowBorder::addActiveBorder(TransparentSurface *source) { + // Assumes NinePatchBitmap invariants hold + _activeBorder = new NinePatchBitmap(source, false); +} + +void MacWindowBorder::addInactiveBorder(TransparentSurface *source) { + _inactiveBorder = new NinePatchBitmap(source, false); +} + +void MacWindowBorder::blitBorderInto(ManagedSurface &destination, bool active) { + + TransparentSurface srf; + NinePatchBitmap *src = active ? _activeBorder : _inactiveBorder; + + srf.create(destination.w, destination.h, src->getSource()->format); + + src->blit(srf, 0, 0, srf.w, srf.h); + destination.transBlitFrom(srf, destination.format.ARGBToColor(0, 255, 255, 255)); +} + +} // End of namespace Graphics diff --git a/graphics/macgui/macwindowborder.h b/graphics/macgui/macwindowborder.h new file mode 100644 index 0000000000..c956add76d --- /dev/null +++ b/graphics/macgui/macwindowborder.h @@ -0,0 +1,78 @@ +/* ScummVM - Graphic Adventure Engine +* +* ScummVM is the legal property of its developers, whose names +* are too numerous to list here. Please refer to the COPYRIGHT +* file distributed with this source distribution. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. + +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +* MIT License: +* +* Copyright (c) 2016 Borja Lorente +* +* Permission is hereby granted, free of charge, to any person +* obtaining a copy of this software and associated documentation +* files (the "Software"), to deal in the Software without +* restriction, including without limitation the rights to use, +* copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following +* conditions: +* +* The above copyright notice and this permission notice shall be +* included in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +*/ + +#ifndef GRAPHICS_MACWINDOWBORDER_H +#define GRAPHICS_MACWINDOWBORDER_H + +#include "common/str.h" +#include "common/list.h" + +#include "graphics/nine_patch.h" +#include "graphics/managed_surface.h" +#include "graphics/transparent_surface.h" + +namespace Graphics { + +class MacWindowBorder { +public: + MacWindowBorder(); + ~MacWindowBorder(); + + void addActiveBorder(TransparentSurface *source); + void addInactiveBorder(TransparentSurface *source); + void blitBorderInto(ManagedSurface &destination, bool active); + +private: + + NinePatchBitmap *_activeBorder; + NinePatchBitmap *_inactiveBorder; + +}; + +} // End of namespace Graphics +#endif + diff --git a/graphics/module.mk b/graphics/module.mk index 941ae1df6c..1af6d282bc 100644 --- a/graphics/module.mk +++ b/graphics/module.mk @@ -31,7 +31,8 @@ MODULE_OBJS := \ yuv_to_rgb.o \ macgui/macwindowmanager.o\ macgui/macwindow.o \ - macgui/macmenu.o + macgui/macmenu.o \ + macgui/macwindowborder.o ifdef USE_SCALERS MODULE_OBJS += \ diff --git a/graphics/nine_patch.h b/graphics/nine_patch.h index ebd6e1e17e..eaebac3e7b 100644 --- a/graphics/nine_patch.h +++ b/graphics/nine_patch.h @@ -47,6 +47,7 @@ #define GRAPHICS_NINE_PATCH_H #include "common/array.h" +#include "common/rect.h" namespace Graphics { |