Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- //depot/Projects/UnrealEngine/Main/Engine/Source/Runtime/Slate/Private/Framework/Text/SlateTextRun.cpp 2015-03-22 07:56:30.000000000 1100
- +++ C:\Local\Projects\UnrealEngine\Main\Engine\Source\Runtime\Slate\Private\Framework\Text\SlateTextRun.cpp 2015-03-22 07:56:30.000000000 1100
- @@ -6,6 +6,16 @@
- #include "SlateTextRun.h"
- +FVector2D GetShadowOffsetAndOutlineThickness(const FVector2D& StyleShadowOffset, float& OutlineThicknessOut, uint32& OutlineDirectionsOut)
- +{
- + FVector2D ShadowOffset(StyleShadowOffset);
- + OutlineThicknessOut = FMath::RoundToInt(StyleShadowOffset.X * 0.001f);
- + ShadowOffset.X -= OutlineThicknessOut * 1000.f;
- + OutlineDirectionsOut = FMath::RoundToInt(StyleShadowOffset.Y * 0.001f);
- + ShadowOffset.Y -= OutlineDirectionsOut * 1000.f;
- + return ShadowOffset;
- +}
- +
- TSharedRef< FSlateTextRun > FSlateTextRun::Create( const FRunInfo& InRunInfo, const TSharedRef< const FString >& InText, const FTextBlockStyle& Style )
- {
- return MakeShareable( new FSlateTextRun( InRunInfo, InText, Style ) );
- @@ -28,19 +38,29 @@
- int16 FSlateTextRun::GetBaseLine( float Scale ) const
- {
- + float OutlineThickness;
- + uint32 OutlineDirections;
- + FVector2D ShadowOffset = GetShadowOffsetAndOutlineThickness(Style.ShadowOffset, OutlineThickness, OutlineDirections);
- const TSharedRef< FSlateFontMeasure > FontMeasure = FSlateApplication::Get().GetRenderer()->GetFontMeasureService();
- - return FontMeasure->GetBaseline( Style.Font, Scale ) - FMath::Min(0.0f, Style.ShadowOffset.Y * Scale);
- + return FontMeasure->GetBaseline( Style.Font, Scale ) - FMath::Min(0.0f, ShadowOffset.Y * Scale);
- }
- int16 FSlateTextRun::GetMaxHeight( float Scale ) const
- {
- + float OutlineThickness;
- + uint32 OutlineDirections;
- + FVector2D ShadowOffset = GetShadowOffsetAndOutlineThickness(Style.ShadowOffset, OutlineThickness, OutlineDirections);
- const TSharedRef< FSlateFontMeasure > FontMeasure = FSlateApplication::Get().GetRenderer()->GetFontMeasureService();
- - return FontMeasure->GetMaxCharacterHeight( Style.Font, Scale ) + FMath::Abs(Style.ShadowOffset.Y * Scale);
- + return FontMeasure->GetMaxCharacterHeight( Style.Font, Scale ) + FMath::Abs(ShadowOffset.Y * Scale);
- }
- FVector2D FSlateTextRun::Measure( int32 BeginIndex, int32 EndIndex, float Scale ) const
- {
- - const FVector2D ShadowOffsetToApply((EndIndex == Range.EndIndex) ? FMath::Abs(Style.ShadowOffset.X * Scale) : 0.0f, FMath::Abs(Style.ShadowOffset.Y * Scale));
- + float OutlineThickness;
- + uint32 OutlineDirections;
- + FVector2D ShadowOffset = GetShadowOffsetAndOutlineThickness(Style.ShadowOffset, OutlineThickness, OutlineDirections);
- +
- + const FVector2D ShadowOffsetToApply((EndIndex == Range.EndIndex) ? FMath::Abs(ShadowOffset.X * Scale) : 0.0f, FMath::Abs(ShadowOffset.Y * Scale));
- if ( EndIndex - BeginIndex == 0 )
- {
- @@ -73,7 +93,11 @@
- const FSlateRect ClippingRect = AllottedGeometry.GetClippingRect().IntersectionWith(MyClippingRect);
- const ESlateDrawEffect::Type DrawEffects = bParentEnabled ? ESlateDrawEffect::None : ESlateDrawEffect::DisabledEffect;
- - const bool ShouldDropShadow = Style.ShadowOffset.Size() > 0;
- + float OutlineThickness;
- + uint32 OutlineDirections;
- + FVector2D ShadowOffset = GetShadowOffsetAndOutlineThickness(Style.ShadowOffset, OutlineThickness, OutlineDirections);
- +
- + const bool ShouldDropShadow = ShadowOffset.Size() > 0;
- const FVector2D BlockLocationOffset = Block->GetLocationOffset();
- const FTextRange BlockRange = Block->GetTextRange();
- @@ -82,14 +106,40 @@
- // A negative shadow offset should be applied as a positive offset to the text to avoid clipping issues
- const FVector2D DrawShadowOffset(
- - (Style.ShadowOffset.X > 0.0f) ? Style.ShadowOffset.X * AllottedGeometry.Scale : 0.0f,
- - (Style.ShadowOffset.Y > 0.0f) ? Style.ShadowOffset.Y * AllottedGeometry.Scale : 0.0f
- + (ShadowOffset.X > 0.0f) ? ShadowOffset.X * AllottedGeometry.Scale : 0.0f,
- + (ShadowOffset.Y > 0.0f) ? ShadowOffset.Y * AllottedGeometry.Scale : 0.0f
- );
- const FVector2D DrawTextOffset(
- - (Style.ShadowOffset.X < 0.0f) ? -Style.ShadowOffset.X * AllottedGeometry.Scale : 0.0f,
- - (Style.ShadowOffset.Y < 0.0f) ? -Style.ShadowOffset.Y * AllottedGeometry.Scale : 0.0f
- + (ShadowOffset.X < 0.0f) ? -ShadowOffset.X * AllottedGeometry.Scale : 0.0f,
- + (ShadowOffset.Y < 0.0f) ? -ShadowOffset.Y * AllottedGeometry.Scale : 0.0f
- );
- + // Draw the outline
- + if (OutlineThickness > 0.f)
- + {
- + FSlateRect OutlineClippingRect(ClippingRect.Left - OutlineThickness, ClippingRect.Top - OutlineThickness, ClippingRect.Right + OutlineThickness, ClippingRect.Bottom + OutlineThickness);
- + FVector2D OutlineOffset;
- + float AngleStep = 360.f / (float)OutlineDirections;
- + FVector2D OutlineDirection(0.f, OutlineThickness * AllottedGeometry.Scale);
- + for (uint32 i = 0; i < OutlineDirections; ++i)
- + {
- + OutlineOffset = OutlineDirection.GetRotated(AngleStep * i);
- + FSlateDrawElement::MakeText(
- + OutDrawElements,
- + ++LayerId,
- + AllottedGeometry.ToPaintGeometry(TransformVector(InverseScale, Block->GetSize()), FSlateLayoutTransform(TransformPoint(InverseScale, Block->GetLocationOffset() + DrawTextOffset + OutlineOffset))),
- + Text.Get(),
- + BlockRange.BeginIndex,
- + BlockRange.EndIndex,
- + Style.Font,
- + OutlineClippingRect,
- + DrawEffects,
- + InWidgetStyle.GetColorAndOpacityTint() * Style.ShadowColorAndOpacity
- + );
- +
- + }
- + }
- +
- // Draw the optional shadow
- if ( ShouldDropShadow )
- {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement