| 1483 | } |
| 1484 | |
| 1485 | void Label::enableShadow(const Color4B& shadowColor /* = Color4B::BLACK */, |
| 1486 | const Vec2& offset /* = Vec2(2 ,-2)*/, |
| 1487 | int /* blurRadius = 0 */) |
| 1488 | { |
| 1489 | _shadowEnabled = true; |
| 1490 | _shadowDirty = true; |
| 1491 | |
| 1492 | _shadowOffset.width = offset.width; |
| 1493 | _shadowOffset.height = offset.height; |
| 1494 | // TODO: support blur for shadow |
| 1495 | |
| 1496 | _shadowColor3B.r = shadowColor.r; |
| 1497 | _shadowColor3B.g = shadowColor.g; |
| 1498 | _shadowColor3B.b = shadowColor.b; |
| 1499 | _shadowOpacity = shadowColor.a; |
| 1500 | |
| 1501 | if (!_systemFontDirty && !_contentDirty && _textSprite) |
| 1502 | { |
| 1503 | auto fontDef = _getFontDefinition(); |
| 1504 | if (_shadowNode) |
| 1505 | { |
| 1506 | if (shadowColor != _shadowColor4F) |
| 1507 | { |
| 1508 | _shadowNode->release(); |
| 1509 | _shadowNode = nullptr; |
| 1510 | createShadowSpriteForSystemFont(fontDef); |
| 1511 | } |
| 1512 | else |
| 1513 | { |
| 1514 | _shadowNode->setPosition(_shadowOffset.width, _shadowOffset.height); |
| 1515 | } |
| 1516 | } |
| 1517 | else |
| 1518 | { |
| 1519 | createShadowSpriteForSystemFont(fontDef); |
| 1520 | } |
| 1521 | } |
| 1522 | |
| 1523 | _shadowColor4F.r = shadowColor.r / 255.0f; |
| 1524 | _shadowColor4F.g = shadowColor.g / 255.0f; |
| 1525 | _shadowColor4F.b = shadowColor.b / 255.0f; |
| 1526 | _shadowColor4F.a = shadowColor.a / 255.0f; |
| 1527 | |
| 1528 | if (_currentLabelType == LabelType::BMFONT || _currentLabelType == LabelType::CHARMAP) |
| 1529 | { |
| 1530 | updateShaderProgram(); |
| 1531 | } |
| 1532 | } |
| 1533 | |
| 1534 | void Label::enableItalics() |
| 1535 | { |