Skip to content

Commit

Permalink
Fixup merge issue cause compile errors
Browse files Browse the repository at this point in the history
  • Loading branch information
halx99 committed Feb 11, 2025
1 parent 7e09a73 commit 4ab1378
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 28 deletions.
9 changes: 4 additions & 5 deletions core/2d/DrawNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion core/2d/DrawNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
14 changes: 8 additions & 6 deletions core/2d/Label.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions tests/cpp-tests/Source/DrawNodeTest/DrawNodeTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}

Expand Down
26 changes: 13 additions & 13 deletions tests/cpp-tests/Source/LabelTest/LabelTestNew.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -3328,29 +3328,29 @@ 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);
label[5]->setColor(Color3B::BLUE);

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++)
{
Expand Down

0 comments on commit 4ab1378

Please sign in to comment.