Skip to content

Commit

Permalink
GRAPHICS: Add vertical alignment to Text
Browse files Browse the repository at this point in the history
  • Loading branch information
farmboy0 committed Nov 25, 2017
1 parent d4674a3 commit e4ea71e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/graphics/aurora/highlightabletext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ namespace Graphics {

namespace Aurora {

HighlightableText::HighlightableText(const FontHandle &font, const Common::UString &str, float r, float g, float b, float a, float halign) :
Text(font, str, r, g, b, a, halign) {
HighlightableText::HighlightableText(const FontHandle &font, const Common::UString &str, float r, float g, float b, float a, float halign, float valign) :
Text(font, str, r, g, b, a, halign, valign) {
}

HighlightableText::~HighlightableText() {
Expand Down
3 changes: 2 additions & 1 deletion src/graphics/aurora/highlightabletext.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ class HighlightableText: public Text, public Highlightable {

public:
HighlightableText(const FontHandle &font, const Common::UString &str,
float r = 1.0f, float g = 1.0f, float b = 1.0f, float a = 1.0f, float halign = kHAlignLeft);
float r = 1.0f, float g = 1.0f, float b = 1.0f, float a = 1.0f,
float halign = kHAlignLeft, float valign = kVAlignTop);
~HighlightableText();

void render(RenderPass pass);
Expand Down
8 changes: 6 additions & 2 deletions src/graphics/aurora/text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ namespace Graphics {
namespace Aurora {

Text::Text(const FontHandle &font, const Common::UString &str,
float r, float g, float b, float a, float halign) :
float r, float g, float b, float a, float halign, float valign) :
Graphics::GUIElement(Graphics::GUIElement::kGUIElementFront),
_r(r), _g(g), _b(b), _a(a), _font(font), _x(0.0f), _y(0.0f), _halign(halign),
_r(r), _g(g), _b(b), _a(a), _font(font), _x(0.0f), _y(0.0f), _halign(halign),_valign(valign),
_disableColorTokens(false) {

set(str);
Expand Down Expand Up @@ -98,6 +98,10 @@ void Text::setHorizontalAlign(float halign) {
_halign = halign;
}

void Text::setVerticalAlign(float valign) {
_valign = valign;
}

const Common::UString &Text::get() const {
return _str;
}
Expand Down
5 changes: 4 additions & 1 deletion src/graphics/aurora/text.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ namespace Aurora {
class Text : public GUIElement {
public:
Text(const FontHandle &font, const Common::UString &str,
float r = 1.0f, float g = 1.0f, float b = 1.0f, float a = 1.0f, float halign = kHAlignLeft);
float r = 1.0f, float g = 1.0f, float b = 1.0f, float a = 1.0f,
float halign = kHAlignLeft, float valign = kVAlignTop);
~Text();

const Common::UString &get() const;
Expand All @@ -54,6 +55,7 @@ class Text : public GUIElement {
void setColor(float r, float g, float b, float a);
void unsetColor();
void setHorizontalAlign(float halign);
void setVerticalAlign(float valign);

/** Change the font of the text. */
void setFont(const Common::UString &fnt);
Expand Down Expand Up @@ -86,6 +88,7 @@ class Text : public GUIElement {
float _height;

float _halign;
float _valign;

Common::UString _str;
ColorPositions _colors;
Expand Down

0 comments on commit e4ea71e

Please sign in to comment.