-
Notifications
You must be signed in to change notification settings - Fork 765
Expand file tree
/
Copy pathSPythonConsole.cpp
More file actions
136 lines (113 loc) · 3.44 KB
/
SPythonConsole.cpp
File metadata and controls
136 lines (113 loc) · 3.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
#include "SPythonConsole.h"
#include "PythonConsolePrivatePCH.h"
#include "PythonConsoleModule.h"
#include "SPythonLog.h"
namespace PythonConsoleDefs
{
// How many seconds to animate when console is summoned
static const float IntroAnimationDuration = 0.25f;
}
BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION
void SPythonConsole::Construct( const FArguments& InArgs, const EPythonConsoleStyle::Type InStyle, FPythonConsoleModule* PythonConsoleModule, const FPythonConsoleDelegates* PythonConsoleDelegates )
{
CurrentStyle = InStyle;
TSharedPtr<SPythonConsoleInputBox> ConsoleInputBox;
check( PythonConsoleModule != NULL );
ChildSlot
[
SNew( SVerticalBox )
+SVerticalBox::Slot()
.AutoHeight()
[
SNew( SVerticalBox )
.Visibility( this, &SPythonConsole::MakeVisibleIfLogIsShown )
+SVerticalBox::Slot()
.AutoHeight()
.Padding( 10.0f )
[
SNew(SBox)
.HeightOverride( 200.0f )
[
SNew( SBorder )
.BorderImage( FEditorStyle::GetBrush( "ToolPanel.GroupBorder" ) )
.ColorAndOpacity( this, &SPythonConsole::GetAnimatedColorAndOpacity )
.BorderBackgroundColor( this, &SPythonConsole::GetAnimatedSlateColor )
[
SNew( SSpacer )
]
]
]
]
+SVerticalBox::Slot()
.AutoHeight()
.Padding( 10.0f )
[
SNew(SBox)
.HeightOverride( 26.0f )
.HAlign( HAlign_Left )
[
SNew( SBorder )
.Padding( FMargin(2) )
.BorderImage( FEditorStyle::GetBrush( "PythonConsole.Background" ) )
.ColorAndOpacity( this, &SPythonConsole::GetAnimatedColorAndOpacity )
.BorderBackgroundColor( this, &SPythonConsole::GetAnimatedSlateColor )
[
SNew(SHorizontalBox)
+ SHorizontalBox::Slot()
.AutoWidth()
.Padding(3.0f)
.VAlign(VAlign_Center)
[
SNew(STextBlock)
.Text(NSLOCTEXT("Console", "ConsoleLabel", "Console"))
]
+ SHorizontalBox::Slot()
.Padding(5.0f, 2.0f)
.VAlign(VAlign_Center)
.MaxWidth(400.0f)
[
SAssignNew(ConsoleInputBox, SPythonConsoleInputBox)
.OnConsoleCommandExecuted(PythonConsoleDelegates->OnConsoleCommandExecuted)
]
]
]
]
];
EditableTextBox = ConsoleInputBox->GetEditableTextBox();
// Kick off intro animation
AnimCurveSequence = FCurveSequence();
AnimCurve = AnimCurveSequence.AddCurve( 0.0f, PythonConsoleDefs::IntroAnimationDuration, ECurveEaseFunction::QuadOut );
FlashCurve = AnimCurveSequence.AddCurve( PythonConsoleDefs::IntroAnimationDuration, .15f, ECurveEaseFunction::QuadInOut );
AnimCurveSequence.Play(this->AsShared());
}
END_SLATE_FUNCTION_BUILD_OPTIMIZATION
SPythonConsole::SPythonConsole()
: CurrentStyle( EPythonConsoleStyle::Compact )
{
}
void SPythonConsole::SetFocusToEditableText()
{
FSlateApplication::Get().SetKeyboardFocus( EditableTextBox.ToSharedRef(), EFocusCause::SetDirectly );
}
EVisibility SPythonConsole::MakeVisibleIfLogIsShown() const
{
return CurrentStyle == EPythonConsoleStyle::WithLog ? EVisibility::Visible : EVisibility::Collapsed;
}
FLinearColor SPythonConsole::GetAnimatedColorAndOpacity() const
{
return FLinearColor( 1.0f, 1.0f, 1.0f, AnimCurve.GetLerp() );
}
FSlateColor SPythonConsole::GetAnimatedSlateColor() const
{
return FSlateColor( GetAnimatedColorAndOpacity() );
}
FSlateColor SPythonConsole::GetFlashColor() const
{
float FlashAlpha = 1.0f - FlashCurve.GetLerp();
if (FlashAlpha == 1.0f)
{
FlashAlpha = 0.0f;
}
return FLinearColor(1,1,1,FlashAlpha);
}