From da757aa2ca1c086ae2f123dc6636d17655b512c7 Mon Sep 17 00:00:00 2001 From: Vicent Marti Date: Mon, 9 Jun 2008 21:16:26 +0000 Subject: InterfaceManager is now a singleton svn-id: r32640 --- base/main.cpp | 4 +--- gui/InterfaceManager.cpp | 19 +++++++++++++------ gui/InterfaceManager.h | 21 +++++++++++++++------ 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/base/main.cpp b/base/main.cpp index be0c84bb1c..45e0aef728 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -70,9 +70,7 @@ static bool launcherDialog(OSystem &system) { #if 1 - GUI::InterfaceManager iManager(&system, GUI::InterfaceManager::kGfxStandard16bit); - - iManager.runGUI(); + g_InterfaceManager.runGUI(); return true; #else diff --git a/gui/InterfaceManager.cpp b/gui/InterfaceManager.cpp index 822b7094b3..ffe19dbe9c 100644 --- a/gui/InterfaceManager.cpp +++ b/gui/InterfaceManager.cpp @@ -32,10 +32,20 @@ #include "gui/InterfaceManager.h" #include "graphics/VectorRenderer.h" +DECLARE_SINGLETON(GUI::InterfaceManager); + namespace GUI { using namespace Graphics; +InterfaceManager::InterfaceManager() : + _vectorRenderer(0), _system(0), _graphicsMode(kGfxDisabled), + _screen(0), _bytesPerPixel(0) { + _system = g_system; + + setGraphicsMode(kGfxStandard16bit); +} + template void InterfaceManager::screenInit() { freeScreen(); @@ -53,10 +63,6 @@ void InterfaceManager::setGraphicsMode(Graphics_Mode mode) { switch (mode) { case kGfxStandard16bit: - _bytesPerPixel = sizeof(uint16); - screenInit(); - break; - case kGfxAntialias16bit: _bytesPerPixel = sizeof(uint16); screenInit(); @@ -70,8 +76,8 @@ void InterfaceManager::setGraphicsMode(Graphics_Mode mode) { _vectorRenderer->setSurface(_screen); } -void InterfaceManager::init() { - +bool InterfaceManager::init() { + return false; } void InterfaceManager::drawWidgetBackground(int x, int y, uint16 hints, WidgetBackground background, WidgetStateInfo state, float scale){ @@ -168,6 +174,7 @@ int InterfaceManager::runGUI() { _vectorRenderer->setFillMode(VectorRenderer::kFillGradient); _vectorRenderer->setFgColor(0, 0, 0); + _vectorRenderer->setBgColor(128, 64, 255); _vectorRenderer->drawTriangle(32, 32, 64, 64, VectorRenderer::kTriangleUp); _vectorRenderer->drawBeveledSquare(128, 128, 256, 64, 4); diff --git a/gui/InterfaceManager.h b/gui/InterfaceManager.h index c7e96103c0..ff8eee3de0 100644 --- a/gui/InterfaceManager.h +++ b/gui/InterfaceManager.h @@ -37,10 +37,14 @@ namespace GUI { +#define g_InterfaceManager (GUI::InterfaceManager::instance()) + struct WidgetDrawData; class InterfaceManager; -class InterfaceManager { +class InterfaceManager : public Common::Singleton { + + friend class Common::Singleton; public: enum Graphics_Mode { @@ -107,12 +111,15 @@ public: kTextAlignRight //! Text should be aligned to the right }; + //! Function used to process areas other than the current dialog + enum ShadingStyle { + kShadingNone, //! No special post processing + kShadingDim, //! Dimming unused areas + kShadingLuminance //! Converting colors to luminance for unused areas + }; - InterfaceManager(OSystem *system, Graphics_Mode mode) : _vectorRenderer(0), - _system(system), _graphicsMode(kGfxDisabled), _screen(0), _bytesPerPixel(0) { - setGraphicsMode(mode); - } + InterfaceManager(); ~InterfaceManager() { freeRenderer(); @@ -121,7 +128,9 @@ public: void setGraphicsMode(Graphics_Mode mode); int runGUI(); - void init(); + + bool init(); + bool deinit(); /** Font management */ const Graphics::Font *getFont(FontStyle font) const { return _font; } -- cgit v1.2.3