More widgets.
svn-id: r33071
This commit is contained in:
parent
d3d34ef295
commit
b44b37d4ca
6 changed files with 98 additions and 23 deletions
|
@ -489,6 +489,8 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual void blitSurface(Graphics::Surface *source, const Common::Rect &r) = 0;
|
virtual void blitSurface(Graphics::Surface *source, const Common::Rect &r) = 0;
|
||||||
|
|
||||||
|
virtual uint32 buildColor(uint8 r, uint8 g, uint8 b) = 0;
|
||||||
|
|
||||||
virtual void drawString(const Graphics::Font *font, const Common::String &text, const Common::Rect &area, GUI::Theme::TextAlign alignH, GUI::Theme::TextAlignVertical alignV) = 0;
|
virtual void drawString(const Graphics::Font *font, const Common::String &text, const Common::Rect &area, GUI::Theme::TextAlign alignH, GUI::Theme::TextAlignVertical alignV) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -650,6 +652,10 @@ public:
|
||||||
src_ptr += src_pitch;
|
src_ptr += src_pitch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual uint32 buildColor(uint8 r, uint8 g, uint8 b) {
|
||||||
|
return RGBToColor<PixelFormat>(r, g, b);
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
|
@ -41,7 +41,10 @@ bool ThemeRenderer::loadDefaultXML() {
|
||||||
"<palette>"
|
"<palette>"
|
||||||
"<color name = 'red' rgb = '255, 0, 0' />"
|
"<color name = 'red' rgb = '255, 0, 0' />"
|
||||||
"<color name = 'green' rgb = '0, 255, 0' />"
|
"<color name = 'green' rgb = '0, 255, 0' />"
|
||||||
"<color name = 'blue' rgb = '0, 0, 255' />"
|
"<color name = 'blue' rgb = '0, 255, 255' />"
|
||||||
|
"<color name = 'text_default' rgb = '0, 0, 0' />"
|
||||||
|
"<color name = 'text_hover' rgb = '255, 255, 255' />"
|
||||||
|
"<color name = 'text_disabled' rgb = '128, 128, 128' />"
|
||||||
"</palette>"
|
"</palette>"
|
||||||
|
|
||||||
"<default fill = 'gradient' fg_color = '255, 255, 255' />"
|
"<default fill = 'gradient' fg_color = '255, 255, 255' />"
|
||||||
|
@ -54,6 +57,10 @@ bool ThemeRenderer::loadDefaultXML() {
|
||||||
"<drawstep func = 'square' fill = 'foreground' height = '3' ypos = 'center' fg_color = '0, 0, 0' />"
|
"<drawstep func = 'square' fill = 'foreground' height = '3' ypos = 'center' fg_color = '0, 0, 0' />"
|
||||||
"</drawdata>"
|
"</drawdata>"
|
||||||
|
|
||||||
|
"<drawdata id = 'scrollbar_base' cache = false>"
|
||||||
|
"<drawstep func = 'roundedsq' stroke = 1 radius = 4 fill = 'none' fg_color = '255, 255, 255' />"
|
||||||
|
"</drawdata>"
|
||||||
|
|
||||||
"<drawdata id = 'popup_idle' cache = false>"
|
"<drawdata id = 'popup_idle' cache = false>"
|
||||||
"<drawstep func = 'square' stroke = 0 fg_color = '0, 0, 0' fill = 'gradient' gradient_start = '214, 113, 8' gradient_end = '240, 200, 25' shadow = 3 />"
|
"<drawstep func = 'square' stroke = 0 fg_color = '0, 0, 0' fill = 'gradient' gradient_start = '214, 113, 8' gradient_end = '240, 200, 25' shadow = 3 />"
|
||||||
"<drawstep func = 'triangle' fg_color = '0, 0, 0' fill = 'foreground' width = '12' height = '12' xpos = '-16' ypos = 'center' orientation = 'bottom' />"
|
"<drawstep func = 'triangle' fg_color = '0, 0, 0' fill = 'foreground' width = '12' height = '12' xpos = '-16' ypos = 'center' orientation = 'bottom' />"
|
||||||
|
|
|
@ -173,30 +173,32 @@ bool ThemeParser::parserCallback_text() {
|
||||||
step.alignVertical = GUI::Theme::kTextAlignVBottom;
|
step.alignVertical = GUI::Theme::kTextAlignVBottom;
|
||||||
else return parserError("Invalid value for text alignment.");
|
else return parserError("Invalid value for text alignment.");
|
||||||
|
|
||||||
|
Common::String paletteColor = "text_default";
|
||||||
|
int red, green, blue;
|
||||||
|
|
||||||
|
if (tNode->name.contains("hover"))
|
||||||
|
paletteColor = "text_hover";
|
||||||
|
|
||||||
|
if (tNode->name.contains("disabled"))
|
||||||
|
paletteColor = "text_disabled";
|
||||||
|
|
||||||
if (tNode->values.contains("color")) {
|
if (tNode->values.contains("color")) {
|
||||||
int red, green, blue;
|
|
||||||
|
|
||||||
if (parseIntegerKey(tNode->values["color"].c_str(), 3, &red, &green, &blue) == false ||
|
if (_palette.contains(tNode->values["color"]))
|
||||||
red < 0 || red > 255 || green < 0 || green > 255 || blue < 0 || blue > 255)
|
getPaletteColor(tNode->values["color"], red, green, blue);
|
||||||
return parserError("Error when parsing color value for text definition");
|
else if (!parseIntegerKey(tNode->values["color"].c_str(), 3, &red, &green, &blue))
|
||||||
|
return parserError("Error when parsing color value for text definition");
|
||||||
|
|
||||||
step.color.r = red;
|
} else if (_palette.contains(paletteColor)) {
|
||||||
step.color.g = green;
|
getPaletteColor(paletteColor, red, green, blue);
|
||||||
step.color.b = blue;
|
|
||||||
step.color.set = true;
|
|
||||||
} else if (_defaultStepLocal && _defaultStepLocal->fgColor.set) {
|
|
||||||
step.color.r = _defaultStepLocal->fgColor.r;
|
|
||||||
step.color.g = _defaultStepLocal->fgColor.g;
|
|
||||||
step.color.b = _defaultStepLocal->fgColor.b;
|
|
||||||
step.color.set = true;
|
|
||||||
} else if (_defaultStepGlobal && _defaultStepGlobal->fgColor.set) {
|
|
||||||
step.color.r = _defaultStepGlobal->fgColor.r;
|
|
||||||
step.color.g = _defaultStepGlobal->fgColor.g;
|
|
||||||
step.color.b = _defaultStepGlobal->fgColor.b;
|
|
||||||
step.color.set = true;
|
|
||||||
} else {
|
} else {
|
||||||
return parserError("Cannot assign color for text drawing.");
|
return parserError("Cannot assign color for text drawing.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
step.color.r = red;
|
||||||
|
step.color.g = green;
|
||||||
|
step.color.b = blue;
|
||||||
|
step.color.set = true;
|
||||||
|
|
||||||
_theme->addTextStep(parentNode->values["id"], step);
|
_theme->addTextStep(parentNode->values["id"], step);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -316,6 +316,17 @@ class ThemeParser : public XMLParser {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ThemeParser(GUI::ThemeRenderer *parent);
|
ThemeParser(GUI::ThemeRenderer *parent);
|
||||||
|
|
||||||
|
bool getPaletteColor(const Common::String &name, int &r, int &g, int &b) {
|
||||||
|
if (!_palette.contains(name))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
r = _palette[name].r;
|
||||||
|
g = _palette[name].g;
|
||||||
|
b = _palette[name].b;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ThemeRenderer *_theme;
|
ThemeRenderer *_theme;
|
||||||
|
|
|
@ -69,7 +69,8 @@ const char *ThemeRenderer::kDrawDataStrings[] = {
|
||||||
"popup_hover",
|
"popup_hover",
|
||||||
|
|
||||||
"caret",
|
"caret",
|
||||||
"separator"
|
"separator",
|
||||||
|
"default_text"
|
||||||
};
|
};
|
||||||
|
|
||||||
ThemeRenderer::ThemeRenderer(Common::String themeName, GraphicsMode mode) :
|
ThemeRenderer::ThemeRenderer(Common::String themeName, GraphicsMode mode) :
|
||||||
|
@ -234,7 +235,20 @@ bool ThemeRenderer::loadTheme(Common::String themeName) {
|
||||||
// draw the cached widget to the cache surface
|
// draw the cached widget to the cache surface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int r, g, b;
|
||||||
|
|
||||||
|
#define __LOAD_COLOR(id, name) { \
|
||||||
|
if (parser()->getPaletteColor(name, r, g, b))\
|
||||||
|
_textColors[id] = _vectorRenderer->buildColor(r, g, b); \
|
||||||
|
}
|
||||||
|
|
||||||
|
__LOAD_COLOR(kTextColorDefault, "text_default");
|
||||||
|
__LOAD_COLOR(kTextColorHover, "text_hover");
|
||||||
|
__LOAD_COLOR(kTextColorDisabled, "text_disabled");
|
||||||
|
|
||||||
|
#undef __LOAD_COLOR
|
||||||
|
|
||||||
_themeOk = true;
|
_themeOk = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -360,6 +374,9 @@ void ThemeRenderer::drawSlider(const Common::Rect &r, int width, WidgetStateInfo
|
||||||
void ThemeRenderer::drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, ScrollbarState sb_state, WidgetStateInfo state) {
|
void ThemeRenderer::drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, ScrollbarState sb_state, WidgetStateInfo state) {
|
||||||
if (!ready())
|
if (!ready())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
drawDD(kDDScrollbarBase, r);
|
||||||
|
|
||||||
|
|
||||||
debugWidgetPosition("SCB", r);
|
debugWidgetPosition("SCB", r);
|
||||||
}
|
}
|
||||||
|
@ -399,7 +416,7 @@ void ThemeRenderer::drawPopUpWidget(const Common::Rect &r, const Common::String
|
||||||
if (!sel.empty()) {
|
if (!sel.empty()) {
|
||||||
Common::Rect text(r.left, r.top, r.right - 16, r.bottom);
|
Common::Rect text(r.left, r.top, r.right - 16, r.bottom);
|
||||||
drawDDText(dd, text, sel);
|
drawDDText(dd, text, sel);
|
||||||
}
|
}
|
||||||
|
|
||||||
debugWidgetPosition("Popup Widget", r);
|
debugWidgetPosition("Popup Widget", r);
|
||||||
}
|
}
|
||||||
|
@ -443,6 +460,15 @@ void ThemeRenderer::drawTab(const Common::Rect &r, int tabHeight, int tabWidth,
|
||||||
debugWidgetPosition("Tab widget", r);
|
debugWidgetPosition("Tab widget", r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ThemeRenderer::drawText(const Common::Rect &r, const Common::String &str, WidgetStateInfo state, TextAlign align, bool inverted, int deltax, bool useEllipsis, FontStyle font) {
|
||||||
|
if (!_initOk)
|
||||||
|
return;
|
||||||
|
|
||||||
|
getFont(font)->drawString(_screen, str, r.left, r.top, r.width(), getTextColor(state), convertAligment(align), deltax, useEllipsis);
|
||||||
|
addDirtyRect(r);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ThemeRenderer::debugWidgetPosition(const char *name, const Common::Rect &r) {
|
void ThemeRenderer::debugWidgetPosition(const char *name, const Common::Rect &r) {
|
||||||
// _font->drawString(_screen, name, r.left, r.top, r.width(), 0xFFFF, Graphics::kTextAlignRight, 0, true);
|
// _font->drawString(_screen, name, r.left, r.top, r.width(), 0xFFFF, Graphics::kTextAlignRight, 0, true);
|
||||||
// _screen->hLine(r.left, r.top, r.right, 0xFFFF);
|
// _screen->hLine(r.left, r.top, r.right, 0xFFFF);
|
||||||
|
|
|
@ -112,8 +112,17 @@ public:
|
||||||
|
|
||||||
kDDCaret,
|
kDDCaret,
|
||||||
kDDSeparator,
|
kDDSeparator,
|
||||||
|
kDDDefaultText,
|
||||||
kDrawDataMAX
|
kDrawDataMAX
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum TextColor {
|
||||||
|
kTextColorDefault,
|
||||||
|
kTextColorHover,
|
||||||
|
kTextColorDisabled,
|
||||||
|
kTextColorInverted,
|
||||||
|
kTextColorMAX
|
||||||
|
};
|
||||||
|
|
||||||
ThemeRenderer(Common::String themeName, GraphicsMode mode);
|
ThemeRenderer(Common::String themeName, GraphicsMode mode);
|
||||||
|
|
||||||
|
@ -160,7 +169,7 @@ public:
|
||||||
void drawLineSeparator(const Common::Rect &r, WidgetStateInfo state = kStateEnabled);
|
void drawLineSeparator(const Common::Rect &r, WidgetStateInfo state = kStateEnabled);
|
||||||
|
|
||||||
void drawDialogBackground(const Common::Rect &r, uint16 hints, WidgetStateInfo state);
|
void drawDialogBackground(const Common::Rect &r, uint16 hints, WidgetStateInfo state);
|
||||||
void drawText(const Common::Rect &r, const Common::String &str, WidgetStateInfo state, TextAlign align, bool inverted, int deltax, bool useEllipsis, FontStyle font) {}
|
void drawText(const Common::Rect &r, const Common::String &str, WidgetStateInfo state, TextAlign align, bool inverted, int deltax, bool useEllipsis, FontStyle font);
|
||||||
void drawChar(const Common::Rect &r, byte ch, const Graphics::Font *font, WidgetStateInfo state) {}
|
void drawChar(const Common::Rect &r, byte ch, const Graphics::Font *font, WidgetStateInfo state) {}
|
||||||
|
|
||||||
bool addDirtyRect(Common::Rect r, bool backup = false, bool special = false) {
|
bool addDirtyRect(Common::Rect r, bool backup = false, bool special = false) {
|
||||||
|
@ -254,6 +263,19 @@ protected:
|
||||||
int getTabPadding() const {
|
int getTabPadding() const {
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32 getTextColor(WidgetStateInfo state) {
|
||||||
|
switch (state) {
|
||||||
|
case kStateDisabled:
|
||||||
|
return _textColors[kTextColorDisabled];
|
||||||
|
|
||||||
|
case kStateHighlight:
|
||||||
|
return _textColors[kTextColorHover];
|
||||||
|
|
||||||
|
default:
|
||||||
|
return _textColors[kTextColorDefault];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
OSystem *_system;
|
OSystem *_system;
|
||||||
Graphics::VectorRenderer *_vectorRenderer;
|
Graphics::VectorRenderer *_vectorRenderer;
|
||||||
|
@ -266,6 +288,7 @@ protected:
|
||||||
|
|
||||||
Common::String _fontName;
|
Common::String _fontName;
|
||||||
const Graphics::Font *_font;
|
const Graphics::Font *_font;
|
||||||
|
uint32 _textColors[kTextColorMAX];
|
||||||
|
|
||||||
WidgetDrawData *_widgets[kDrawDataMAX];
|
WidgetDrawData *_widgets[kDrawDataMAX];
|
||||||
Common::Array<Common::Rect> _dirtyScreen;
|
Common::Array<Common::Rect> _dirtyScreen;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue