diff --git a/core/2d/DrawNode.cpp b/core/2d/DrawNode.cpp index 6605b2c95b9..fed0fad9ac9 100644 --- a/core/2d/DrawNode.cpp +++ b/core/2d/DrawNode.cpp @@ -1179,17 +1179,16 @@ void DrawNode::_drawSegment(const Vec2& from, } } // Internal function _drawLine => thickness is always 1 (fastes way to draw a line) -void DrawNode::_drawLine(const Vec2& from, const Vec2& to, const Color4B& color) +void DrawNode::_drawLine(const Vec2& from, const Vec2& to, const Color& color) { Vec2 vertices[2] = {from, to}; applyTransform(vertices, vertices, 2); - - auto line = expandBufferAndGetPointer(_lines, 2); + auto line = expandBufferAndGetPointer(_lines, 2); _linesDirty = true; - line[0] = {vertices[0], color, Vec2::ZERO}; - line[1] = {vertices[1], color, Vec2::ZERO}; + line[0] = {vertices[0], Vec2::ZERO, color}; + line[1] = {vertices[1], Vec2::ZERO, color}; } void DrawNode::_drawDot(const Vec2& pos, float radius, const Color& color) diff --git a/core/2d/DrawNode.h b/core/2d/DrawNode.h index 6b127e2e736..382e6801da3 100644 --- a/core/2d/DrawNode.h +++ b/core/2d/DrawNode.h @@ -634,7 +634,7 @@ class AX_DLL DrawNode : public Node bool isconvex = true); // Internal function _drawLine - void _drawLine(const Vec2& from, const Vec2& to, const Color4B& color); + void _drawLine(const Vec2& from, const Vec2& to, const Color& color); // Internal function _drawSegment void _drawSegment(const Vec2& origin, diff --git a/core/2d/Label.cpp b/core/2d/Label.cpp index 9171771b7b3..a5d49c7c4d0 100644 --- a/core/2d/Label.cpp +++ b/core/2d/Label.cpp @@ -1724,8 +1724,8 @@ void Label::updateContent() if (_lineDrawNode) { - Color4B lineColor = Color4B(_displayedColor); - if (_textColor != Color4B::WHITE && _textColor != lineColor) + Color32 lineColor = Color32(_displayedColor); + if (_textColor != Color32::WHITE && _textColor != lineColor) lineColor = _textColor; _lineDrawNode->clear(); @@ -1746,10 +1746,12 @@ void Label::updateContent() Color(lineColor), thickness); } - // Github issue #15214. Uses _displayedColor instead of _textColor for the underline. - // This is to have the same behavior of SystemFonts. - _underlineNode->drawLine(Vec2(_linesOffsetX[i], y), Vec2(_linesWidth[i] + _linesOffsetX[i], y), - Color(_displayedColor), charheight / 6); + if (_underlineEnabled) + { + float y = (_numberOfLines - i - 1) * charheight; + _lineDrawNode->drawLine(Vec2(_linesOffsetX[i], y), Vec2(_linesWidth[i] + _linesOffsetX[i], y), + Color(lineColor), thickness); + } } } else if (_textSprite) // ...and is the logic for System fonts diff --git a/tests/cpp-tests/Source/DrawNodeTest/DrawNodeTest.cpp b/tests/cpp-tests/Source/DrawNodeTest/DrawNodeTest.cpp index 30f1d47bddf..1a42ecef0bd 100644 --- a/tests/cpp-tests/Source/DrawNodeTest/DrawNodeTest.cpp +++ b/tests/cpp-tests/Source/DrawNodeTest/DrawNodeTest.cpp @@ -1929,9 +1929,9 @@ void DrawNodeLineDrawTest::update(float dt) float x = radius * cosf(rads) + center.x; float y = radius * sinf(rads) + center.y; - drawNode->drawLine(center - Vec2(20, 40), Vec2(x, y)- Vec2(20, 40), Color4F::RED, sliderValue[sliderType::Thickness]); - drawNode->drawLine(center + Vec2(120, 20), Vec2(x, y) + Vec2(120,20), Color4F::BLUE, sliderValue[sliderType::Thickness]); - drawNode->drawLine(center - Vec2(130, 110),Vec2(x,y) - Vec2(130,110), Color4F::GREEN, sliderValue[sliderType::Thickness]); + drawNode->drawLine(center - Vec2(20, 40), Vec2(x, y)- Vec2(20, 40), Color::RED, sliderValue[sliderType::Thickness]); + drawNode->drawLine(center + Vec2(120, 20), Vec2(x, y) + Vec2(120,20), Color::BLUE, sliderValue[sliderType::Thickness]); + drawNode->drawLine(center - Vec2(130, 110),Vec2(x,y) - Vec2(130,110), Color::GREEN, sliderValue[sliderType::Thickness]); } } diff --git a/tests/cpp-tests/Source/LabelTest/LabelTestNew.cpp b/tests/cpp-tests/Source/LabelTest/LabelTestNew.cpp index 9b71bb14bbf..4123f65e65c 100644 --- a/tests/cpp-tests/Source/LabelTest/LabelTestNew.cpp +++ b/tests/cpp-tests/Source/LabelTest/LabelTestNew.cpp @@ -3279,8 +3279,8 @@ LabelUnderlineStrikethroughMultiline::LabelUnderlineStrikethroughMultiline() // Glow SDF (GPU) auto label1 = Label::createWithTTF(ttfConf, "Glow1", TextHAlignment::CENTER, s.width); label1->setPosition(Vec2(s.width / 2, s.height * 0.7)); - label1->setTextColor(Color4B::GREEN); - label1->enableGlow(Color4B::YELLOW); + label1->setTextColor(Color32::GREEN); + label1->enableGlow(Color32::YELLOW); label1->enableUnderline(); label1->enableStrikethrough(); addChild(label1); @@ -3289,8 +3289,8 @@ LabelUnderlineStrikethroughMultiline::LabelUnderlineStrikethroughMultiline() ttfConf.distanceFieldEnabled = false; auto label2 = Label::createWithTTF(ttfConf, "Glow2", TextHAlignment::CENTER, s.width); label2->setPosition(Vec2(s.width / 2, s.height * 0.6)); - label2->setTextColor(Color4B::GREEN); - label2->enableGlow(Color4B::YELLOW); + label2->setTextColor(Color32::GREEN); + label2->enableGlow(Color32::YELLOW); label2->enableUnderline(); label2->enableStrikethrough(); addChild(label2); @@ -3300,8 +3300,8 @@ LabelUnderlineStrikethroughMultiline::LabelUnderlineStrikethroughMultiline() ttfConf.outlineSize = 2; auto label3 = Label::createWithTTF(ttfConf, "Outline1", TextHAlignment::CENTER, s.width); label3->setPosition(Vec2(s.width / 2, s.height * 0.48)); - label3->setTextColor(Color4B::RED); - label3->enableOutline(Color4B::BLUE); + label3->setTextColor(Color32::RED); + label3->enableOutline(Color32::BLUE); label3->enableUnderline(); label3->enableStrikethrough(); addChild(label3); @@ -3311,8 +3311,8 @@ LabelUnderlineStrikethroughMultiline::LabelUnderlineStrikethroughMultiline() ttfConf.outlineSize = 2; auto label4 = Label::createWithTTF(ttfConf, "Outline2", TextHAlignment::CENTER, s.width); label4->setPosition(Vec2(s.width / 2, s.height * 0.36)); - label4->setTextColor(Color4B::RED); - label4->enableOutline(Color4B::BLUE, 2); + label4->setTextColor(Color32::RED); + label4->enableOutline(Color32::BLUE, 2); label4->enableUnderline(); label4->enableStrikethrough(); addChild(label4); @@ -3328,21 +3328,21 @@ LabelUnderlineStrikethroughMultiline::LabelUnderlineStrikethroughMultiline() Label* label[count]; label[0] = Label::createWithSystemFont("SystemFont TextVAlignment::TOP\nusing setTextColor(255, 0, 255, 100)", font, 14, Vec2::ZERO, TextHAlignment::LEFT, TextVAlignment::TOP); - label[0]->setTextColor(Color4B(255, 0, 255, 100)); - label[0]->enableGlow(Color4B::BLUE); + label[0]->setTextColor(Color32(255, 0, 255, 100)); + label[0]->enableGlow(Color32::BLUE); label[1] = Label::createWithSystemFont("SystemFont TextVAlignment::CENTER\nusing setColor(*RED*)", font, 14, Vec2::ZERO, TextHAlignment::RIGHT, TextVAlignment::CENTER); label[1]->setColor(Color3B::RED); label[2] = Label::createWithSystemFont("SystemFont TextVAlignment::BOTTOM\nusingsetTextColor(*YELLOW)", font, 14, Vec2::ZERO, TextHAlignment::CENTER, TextVAlignment::BOTTOM); - label[2]->setTextColor(Color4B::YELLOW); + label[2]->setTextColor(Color32::YELLOW); label[3] = Label::createWithBMFont("fonts/bitmapFontTest5.fnt", "BMFont\nwith default color", TextHAlignment::CENTER, s.width); label[4] = Label::createWithBMFont("fonts/bitmapFontTest5.fnt", "BMFont\nusing setTextColor(0, 255, 0, 100)", TextHAlignment::CENTER, s.width); - label[4]->setTextColor(Color4B(0, 255, 0, 100)); + label[4]->setTextColor(Color32(0, 255, 0, 100)); label[5] = Label::createWithTTF(ttfConfig, "TTF setColor(*BLUE*)\nwith multiline 1\nand a much more longer multiline 2", TextHAlignment::LEFT, s.width); @@ -3350,7 +3350,7 @@ LabelUnderlineStrikethroughMultiline::LabelUnderlineStrikethroughMultiline() label[6] = Label::createWithTTF("TTF setTextColor(*RED*)\nwith multiline 1\nand a much more longer multiline 2", font, 14); - label[6]->setTextColor(Color4B::RED); + label[6]->setTextColor(Color32::RED); for (int i = 0; i < count; i++) {