Integrating live coding feature (aka Live++) into UE4.
Allows fast iteration of C++ changes without restarting the application. To use, select the "Live Coding (Experimental)" mode from the drop down menu next to the editor's compile button, or type "LiveCoding" into the console for a monolithic build. Press Ctrl+Alt+F11 to find changes and compile.
Changes vs standalone Live++ version:
* UBT is used to execute builds. This allows standard UE4 adaptive unity mode, allows us to reuse object files when we do regular builds, supports using any build executor allowed by UBT (XGE, SNDBS, etc..).
* Adding new source files is supported.
* Custom visualizer for FNames is supported via a weakly linked symbol in a static library (Engine/Extras/NatvisHelpers).
* Settings are exposed in the editor's project settings dialog.
* Standalone application has been rewritten as a Slate app ("LiveCodingConsole"). There is an additional option to start the program as hidden, where it will not be visible until Ctrl+Alt+F11 is hit. Similarly, closing the window will hide it instead of closing the application.
* Does not require a standalone licensed version of Live++.
Known issues:
* Does not currently support class layout changes / object reinstancing
#rb none
[FYI] Marc.Audy, Stefan.Boberg, Nick.Penwarden
#jira
#ROBOMERGE-SOURCE: CL 5304722 in //UE4/Release-4.22/...
#ROBOMERGE-BOT: RELEASE (Release-4.22 -> Main)
[CL 5309051 by ben marsh in Main branch]
2019-03-05 18:49:25 -05:00
|
|
|
// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#include "SLogWidget.h"
|
|
|
|
|
#include "Framework/Text/SlateTextRun.h"
|
|
|
|
|
#include "LiveCodingConsoleStyle.h"
|
|
|
|
|
#include "SlateOptMacros.h"
|
|
|
|
|
|
|
|
|
|
BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION
|
|
|
|
|
|
|
|
|
|
#define LOCTEXT_NAMESPACE "LiveCoding"
|
|
|
|
|
|
|
|
|
|
//// FLogWidgetTextLayoutMarshaller ////
|
|
|
|
|
|
|
|
|
|
FLogWidgetTextLayoutMarshaller::FLogWidgetTextLayoutMarshaller()
|
|
|
|
|
: TextLayout(nullptr)
|
|
|
|
|
{
|
|
|
|
|
DefaultStyle = FTextBlockStyle()
|
|
|
|
|
.SetFont( FCoreStyle::GetDefaultFontStyle( "Mono", 9 ) )
|
|
|
|
|
.SetColorAndOpacity( FLinearColor::White )
|
|
|
|
|
.SetSelectedBackgroundColor( FLinearColor(0.9f, 0.9f, 0.9f) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FLogWidgetTextLayoutMarshaller::~FLogWidgetTextLayoutMarshaller()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FLogWidgetTextLayoutMarshaller::SetText(const FString& SourceString, FTextLayout& TargetTextLayout)
|
|
|
|
|
{
|
|
|
|
|
TextLayout = &TargetTextLayout;
|
|
|
|
|
|
|
|
|
|
for(const TSharedRef<FString>& Line : Lines)
|
|
|
|
|
{
|
|
|
|
|
TextLayout->AddLine(FSlateTextLayout::FNewLineData(Line, TArray<TSharedRef<IRun>>()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FLogWidgetTextLayoutMarshaller::GetText(FString& TargetString, const FTextLayout& SourceTextLayout)
|
|
|
|
|
{
|
|
|
|
|
SourceTextLayout.GetAsText(TargetString);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FLogWidgetTextLayoutMarshaller::Clear()
|
|
|
|
|
{
|
|
|
|
|
Lines.Empty();
|
|
|
|
|
MakeDirty();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FLogWidgetTextLayoutMarshaller::AppendLine(const FSlateColor& Color, const FString& Line)
|
|
|
|
|
{
|
|
|
|
|
TSharedRef<FString> NewLine = MakeShared<FString>(Line);
|
|
|
|
|
Lines.Add(NewLine);
|
|
|
|
|
|
|
|
|
|
if(TextLayout)
|
|
|
|
|
{
|
|
|
|
|
// Remove the "default" line that's added for an empty text box.
|
|
|
|
|
if(Lines.Num() == 1)
|
|
|
|
|
{
|
|
|
|
|
TextLayout->ClearLines();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FTextBlockStyle Style = DefaultStyle;
|
|
|
|
|
Style.ColorAndOpacity = Color;
|
|
|
|
|
|
|
|
|
|
TArray<TSharedRef<IRun>> Runs;
|
|
|
|
|
Runs.Add(FSlateTextRun::Create(FRunInfo(), NewLine, Style));
|
|
|
|
|
TextLayout->AddLine(FSlateTextLayout::FNewLineData(NewLine, Runs));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int32 FLogWidgetTextLayoutMarshaller::GetNumLines() const
|
|
|
|
|
{
|
|
|
|
|
return Lines.Num();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//// SLogWidget ////
|
|
|
|
|
|
|
|
|
|
SLogWidget::SLogWidget()
|
2019-04-19 16:04:27 -04:00
|
|
|
: bIsUserScrolledX(false)
|
|
|
|
|
, bIsUserScrolledY(false)
|
Integrating live coding feature (aka Live++) into UE4.
Allows fast iteration of C++ changes without restarting the application. To use, select the "Live Coding (Experimental)" mode from the drop down menu next to the editor's compile button, or type "LiveCoding" into the console for a monolithic build. Press Ctrl+Alt+F11 to find changes and compile.
Changes vs standalone Live++ version:
* UBT is used to execute builds. This allows standard UE4 adaptive unity mode, allows us to reuse object files when we do regular builds, supports using any build executor allowed by UBT (XGE, SNDBS, etc..).
* Adding new source files is supported.
* Custom visualizer for FNames is supported via a weakly linked symbol in a static library (Engine/Extras/NatvisHelpers).
* Settings are exposed in the editor's project settings dialog.
* Standalone application has been rewritten as a Slate app ("LiveCodingConsole"). There is an additional option to start the program as hidden, where it will not be visible until Ctrl+Alt+F11 is hit. Similarly, closing the window will hide it instead of closing the application.
* Does not require a standalone licensed version of Live++.
Known issues:
* Does not currently support class layout changes / object reinstancing
#rb none
[FYI] Marc.Audy, Stefan.Boberg, Nick.Penwarden
#jira
#ROBOMERGE-SOURCE: CL 5304722 in //UE4/Release-4.22/...
#ROBOMERGE-BOT: RELEASE (Release-4.22 -> Main)
[CL 5309051 by ben marsh in Main branch]
2019-03-05 18:49:25 -05:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SLogWidget::~SLogWidget()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SLogWidget::Construct(const FArguments& InArgs)
|
|
|
|
|
{
|
|
|
|
|
MessagesTextMarshaller = MakeShared<FLogWidgetTextLayoutMarshaller>();
|
|
|
|
|
|
|
|
|
|
ChildSlot
|
|
|
|
|
[
|
2019-04-19 16:04:27 -04:00
|
|
|
SNew(SBorder)
|
|
|
|
|
[
|
|
|
|
|
SAssignNew(MessagesTextBox, SMultiLineEditableTextBox)
|
Integrating live coding feature (aka Live++) into UE4.
Allows fast iteration of C++ changes without restarting the application. To use, select the "Live Coding (Experimental)" mode from the drop down menu next to the editor's compile button, or type "LiveCoding" into the console for a monolithic build. Press Ctrl+Alt+F11 to find changes and compile.
Changes vs standalone Live++ version:
* UBT is used to execute builds. This allows standard UE4 adaptive unity mode, allows us to reuse object files when we do regular builds, supports using any build executor allowed by UBT (XGE, SNDBS, etc..).
* Adding new source files is supported.
* Custom visualizer for FNames is supported via a weakly linked symbol in a static library (Engine/Extras/NatvisHelpers).
* Settings are exposed in the editor's project settings dialog.
* Standalone application has been rewritten as a Slate app ("LiveCodingConsole"). There is an additional option to start the program as hidden, where it will not be visible until Ctrl+Alt+F11 is hit. Similarly, closing the window will hide it instead of closing the application.
* Does not require a standalone licensed version of Live++.
Known issues:
* Does not currently support class layout changes / object reinstancing
#rb none
[FYI] Marc.Audy, Stefan.Boberg, Nick.Penwarden
#jira
#ROBOMERGE-SOURCE: CL 5304722 in //UE4/Release-4.22/...
#ROBOMERGE-BOT: RELEASE (Release-4.22 -> Main)
[CL 5309051 by ben marsh in Main branch]
2019-03-05 18:49:25 -05:00
|
|
|
.Style(FLiveCodingConsoleStyle::Get(), "Log.TextBox")
|
2019-04-19 16:04:27 -04:00
|
|
|
.Marshaller(MessagesTextMarshaller)
|
|
|
|
|
.IsReadOnly(true)
|
|
|
|
|
.AlwaysShowScrollbars(true)
|
|
|
|
|
.OnHScrollBarUserScrolled(this, &SLogWidget::OnScrollX)
|
|
|
|
|
.OnVScrollBarUserScrolled(this, &SLogWidget::OnScrollY)
|
|
|
|
|
]
|
|
|
|
|
];
|
Integrating live coding feature (aka Live++) into UE4.
Allows fast iteration of C++ changes without restarting the application. To use, select the "Live Coding (Experimental)" mode from the drop down menu next to the editor's compile button, or type "LiveCoding" into the console for a monolithic build. Press Ctrl+Alt+F11 to find changes and compile.
Changes vs standalone Live++ version:
* UBT is used to execute builds. This allows standard UE4 adaptive unity mode, allows us to reuse object files when we do regular builds, supports using any build executor allowed by UBT (XGE, SNDBS, etc..).
* Adding new source files is supported.
* Custom visualizer for FNames is supported via a weakly linked symbol in a static library (Engine/Extras/NatvisHelpers).
* Settings are exposed in the editor's project settings dialog.
* Standalone application has been rewritten as a Slate app ("LiveCodingConsole"). There is an additional option to start the program as hidden, where it will not be visible until Ctrl+Alt+F11 is hit. Similarly, closing the window will hide it instead of closing the application.
* Does not require a standalone licensed version of Live++.
Known issues:
* Does not currently support class layout changes / object reinstancing
#rb none
[FYI] Marc.Audy, Stefan.Boberg, Nick.Penwarden
#jira
#ROBOMERGE-SOURCE: CL 5304722 in //UE4/Release-4.22/...
#ROBOMERGE-BOT: RELEASE (Release-4.22 -> Main)
[CL 5309051 by ben marsh in Main branch]
2019-03-05 18:49:25 -05:00
|
|
|
|
|
|
|
|
RegisterActiveTimer(0.03f, FWidgetActiveTimerDelegate::CreateSP(this, &SLogWidget::OnTimerElapsed));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SLogWidget::Clear()
|
|
|
|
|
{
|
|
|
|
|
MessagesTextMarshaller->Clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SLogWidget::ScrollToEnd()
|
|
|
|
|
{
|
|
|
|
|
MessagesTextBox->ScrollTo(FTextLocation(MessagesTextMarshaller->GetNumLines() - 1));
|
2019-04-19 16:04:27 -04:00
|
|
|
bIsUserScrolledX = false;
|
|
|
|
|
bIsUserScrolledY = false;
|
Integrating live coding feature (aka Live++) into UE4.
Allows fast iteration of C++ changes without restarting the application. To use, select the "Live Coding (Experimental)" mode from the drop down menu next to the editor's compile button, or type "LiveCoding" into the console for a monolithic build. Press Ctrl+Alt+F11 to find changes and compile.
Changes vs standalone Live++ version:
* UBT is used to execute builds. This allows standard UE4 adaptive unity mode, allows us to reuse object files when we do regular builds, supports using any build executor allowed by UBT (XGE, SNDBS, etc..).
* Adding new source files is supported.
* Custom visualizer for FNames is supported via a weakly linked symbol in a static library (Engine/Extras/NatvisHelpers).
* Settings are exposed in the editor's project settings dialog.
* Standalone application has been rewritten as a Slate app ("LiveCodingConsole"). There is an additional option to start the program as hidden, where it will not be visible until Ctrl+Alt+F11 is hit. Similarly, closing the window will hide it instead of closing the application.
* Does not require a standalone licensed version of Live++.
Known issues:
* Does not currently support class layout changes / object reinstancing
#rb none
[FYI] Marc.Audy, Stefan.Boberg, Nick.Penwarden
#jira
#ROBOMERGE-SOURCE: CL 5304722 in //UE4/Release-4.22/...
#ROBOMERGE-BOT: RELEASE (Release-4.22 -> Main)
[CL 5309051 by ben marsh in Main branch]
2019-03-05 18:49:25 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SLogWidget::AppendLine(const FSlateColor& Color, const FString& Text)
|
|
|
|
|
{
|
|
|
|
|
FLine Line;
|
|
|
|
|
Line.Color = Color;
|
|
|
|
|
Line.Text = Text;
|
|
|
|
|
|
|
|
|
|
FScopeLock Lock(&CriticalSection);
|
|
|
|
|
QueuedLines.Add(MoveTemp(Line));
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-19 16:04:27 -04:00
|
|
|
void SLogWidget::OnScrollX(float ScrollOffset)
|
Integrating live coding feature (aka Live++) into UE4.
Allows fast iteration of C++ changes without restarting the application. To use, select the "Live Coding (Experimental)" mode from the drop down menu next to the editor's compile button, or type "LiveCoding" into the console for a monolithic build. Press Ctrl+Alt+F11 to find changes and compile.
Changes vs standalone Live++ version:
* UBT is used to execute builds. This allows standard UE4 adaptive unity mode, allows us to reuse object files when we do regular builds, supports using any build executor allowed by UBT (XGE, SNDBS, etc..).
* Adding new source files is supported.
* Custom visualizer for FNames is supported via a weakly linked symbol in a static library (Engine/Extras/NatvisHelpers).
* Settings are exposed in the editor's project settings dialog.
* Standalone application has been rewritten as a Slate app ("LiveCodingConsole"). There is an additional option to start the program as hidden, where it will not be visible until Ctrl+Alt+F11 is hit. Similarly, closing the window will hide it instead of closing the application.
* Does not require a standalone licensed version of Live++.
Known issues:
* Does not currently support class layout changes / object reinstancing
#rb none
[FYI] Marc.Audy, Stefan.Boberg, Nick.Penwarden
#jira
#ROBOMERGE-SOURCE: CL 5304722 in //UE4/Release-4.22/...
#ROBOMERGE-BOT: RELEASE (Release-4.22 -> Main)
[CL 5309051 by ben marsh in Main branch]
2019-03-05 18:49:25 -05:00
|
|
|
{
|
2019-04-19 16:04:27 -04:00
|
|
|
bIsUserScrolledX = ScrollOffset > 0.0 && !FMath::IsNearlyEqual(ScrollOffset, 0.0f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SLogWidget::OnScrollY(float ScrollOffset)
|
|
|
|
|
{
|
|
|
|
|
bIsUserScrolledY = ScrollOffset < 1.0 && !FMath::IsNearlyEqual(ScrollOffset, 1.0f);
|
Integrating live coding feature (aka Live++) into UE4.
Allows fast iteration of C++ changes without restarting the application. To use, select the "Live Coding (Experimental)" mode from the drop down menu next to the editor's compile button, or type "LiveCoding" into the console for a monolithic build. Press Ctrl+Alt+F11 to find changes and compile.
Changes vs standalone Live++ version:
* UBT is used to execute builds. This allows standard UE4 adaptive unity mode, allows us to reuse object files when we do regular builds, supports using any build executor allowed by UBT (XGE, SNDBS, etc..).
* Adding new source files is supported.
* Custom visualizer for FNames is supported via a weakly linked symbol in a static library (Engine/Extras/NatvisHelpers).
* Settings are exposed in the editor's project settings dialog.
* Standalone application has been rewritten as a Slate app ("LiveCodingConsole"). There is an additional option to start the program as hidden, where it will not be visible until Ctrl+Alt+F11 is hit. Similarly, closing the window will hide it instead of closing the application.
* Does not require a standalone licensed version of Live++.
Known issues:
* Does not currently support class layout changes / object reinstancing
#rb none
[FYI] Marc.Audy, Stefan.Boberg, Nick.Penwarden
#jira
#ROBOMERGE-SOURCE: CL 5304722 in //UE4/Release-4.22/...
#ROBOMERGE-BOT: RELEASE (Release-4.22 -> Main)
[CL 5309051 by ben marsh in Main branch]
2019-03-05 18:49:25 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EActiveTimerReturnType SLogWidget::OnTimerElapsed(double CurrentTime, float DeltaTime)
|
|
|
|
|
{
|
|
|
|
|
FScopeLock Lock(&CriticalSection);
|
|
|
|
|
for(const FLine& QueuedLine : QueuedLines)
|
|
|
|
|
{
|
|
|
|
|
MessagesTextMarshaller->AppendLine(QueuedLine.Color, QueuedLine.Text);
|
|
|
|
|
}
|
2019-04-19 16:04:27 -04:00
|
|
|
if(!bIsUserScrolledX && !bIsUserScrolledY)
|
Integrating live coding feature (aka Live++) into UE4.
Allows fast iteration of C++ changes without restarting the application. To use, select the "Live Coding (Experimental)" mode from the drop down menu next to the editor's compile button, or type "LiveCoding" into the console for a monolithic build. Press Ctrl+Alt+F11 to find changes and compile.
Changes vs standalone Live++ version:
* UBT is used to execute builds. This allows standard UE4 adaptive unity mode, allows us to reuse object files when we do regular builds, supports using any build executor allowed by UBT (XGE, SNDBS, etc..).
* Adding new source files is supported.
* Custom visualizer for FNames is supported via a weakly linked symbol in a static library (Engine/Extras/NatvisHelpers).
* Settings are exposed in the editor's project settings dialog.
* Standalone application has been rewritten as a Slate app ("LiveCodingConsole"). There is an additional option to start the program as hidden, where it will not be visible until Ctrl+Alt+F11 is hit. Similarly, closing the window will hide it instead of closing the application.
* Does not require a standalone licensed version of Live++.
Known issues:
* Does not currently support class layout changes / object reinstancing
#rb none
[FYI] Marc.Audy, Stefan.Boberg, Nick.Penwarden
#jira
#ROBOMERGE-SOURCE: CL 5304722 in //UE4/Release-4.22/...
#ROBOMERGE-BOT: RELEASE (Release-4.22 -> Main)
[CL 5309051 by ben marsh in Main branch]
2019-03-05 18:49:25 -05:00
|
|
|
{
|
|
|
|
|
ScrollToEnd();
|
|
|
|
|
}
|
|
|
|
|
QueuedLines.Empty();
|
|
|
|
|
return EActiveTimerReturnType::Continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#undef LOCTEXT_NAMESPACE
|
|
|
|
|
|
|
|
|
|
END_SLATE_FUNCTION_BUILD_OPTIMIZATION
|