Files
UnrealEngineUWP/Engine/Source/Runtime/Slate/Private/Framework/Text/SlateWidgetRun.cpp

213 lines
7.1 KiB
C++
Raw Normal View History

// Copyright Epic Games, Inc. All Rights Reserved.
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340) #lockdown Nick.Penwarden #rb none ========================== MAJOR FEATURES + CHANGES ========================== Change 3209340 on 2016/11/23 by Ben.Marsh Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h. Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms. * Every header now includes everything it needs to compile. * There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first. * There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h. * Every .cpp file includes its matching .h file first. * This helps validate that each header is including everything it needs to compile. * No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more. * You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there. * There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible. * No engine code explicitly includes a precompiled header any more. * We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies. * PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files. Tool used to generate this transform is at Engine\Source\Programs\IncludeTool. [CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
#include "Framework/Text/SlateWidgetRun.h"
#include "Layout/ArrangedChildren.h"
#include "Framework/Text/DefaultLayoutBlock.h"
#if WITH_FANCY_TEXT
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340) #lockdown Nick.Penwarden #rb none ========================== MAJOR FEATURES + CHANGES ========================== Change 3209340 on 2016/11/23 by Ben.Marsh Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h. Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms. * Every header now includes everything it needs to compile. * There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first. * There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h. * Every .cpp file includes its matching .h file first. * This helps validate that each header is including everything it needs to compile. * No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more. * You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there. * There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible. * No engine code explicitly includes a precompiled header any more. * We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies. * PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files. Tool used to generate this transform is at Engine\Source\Programs\IncludeTool. [CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
#include "Framework/Text/RunUtils.h"
TSharedRef< FSlateWidgetRun > FSlateWidgetRun::Create(const TSharedRef<class FTextLayout>& TextLayout, const FRunInfo& InRunInfo, const TSharedRef< const FString >& InText, const FWidgetRunInfo& InWidgetInfo)
{
return MakeShareable(new FSlateWidgetRun(TextLayout, InRunInfo, InText, InWidgetInfo));
}
TSharedRef< FSlateWidgetRun > FSlateWidgetRun::Create(const TSharedRef<class FTextLayout>& TextLayout, const FRunInfo& InRunInfo, const TSharedRef< const FString >& InText, const FWidgetRunInfo& InWidgetInfo, const FTextRange& InRange)
{
return MakeShareable(new FSlateWidgetRun(TextLayout, InRunInfo, InText, InWidgetInfo, InRange));
}
FTextRange FSlateWidgetRun::GetTextRange() const
{
return Range;
}
void FSlateWidgetRun::SetTextRange( const FTextRange& Value )
{
Range = Value;
}
int16 FSlateWidgetRun::GetBaseLine( float Scale ) const
{
return Info.Baseline.Get(0) * Scale;
}
int16 FSlateWidgetRun::GetMaxHeight( float Scale ) const
{
return Info.Size.Get( Info.Widget->GetDesiredSize() ).Y * Scale;
}
FVector2D FSlateWidgetRun::Measure( int32 StartIndex, int32 EndIndex, float Scale, const FRunTextContext& TextContext ) const
{
if ( EndIndex - StartIndex == 0 )
{
return FVector2D( 0, GetMaxHeight( Scale ) );
}
return Info.Size.Get( Info.Widget->GetDesiredSize() ) * Scale;
}
int8 FSlateWidgetRun::GetKerning( int32 CurrentIndex, float Scale, const FRunTextContext& TextContext ) const
{
return 0;
}
TSharedRef< ILayoutBlock > FSlateWidgetRun::CreateBlock( int32 StartIndex, int32 EndIndex, FVector2D Size, const FLayoutBlockTextContext& TextContext, const TSharedPtr< IRunRenderer >& Renderer )
{
return FDefaultLayoutBlock::Create( SharedThis( this ), FTextRange( StartIndex, EndIndex ), Size, TextContext, Renderer );
}
int32 FSlateWidgetRun::OnPaint(const FPaintArgs& PaintArgs, const FTextArgs& TextArgs, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const
{
// The block size and offset values are pre-scaled, so we need to account for that when converting the block offsets into paint geometry
const float InverseScale = Inverse(AllottedGeometry.Scale);
const FVector2D DesiredWidgetSize = Info.Widget->GetDesiredSize();
if (DesiredWidgetSize != WidgetSize)
{
WidgetSize = DesiredWidgetSize;
const TSharedPtr<FTextLayout> TextLayoutPtr = TextLayout.Pin();
if (TextLayoutPtr.IsValid())
{
TextLayoutPtr->DirtyRunLayout(SharedThis(this));
}
}
const FGeometry WidgetGeometry = AllottedGeometry.MakeChild(TransformVector(InverseScale, TextArgs.Block->GetSize()), FSlateLayoutTransform(TransformPoint(InverseScale, TextArgs.Block->GetLocationOffset())));
return Info.Widget->Paint(PaintArgs, WidgetGeometry, MyCullingRect, OutDrawElements, LayerId, InWidgetStyle, bParentEnabled);
}
const TArray< TSharedRef<SWidget> >& FSlateWidgetRun::GetChildren()
{
return Children;
}
void FSlateWidgetRun::ArrangeChildren( const TSharedRef< ILayoutBlock >& Block, const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren ) const
{
// The block size and offset values are pre-scaled, so we need to account for that when converting the block offsets into paint geometry
const float InverseScale = Inverse(AllottedGeometry.Scale);
ArrangedChildren.AddWidget(
AllottedGeometry.MakeChild(Info.Widget, TransformVector(InverseScale, Block->GetSize()), FSlateLayoutTransform(TransformPoint(InverseScale, Block->GetLocationOffset())))
);
}
Fixed some cursor movement/placement issues in the multi-line editable text TTP# 336464 - Editor: Finish the Multiline Editable Text Block The fact that the end of a soft-wrapped line has the same FTextLocation as the start of the next soft-wrapped line leads to ambiguity when moving the cursor, as the cursor is always positioned based upon the line model (FTextLocation) rather than the line view. I'd previously attempted to fix this when placing the cursor with the mouse by moving the cursor back one place (and aligning the cursor to the right) if it matched the end of a soft-line boundary. This worked for the end of the lines, but caused another issue where the clicking to the left of the start of a soft-line would move the cursor back to the previous line. I've removed that code, and instead added code which allows the text layout (and text run) to report where on the line the given position has hit (either within the line itself, or inside the left or right gutter). This lets me adjust the cursor only if the click landed in the right gutter. I also had to fix some issues with PreferredCursorScreenOffsetInLine as it was sometimes being set to a different position to the cursor, which could lead to it jumping around. I also changed the code which converts a position into a line view location (GetLineViewIndexForTextLocation) to perform a non-exclusive range check - this ensures that the FTextLocation will match the start of a line view, rather than the end of a line view (which is correct due to the way I move the cursor back). The only exception to this is when the cursor has been placed to the right of a character, as this is assumed to mean that the cursor is at the end of a line view, and therefore we want to return the line view index for end of that line. ReviewedBy Andrew.Rodham, Justin.Sargent [CL 2225429 by Jamie Dale in Main branch]
2014-07-21 06:48:45 -04:00
int32 FSlateWidgetRun::GetTextIndexAt( const TSharedRef< ILayoutBlock >& Block, const FVector2D& Location, float Scale, ETextHitPoint* const OutHitPoint ) const
{
// A widget should always contain a single character (a breaking space)
check(Range.Len() == 1);
const FVector2D& BlockOffset = Block->GetLocationOffset();
const FVector2D& BlockSize = Block->GetSize();
const float Left = BlockOffset.X;
const float Top = BlockOffset.Y;
const float Right = BlockOffset.X + BlockSize.X;
const float Bottom = BlockOffset.Y + BlockSize.Y;
const bool ContainsPoint = Location.X >= Left && Location.X < Right && Location.Y >= Top && Location.Y < Bottom;
if ( !ContainsPoint )
{
return INDEX_NONE;
}
const FVector2D ScaledWidgetSize = Info.Widget->GetDesiredSize() * Scale;
const int32 Index = (Location.X <= (Left + (ScaledWidgetSize.X * 0.5f))) ? Range.BeginIndex : Range.EndIndex;
if (OutHitPoint)
{
const FTextRange BlockRange = Block->GetTextRange();
Merging //UE4/Release-4.11 to //UE4/Main (up to CL#2835147) ========================== MAJOR FEATURES + CHANGES ========================== Change 2817214 on 2016/01/06 by mason.seay Adjusted Walkable Slope Override for mesh #jira UE-24473 Change 2817384 on 2016/01/06 by Michael.Schoell Crash fix when selecting a variable node for a variable that is not owned by a Blueprint. #jira UE-24958 - Crash when getting the sequence player in level blueprint Change 2817438 on 2016/01/06 by Max.Chen Sequencer: Add option to specify position of material name from the movie scene capture interface. For example, MovieCapture_{material}_{width}x{height}.{frame} will create files like this: MovieCapture_FinalImage_1920x1080.0010.exr #rb Andrew.Rodham #jira UE-24926 Change 2817459 on 2016/01/06 by Marc.Audy PR #1679: Move MinRespawnDelay to virtual method AController::GetMinRespawnDelay() (Contributed by bozaro) #jira UE-22309 Change 2817472 on 2016/01/06 by Ben.Marsh Always run UHT in unattended mode from UBT; we don't want it opening any dialogs. Match3 is currently missing a plugin, and it's causing builds to time out. Change 2817473 on 2016/01/06 by Marc.Audy PR #1644: Improve "SpawnActor failed because the spawned actor IsPendingKill" error message (Contributed by slonopotamus) #jira UE-21911 Change 2817533 on 2016/01/06 by Lauren.Ridge Fixing Match3 not compiling in Debug (removed two checks on TileLibrary) #jira UE-25004 Change 2817625 on 2016/01/06 by Taizyd.Korambayil #jira UE-19659 Reimported Template Animations with Proper Skeletons Change 2817647 on 2016/01/06 by Lukasz.Furman replaced ensure during initialization of blackboard based behavior tree task with log warning #ue4 #jira UE-24448 #rb Mieszko.Zielinski Change 2817648 on 2016/01/06 by Lukasz.Furman fixed broken rendering component of navmesh actor after delete-undo operation #ue4 #jira UE-24446 #rb Mieszko.Zielinski Change 2817688 on 2016/01/06 by Taizyd.Korambayil #jira UE-22347 Fixed Message Warnings on Startup Change 2817815 on 2016/01/06 by Jamie.Dale Multiple fixes when editing right-to-left text - Text is now shaped over the entire line to allow rich-text and selected text to be shaped correctly across block boundaries. - Text layout highlights are now able to correctly handle bi-directional and right-to-left text. - Text picking can now handle bi-directional and right-to-left text. - Text picking can now pick the individual characters that make up a ligature glyph. - The caret now draws on the logical (rather than visual) side of the glyph (to handle right-to-left text). - Glyph clusters (multiple glyphs produced from a single character) are now treated as a single logical glyph. - Optimized some of the FShapedGlyphSequence to allow an early out once they've found and processed the start and end glyphs. #jira UE-25013 Change 2817828 on 2016/01/06 by Nick.Darnell Editor - Fixing the OpenLauncher call to be take a structure to allow us to customize it more, and to properly handle the silent command the way we're planning to handle it in the launcher. #jira UE-24563 Change 2818052 on 2016/01/06 by Nick.Darnell Editor - Adding another application check for the launcher to catch the current app name on mac. #jira UE-24563 Change 2818149 on 2016/01/06 by Taizyd.Korambayil #jira UE-19097 Adjusted FirstPerson Pawn, so that Camera doesnt clip the Arm Mesh Change 2818360 on 2016/01/06 by Chris.Babcock Fix reading from ini sections not cached after build system changes for 4.11 #jira UE-25027 #ue4 #android Change 2818369 on 2016/01/06 by Ryan.Vance #jira UE-24976 Adding tessellation support to instanced stereo Change 2818999 on 2016/01/07 by Robert.Manuszewski UHT will no longer try to load game-only plugins. #jira UE-25032 - Changed module type RuntimeNoProgram to RuntimeAndProgram so that bu default Runtime plugin modules won't be loaded by programs - Added better error message when UHT's PreInit fails Change 2819064 on 2016/01/07 by Richard.Hinckley #jira UE-24694 Fixing array usage in 4.11 stream. Change 2819067 on 2016/01/07 by Ori.Cohen When editor tries to spawn a physics asset we automatically load the needed skeletal mesh #rb Matt.K #JIRA UE-24165
2016-01-22 08:13:18 -05:00
const FLayoutBlockTextContext BlockTextContext = Block->GetTextContext();
// The block for a widget will always detect a LTR reading direction, so use the base direction (of the line) for the image hit-point detection
*OutHitPoint = RunUtils::CalculateTextHitPoint(Index, BlockRange, BlockTextContext.BaseDirection);
}
return Index;
}
FVector2D FSlateWidgetRun::GetLocationAt( const TSharedRef< ILayoutBlock >& Block, int32 Offset, float Scale ) const
{
return Block->GetLocationOffset();
}
void FSlateWidgetRun::Move(const TSharedRef<FString>& NewText, const FTextRange& NewRange)
{
Text = NewText;
Range = NewRange;
}
TSharedRef<IRun> FSlateWidgetRun::Clone() const
{
return FSlateWidgetRun::Create(TextLayout.Pin().ToSharedRef(), RunInfo, Text, Info, Range);
}
Added support for SMultiLineEditableText to edit rich-text TTP# 336464 - Editor: Finish the Multiline Editable Text Block Abstracted away the SetEditableText and GetEditableText functions from SMultiLineEditableText into "text marshallers" which handle converting text to and from a TextLayout. There are three types of text marshallers currently implemented: * Plain-text * Rich-text * Syntax highlighting Text marshallers also have the ability to inject formatting "live" (as the text changes), which is how the syntax highlighting marshaller works. Added the ability for a run to query the information it was created with. This allows the rich-text marshaller to reconstruct the original rich-text from the styled runs. To test this out, I've implemented a simple WYSIWYG rich-text editor demo with the following features: * Two SMultiLineEditableText widgets showing the same source text, one using a rich-text marshaller, and one using a syntax highlighter marshaller. * A toolbar to allow you to control the style of the selected text. * A button to allow you to insert a hyperlink into the document. The demo also makes use of the meta-data stored in the runs (the same information used to reconstruct the original rich-text) to read the text style of whatever is currently under the cursor, live, as the cursor is moved. Miscellaneous fixes: * Fixed an issue where deleting text that spanned multiple runs could leave the remaining runs in a bad state, leading to phantom text appearing (see FTextLayout::RemoveAt). * Fixed an issue where new-lines at the end of a rich-text document would be lost (see CalculateLineRanges). * Fixed an issue where \\r\\n line endings werenÆt being handled correctly by the rich-text parser (see CalculateLineRanges). * Fixed an issue where the rich-text parser would treat an empty run as plain-text (see FRichTextMarkupProcessing::ParseLineRanges). * Fixed an issue where inserting a line break when the cursor was at the end of a line containing multiple runs could sometimes fail (see FTextLayout::SplitLineAt). * Fixed mouse cursor movement not working correctly with a FSlateHyperlinkRun (see FSlateHyperlinkRun::GetTextIndexAt). ReviewedBy Justin.Sargent [CL 2246838 by Jamie Dale in Main branch]
2014-08-07 06:46:11 -04:00
void FSlateWidgetRun::AppendTextTo(FString& AppendToText) const
{
AppendToText.Append(**Text + Range.BeginIndex, Range.Len());
}
Added support for SMultiLineEditableText to edit rich-text TTP# 336464 - Editor: Finish the Multiline Editable Text Block Abstracted away the SetEditableText and GetEditableText functions from SMultiLineEditableText into "text marshallers" which handle converting text to and from a TextLayout. There are three types of text marshallers currently implemented: * Plain-text * Rich-text * Syntax highlighting Text marshallers also have the ability to inject formatting "live" (as the text changes), which is how the syntax highlighting marshaller works. Added the ability for a run to query the information it was created with. This allows the rich-text marshaller to reconstruct the original rich-text from the styled runs. To test this out, I've implemented a simple WYSIWYG rich-text editor demo with the following features: * Two SMultiLineEditableText widgets showing the same source text, one using a rich-text marshaller, and one using a syntax highlighter marshaller. * A toolbar to allow you to control the style of the selected text. * A button to allow you to insert a hyperlink into the document. The demo also makes use of the meta-data stored in the runs (the same information used to reconstruct the original rich-text) to read the text style of whatever is currently under the cursor, live, as the cursor is moved. Miscellaneous fixes: * Fixed an issue where deleting text that spanned multiple runs could leave the remaining runs in a bad state, leading to phantom text appearing (see FTextLayout::RemoveAt). * Fixed an issue where new-lines at the end of a rich-text document would be lost (see CalculateLineRanges). * Fixed an issue where \\r\\n line endings werenÆt being handled correctly by the rich-text parser (see CalculateLineRanges). * Fixed an issue where the rich-text parser would treat an empty run as plain-text (see FRichTextMarkupProcessing::ParseLineRanges). * Fixed an issue where inserting a line break when the cursor was at the end of a line containing multiple runs could sometimes fail (see FTextLayout::SplitLineAt). * Fixed mouse cursor movement not working correctly with a FSlateHyperlinkRun (see FSlateHyperlinkRun::GetTextIndexAt). ReviewedBy Justin.Sargent [CL 2246838 by Jamie Dale in Main branch]
2014-08-07 06:46:11 -04:00
void FSlateWidgetRun::AppendTextTo(FString& AppendToText, const FTextRange& PartialRange) const
{
check(Range.BeginIndex <= PartialRange.BeginIndex);
check(Range.EndIndex >= PartialRange.EndIndex);
AppendToText.Append(**Text + PartialRange.BeginIndex, PartialRange.Len());
}
Added support for SMultiLineEditableText to edit rich-text TTP# 336464 - Editor: Finish the Multiline Editable Text Block Abstracted away the SetEditableText and GetEditableText functions from SMultiLineEditableText into "text marshallers" which handle converting text to and from a TextLayout. There are three types of text marshallers currently implemented: * Plain-text * Rich-text * Syntax highlighting Text marshallers also have the ability to inject formatting "live" (as the text changes), which is how the syntax highlighting marshaller works. Added the ability for a run to query the information it was created with. This allows the rich-text marshaller to reconstruct the original rich-text from the styled runs. To test this out, I've implemented a simple WYSIWYG rich-text editor demo with the following features: * Two SMultiLineEditableText widgets showing the same source text, one using a rich-text marshaller, and one using a syntax highlighter marshaller. * A toolbar to allow you to control the style of the selected text. * A button to allow you to insert a hyperlink into the document. The demo also makes use of the meta-data stored in the runs (the same information used to reconstruct the original rich-text) to read the text style of whatever is currently under the cursor, live, as the cursor is moved. Miscellaneous fixes: * Fixed an issue where deleting text that spanned multiple runs could leave the remaining runs in a bad state, leading to phantom text appearing (see FTextLayout::RemoveAt). * Fixed an issue where new-lines at the end of a rich-text document would be lost (see CalculateLineRanges). * Fixed an issue where \\r\\n line endings werenÆt being handled correctly by the rich-text parser (see CalculateLineRanges). * Fixed an issue where the rich-text parser would treat an empty run as plain-text (see FRichTextMarkupProcessing::ParseLineRanges). * Fixed an issue where inserting a line break when the cursor was at the end of a line containing multiple runs could sometimes fail (see FTextLayout::SplitLineAt). * Fixed mouse cursor movement not working correctly with a FSlateHyperlinkRun (see FSlateHyperlinkRun::GetTextIndexAt). ReviewedBy Justin.Sargent [CL 2246838 by Jamie Dale in Main branch]
2014-08-07 06:46:11 -04:00
const FRunInfo& FSlateWidgetRun::GetRunInfo() const
{
return RunInfo;
}
ERunAttributes FSlateWidgetRun::GetRunAttributes() const
{
return ERunAttributes::None;
}
FSlateWidgetRun::FSlateWidgetRun(const TSharedRef<class FTextLayout>& InTextLayout, const FRunInfo& InRunInfo, const TSharedRef< const FString >& InText, const FWidgetRunInfo& InWidgetInfo)
: TextLayout(InTextLayout)
, RunInfo( InRunInfo )
Added support for SMultiLineEditableText to edit rich-text TTP# 336464 - Editor: Finish the Multiline Editable Text Block Abstracted away the SetEditableText and GetEditableText functions from SMultiLineEditableText into "text marshallers" which handle converting text to and from a TextLayout. There are three types of text marshallers currently implemented: * Plain-text * Rich-text * Syntax highlighting Text marshallers also have the ability to inject formatting "live" (as the text changes), which is how the syntax highlighting marshaller works. Added the ability for a run to query the information it was created with. This allows the rich-text marshaller to reconstruct the original rich-text from the styled runs. To test this out, I've implemented a simple WYSIWYG rich-text editor demo with the following features: * Two SMultiLineEditableText widgets showing the same source text, one using a rich-text marshaller, and one using a syntax highlighter marshaller. * A toolbar to allow you to control the style of the selected text. * A button to allow you to insert a hyperlink into the document. The demo also makes use of the meta-data stored in the runs (the same information used to reconstruct the original rich-text) to read the text style of whatever is currently under the cursor, live, as the cursor is moved. Miscellaneous fixes: * Fixed an issue where deleting text that spanned multiple runs could leave the remaining runs in a bad state, leading to phantom text appearing (see FTextLayout::RemoveAt). * Fixed an issue where new-lines at the end of a rich-text document would be lost (see CalculateLineRanges). * Fixed an issue where \\r\\n line endings werenÆt being handled correctly by the rich-text parser (see CalculateLineRanges). * Fixed an issue where the rich-text parser would treat an empty run as plain-text (see FRichTextMarkupProcessing::ParseLineRanges). * Fixed an issue where inserting a line break when the cursor was at the end of a line containing multiple runs could sometimes fail (see FTextLayout::SplitLineAt). * Fixed mouse cursor movement not working correctly with a FSlateHyperlinkRun (see FSlateHyperlinkRun::GetTextIndexAt). ReviewedBy Justin.Sargent [CL 2246838 by Jamie Dale in Main branch]
2014-08-07 06:46:11 -04:00
, Text( InText )
, Range( 0, Text->Len() )
, Info( InWidgetInfo )
, Children()
, WidgetSize()
{
Info.Widget->SlatePrepass();
WidgetSize = Info.Widget->GetDesiredSize();
Children.Add(Info.Widget);
}
FSlateWidgetRun::FSlateWidgetRun(const TSharedRef<class FTextLayout>& InTextLayout, const FRunInfo& InRunInfo, const TSharedRef< const FString >& InText, const FWidgetRunInfo& InWidgetInfo, const FTextRange& InRange)
: TextLayout(InTextLayout)
, RunInfo(InRunInfo)
Added support for SMultiLineEditableText to edit rich-text TTP# 336464 - Editor: Finish the Multiline Editable Text Block Abstracted away the SetEditableText and GetEditableText functions from SMultiLineEditableText into "text marshallers" which handle converting text to and from a TextLayout. There are three types of text marshallers currently implemented: * Plain-text * Rich-text * Syntax highlighting Text marshallers also have the ability to inject formatting "live" (as the text changes), which is how the syntax highlighting marshaller works. Added the ability for a run to query the information it was created with. This allows the rich-text marshaller to reconstruct the original rich-text from the styled runs. To test this out, I've implemented a simple WYSIWYG rich-text editor demo with the following features: * Two SMultiLineEditableText widgets showing the same source text, one using a rich-text marshaller, and one using a syntax highlighter marshaller. * A toolbar to allow you to control the style of the selected text. * A button to allow you to insert a hyperlink into the document. The demo also makes use of the meta-data stored in the runs (the same information used to reconstruct the original rich-text) to read the text style of whatever is currently under the cursor, live, as the cursor is moved. Miscellaneous fixes: * Fixed an issue where deleting text that spanned multiple runs could leave the remaining runs in a bad state, leading to phantom text appearing (see FTextLayout::RemoveAt). * Fixed an issue where new-lines at the end of a rich-text document would be lost (see CalculateLineRanges). * Fixed an issue where \\r\\n line endings werenÆt being handled correctly by the rich-text parser (see CalculateLineRanges). * Fixed an issue where the rich-text parser would treat an empty run as plain-text (see FRichTextMarkupProcessing::ParseLineRanges). * Fixed an issue where inserting a line break when the cursor was at the end of a line containing multiple runs could sometimes fail (see FTextLayout::SplitLineAt). * Fixed mouse cursor movement not working correctly with a FSlateHyperlinkRun (see FSlateHyperlinkRun::GetTextIndexAt). ReviewedBy Justin.Sargent [CL 2246838 by Jamie Dale in Main branch]
2014-08-07 06:46:11 -04:00
, Text( InText )
, Range( InRange )
, Info( InWidgetInfo )
, Children()
, WidgetSize()
{
Info.Widget->SlatePrepass();
WidgetSize = Info.Widget->GetDesiredSize();
Children.Add( Info.Widget );
}
FSlateWidgetRun::FSlateWidgetRun( const FSlateWidgetRun& Run )
: TextLayout(Run.TextLayout)
, RunInfo(Run.RunInfo)
Added support for SMultiLineEditableText to edit rich-text TTP# 336464 - Editor: Finish the Multiline Editable Text Block Abstracted away the SetEditableText and GetEditableText functions from SMultiLineEditableText into "text marshallers" which handle converting text to and from a TextLayout. There are three types of text marshallers currently implemented: * Plain-text * Rich-text * Syntax highlighting Text marshallers also have the ability to inject formatting "live" (as the text changes), which is how the syntax highlighting marshaller works. Added the ability for a run to query the information it was created with. This allows the rich-text marshaller to reconstruct the original rich-text from the styled runs. To test this out, I've implemented a simple WYSIWYG rich-text editor demo with the following features: * Two SMultiLineEditableText widgets showing the same source text, one using a rich-text marshaller, and one using a syntax highlighter marshaller. * A toolbar to allow you to control the style of the selected text. * A button to allow you to insert a hyperlink into the document. The demo also makes use of the meta-data stored in the runs (the same information used to reconstruct the original rich-text) to read the text style of whatever is currently under the cursor, live, as the cursor is moved. Miscellaneous fixes: * Fixed an issue where deleting text that spanned multiple runs could leave the remaining runs in a bad state, leading to phantom text appearing (see FTextLayout::RemoveAt). * Fixed an issue where new-lines at the end of a rich-text document would be lost (see CalculateLineRanges). * Fixed an issue where \\r\\n line endings werenÆt being handled correctly by the rich-text parser (see CalculateLineRanges). * Fixed an issue where the rich-text parser would treat an empty run as plain-text (see FRichTextMarkupProcessing::ParseLineRanges). * Fixed an issue where inserting a line break when the cursor was at the end of a line containing multiple runs could sometimes fail (see FTextLayout::SplitLineAt). * Fixed mouse cursor movement not working correctly with a FSlateHyperlinkRun (see FSlateHyperlinkRun::GetTextIndexAt). ReviewedBy Justin.Sargent [CL 2246838 by Jamie Dale in Main branch]
2014-08-07 06:46:11 -04:00
, Text( Run.Text )
, Range( Run.Range )
, Info( Run.Info )
, Children()
, WidgetSize(Run.WidgetSize)
{
}
#endif //WITH_FANCY_TEXT