diff options
Diffstat (limited to 'gui')
-rw-r--r-- | gui/InterfaceManager.cpp | 50 | ||||
-rw-r--r-- | gui/InterfaceManager.h | 102 |
2 files changed, 152 insertions, 0 deletions
diff --git a/gui/InterfaceManager.cpp b/gui/InterfaceManager.cpp index cccf7a2be5..822b7094b3 100644 --- a/gui/InterfaceManager.cpp +++ b/gui/InterfaceManager.cpp @@ -70,6 +70,50 @@ void InterfaceManager::setGraphicsMode(Graphics_Mode mode) { _vectorRenderer->setSurface(_screen); } +void InterfaceManager::init() { + +} + +void InterfaceManager::drawWidgetBackground(int x, int y, uint16 hints, WidgetBackground background, WidgetStateInfo state, float scale){ + +} + +void InterfaceManager::drawButton(int x, int y, const Common::String &str, WidgetStateInfo state, uint16 hints, float scale) { + +} + +void InterfaceManager::drawSurface(int x, int y, const Graphics::Surface &surface, WidgetStateInfo state, int alpha, bool themeTrans, float scale) { + +} + +void InterfaceManager::drawSlider(int x, int y, int width, WidgetStateInfo state, float scale) { + +} + +void InterfaceManager::drawCheckbox(int x, int y, const Common::String &str, bool checked, WidgetStateInfo state, float scale) { + +} + +void InterfaceManager::drawTab(int x, int y, int tabHeight, int tabWidth, const Common::Array<Common::String> &tabs, int active, uint16 hints, int titleVPad, WidgetStateInfo state, float scale) { + +} + +void InterfaceManager::drawScrollbar(int x, int y, int sliderY, int sliderHeight, ScrollbarState, WidgetStateInfo state, float scale) { + +} + +void InterfaceManager::drawPopUpWidget(int x, int y, const Common::String &sel, int deltax, WidgetStateInfo state, TextAlign align, float scale) { + +} + +void InterfaceManager::drawCaret(int x, int y, bool erase, WidgetStateInfo state, float scale) { + +} + +void InterfaceManager::drawLineSeparator(int x, int y, WidgetStateInfo state, float scale) { + +} + int InterfaceManager::runGUI() { Common::EventManager *eventMan = _system->getEventManager(); _system->showOverlay(); @@ -122,6 +166,12 @@ int InterfaceManager::runGUI() { for (int i = 0; i < 4; ++i) _vectorRenderer->drawStep(&steps[i]); + _vectorRenderer->setFillMode(VectorRenderer::kFillGradient); + _vectorRenderer->setFgColor(0, 0, 0); + _vectorRenderer->drawTriangle(32, 32, 64, 64, VectorRenderer::kTriangleUp); + + _vectorRenderer->drawBeveledSquare(128, 128, 256, 64, 4); + _vectorRenderer->copyFrame(_system); Common::Event event; diff --git a/gui/InterfaceManager.h b/gui/InterfaceManager.h index f3f1784b0c..c7e96103c0 100644 --- a/gui/InterfaceManager.h +++ b/gui/InterfaceManager.h @@ -30,10 +30,16 @@ #include "graphics/surface.h" #include "common/system.h" +#include "graphics/surface.h" +#include "graphics/fontman.h" + #include "graphics/VectorRenderer.h" namespace GUI { +struct WidgetDrawData; +class InterfaceManager; + class InterfaceManager { public: @@ -43,6 +49,65 @@ public: kGfxAntialias16bit }; + enum DrawData { + kDrawDataBackground, + kDrawDataButton, + kDrawDataSurface, + kDrawDataSlider, + kDrawDataCheckbox, + kDrawDataTab, + kDrawDataScrollBar, + kDrawDataPopUp, + kDrawDataCaret, + kDrawDataSeparator, + kDrawDataMAX + }; + + enum FontStyle { + kFontStyleBold = 0, //! A bold font. This is also the default font. + kFontStyleNormal = 1, //! A normal font. + kFontStyleItalic = 2, //! Italic styled font. + kFontStyleFixedNormal = 3, //! Fixed size font. + kFontStyleFixedBold = 4, //! Fixed size bold font. + kFontStyleFixedItalic = 5, //! Fixed size italic font. + kFontStyleMax + }; + + enum State { + kStateDisabled, //! Indicates that the widget is disabled, that does NOT include that it is invisible + kStateEnabled, //! Indicates that the widget is enabled + kStateHighlight //! Indicates that the widget is highlighted by the user + }; + + //! Widget background type + enum WidgetBackground { + kWidgetBackgroundNo, //! No background at all + kWidgetBackgroundPlain, //! Simple background, this may not include borders + kWidgetBackgroundBorder, //! Same as kWidgetBackgroundPlain just with a border + kWidgetBackgroundBorderSmall, //! Same as kWidgetBackgroundPlain just with a small border + kWidgetBackgroundEditText, //! Background used for edit text fields + kWidgetBackgroundSlider //! Background used for sliders + }; + + typedef State WidgetStateInfo; + + //! State of the scrollbar + enum ScrollbarState { + kScrollbarStateNo, + kScrollbarStateUp, + kScrollbarStateDown, + kScrollbarStateSlider, + kScrollbarStateSinglePage + }; + + //! Defined the align of the text + enum TextAlign { + kTextAlignLeft, //! Text should be aligned to the left + kTextAlignCenter, //! Text should be centered + kTextAlignRight //! Text should be aligned to the right + }; + + InterfaceManager(OSystem *system, Graphics_Mode mode) : _vectorRenderer(0), _system(system), _graphicsMode(kGfxDisabled), _screen(0), _bytesPerPixel(0) { @@ -56,6 +121,25 @@ public: void setGraphicsMode(Graphics_Mode mode); int runGUI(); + void init(); + + /** Font management */ + const Graphics::Font *getFont(FontStyle font) const { return _font; } + int getFontHeight(FontStyle font = kFontStyleBold) const { if (_initOk) return _font->getFontHeight(); return 0; } + int getStringWidth(const Common::String &str, FontStyle font) const { if (_initOk) return _font->getStringWidth(str); return 0; } + int getCharWidth(byte c, FontStyle font) const { if (_initOk) return _font->getCharWidth(c); return 0; } + + /** Widget drawing */ + void drawWidgetBackground(int x, int y, uint16 hints, WidgetBackground background, WidgetStateInfo state, float scale = 1.0f); + void drawButton(int x, int y, const Common::String &str, WidgetStateInfo state, uint16 hints, float scale = 1.0f); + void drawSurface(int x, int y, const Graphics::Surface &surface, WidgetStateInfo state, int alpha, bool themeTrans, float scale = 1.0f); + void drawSlider(int x, int y, int width, WidgetStateInfo state, float scale = 1.0f); + void drawCheckbox(int x, int y, const Common::String &str, bool checked, WidgetStateInfo state, float scale = 1.0f); + void drawTab(int x, int y, int tabHeight, int tabWidth, const Common::Array<Common::String> &tabs, int active, uint16 hints, int titleVPad, WidgetStateInfo state, float scale = 1.0f); + void drawScrollbar(int x, int y, int sliderY, int sliderHeight, ScrollbarState, WidgetStateInfo state, float scale = 1.0f); + void drawPopUpWidget(int x, int y, const Common::String &sel, int deltax, WidgetStateInfo state, TextAlign align, float scale = 1.0f); + void drawCaret(int x, int y, bool erase, WidgetStateInfo state, float scale = 1.0f); + void drawLineSeparator(int x, int y, WidgetStateInfo state, float scale = 1.0f); protected: template<typename PixelType> void screenInit(); @@ -79,6 +163,24 @@ protected: int _bytesPerPixel; Graphics_Mode _graphicsMode; + + Common::String _fontName; + const Graphics::Font *_font; + + WidgetDrawData *_widgets[kDrawDataMAX]; + + bool _initOk; + bool _caching; +}; + +struct WidgetDrawData { + Graphics::DrawStep **_steps; + int _stepCount; + + bool _cached; + Graphics::Surface *_surfaceCache; + + InterfaceManager::DrawData _type; }; } // end of namespace GUI. |