diff --git a/map/drawer_yg.cpp b/map/drawer_yg.cpp index f5a6c0f88f..4636a44e49 100644 --- a/map/drawer_yg.cpp +++ b/map/drawer_yg.cpp @@ -234,37 +234,35 @@ void DrawerYG::drawText(m2::PointD const & pt, string const & name, rule_ptr_t p if (textColor == yg::Color(255, 255, 255, 255)) textColor = yg::Color(0, 0, 0, 0); +// bool isMasked = pRule->GetColor() != -1; + bool isMasked = true; + yg::FontDesc fontDesc(false, get_text_font_size(pRule), textColor, isMasked, yg::Color(255, 255, 255, 255)); + if (!filter_text_size(pRule)) m_pScreen->drawText( - pt, - pos, - 0.0, - get_text_font_size(pRule), - textColor, - name, - pRule->GetColor() != -1, - yg::Color(255, 255, 255, 255), - depth, - false, - true); + fontDesc, + pt, + pos, + 0.0, + name, + depth, + true); } bool DrawerYG::drawPathText(di::PathInfo const & info, string const & name, uint8_t fontSize, int /*depth*/) { // bool const isMasked = (double(fontSize) / m_visualScale >= min_text_height); - return m_pScreen->drawPathText( &info.m_path[0], + yg::FontDesc fontDesc(false, fontSize); + + return m_pScreen->drawPathText( fontDesc, + &info.m_path[0], info.m_path.size(), - fontSize, - yg::Color(0, 0, 0, 0), name, info.GetLength(), info.GetOffset(), yg::gl::Screen::middle_line, - true, - yg::Color(255, 255, 255, 255), - yg::maxDepth, - false); + yg::maxDepth); } shared_ptr DrawerYG::screen() const @@ -294,11 +292,11 @@ void DrawerYG::Draw(di::DrawInfo const * pInfo, di::DrawRule const * rules, size string symbol; pRule->GetSymbol(symbol); - bool const isSymbol = !symbol.empty(); + bool const hasSymbol = !symbol.empty(); bool const isCaption = pRule->GetTextHeight() >= 0.0; bool const isPath = !pInfo->m_pathes.empty(); - if (!isCaption && isPath && !isSymbol && (pRule->GetColor() != -1)) + if (!isCaption && isPath && !hasSymbol && (pRule->GetColor() != -1)) pathRules.push_back(rules[i]); } @@ -317,11 +315,11 @@ void DrawerYG::Draw(di::DrawInfo const * pInfo, di::DrawRule const * rules, size string symbol; pRule->GetSymbol(symbol); - bool const isSymbol = !symbol.empty(); + bool const hasSymbol = !symbol.empty(); bool const isPath = !pInfo->m_pathes.empty(); bool const isArea = !pInfo->m_areas.empty(); - bool const isName = !pInfo->m_name.empty(); + bool const hasName = !pInfo->m_name.empty(); bool const isCircle = (pRule->GetRadius() != -1); @@ -339,13 +337,13 @@ void DrawerYG::Draw(di::DrawInfo const * pInfo, di::DrawRule const * rules, size if (isArea) { bool const isFill = pRule->GetFillColor() != -1; - bool const isSym = isSymbol && ((pRule->GetType() & drule::way) != 0); + bool const hasSym = hasSymbol && ((pRule->GetType() & drule::way) != 0); for (list::const_iterator i = pInfo->m_areas.begin(); i != pInfo->m_areas.end(); ++i) { if (isFill) drawArea(i->m_path, pRule, depth); - else if (isSym) + else if (hasSym) drawSymbol(i->GetCenter() + m2::PointD(0, 2 * m_visualScale), pRule, yg::EPosUnder, depth); } } @@ -353,7 +351,7 @@ void DrawerYG::Draw(di::DrawInfo const * pInfo, di::DrawRule const * rules, size // draw point symbol if (!isPath && !isArea && ((pRule->GetType() & drule::node) != 0)) { - if (isSymbol) + if (hasSymbol) drawSymbol(pInfo->m_point + m2::PointD(0, 2 * m_visualScale), pRule, yg::EPosUnder, depth); if (isCircle) drawCircle(pInfo->m_point + m2::PointD(0, 2 * m_visualScale), pRule, yg::EPosUnder, depth); @@ -361,7 +359,7 @@ void DrawerYG::Draw(di::DrawInfo const * pInfo, di::DrawRule const * rules, size } else { - if (isName) + if (hasName) { bool isN = ((pRule->GetType() & drule::way) != 0); diff --git a/map/information_display.cpp b/map/information_display.cpp index 1d2beeec34..1fe6e9a096 100644 --- a/map/information_display.cpp +++ b/map/information_display.cpp @@ -273,17 +273,15 @@ void InformationDisplay::drawRuler(DrawerYG * pDrawer) pDrawer->screen()->skin()->mapPenInfo(yg::PenInfo(yg::Color(0, 0, 0, 255), 2, 0, 0, 0)), yg::maxDepth); - m2::RectD textRect = pDrawer->screen()->textRect(scalerText.c_str(), 10, true, true, false); - pDrawer->screen()->drawText(scalerPts[1] + m2::PointD(7, -7), + yg::FontDesc fontDesc = yg::FontDesc::defaultFont; + + m2::RectD textRect = pDrawer->screen()->textRect(fontDesc, scalerText.c_str(), false); + pDrawer->screen()->drawText(fontDesc, + scalerPts[1] + m2::PointD(7, -7), yg::EPosAboveRight, 0, - 10, - yg::Color(0, 0, 0, 0), scalerText.c_str(), - true, - yg::Color(255, 255, 255, 255), yg::maxDepth, - true, false); /* m2::PointD minPixPath[4]; @@ -322,10 +320,8 @@ void InformationDisplay::drawCenter(DrawerYG * drawer) << fixed << setprecision(4) << setw(8) << m_centerPt.y << ")"; m2::RectD const & textRect = drawer->screen()->textRect( + yg::FontDesc::defaultFont, out.str().c_str(), - 10, - true, - true, false); m2::RectD bgRect = m2::Offset(m2::Inflate(textRect, 5.0, 5.0), @@ -338,17 +334,14 @@ void InformationDisplay::drawCenter(DrawerYG * drawer) yg::maxDepth - 1); drawer->screen()->drawText( - m2::PointD(m_displayRect.maxX() - textRect.SizeX() - 10 * m_visualScale, - m_displayRect.maxY() - (m_bottomShift + 10) * m_visualScale - 5), - yg::EPosAboveRight, - 0, 10, - yg::Color(0, 0, 0, 0), - out.str().c_str(), - true, - yg::Color(255, 255, 255, 255), - yg::maxDepth, - true, - false); + yg::FontDesc::defaultFont, + m2::PointD(m_displayRect.maxX() - textRect.SizeX() - 10 * m_visualScale, + m_displayRect.maxY() - (m_bottomShift + 10) * m_visualScale - 5), + yg::EPosAboveRight, + 0, + out.str().c_str(), + yg::maxDepth, + false); } void InformationDisplay::enableGlobalRect(bool doEnable) @@ -367,16 +360,13 @@ void InformationDisplay::drawGlobalRect(DrawerYG *pDrawer) ostringstream out; out << "(" << m_globalRect.minX() << ", " << m_globalRect.minY() << ", " << m_globalRect.maxX() << ", " << m_globalRect.maxY() << ") Scale : " << m_currentScale; pDrawer->screen()->drawText( - m2::PointD(m_displayRect.minX() + 10, m_displayRect.minY() + m_yOffset), - yg::EPosAboveRight, - 0, 10, - yg::Color(0, 0, 0, 0), - out.str().c_str(), - true, - yg::Color(255, 255, 255, 255), - yg::maxDepth, - true, - false); + yg::FontDesc::defaultFont, + m2::PointD(m_displayRect.minX() + 10, m_displayRect.minY() + m_yOffset), + yg::EPosAboveRight, + 0, + out.str().c_str(), + yg::maxDepth, + false); } void InformationDisplay::enableDebugInfo(bool doEnable) @@ -403,15 +393,12 @@ void InformationDisplay::drawDebugInfo(DrawerYG * drawer) m2::PointD pos = m2::PointD(m_displayRect.minX() + 10, m_displayRect.minY() + m_yOffset); - drawer->screen()->drawText(pos, + drawer->screen()->drawText(yg::FontDesc::defaultFont, + pos, yg::EPosAboveRight, - 0, 10, - yg::Color(0, 0, 0, 0), + 0, out.str().c_str(), - true, - yg::Color(255, 255, 255, 255), yg::maxDepth, - true, false); } @@ -434,15 +421,12 @@ void InformationDisplay::drawMemoryWarning(DrawerYG * drawer) ostringstream out; out << "MemoryWarning : " << m_lastMemoryWarning.ElapsedSeconds() << " sec. ago."; - drawer->screen()->drawText(pos, + drawer->screen()->drawText(yg::FontDesc::defaultFont, + pos, yg::EPosAboveRight, - 0, 10, - yg::Color(0, 0, 0, 0), + 0, out.str().c_str(), - true, - yg::Color(255, 255, 255, 255), yg::maxDepth, - true, false); if (m_lastMemoryWarning.ElapsedSeconds() > 5) @@ -508,12 +492,10 @@ void InformationDisplay::drawLog(DrawerYG * pDrawer) m2::PointD startPt(m_displayRect.minX() + 10, m_displayRect.minY() + m_yOffset); m2::RectD textRect = pDrawer->screen()->textRect( - it->c_str(), - 10, - true, - true, - false - ); + yg::FontDesc::defaultFont, + it->c_str(), + false + ); pDrawer->screen()->drawRectangle( m2::Inflate(m2::Offset(textRect, startPt), m2::PointD(2, 2)), @@ -522,17 +504,14 @@ void InformationDisplay::drawLog(DrawerYG * pDrawer) ); pDrawer->screen()->drawText( - startPt, - yg::EPosAboveRight, - 0, 10, - yg::Color(0, 0, 0, 255), - it->c_str(), - true, - yg::Color(255, 255, 255, 255), - yg::maxDepth, - true, - false - ); + yg::FontDesc::defaultFont, + startPt, + yg::EPosAboveRight, + 0, + it->c_str(), + yg::maxDepth, + false + ); } } @@ -551,37 +530,41 @@ void InformationDisplay::drawEmptyModelMessage(DrawerYG * pDrawer) char const s2 [] = "Just click the button at the bottom"; char const s3 [] = "right corner to download the maps."; - m2::RectD tr0 = pDrawer->screen()->textRect(s0, 10, true, true, false); - m2::RectD tr1 = pDrawer->screen()->textRect(s1, 10, true, true, false); - m2::RectD tr2 = pDrawer->screen()->textRect(s2, 10, true, true, false); - m2::RectD tr3 = pDrawer->screen()->textRect(s3, 10, true, true, false); + m2::RectD tr0 = pDrawer->screen()->textRect(yg::FontDesc::defaultFont, s0, false); + m2::RectD tr1 = pDrawer->screen()->textRect(yg::FontDesc::defaultFont, s1, false); + m2::RectD tr2 = pDrawer->screen()->textRect(yg::FontDesc::defaultFont, s2, false); + m2::RectD tr3 = pDrawer->screen()->textRect(yg::FontDesc::defaultFont, s3, false); - pDrawer->screen()->drawText(m2::PointD(0, -(tr1.SizeY() + 5)) + pt, + pDrawer->screen()->drawText(yg::FontDesc::defaultFont, + m2::PointD(0, -(tr1.SizeY() + 5)) + pt, yg::EPosCenter, - 0, 10, yg::Color(255, 255, 255, 255), s0, true, yg::Color(255, 255, 255, 255), + 0, + s0, yg::maxDepth, - true, false); - pDrawer->screen()->drawText(m2::PointD(0, 0) + pt, + pDrawer->screen()->drawText(yg::FontDesc::defaultFont, + m2::PointD(0, 0) + pt, yg::EPosCenter, - 0, 10, yg::Color(255, 255, 255, 255), s1, true, yg::Color(255, 255, 255, 255), + 0, + s1, yg::maxDepth, - true, false); - pDrawer->screen()->drawText(m2::PointD(0, tr2.SizeY() + 5) + pt, + pDrawer->screen()->drawText(yg::FontDesc::defaultFont, + m2::PointD(0, tr2.SizeY() + 5) + pt, yg::EPosCenter, - 0, 10, yg::Color(255, 255, 255, 255), s2, true, yg::Color(255, 255, 255, 255), + 0, + s2, yg::maxDepth, - true, false); - pDrawer->screen()->drawText(m2::PointD(0, tr2.SizeY() + 5 + tr3.SizeY() + 5) + pt, + pDrawer->screen()->drawText(yg::FontDesc::defaultFont, + m2::PointD(0, tr2.SizeY() + 5 + tr3.SizeY() + 5) + pt, yg::EPosCenter, - 0, 10, yg::Color(255, 255, 255, 255), s3, true, yg::Color(255, 255, 255, 255), + 0, + s3, yg::maxDepth, - true, false); } #endif @@ -626,15 +609,12 @@ void InformationDisplay::drawBenchmarkInfo(DrawerYG * pDrawer) { m_yOffset += 20; m2::PointD pos(m_displayRect.minX() + 10, m_displayRect.minY() + m_yOffset); - pDrawer->screen()->drawText(pos, + pDrawer->screen()->drawText(yg::FontDesc::defaultFont, + pos, yg::EPosAboveRight, - 0, 10, - yg::Color(0, 0, 0, 0), + 0, "benchmark info :", - true, - yg::Color(255, 255, 255, 255), yg::maxDepth, - true, false); for (unsigned i = 0; i < m_benchmarkInfo.size(); ++i) @@ -649,15 +629,12 @@ void InformationDisplay::drawBenchmarkInfo(DrawerYG * pDrawer) << "), duration : " << m_benchmarkInfo[i].m_duration; m_yOffset += 20; pos.y += 20; - pDrawer->screen()->drawText(pos, + pDrawer->screen()->drawText(yg::FontDesc::defaultFont, + pos, yg::EPosAboveRight, - 0, 10, - yg::Color(0, 0, 0, 0), + 0, out.str().c_str(), - true, - yg::Color(255, 255, 255, 255), yg::maxDepth, - true, false ); } diff --git a/yg/color.cpp b/yg/color.cpp index dd2f7564f1..5b2703ffe7 100644 --- a/yg/color.cpp +++ b/yg/color.cpp @@ -68,6 +68,15 @@ namespace yg return false; } + bool operator > (Color const & l, Color const & r) + { + if (l.r != r.r) return l.r > r.r; + if (l.g != r.g) return l.g > r.g; + if (l.b != r.b) return l.b > r.b; + if (l.a != r.a) return l.a > r.a; + return false; + } + bool operator != (Color const & l, Color const & r) { return (l.r != r.r) || (l.g != r.g) || (l.b != r.b) || (l.a != r.a); diff --git a/yg/color.hpp b/yg/color.hpp index fe8cdef071..a66a918903 100644 --- a/yg/color.hpp +++ b/yg/color.hpp @@ -23,6 +23,7 @@ namespace yg }; bool operator < (Color const & l, Color const & r); + bool operator > (Color const & l, Color const & r); bool operator !=(Color const & l, Color const & r); bool operator ==(Color const & l, Color const & r); diff --git a/yg/defines.hpp b/yg/defines.hpp index 7776ac3e9b..3b3b1337a1 100644 --- a/yg/defines.hpp +++ b/yg/defines.hpp @@ -3,4 +3,17 @@ namespace yg { static const int maxDepth = 12000; + + enum EPosition + { + EPosCenter = 0x00, + EPosAbove = 0x01, + EPosUnder = 0x02, + EPosLeft = 0x04, + EPosRight = 0x10, + EPosAboveLeft = EPosAbove | EPosLeft, + EPosAboveRight = EPosAbove | EPosRight, + EPosUnderLeft = EPosUnder | EPosLeft, + EPosUnderRight = EPosUnder | EPosRight + }; } diff --git a/yg/font_desc.cpp b/yg/font_desc.cpp new file mode 100644 index 0000000000..346f55c741 --- /dev/null +++ b/yg/font_desc.cpp @@ -0,0 +1,57 @@ +#include "../base/SRC_FIRST.hpp" +#include "font_desc.hpp" + +namespace yg +{ + FontDesc const & FontDesc::defaultFont = FontDesc(); + + FontDesc::FontDesc(bool isStatic, int size, yg::Color const & color, + bool isMasked, yg::Color const & maskColor) + : m_isStatic(isStatic), m_size(size), m_color(color), + m_isMasked(isMasked), m_maskColor(maskColor) + {} + + bool FontDesc::operator ==(FontDesc const & src) const + { + return (m_isStatic == src.m_isStatic) + && (m_size == src.m_size) + && (m_color == src.m_color) + && (m_isMasked == src.m_isMasked) + && (m_maskColor == src.m_maskColor); + } + + bool FontDesc::operator !=(FontDesc const & src) const + { + return !(*this == src); + } + + bool FontDesc::operator < (FontDesc const & src) const + { + if (m_isStatic != src.m_isStatic) + return m_isStatic < src.m_isStatic; + if (m_size != src.m_size) + return m_size < src.m_size; + if (m_color != src.m_color) + return m_color < src.m_color; + if (m_isMasked != src.m_isMasked) + return m_isMasked < src.m_isMasked; + if (m_maskColor != src.m_maskColor) + return m_maskColor < src.m_maskColor; + return false; + } + + bool FontDesc::operator > (FontDesc const & src) const + { + if (m_isStatic != src.m_isStatic) + return m_isStatic > src.m_isStatic; + if (m_size != src.m_size) + return m_size > src.m_size; + if (m_color != src.m_color) + return m_color > src.m_color; + if (m_isMasked != src.m_isMasked) + return m_isMasked > src.m_isMasked; + if (m_maskColor != src.m_maskColor) + return m_maskColor > src.m_maskColor; + return false; + } +} diff --git a/yg/font_desc.hpp b/yg/font_desc.hpp new file mode 100644 index 0000000000..ab67c3786d --- /dev/null +++ b/yg/font_desc.hpp @@ -0,0 +1,25 @@ +#pragma once + +#include "color.hpp" + +namespace yg +{ + struct FontDesc + { + bool m_isStatic; + int m_size; + yg::Color m_color; + bool m_isMasked; + yg::Color m_maskColor; + + FontDesc(bool isStatic = true, int size = 10, yg::Color const & color = yg::Color(0, 0, 0, 255), + bool isMasked = true, yg::Color const & maskColor = yg::Color(255, 255, 255, 255)); + + bool operator != (FontDesc const & src) const; + bool operator == (FontDesc const & src) const; + bool operator < (FontDesc const & src) const; + bool operator > (FontDesc const & src) const; + + static FontDesc const & defaultFont; + }; +} diff --git a/yg/geometry_batcher.hpp b/yg/geometry_batcher.hpp index 35c12dc1d5..0efe2e2f20 100644 --- a/yg/geometry_batcher.hpp +++ b/yg/geometry_batcher.hpp @@ -27,19 +27,6 @@ namespace yg class Skin; struct CharStyle; - enum EPosition - { - EPosCenter = 0x00, - EPosAbove = 0x01, - EPosUnder = 0x02, - EPosLeft = 0x04, - EPosRight = 0x10, - EPosAboveLeft = EPosAbove | EPosLeft, - EPosAboveRight = EPosAbove | EPosRight, - EPosUnderLeft = EPosUnder | EPosLeft, - EPosUnderRight = EPosUnder | EPosRight - }; - namespace gl { class GeometryBatcher : public RenderStateUpdater diff --git a/yg/layout_element.cpp b/yg/layout_element.cpp new file mode 100644 index 0000000000..4a5ae3dfc4 --- /dev/null +++ b/yg/layout_element.cpp @@ -0,0 +1,56 @@ +#include "../base/SRC_FIRST.hpp" + +#include "layout_element.hpp" +#include "screen.hpp" + +namespace yg +{ + LayoutElement::LayoutElement(int groupID, m2::PointD const & pivot, EPosition pos) + : m_groupID(groupID), m_pivot(pivot), m_pos(pos) + {} + + int LayoutElement::groupID() const + { + return m_groupID; + } + + m2::PointD const & LayoutElement::pivot() const + { + return m_pivot; + } + + EPosition LayoutElement::position() const + { + return m_pos; + } + + bool LayoutElement::isFreeElement() const + { + return m_isFreeElement; + } + + void LayoutElement::setIsFreeElement(bool flag) const + { + m_isFreeElement = flag; + } + + bool LayoutElement::isFrozen() const + { + return m_isFrozen; + } + + void LayoutElement::setIsFrozen(bool flag) const + { + m_isFrozen = flag; + } + + bool LayoutElement::doNeedRedraw() const + { + return m_doNeedRedraw; + } + + void LayoutElement::setNeedRedraw(bool flag) const + { + m_doNeedRedraw = flag; + } +} diff --git a/yg/layout_element.hpp b/yg/layout_element.hpp new file mode 100644 index 0000000000..6259e84ce2 --- /dev/null +++ b/yg/layout_element.hpp @@ -0,0 +1,69 @@ +#pragma once + +#include "../geometry/point2d.hpp" +#include "../geometry/rect2d.hpp" +#include "defines.hpp" + +namespace yg +{ + class Screen; + struct FontDesc; + + class LayoutElement + { + private: + + int m_groupID; + m2::PointD m_pivot; + EPosition m_pos; + + mutable bool m_isFreeElement; + mutable bool m_isFrozen; + mutable bool m_doNeedRedraw; + + public: + LayoutElement(int groupID, m2::PointD const & pivot, EPosition pos); + /// id of the group, composed of several layoutElements + int groupID() const; + /// pivot is expressed in group coordinates + m2::PointD const & pivot() const; + /// position of the element related to pivot point + EPosition position() const; + + bool isFreeElement() const; + void setIsFreeElement(bool flag) const; + + bool isFrozen() const; + void setIsFrozen(bool flag) const; + + bool doNeedRedraw() const; + void setNeedRedraw(bool flag) const; + + /// bounding rect in pivot-aligned coordinates + virtual m2::RectD const boundRect() const = 0; + /// draw layout element + virtual void draw(Screen * screen) = 0; + }; + + class TextLayoutElement : public LayoutElement + { + public: + + TextLayoutElement(char const * text, double depth, FontDesc const & fontDesc); + + m2::RectD const boundRect() const; + + void draw(Screen * screen); + }; + + class SymbolLayoutElement : public LayoutElement + { + public: + + SymbolLayoutElement(); + + m2::RectD const boundRect() const; + + void draw(Screen * screen); + }; +} diff --git a/yg/text_renderer.cpp b/yg/text_renderer.cpp index b4d9940df0..2fface166a 100644 --- a/yg/text_renderer.cpp +++ b/yg/text_renderer.cpp @@ -23,6 +23,7 @@ namespace yg { namespace gl { + TextRenderer::Params::Params() : m_textTreeAutoClean(true), m_useTextTree(false), @@ -39,8 +40,8 @@ namespace yg m_doPeriodicalTextUpdate(params.m_doPeriodicalTextUpdate) {} - TextRenderer::TextObj::TextObj(m2::PointD const & pt, yg::EPosition pos, string const & txt, uint8_t sz, yg::Color const & c, bool isMasked, yg::Color const & maskColor, double d, bool isFixedFont, bool log2vis) - : m_pt(pt), m_pos(pos), m_size(sz), m_utf8Text(txt), m_isMasked(isMasked), m_depth(d), m_needRedraw(true), m_frozen(false), m_isFixedFont(isFixedFont), m_log2vis(log2vis), m_color(c), m_maskColor(maskColor) + TextRenderer::TextObj::TextObj(FontDesc const & fontDesc, m2::PointD const & pt, yg::EPosition pos, string const & txt, double d, bool log2vis) + : m_fontDesc(fontDesc), m_pt(pt), m_pos(pos), m_utf8Text(txt), m_depth(d), m_needRedraw(true), m_frozen(false), m_log2vis(log2vis) { } @@ -50,14 +51,14 @@ namespace yg /// lies inside the testing rect and therefore should be skipped. if (m_needRedraw) { - pTextRenderer->drawTextImpl(m_pt, m_pos, 0.0, m_size, m_color, m_utf8Text, true, m_maskColor, yg::maxDepth, m_isFixedFont, m_log2vis); + pTextRenderer->drawTextImpl(m_fontDesc, m_pt, m_pos, 0.0, m_utf8Text, yg::maxDepth, m_log2vis); m_frozen = true; } } m2::RectD const TextRenderer::TextObj::GetLimitRect(TextRenderer* pTextRenderer) const { - m2::RectD limitRect = pTextRenderer->textRect(m_utf8Text, m_size, m_isMasked, false, m_log2vis); + m2::RectD limitRect = pTextRenderer->textRect(m_fontDesc, m_utf8Text, m_log2vis); double dx = -limitRect.SizeX() / 2; double dy = limitRect.SizeY() / 2; @@ -111,32 +112,28 @@ namespace yg // because frozen texts shouldn't be popped out by newly arrived texts. if (r2.m_frozen) return false; - if (r1.m_size != r2.m_size) - return r1.m_size > r2.m_size; + if (r1.m_fontDesc != r2.m_fontDesc) + return r1.m_fontDesc > r2.m_fontDesc; return (r1.m_depth > r2.m_depth); } - void TextRenderer::drawText(m2::PointD const & pt, + void TextRenderer::drawText(FontDesc const & fontDesc, + m2::PointD const & pt, yg::EPosition pos, float angle, - uint8_t fontSize, - yg::Color const & color, string const & utf8Text, - bool isMasked, - yg::Color const & maskColor, double depth, - bool isFixedFont, bool log2vis) { if (!m_drawTexts) return; - if (!m_useTextTree || isFixedFont) - drawTextImpl(pt, pos, angle, fontSize, color, utf8Text, true, maskColor, depth, isFixedFont, log2vis); + if (!m_useTextTree || fontDesc.m_isStatic) + drawTextImpl(fontDesc, pt, pos, angle, utf8Text, depth, log2vis); else { checkTextRedraw(); - TextObj obj(pt, pos, utf8Text, fontSize, color, isMasked, maskColor, depth, isFixedFont, log2vis); + TextObj obj(fontDesc, pt, pos, utf8Text, depth, log2vis); m2::RectD r = obj.GetLimitRect(this); m_tree.ReplaceIf(obj, r, &TextObj::better_text); } @@ -225,12 +222,12 @@ namespace yg } template - void TextRenderer::ForEachGlyph(uint8_t fontSize, yg::Color const & color, wstring const & text, bool isMasked, bool isFixedFont, ToDo toDo) + void TextRenderer::ForEachGlyph(FontDesc const & fontDesc, wstring const & text, ToDo toDo) { m2::PointD currPt(0, 0); for (size_t i = 0; i < text.size(); ++i) { - uint32_t glyphID = skin()->mapGlyph(GlyphKey(text[i], fontSize, isMasked, color), isFixedFont); + uint32_t glyphID = skin()->mapGlyph(GlyphKey(text[i], fontDesc.m_size, fontDesc.m_isMasked, fontDesc.m_isMasked ? fontDesc.m_maskColor : fontDesc.m_color), fontDesc.m_isStatic); CharStyle const * p = static_cast(skin()->fromID(glyphID)); if (p) { @@ -250,14 +247,14 @@ namespace yg return res; } - void TextRenderer::drawTextImpl(m2::PointD const & pt, yg::EPosition pos, float angle, uint8_t fontSize, yg::Color const & color, string const & utf8Text, bool isMasked, yg::Color const & maskColor, double depth, bool isFixedFont, bool log2vis) + void TextRenderer::drawTextImpl(FontDesc const & fontDesc, m2::PointD const & pt, yg::EPosition pos, float angle, string const & utf8Text, double depth, bool log2vis) { wstring text = FromUtf8(utf8Text); if (log2vis) text = Log2Vis(text); - m2::RectD r = textRect(utf8Text, fontSize, isMasked, isFixedFont, log2vis); + m2::RectD r = textRect(fontDesc, utf8Text, log2vis); m2::PointD orgPt(pt.x - r.SizeX() / 2, pt.y + r.SizeY() / 2); @@ -276,12 +273,18 @@ namespace yg orgPt.x = ::floor(orgPt.x); orgPt.y = ::floor(orgPt.y); - if (isMasked) - ForEachGlyph(fontSize, maskColor, text, true, isFixedFont, bind(&TextRenderer::drawGlyph, this, cref(orgPt), _1, angle, 0, _2, depth)); - ForEachGlyph(fontSize, color, text, false, isFixedFont, bind(&TextRenderer::drawGlyph, this, cref(orgPt), _1, angle, 0, _2, depth)); + yg::FontDesc desc = fontDesc; + + if (desc.m_isMasked) + { + ForEachGlyph(desc, text, bind(&TextRenderer::drawGlyph, this, cref(orgPt), _1, angle, 0, _2, depth)); + desc.m_isMasked = false; + } + + ForEachGlyph(desc, text, bind(&TextRenderer::drawGlyph, this, cref(orgPt), _1, angle, 0, _2, depth)); } - m2::RectD const TextRenderer::textRect(string const & utf8Text, uint8_t fontSize, bool isMasked, bool fixedFont, bool log2vis) + m2::RectD const TextRenderer::textRect(FontDesc const & fontDesc, string const & utf8Text, bool log2vis) { if (m_useTextTree) checkTextRedraw(); @@ -295,9 +298,9 @@ namespace yg for (size_t i = 0; i < text.size(); ++i) { - if (fixedFont) + if (fontDesc.m_isStatic) { - uint32_t glyphID = skin()->mapGlyph(GlyphKey(text[i], fontSize, isMasked, yg::Color(0, 0, 0, 0)), fixedFont); + uint32_t glyphID = skin()->mapGlyph(GlyphKey(text[i], fontDesc.m_size, fontDesc.m_isMasked, yg::Color(0, 0, 0, 0)), fontDesc.m_isStatic); CharStyle const * p = static_cast(skin()->fromID(glyphID)); if (p != 0) { @@ -308,7 +311,7 @@ namespace yg } else { - GlyphMetrics const m = resourceManager()->getGlyphMetrics(GlyphKey(text[i], fontSize, isMasked, yg::Color(0, 0, 0, 0))); + GlyphMetrics const m = resourceManager()->getGlyphMetrics(GlyphKey(text[i], fontDesc.m_size, fontDesc.m_isMasked, yg::Color(0, 0, 0, 0))); rect.Add(pt); rect.Add(pt + m2::PointD(m.m_xOffset + m.m_width, - m.m_yOffset - m.m_height)); @@ -393,23 +396,29 @@ namespace yg } bool TextRenderer::drawPathText( - m2::PointD const * path, size_t s, uint8_t fontSize, yg::Color const & color, string const & utf8Text, - double fullLength, double pathOffset, TextPos pos, bool isMasked, yg::Color const & maskColor, double depth, bool isFixedFont) + FontDesc const & fontDesc, m2::PointD const * path, size_t s, string const & utf8Text, + double fullLength, double pathOffset, TextPos pos, double depth) { if (!m_drawTexts) return false; if (m_useTextTree) checkTextRedraw(); - if (isMasked) - if (!drawPathTextImpl(path, s, fontSize, maskColor, utf8Text, fullLength, pathOffset, pos, true, depth, isFixedFont)) + yg::FontDesc desc = fontDesc; + + if (desc.m_isMasked) + { + if (!drawPathTextImpl(desc, path, s, utf8Text, fullLength, pathOffset, pos, depth)) return false; - return drawPathTextImpl(path, s, fontSize, color, utf8Text, fullLength, pathOffset, pos, false, depth, isFixedFont); + else + desc.m_isMasked = false; + } + return drawPathTextImpl(desc, path, s, utf8Text, fullLength, pathOffset, pos, depth); } bool TextRenderer::drawPathTextImpl( - m2::PointD const * path, size_t s, uint8_t fontSize, yg::Color const & color, string const & utf8Text, - double fullLength, double pathOffset, TextPos pos, bool isMasked, double depth, bool isFixedFont) + FontDesc const & fontDesc, m2::PointD const * path, size_t s, string const & utf8Text, + double fullLength, double pathOffset, TextPos pos, double depth) { pts_array arrPath(path, s, fullLength, pathOffset); @@ -419,8 +428,8 @@ namespace yg float blOffset = 2; switch (pos) { - case under_line: blOffset -= fontSize; break; - case middle_line: blOffset -= fontSize / 2; break; + case under_line: blOffset -= fontDesc.m_size; break; + case middle_line: blOffset -= fontDesc.m_size / 2; break; case above_line: blOffset -= 0; break; } @@ -432,7 +441,7 @@ namespace yg double strLength = 0.0; for (size_t i = 0; i < count; ++i) { - glyphs[i] = resourceManager()->getGlyphMetrics(GlyphKey(text[i], fontSize, isMasked, yg::Color(0, 0, 0, 0))); + glyphs[i] = resourceManager()->getGlyphMetrics(GlyphKey(text[i], fontDesc.m_size, fontDesc.m_isMasked, yg::Color(0, 0, 0, 0))); strLength += glyphs[i].m_xAdvance; } @@ -457,7 +466,7 @@ namespace yg if (!CalcPointAndAngle(arrPath, offset, ind, ptOrg, angle)) break; - uint32_t const glyphID = skin()->mapGlyph(GlyphKey(text[i], fontSize, isMasked, color), isFixedFont); + uint32_t const glyphID = skin()->mapGlyph(GlyphKey(text[i], fontDesc.m_size, fontDesc.m_isMasked, fontDesc.m_isMasked ? fontDesc.m_maskColor : fontDesc.m_color), fontDesc.m_isStatic); CharStyle const * charStyle = static_cast(skin()->fromID(glyphID)); drawGlyph(ptOrg, m2::PointD(0.0, 0.0), angle, blOffset, charStyle, depth); diff --git a/yg/text_renderer.hpp b/yg/text_renderer.hpp index f990a3a5b5..1114f4aa53 100644 --- a/yg/text_renderer.hpp +++ b/yg/text_renderer.hpp @@ -1,11 +1,14 @@ #pragma once #include "path_renderer.hpp" +#include "defines.hpp" +#include "font_desc.hpp" #include "../geometry/tree4d.hpp" #include "../std/shared_ptr.hpp" + namespace yg { class ResourceManager; @@ -19,24 +22,26 @@ namespace yg enum TextPos { under_line, middle_line, above_line }; + class TextObj { + FontDesc m_fontDesc; m2::PointD m_pt; yg::EPosition m_pos; - uint8_t m_size; string m_utf8Text; - bool m_isMasked; double m_depth; mutable bool m_needRedraw; mutable bool m_frozen; - bool m_isFixedFont; bool m_log2vis; - yg::Color m_color; - yg::Color m_maskColor; public: - TextObj(m2::PointD const & pt, yg::EPosition pos, string const & txt, uint8_t sz, yg::Color const & c, bool isMasked, yg::Color const & maskColor, double d, bool isFixedFont, bool log2vis); + TextObj(FontDesc const & fontDesc, + m2::PointD const & pt, + yg::EPosition pos, + string const & txt, + double depth, + bool log2vis); void Draw(TextRenderer * pTextRenderer) const; m2::RectD const GetLimitRect(TextRenderer * pTextRenderer) const; void SetNeedRedraw(bool needRedraw) const; @@ -58,7 +63,7 @@ namespace yg static wstring Log2Vis(wstring const & str); template - void ForEachGlyph(uint8_t fontSize, yg::Color const & color, wstring const & text, bool isMask, bool isFixedFont, ToDo toDo); + void ForEachGlyph(FontDesc const & fontDesc, wstring const & text, ToDo toDo); void drawGlyph(m2::PointD const & ptOrg, m2::PointD const & ptGlyph, @@ -68,29 +73,22 @@ namespace yg double depth); - bool drawPathTextImpl(m2::PointD const * path, - size_t s, - uint8_t fontSize, - yg::Color const & color, - string const & utf8Text, - double fullLength, - double pathOffset, - TextPos pos, - bool isMasked, - double depth, - bool isFixedFont); + bool drawPathTextImpl(FontDesc const & fontDesc, + m2::PointD const * path, + size_t s, + string const & utf8Text, + double fullLength, + double pathOffset, + TextPos pos, + double depth); /// Drawing text from point rotated by the angle. - void drawTextImpl(m2::PointD const & pt, + void drawTextImpl(FontDesc const & fontDesc, + m2::PointD const & pt, yg::EPosition pos, float angle, - uint8_t fontSize, - yg::Color const & color, string const & utf8Text, - bool isMasked, - yg::Color const & maskColor, double depth, - bool fixedFont, bool log2vis); bool m_textTreeAutoClean; @@ -114,37 +112,27 @@ namespace yg TextRenderer(Params const & params); /// Drawing text from point rotated by the angle. - void drawText(m2::PointD const & pt, + void drawText(FontDesc const & fontDesc, + m2::PointD const & pt, yg::EPosition pos, float angle, - uint8_t fontSize, - yg::Color const & color, string const & utf8Text, - bool isMasked, - yg::Color const & maskColor, double depth, - bool fixedFont, bool log2vis); - m2::RectD const textRect(string const & utf8Text, - uint8_t fontSize, - bool isMasked, - bool fixedFont, + m2::RectD const textRect(FontDesc const & fontDesc, + string const & utf8Text, bool log2vis); /// Drawing text in the middle of the path. - bool drawPathText(m2::PointD const * path, + bool drawPathText(FontDesc const & fontDesc, + m2::PointD const * path, size_t s, - uint8_t fontSize, - yg::Color const & color, string const & utf8Text, double fullLength, double pathOffset, TextPos pos, - bool isMasked, - yg::Color const & maskColor, - double depth, - bool isFixedFont = false); + double depth); void setClipRect(m2::RectI const & rect); diff --git a/yg/yg.pro b/yg/yg.pro index 74c08c8f69..e44b84a3e1 100644 --- a/yg/yg.pro +++ b/yg/yg.pro @@ -55,7 +55,9 @@ SOURCES += \ shape_renderer.cpp \ symbol_renderer.cpp \ circle_info.cpp \ - area_renderer.cpp + area_renderer.cpp \ + layout_element.cpp \ + font_desc.cpp HEADERS += \ internal/opengl.hpp \ @@ -104,7 +106,9 @@ HEADERS += \ shape_renderer.hpp \ symbol_renderer.hpp \ circle_info.hpp \ - area_renderer.hpp + area_renderer.hpp \ + layout_element.hpp \ + font_desc.hpp !iphone*:!bada-simulator { HEADERS += internal/opengl_win32.hpp diff --git a/yg/yg_tests/screengl_test.cpp b/yg/yg_tests/screengl_test.cpp index 4e9b2dc517..43d84651ee 100644 --- a/yg/yg_tests/screengl_test.cpp +++ b/yg/yg_tests/screengl_test.cpp @@ -520,12 +520,14 @@ namespace double pat[2] = {2, 2}; p->drawPath(path, sizeof(path) / sizeof(m2::PointD), p->skin()->mapPenInfo(yg::PenInfo(yg::Color(0, 0, 0, 0xFF), 2, pat, 2, 0)), 0); - p->drawText(m2::PointD(200, 200), yg::EPosAboveRight, 0 , 20, yg::Color(0, 0, 0, 0), "0", true, yg::Color(255, 255, 255, 255), 0, false, true); - p->drawText(m2::PointD(240, 200), yg::EPosAboveRight, math::pi / 2 , 20, yg::Color(0, 0, 0, 0), "0", true, yg::Color(255, 255, 255, 255), 0, false, true); - p->drawText(m2::PointD(280, 200), yg::EPosAboveRight, math::pi , 20, yg::Color(0, 0, 0, 0), "0", true, yg::Color(255, 255, 255, 255), 0, false, true); - p->drawText(m2::PointD(320, 200), yg::EPosAboveRight, math::pi * 3 / 2 , 20, yg::Color(0, 0, 0, 0), "0", true, yg::Color(255, 255, 255, 255), 0, false, true); - p->drawText(m2::PointD(360, 200), yg::EPosAboveRight, math::pi / 18, 20, yg::Color(0, 0, 0, 0), "0", true, yg::Color(255, 255, 255, 255), 0, false, true); - p->drawText(m2::PointD(40, 50), yg::EPosAboveRight, math::pi / 18, 20, yg::Color(0, 0, 0, 0), "Simplicity is the ultimate sophistication", true, yg::Color(255, 255, 255, 255), 0, false, true); + yg::FontDesc fontDesc(false, 20, yg::Color(0, 0, 0, 0), true, yg::Color(255, 255, 255, 255)); + + p->drawText(fontDesc, m2::PointD(200, 200), yg::EPosAboveRight, 0 , "0", 0, true); + p->drawText(fontDesc, m2::PointD(240, 200), yg::EPosAboveRight, math::pi / 2 , "0", 0, true); + p->drawText(fontDesc, m2::PointD(280, 200), yg::EPosAboveRight, math::pi , "0", 0, true); + p->drawText(fontDesc, m2::PointD(320, 200), yg::EPosAboveRight, math::pi * 3 / 2 , "0", 0, true); + p->drawText(fontDesc, m2::PointD(360, 200), yg::EPosAboveRight, math::pi / 18, "0", 0, true); + p->drawText(fontDesc, m2::PointD(40, 50), yg::EPosAboveRight, math::pi / 18, "Simplicity is the ultimate sophistication", 0, true); } }; @@ -533,7 +535,8 @@ namespace { void DoDraw(shared_ptr p) { - p->drawText(m2::PointD(40, 50), yg::EPosAboveRight, 0, 20, yg::Color(0, 0, 0, 0), "X", true, yg::Color(255, 255, 255, 255), 1, false, true); + yg::FontDesc fontDesc(false, 20, yg::Color(0, 0, 0, 0), true, yg::Color(255, 255, 255, 255)); + p->drawText(fontDesc, m2::PointD(40, 50), yg::EPosAboveRight, 0, "X", 1, true); } }; @@ -541,7 +544,8 @@ namespace { void DoDraw(shared_ptr p) { - p->drawText(m2::PointD(40, 50), yg::EPosAboveRight, 0, 20, yg::Color(0, 0, 0, 0), " ", true, yg::Color(255, 255, 255, 255), 1, false, true); + yg::FontDesc fontDesc(false, 20, yg::Color(0, 0, 0, 0), true, yg::Color(255, 255, 255, 255)); + p->drawText(fontDesc, m2::PointD(40, 50), yg::EPosAboveRight, 0, " ", 1, true); } }; @@ -552,9 +556,11 @@ namespace size_t const maxTimes = 10; size_t const yStep = 30; + yg::FontDesc fontDesc(false, 20, yg::Color(0, 0, 0, 0), true, yg::Color(255, 255, 255, 255)); + for (size_t i = 0; i < maxTimes; ++i) for (size_t j = 1; j <= i+1; ++j) - p->drawText(m2::PointD(40, 10 + yStep * i), yg::EPosAboveRight, math::pi / 6, 20, yg::Color(0, 0, 0, 0), "Simplicity is the ultimate sophistication", true, yg::Color(255, 255, 255, 255), 0, false, true); + p->drawText(fontDesc, m2::PointD(40, 10 + yStep * i), yg::EPosAboveRight, math::pi / 6, "Simplicity is the ultimate sophistication", 0, true); } }; @@ -570,7 +576,9 @@ namespace yg::PenInfo penInfo = yg::PenInfo(yg::Color(0, 0, 0, 0xFF), 2, &pat[0], ARRAY_SIZE(pat), 0); yg::PenInfo solidPenInfo = yg::PenInfo(yg::Color(0xFF, 0, 0, 0xFF), 4, 0, 0, 0); - p->drawText(m2::PointD(40, 50), yg::EPosAboveRight, 0, 20, yg::Color(0, 0, 0, 0), "S", true, yg::Color(255, 255, 255, 255), 0, false, true); + yg::FontDesc fontDesc(false, 20, yg::Color(0, 0, 0, 0), true, yg::Color(255, 255, 255, 255)); + + p->drawText(fontDesc, m2::PointD(40, 50), yg::EPosAboveRight, 0, "S", 0, true); p->drawPath(&path[0], path.size(), p->skin()->mapPenInfo(solidPenInfo), 0); } @@ -580,7 +588,8 @@ namespace { void DoDraw(shared_ptr p) { - p->drawText(m2::PointD(40, 50), yg::EPosAboveRight, 0/*, math::pi / 18*/, 20, yg::Color(0, 0, 0, 0), "Simplicity is the ultimate sophistication", true, yg::Color(255, 255, 255, 255), 0, false, true); + yg::FontDesc fontDesc(false, 20, yg::Color(0, 0, 0, 0), true, yg::Color(255, 255, 255, 255)); + p->drawText(fontDesc, m2::PointD(40, 50), yg::EPosAboveRight, 0/*, math::pi / 18*/, "Simplicity is the ultimate sophistication", 0, true); } }; @@ -588,7 +597,7 @@ namespace { void DoDraw(shared_ptr p) { - p->drawText(m2::PointD(40, 50), yg::EPosAboveRight, 0/*, math::pi / 18*/, 12, yg::Color(0, 0, 0, 0), "Simplicity is the ultimate sophistication", true, yg::Color(255, 255, 255, 255), 0, true, true); + p->drawText(yg::FontDesc::defaultFont, m2::PointD(40, 50), yg::EPosAboveRight, 0/*, math::pi / 18*/, "Simplicity is the ultimate sophistication", 0, true); } }; @@ -596,7 +605,8 @@ namespace { void DoDraw(shared_ptr p) { - p->drawText(m2::PointD(40, 50), yg::EPosAboveRight, 0/*, math::pi / 18*/, 25, yg::Color(0, 0, 255, 255), "Simplicity is the ultimate sophistication", true, yg::Color(255, 255, 255, 255), 0, false, true); + yg::FontDesc fontDesc(false, 25, yg::Color(0, 0, 255, 255), true, yg::Color(255, 255, 255, 255)); + p->drawText(fontDesc, m2::PointD(40, 50), yg::EPosAboveRight, 0/*, math::pi / 18*/, "Simplicity is the ultimate sophistication", 0, true); } }; @@ -605,8 +615,9 @@ namespace { void DoDraw(shared_ptr p) { - p->drawText(m2::PointD(40, 50), yg::EPosAboveRight, 0, 12, yg::Color(0, 0, 0, 0), "Latin Symbol : A", true, yg::Color(255, 255, 255, 255), 0, false, true); - p->drawText(m2::PointD(40, 80), yg::EPosAboveRight, 0, 12, yg::Color(0, 0, 0, 0), "Cyrillic Symbol : Ы", true, yg::Color(255, 255, 255, 255), 0, false, true); + yg::FontDesc fontDesc(false, 12); + p->drawText(fontDesc, m2::PointD(40, 50), yg::EPosAboveRight, 0, "Latin Symbol : A", 0, true); + p->drawText(fontDesc, m2::PointD(40, 80), yg::EPosAboveRight, 0, "Cyrillic Symbol : Ы", 0, true); } }; @@ -615,7 +626,7 @@ namespace typedef TestDrawStringWithFixedFont base_t; void DoDraw(shared_ptr p) { - m2::RectD r = p->textRect("Simplicity is the ultimate sophistication", 12, true, true, false); + m2::RectD r = p->textRect(yg::FontDesc::defaultFont, "Simplicity is the ultimate sophistication", false); m2::PointD startPt(40, 50); @@ -664,7 +675,8 @@ namespace void DoDraw(shared_ptr p) { p->drawPath(&m_path[0], m_path.size(), p->skin()->mapPenInfo(m_penInfo), 0); - p->drawPathText(&m_path[0], m_path.size(), 10, yg::Color(0, 0, 0, 0), m_text, calc_length(m_path), 0.0, yg::gl::Screen::middle_line, true, yg::Color(255, 255, 255, 255), 0, false); + 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); } }; @@ -675,8 +687,10 @@ namespace p->drawPath(&m_path[0], m_path.size(), p->skin()->mapPenInfo(m_penInfo), 0); double const len = calc_length(m_path); - p->drawPathText(&m_path[0], m_path.size(), 10, yg::Color(0, 0, 0, 0), m_text, len, 0.0, yg::gl::Screen::above_line, true, yg::Color(255, 255, 255, 255), 0, false); - p->drawPathText(&m_path[0], m_path.size(), 10, yg::Color(0, 0, 0, 0), m_text, len, 0.0, yg::gl::Screen::under_line, true, yg::Color(255, 255, 255, 255), 0, false); + 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); } }; @@ -690,8 +704,9 @@ namespace int startY = 30; for (size_t i = 0; i < sizesCount; ++i) { - p->drawText(m2::PointD(10, startY), yg::EPosAboveRight, 0, startSize + i, yg::Color(0, 0, 0, 0), "Simplicity is the ultimate sophistication. Leonardo Da Vinci", true, yg::Color(255, 255, 255, 255), 0, false, true); - startY += startSize + i; + yg::FontDesc fontDesc(false, startSize + i); + p->drawText(fontDesc, m2::PointD(10, startY), yg::EPosAboveRight, 0, "Simplicity is the ultimate sophistication. Leonardo Da Vinci", 0, true); + startY += fontDesc.m_size; } } }; @@ -706,8 +721,9 @@ namespace int startY = 30; for (size_t i = 0; i < sizesCount; ++i) { - p->drawText(m2::PointD(10, startY), yg::EPosAboveRight, 0, startSize/* + i*/, yg::Color(0, 0, 0, 0), "Simplicity is the ultimate sophistication. Leonardo Da Vinci", true, yg::Color(255, 255, 255, 255), 100, false, true); - p->drawText(m2::PointD(5, startY + (startSize + i) / 2), yg::EPosAboveRight, 0, startSize/* + i*/, yg::Color(0, 0, 0, 0), "This text should be filtered", true, yg::Color(255, 255, 255, 255), 100, false, true); + yg::FontDesc fontDesc(false, startSize); + p->drawText(fontDesc, m2::PointD(10, startY), yg::EPosAboveRight, 0, "Simplicity is the ultimate sophistication. Leonardo Da Vinci", 100, true); + p->drawText(fontDesc, m2::PointD(5, startY + (startSize + i) / 2), yg::EPosAboveRight, 0, "This text should be filtered", 100, true); startY += startSize + i; } } @@ -725,18 +741,20 @@ namespace int textsCount = 200; for (int i = 0; i < textsCount; ++i) + { + yg::FontDesc fontDesc(false, + rand() % (endSize - startSize) + startSize, + yg::Color(rand() % 255, rand() % 255, rand() % 255, 255) + ); p->drawText( - m2::PointD(rand() % 500, rand() % 500), - yg::EPosAboveRight, - 0, - rand() % (endSize - startSize) + startSize, - yg::Color(rand() % 255, rand() % 255, rand() % 255, 255), - texts[rand() % (sizeof(texts) / sizeof(char*))], - true, - yg::Color(255, 255, 255, 255), - rand() % 10, - false, - true); + fontDesc, + m2::PointD(rand() % 500, rand() % 500), + yg::EPosAboveRight, + 0, + texts[rand() % (sizeof(texts) / sizeof(char*))], + rand() % 10, + true); + } } }; @@ -937,21 +955,21 @@ namespace }; // UNIT_TEST_GL(TestDrawPolyOverflow); -// UNIT_TEST_GL(TestDrawText); + UNIT_TEST_GL(TestDrawText); // UNIT_TEST_GL(TestDrawSingleSymbol); // UNIT_TEST_GL(TestDrawEmptySymbol); // UNIT_TEST_GL(TestDrawSingleSymbolAndSolidPath); -// UNIT_TEST_GL(TestDrawString); -// UNIT_TEST_GL(TestDrawStringWithFixedFont); -// UNIT_TEST_GL(TestDrawStringWithColor); -// UNIT_TEST_GL(TestDrawUnicodeSymbols); -// UNIT_TEST_GL(TestDrawTextRectWithFixedFont); -// UNIT_TEST_GL(TestDrawStringOnString); -// UNIT_TEST_GL(TestDrawTextOnPath); -// UNIT_TEST_GL(TestDrawTextOnPathWithOffset); -// UNIT_TEST_GL(TestDrawTextOverflow); -// UNIT_TEST_GL(TestDrawTextFiltering); -// UNIT_TEST_GL(TestDrawRandomTextFiltering); + UNIT_TEST_GL(TestDrawString); + UNIT_TEST_GL(TestDrawStringWithFixedFont); + UNIT_TEST_GL(TestDrawStringWithColor); + UNIT_TEST_GL(TestDrawUnicodeSymbols); + UNIT_TEST_GL(TestDrawTextRectWithFixedFont); + UNIT_TEST_GL(TestDrawStringOnString); + UNIT_TEST_GL(TestDrawTextOnPath); + UNIT_TEST_GL(TestDrawTextOnPathWithOffset); + UNIT_TEST_GL(TestDrawTextOverflow); + UNIT_TEST_GL(TestDrawTextFiltering); + UNIT_TEST_GL(TestDrawRandomTextFiltering); // UNIT_TEST_GL(TestDrawSGIConvex); // UNIT_TEST_GL(TestDrawPoly); // UNIT_TEST_GL(TestDrawSolidRect); @@ -962,7 +980,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(TestDrawPathSolidWithZ); // UNIT_TEST_GL(TestDrawPathSolidWithClipRect); // UNIT_TEST_GL(TestDrawUtilsRect);