Files
UnrealEngineUWP/Engine/Source/Editor/IntroTutorials/Private/STutorialNavigation.cpp
Thomas Sarkanen 918ef98415 Tidied up Tutorials Browser
Tweaked padding and button styles so the layout is more consistent.
Add ability to display textures as icons in the browser (for categories and tutorials).

[CL 2292442 by Thomas Sarkanen in Main branch]
2014-09-10 12:30:30 -04:00

121 lines
3.2 KiB
C++

// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
#include "IntroTutorialsPrivatePCH.h"
#include "STutorialNavigation.h"
void STutorialNavigation::Construct(const FArguments& InArgs)
{
OnBackClicked = InArgs._OnBackClicked;
OnHomeClicked = InArgs._OnHomeClicked;
OnNextClicked = InArgs._OnNextClicked;
IsBackEnabled = InArgs._IsBackEnabled;
IsHomeEnabled = InArgs._IsHomeEnabled;
IsNextEnabled = InArgs._IsNextEnabled;
OnGetProgress = InArgs._OnGetProgress;
ChildSlot
[
SNew(SBorder)
.Padding(24.0f)
.BorderImage(FEditorStyle::GetBrush("Tutorials.Border"))
[
SNew(SVerticalBox)
+SVerticalBox::Slot()
.AutoHeight()
[
SNew(SHorizontalBox)
+SHorizontalBox::Slot()
.Padding(2.0f)
.AutoWidth()
[
SNew(SButton)
.OnClicked(this, &STutorialNavigation::OnBackButtonClicked)
.IsEnabled(InArgs._IsBackEnabled)
.ButtonStyle(&FEditorStyle::Get().GetWidgetStyle<FButtonStyle>("Tutorials.Content.Button"))
.Content()
[
SNew(SImage)
.Image(FEditorStyle::GetBrush("Tutorials.Back"))
.ColorAndOpacity(this, &STutorialNavigation::GetBackButtonColor)
]
]
+SHorizontalBox::Slot()
.Padding(2.0f)
.AutoWidth()
[
SNew(SButton)
.OnClicked(this, &STutorialNavigation::OnHomeButtonClicked)
.IsEnabled(InArgs._IsHomeEnabled)
.ButtonStyle(&FEditorStyle::Get().GetWidgetStyle<FButtonStyle>("Tutorials.Content.Button"))
.Content()
[
SNew(SImage)
.Image(FEditorStyle::GetBrush("Tutorials.Home"))
.ColorAndOpacity(this, &STutorialNavigation::GetHomeButtonColor)
]
]
+SHorizontalBox::Slot()
.Padding(2.0f)
.AutoWidth()
[
SNew(SButton)
.OnClicked(this, &STutorialNavigation::OnNextButtonClicked)
.IsEnabled(InArgs._IsNextEnabled)
.ButtonStyle(&FEditorStyle::Get().GetWidgetStyle<FButtonStyle>("Tutorials.Content.Button"))
.Content()
[
SNew(SImage)
.Image(FEditorStyle::GetBrush("Tutorials.Next"))
.ColorAndOpacity(this, &STutorialNavigation::GetNextButtonColor)
]
]
]
+SVerticalBox::Slot()
.AutoHeight()
.MaxHeight(4.0f)
.Padding(0.0f, 2.0f)
[
SNew(SProgressBar)
.Percent(this, &STutorialNavigation::GetPercentComplete)
]
]
];
}
FReply STutorialNavigation::OnBackButtonClicked()
{
OnBackClicked.ExecuteIfBound();
return FReply::Handled();
}
FSlateColor STutorialNavigation::GetBackButtonColor() const
{
return IsBackEnabled.Get() ? FLinearColor(0.0f, 0.0f, 0.0f, 1.0f) : FLinearColor(1.0f, 1.0f, 1.0f, 0.25f);
}
FReply STutorialNavigation::OnHomeButtonClicked()
{
OnHomeClicked.ExecuteIfBound();
return FReply::Handled();
}
FSlateColor STutorialNavigation::GetHomeButtonColor() const
{
return IsHomeEnabled.Get() ? FLinearColor(0.0f, 0.0f, 0.0f, 1.0f) : FLinearColor(1.0f, 1.0f, 1.0f, 0.25f);
}
FReply STutorialNavigation::OnNextButtonClicked()
{
OnNextClicked.ExecuteIfBound();
return FReply::Handled();
}
FSlateColor STutorialNavigation::GetNextButtonColor() const
{
return IsNextEnabled.Get() ? FLinearColor(0.0f, 0.0f, 0.0f, 1.0f) : FLinearColor(1.0f, 1.0f, 1.0f, 0.25f);
}
TOptional<float> STutorialNavigation::GetPercentComplete() const
{
return OnGetProgress.Get();
}