reorganize all constants and place them into namespaces

This commit is contained in:
Eduardo Bart
2011-08-28 13:02:26 -03:00
parent dab483caab
commit e87297c1b5
62 changed files with 527 additions and 800 deletions

View File

@@ -49,7 +49,7 @@ void Font::load(const OTMLNodePtr& fontNode)
// read custom widths
if(OTMLNodePtr node = fontNode->get("glyph widths")) {
for(const OTMLNodePtr& child : node->children())
m_glyphsSize[fw::safe_cast<int>(child->tag())].setWidth(child->value<int>());
m_glyphsSize[Fw::safeCast<int>(child->tag())].setWidth(child->value<int>());
}
// calculate glyphs texture coords
@@ -68,13 +68,13 @@ void Font::renderText(const std::string& text,
{
Size boxSize = g_graphics.getScreenSize() - startPos.toSize();
Rect screenCoords(startPos, boxSize);
renderText(text, screenCoords, AlignTopLeft, color);
renderText(text, screenCoords, Fw::AlignTopLeft, color);
}
void Font::renderText(const std::string& text,
const Rect& screenCoords,
AlignmentFlag align,
Fw::AlignmentFlag align,
const Color& color)
{
// prevent glitches from invalid rects
@@ -103,17 +103,17 @@ void Font::renderText(const std::string& text,
Rect glyphTextureCoords = m_glyphsTextureCoords[glyph];
// first translate to align position
if(align & AlignBottom) {
if(align & Fw::AlignBottom) {
glyphScreenCoords.translate(0, screenCoords.height() - textBoxSize.height());
} else if(align & AlignVerticalCenter) {
} else if(align & Fw::AlignVerticalCenter) {
glyphScreenCoords.translate(0, (screenCoords.height() - textBoxSize.height()) / 2);
} else { // AlignTop
// nothing to do
}
if(align & AlignRight) {
if(align & Fw::AlignRight) {
glyphScreenCoords.translate(screenCoords.width() - textBoxSize.width(), 0);
} else if(align & AlignHorizontalCenter) {
} else if(align & Fw::AlignHorizontalCenter) {
glyphScreenCoords.translate((screenCoords.width() - textBoxSize.width()) / 2, 0);
} else { // AlignLeft
// nothing to do
@@ -158,7 +158,7 @@ void Font::renderText(const std::string& text,
}
const std::vector<Point>& Font::calculateGlyphsPositions(const std::string& text,
AlignmentFlag align,
Fw::AlignmentFlag align,
Size *textBoxSize) const
{
// for performance reasons we use statics vectors that are allocated on demand
@@ -183,7 +183,7 @@ const std::vector<Point>& Font::calculateGlyphsPositions(const std::string& text
glyphsPositions.resize(textLength);
// calculate lines width
if((align & AlignRight || align & AlignHorizontalCenter) || textBoxSize) {
if((align & Fw::AlignRight || align & Fw::AlignHorizontalCenter) || textBoxSize) {
lineWidths[0] = 0;
for(i = 0; i< textLength; ++i) {
glyph = (uchar)text[i];
@@ -213,9 +213,9 @@ const std::vector<Point>& Font::calculateGlyphsPositions(const std::string& text
}
// calculate start x pos
if(align & AlignRight) {
if(align & Fw::AlignRight) {
virtualPos.x = (maxLineWidth - lineWidths[lines]);
} else if(align & AlignHorizontalCenter) {
} else if(align & Fw::AlignHorizontalCenter) {
virtualPos.x = (maxLineWidth - lineWidths[lines]) / 2;
} else { // AlignLeft
virtualPos.x = 0;
@@ -242,7 +242,7 @@ const std::vector<Point>& Font::calculateGlyphsPositions(const std::string& text
Size Font::calculateTextRectSize(const std::string& text)
{
Size size;
calculateGlyphsPositions(text, AlignTopLeft, &size);
calculateGlyphsPositions(text, Fw::AlignTopLeft, &size);
return size;
}

View File

@@ -38,17 +38,17 @@ public:
/// Simple text render starting at startPos
void renderText(const std::string& text,
const Point& startPos,
const Color& color = Color::white);
const Color& color = Fw::white);
/// Advanced text render delimited by a screen region and alignment
void renderText(const std::string& text,
const Rect& screenCoords,
AlignmentFlag align = AlignTopLeft,
const Color& color = Color::white);
Fw::AlignmentFlag align = Fw::AlignTopLeft,
const Color& color = Fw::white);
/// Calculate glyphs positions to use on render, also calculates textBoxSize if wanted
const std::vector<Point>& calculateGlyphsPositions(const std::string& text,
AlignmentFlag align = AlignTopLeft,
Fw::AlignmentFlag align = Fw::AlignTopLeft,
Size* textBoxSize = NULL) const;
/// Simulate render and calculate text size

View File

@@ -50,8 +50,8 @@ void Graphics::init()
m_opacity = 255;
m_emptyTexture = TexturePtr(new Texture);
bindColor(Color::white);
bindBlendFunc(BLEND_NORMAL);
bindColor(Fw::white);
bindBlendFunc(Fw::BlendNormal);
}
void Graphics::terminate()
@@ -299,13 +299,13 @@ void Graphics::bindTexture(const TexturePtr& texture)
glBindTexture(GL_TEXTURE_2D, texture->getId());
}
void Graphics::bindBlendFunc(BlendFuncType blendType)
void Graphics::bindBlendFunc(Fw::BlendFunc blendType)
{
switch(blendType) {
case BLEND_NORMAL:
case Fw::BlendNormal:
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
break;
case BLEND_COLORIZING:
case Fw::BlendColorzing:
glBlendFunc(GL_DST_COLOR, GL_ONE_MINUS_SRC_ALPHA);
break;
}

View File

@@ -25,11 +25,6 @@
#include "declarations.h"
enum BlendFuncType {
BLEND_NORMAL,
BLEND_COLORIZING
};
class Graphics
{
public:
@@ -56,7 +51,7 @@ public:
void bindColor(const Color& color);
void bindTexture(const TexturePtr& texture);
void bindBlendFunc(BlendFuncType blendType);
void bindBlendFunc(Fw::BlendFunc blendType);
// drawing API
void drawTexturedRect(const Rect& screenCoords,