mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-14 05:38:56 +00:00
Expanded the InterfaceManager skeleton quite a bit.
svn-id: r32604
This commit is contained in:
parent
18d5678e7b
commit
69694c72f6
@ -48,6 +48,7 @@ struct DrawStep {
|
||||
color2; /** Background color/gradient end */
|
||||
|
||||
uint16 x, y, w, h, r; /** Shape size */
|
||||
uint16 offset_x, offset_y; /** Offset when drawing directly to the whole screen */
|
||||
uint8 shadow, stroke, factor; /** Misc options... */
|
||||
|
||||
int fill_mode; /** active fill mode */
|
||||
@ -87,7 +88,12 @@ VectorRenderer *createRenderer(int mode);
|
||||
*/
|
||||
class VectorRenderer {
|
||||
public:
|
||||
VectorRenderer() : _shadowOffset(0), _fillMode(kFillDisabled), _activeSurface(NULL), _strokeWidth(1), _gradientFactor(1) {}
|
||||
VectorRenderer() : _shadowOffset(0), _fillMode(kFillDisabled),
|
||||
_activeSurface(NULL), _strokeWidth(1), _gradientFactor(1),
|
||||
_stepOffsetX(0), _stepOffsetY(0) {
|
||||
|
||||
}
|
||||
|
||||
virtual ~VectorRenderer() {}
|
||||
|
||||
/** Specifies the way in which a shape is filled */
|
||||
@ -317,19 +323,19 @@ public:
|
||||
* DrawStep callback functions for each drawing feature
|
||||
*/
|
||||
void drawCallback_CIRCLE(DrawStep *step) {
|
||||
drawCircle(step->x, step->y, step->r);
|
||||
drawCircle(_stepOffsetX + step->x, _stepOffsetY + step->y, step->r);
|
||||
}
|
||||
|
||||
void drawCallback_SQUARE(DrawStep *step) {
|
||||
drawSquare(step->x, step->y, step->w, step->h);
|
||||
drawSquare(_stepOffsetX + step->x, _stepOffsetY + step->y, step->w, step->h);
|
||||
}
|
||||
|
||||
void drawCallback_LINE(DrawStep *step) {
|
||||
drawLine(step->x, step->y, step->x + step->w, step->y + step->h);
|
||||
drawLine(_stepOffsetX + step->x, _stepOffsetY + step->y, step->x + step->w, step->y + step->h);
|
||||
}
|
||||
|
||||
void drawCallback_ROUNDSQ(DrawStep *step) {
|
||||
drawRoundedSquare(step->x, step->y, step->r, step->w, step->h);
|
||||
drawRoundedSquare(_stepOffsetX + step->x, _stepOffsetY + step->y, step->r, step->w, step->h);
|
||||
}
|
||||
|
||||
void drawCallback_FILLSURFACE(DrawStep *step) {
|
||||
@ -337,11 +343,11 @@ public:
|
||||
}
|
||||
|
||||
void drawCallback_TRIANGLE(DrawStep *step) {
|
||||
drawTriangle(step->x, step->y, step->w, step->h, (TriangleOrientation)step->extra);
|
||||
drawTriangle(_stepOffsetX + step->x, _stepOffsetY + step->y, step->w, step->h, (TriangleOrientation)step->extra);
|
||||
}
|
||||
|
||||
void drawCallback_BEVELSQ(DrawStep *step) {
|
||||
drawBeveledSquare(step->x, step->y, step->w, step->h, step->extra);
|
||||
drawBeveledSquare(_stepOffsetX + step->x, _stepOffsetY + step->y, step->w, step->h, step->extra);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -359,9 +365,32 @@ public:
|
||||
*/
|
||||
virtual void copyFrame(OSystem *sys) = 0;
|
||||
|
||||
/**
|
||||
* Enables drawing offset for all the Draw Step operations,
|
||||
* i.e. when we are drawing widgets directly on a whole screen
|
||||
* instead of individual surfaces for caching/blitting.
|
||||
*
|
||||
* @param x Horizontal drawing offset.
|
||||
* @param y Veritcal drawing offset.
|
||||
*/
|
||||
void setDrawOffset(int x, int y) {
|
||||
_stepOffsetX = x;
|
||||
_stepOffsetY = y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables the drawing offset for draw step operations.
|
||||
*/
|
||||
void disableDrawOffset() {
|
||||
_stepOffsetX = _stepOffsetY = 0;
|
||||
}
|
||||
|
||||
protected:
|
||||
Surface *_activeSurface; /** Pointer to the surface currently being drawn */
|
||||
|
||||
int _stepOffsetX; /** Offset for all the drawing steps */
|
||||
int _stepOffsetY; /** Offset for all the drawing steps */
|
||||
|
||||
FillMode _fillMode; /** Defines in which way (if any) are filled the drawn shapes */
|
||||
|
||||
int _shadowOffset; /** offset for drawn shadows */
|
||||
|
@ -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;
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user