[Scummvm-cvs-logs] SF.net SVN: scummvm: [32995] scummvm/branches/gsoc2008-gui
Tanoku at users.sourceforge.net
Tanoku at users.sourceforge.net
Thu Jul 10 22:36:05 CEST 2008
Revision: 32995
http://scummvm.svn.sourceforge.net/scummvm/?rev=32995&view=rev
Author: Tanoku
Date: 2008-07-10 13:36:02 -0700 (Thu, 10 Jul 2008)
Log Message:
-----------
Support for Vertical text alignement.
Modified Paths:
--------------
scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.cpp
scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h
scummvm/branches/gsoc2008-gui/gui/ThemeDefaultXML.cpp
scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp
scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp
scummvm/branches/gsoc2008-gui/gui/theme.h
Modified: scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.cpp 2008-07-10 18:01:54 UTC (rev 32994)
+++ scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.cpp 2008-07-10 20:36:02 UTC (rev 32995)
@@ -75,7 +75,7 @@
if (step.color.set)
setFgColor(step.color.r, step.color.g, step.color.b);
- drawString(step.font, text.c_str(), area, step.align);
+ drawString(step.font, text.c_str(), area, step.alignHorizontal, step.alignVertical);
}
/********************************************************************
@@ -185,8 +185,24 @@
********************************************************************/
template <typename PixelType, typename PixelFormat>
void VectorRendererSpec<PixelType, PixelFormat>::
-drawString(const Graphics::Font *font, const Common::String &text, const Common::Rect &area, GUI::Theme::TextAlign align) {
- font->drawString(_activeSurface, text, area.left, area.top, area.width(), _fgColor, (Graphics::TextAlignment)align, 0, false);
+drawString(const Graphics::Font *font, const Common::String &text, const Common::Rect &area,
+ GUI::Theme::TextAlign alignH, GUI::Theme::TextAlignVertical alignV) {
+
+ int offset = 0;
+
+ switch (alignV) {
+ case GUI::Theme::kTextAlignVCenter:
+ offset = area.top + (area.height() - font->getFontHeight()) / 2;
+ break;
+ case GUI::Theme::kTextAlignVBottom:
+ offset = area.bottom - font->getFontHeight();
+ break;
+ case GUI::Theme::kTextAlignVTop:
+ offset = area.top;
+ break;
+ }
+
+ font->drawString(_activeSurface, text, area.left, offset, area.width(), _fgColor, (Graphics::TextAlignment)alignH, 0, false);
}
/** LINES **/
Modified: scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h
===================================================================
--- scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h 2008-07-10 18:01:54 UTC (rev 32994)
+++ scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h 2008-07-10 20:36:02 UTC (rev 32995)
@@ -46,7 +46,8 @@
}
color; /** text color */
- GUI::Theme::TextAlign align;
+ GUI::Theme::TextAlign alignHorizontal;
+ GUI::Theme::TextAlignVertical alignVertical;
char *text;
const Graphics::Font *font;
};
@@ -446,7 +447,7 @@
*/
virtual void blitSurface(Graphics::Surface *source, const Common::Rect &r) = 0;
- virtual void drawString(const Graphics::Font *font, const Common::String &text, const Common::Rect &area, GUI::Theme::TextAlign align) = 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:
Surface *_activeSurface; /** Pointer to the surface currently being drawn */
@@ -513,7 +514,9 @@
drawBevelSquareAlg(x, y, w, h, bevel, _fgColor, _bgColor);
}
- void drawString(const Graphics::Font *font, const Common::String &text, const Common::Rect &area, GUI::Theme::TextAlign align);
+ void drawString(const Graphics::Font *font, const Common::String &text,
+ const Common::Rect &area, GUI::Theme::TextAlign alignH,
+ GUI::Theme::TextAlignVertical alignV);
/**
* @see VectorRenderer::setFgColor()
Modified: scummvm/branches/gsoc2008-gui/gui/ThemeDefaultXML.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeDefaultXML.cpp 2008-07-10 18:01:54 UTC (rev 32994)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeDefaultXML.cpp 2008-07-10 20:36:02 UTC (rev 32995)
@@ -51,17 +51,17 @@
"</drawdata>"
"<drawdata id = 'button_idle' cache = false>"
- "<text align = 'center' color = '255, 0, 0' />"
+ "<text vertical_align = 'center' horizontal_align = 'center' color = '255, 255, 255' />"
"<drawstep func = 'roundedsq' radius = '8' stroke = 0 fill = 'gradient' gradient_start = '206, 121, 99' gradient_end = '173, 40, 8' size = 'auto' shadow = 3 />"
"</drawdata>"
"<drawdata id = 'button_hover' cache = false>"
- "<text align = 'center' color = '255, 0, 0' />"
+ "<text vertical_align = 'center' horizontal_align = 'center' color = '255, 255, 255' />"
"<drawstep func = 'roundedsq' radius = '8' fill = 'gradient' gradient_start = '206, 121, 99' gradient_end = '173, 40, 8' size = 'auto' shadow = 3 />"
"</drawdata>"
"<drawdata id = 'checkbox_disabled' cache = false>"
- "<text align = 'center' color = '255, 0, 0' />"
+ "<text vertical_align = 'center' horizontal_align = 'center' color = '255, 0, 0' />"
"<drawstep func = 'square' fill = 'gradient' gradient_start = '206, 121, 99' gradient_end = '173, 40, 8' size = 'auto' shadow = 0 />"
"</drawdata>"
Modified: scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp 2008-07-10 18:01:54 UTC (rev 32994)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp 2008-07-10 20:36:02 UTC (rev 32995)
@@ -146,17 +146,24 @@
Graphics::TextStep step;
- if (tNode->values.contains("align") == false)
- return parserError("Text inside widgets requires an alignement key.");
+ if (tNode->values.contains("horizontal_align") == false || tNode->values.contains("vertical_align") == false)
+ return parserError("Text inside widgets requires proper alignment keys.");
- if (tNode->values["align"] == "left")
- step.align = GUI::Theme::kTextAlignLeft;
- else if (tNode->values["align"] == "right")
- step.align = GUI::Theme::kTextAlignRight;
- else if (tNode->values["align"] == "center")
- step.align = GUI::Theme::kTextAlignCenter;
+ if (tNode->values["horizontal_align"] == "left")
+ step.alignHorizontal = GUI::Theme::kTextAlignLeft;
+ else if (tNode->values["horizontal_align"] == "right")
+ step.alignHorizontal = GUI::Theme::kTextAlignRight;
+ else if (tNode->values["horizontal_align"] == "center")
+ step.alignHorizontal = GUI::Theme::kTextAlignCenter;
else return parserError("Invalid value for text alignment.");
+ if (tNode->values["vertical_align"] == "top")
+ step.alignVertical = GUI::Theme::kTextAlignVTop;
+ else if (tNode->values["vertical_align"] == "center")
+ step.alignVertical = GUI::Theme::kTextAlignVCenter;
+ else if (tNode->values["vertical_align"] == "bottom")
+ step.alignVertical = GUI::Theme::kTextAlignVBottom;
+ else return parserError("Invalid value for text alignment.");
if (tNode->values.contains("color")) {
int red, green, blue;
Modified: scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp 2008-07-10 18:01:54 UTC (rev 32994)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp 2008-07-10 20:36:02 UTC (rev 32995)
@@ -302,10 +302,7 @@
dd = kDDButtonDisabled;
drawDD(dd, r);
- drawDDText(dd, r, str);
- if (hasWidgetText(dd))
- _vectorRenderer->textStep(str, r, _widgets[dd]->_textStep);
-
+ drawDDText(dd, r, str);
addDirtyRect(r);
debugWidgetPosition(r);
Modified: scummvm/branches/gsoc2008-gui/gui/theme.h
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/theme.h 2008-07-10 18:01:54 UTC (rev 32994)
+++ scummvm/branches/gsoc2008-gui/gui/theme.h 2008-07-10 20:36:02 UTC (rev 32995)
@@ -92,6 +92,13 @@
kTextAlignCenter, //! Text should be centered
kTextAlignRight //! Text should be aligned to the right
};
+
+ //! Vertical alignment of the text.
+ enum TextAlignVertical {
+ kTextAlignVBottom,
+ kTextAlignVCenter,
+ kTextAlignVTop
+ };
//! Widget background type
enum WidgetBackground {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list