replaced TextPos with yg::EPosition.

This commit is contained in:
rachytski 2011-05-01 17:24:57 +03:00 committed by Alex Zolotarev
parent f605febe69
commit c113fe9b32
4 changed files with 41 additions and 16 deletions

View file

@ -261,7 +261,7 @@ bool DrawerYG::drawPathText(di::PathInfo const & info, string const & name, uint
name,
info.GetLength(),
info.GetOffset(),
yg::gl::Screen::middle_line,
yg::EPosCenter,
yg::maxDepth);
}

View file

@ -397,7 +397,7 @@ namespace yg
bool TextRenderer::drawPathText(
FontDesc const & fontDesc, m2::PointD const * path, size_t s, string const & utf8Text,
double fullLength, double pathOffset, TextPos pos, double depth)
double fullLength, double pathOffset, yg::EPosition pos, double depth)
{
if (!m_drawTexts)
return false;
@ -418,7 +418,7 @@ namespace yg
bool TextRenderer::drawPathTextImpl(
FontDesc const & fontDesc, m2::PointD const * path, size_t s, string const & utf8Text,
double fullLength, double pathOffset, TextPos pos, double depth)
double fullLength, double pathOffset, yg::EPosition pos, double depth)
{
pts_array arrPath(path, s, fullLength, pathOffset);
@ -428,9 +428,10 @@ namespace yg
float blOffset = 2;
switch (pos)
{
case under_line: blOffset -= fontDesc.m_size; break;
case middle_line: blOffset -= fontDesc.m_size / 2; break;
case above_line: blOffset -= 0; break;
case yg::EPosUnder: blOffset -= fontDesc.m_size; break;
case yg::EPosCenter: blOffset -= fontDesc.m_size / 2; break;
case yg::EPosAbove: blOffset -= 0; break;
default: blOffset -= fontDesc.m_size / 2; break;
}
size_t const count = text.size();

View file

@ -20,9 +20,6 @@ namespace yg
{
public:
enum TextPos { under_line, middle_line, above_line };
class TextObj
{
FontDesc m_fontDesc;
@ -79,7 +76,7 @@ namespace yg
string const & utf8Text,
double fullLength,
double pathOffset,
TextPos pos,
yg::EPosition pos,
double depth);
/// Drawing text from point rotated by the angle.
@ -131,7 +128,7 @@ namespace yg
string const & utf8Text,
double fullLength,
double pathOffset,
TextPos pos,
yg::EPosition pos,
double depth);

View file

@ -719,7 +719,33 @@ namespace
{
p->drawPath(&m_path[0], m_path.size(), p->skin()->mapPenInfo(m_penInfo), 0);
yg::FontDesc fontDesc(false, 10);
p->drawPathText(fontDesc, &m_path[0], m_path.size(), m_text, calc_length(m_path), 0.0, yg::gl::Screen::middle_line, 0);
p->drawPathText(fontDesc, &m_path[0], m_path.size(), m_text, calc_length(m_path), 0.0, yg::EPosCenter, 0);
}
};
struct TestDrawTextOnPathZigZag
{
std::vector<m2::PointD> m_path;
std::string m_text;
yg::PenInfo m_penInfo;
TestDrawTextOnPathZigZag()
{
m_path.push_back(m2::PointD(40, 200));
m_path.push_back(m2::PointD(100, 100));
m_path.push_back(m2::PointD(160, 200));
m_path.push_back(m2::PointD(200, 100));
m_text = "Simplicity is the ultimate sophistication. Leonardo Da Vinci.";
double pat[] = { 2, 2 };
m_penInfo = yg::PenInfo(yg::Color(0, 0, 0, 0xFF), 2, &pat[0], ARRAY_SIZE(pat), 0);
}
void DoDraw(shared_ptr<yg::gl::Screen> p)
{
p->drawPath(&m_path[0], m_path.size(), p->skin()->mapPenInfo(m_penInfo), 0);
yg::FontDesc fontDesc(false, 10);
p->drawPathText(fontDesc, &m_path[0], m_path.size(), m_text, calc_length(m_path), 0.0, yg::EPosCenter, 0);
}
};
@ -732,8 +758,8 @@ namespace
double const len = calc_length(m_path);
yg::FontDesc fontDesc(false, 10);
p->drawPathText(fontDesc, &m_path[0], m_path.size(), m_text, len, 0.0, yg::gl::Screen::above_line, 0);
p->drawPathText(fontDesc, &m_path[0], m_path.size(), m_text, len, 0.0, yg::gl::Screen::under_line, 0);
p->drawPathText(fontDesc, &m_path[0], m_path.size(), m_text, len, 0.0, yg::EPosAbove, 0);
p->drawPathText(fontDesc, &m_path[0], m_path.size(), m_text, len, 0.0, yg::EPosUnder, 0);
}
};
@ -1008,7 +1034,8 @@ namespace
// UNIT_TEST_GL(TestDrawUnicodeSymbols);
// UNIT_TEST_GL(TestDrawTextRectWithFixedFont);
// UNIT_TEST_GL(TestDrawStringOnString);
// UNIT_TEST_GL(TestDrawTextOnPath);
// UNIT_TEST_GL(TestDrawTextOnPath);
UNIT_TEST_GL(TestDrawTextOnPathZigZag);
// UNIT_TEST_GL(TestDrawTextOnPathWithOffset);
// UNIT_TEST_GL(TestDrawTextOverflow);
// UNIT_TEST_GL(TestDrawTextFiltering);
@ -1023,7 +1050,7 @@ namespace
// UNIT_TEST_GL(TestDrawPathSolid2PX);
// UNIT_TEST_GL(TestDrawPathSolid);
// UNIT_TEST_GL(TestDrawSector);
UNIT_TEST_GL(TestDrawPathSolidDiffWidth);
// UNIT_TEST_GL(TestDrawPathSolidDiffWidth);
// UNIT_TEST_GL(TestDrawPathZigZag);
// UNIT_TEST_GL(TestDrawPathSolidWithZ);
// UNIT_TEST_GL(TestDrawPathSolidWithClipRect);