Skip to content

Commit 5dd5ae5

Browse files
authored
Ensure opacity is applied to DrawNode used in Label (#2396)
* Ensure opacity is applied to label underline * Set DrawNode opacity * Apply formatting
1 parent 0010e77 commit 5dd5ae5

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

core/2d/Label.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,7 +1503,9 @@ void Label::enableUnderline()
15031503
{
15041504
_lineDrawNode = DrawNode::create();
15051505
_lineDrawNode->setGlobalZOrder(getGlobalZOrder());
1506-
_lineDrawNode->properties.setFactor(_lineDrawNode->properties.getFactor() * 2.0f); // 2.0f: Makes the line smaller
1506+
_lineDrawNode->setOpacity(_displayedOpacity);
1507+
_lineDrawNode->properties.setFactor(_lineDrawNode->properties.getFactor() *
1508+
2.0f); // 2.0f: Makes the line smaller
15071509
addChild(_lineDrawNode, 100000);
15081510
}
15091511
}
@@ -1520,7 +1522,9 @@ void Label::enableStrikethrough()
15201522
{
15211523
_lineDrawNode = DrawNode::create();
15221524
_lineDrawNode->setGlobalZOrder(getGlobalZOrder());
1523-
_lineDrawNode->properties.setFactor(_lineDrawNode->properties.getFactor() * 2.0f); // 2.0f: Makes the line smaller
1525+
_lineDrawNode->setOpacity(_displayedOpacity);
1526+
_lineDrawNode->properties.setFactor(_lineDrawNode->properties.getFactor() *
1527+
2.0f); // 2.0f: Makes the line smaller
15241528
addChild(_lineDrawNode, 100000);
15251529
}
15261530
}
@@ -2424,6 +2428,12 @@ void Label::updateDisplayedOpacity(uint8_t parentOpacity)
24242428
{
24252429
it.second->updateDisplayedOpacity(_displayedOpacity);
24262430
}
2431+
2432+
if (_lineDrawNode)
2433+
{
2434+
_lineDrawNode->setOpacity(_displayedOpacity);
2435+
_contentDirty = true;
2436+
}
24272437
}
24282438

24292439
// FIXME: it is not clear what is the difference between setTextColor() and setColor()

0 commit comments

Comments
 (0)