Skip to content

Commit

Permalink
Slate fixes for FAppStyle vs FEditorStyle in UE4 & other limitations
Browse files Browse the repository at this point in the history
  • Loading branch information
SRombautsU committed Nov 15, 2023
1 parent 1a5fd7d commit 31b1bb9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,21 @@ void SPlasticSourceControlBranchRow::Construct(const FArguments& InArgs, const T

TSharedRef<SWidget> SPlasticSourceControlBranchRow::GenerateWidgetForColumn(const FName& InColumnId)
{
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 1
const FSlateFontInfo FontInfo = bIsCurrentBranch ? FAppStyle::GetFontStyle("BoldFont") : FAppStyle::GetFontStyle("NormalFont");
#else
const FSlateFontInfo FontInfo = bIsCurrentBranch ? FEditorStyle::GetFontStyle("BoldFont") : FEditorStyle::GetFontStyle("NormalFont");
#endif

if (InColumnId == PlasticSourceControlBranchesListViewColumn::Name::Id())
{
return SNew(STextBlock)
.Text(FText::FromString(BranchToVisualize->Name))
.ToolTipText(FText::FromString(BranchToVisualize->Name))
.Margin(FMargin(6.f, 1.f))
#if ENGINE_MAJOR_VERSION >= 5
.OverflowPolicy(ETextOverflowPolicy::Ellipsis)
#endif
.Font(FontInfo)
.HighlightText(HighlightText);
}
Expand Down Expand Up @@ -95,7 +101,9 @@ TSharedRef<SWidget> SPlasticSourceControlBranchRow::GenerateWidgetForColumn(cons
.Text(FText::FromString(MoveTemp(CommentOnOneLine)))
.ToolTipText(FText::FromString(BranchToVisualize->Comment))
.Margin(FMargin(6.f, 1.f))
#if ENGINE_MAJOR_VERSION >= 5
.OverflowPolicy(ETextOverflowPolicy::Ellipsis)
#endif
.Font(FontInfo)
.HighlightText(HighlightText);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 3
#include "Misc/ComparisonUtility.h"
#endif
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 1
#include "Styling/AppStyle.h"
#else
#include "EditorStyleSet.h"
#endif
#include "Widgets/Input/SSearchBox.h"
#include "Widgets/Text/STextBlock.h"
#include "Widgets/Views/SHeaderRow.h"
Expand All @@ -36,7 +41,11 @@ void SPlasticSourceControlBranchesWidget::Construct(const FArguments& InArgs)
.AutoHeight()
[
SNew(SBorder)
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 1
.BorderImage(FAppStyle::GetBrush("ToolPanel.GroupBorder"))
#else
.BorderImage(FEditorStyle::GetBrush("DetailsView.CategoryBottom"))
#endif
.Padding(4)
[
SNew(SHorizontalBox)
Expand Down Expand Up @@ -71,7 +80,7 @@ void SPlasticSourceControlBranchesWidget::Construct(const FArguments& InArgs)
.AutoHeight()
[
SNew(SBox)
.Padding(0, 3)
.Padding(FMargin(0.f, 3.f))
[
SNew(SHorizontalBox)
+SHorizontalBox::Slot()
Expand Down Expand Up @@ -104,15 +113,23 @@ void SPlasticSourceControlBranchesWidget::Construct(const FArguments& InArgs)

TSharedRef<SWidget> SPlasticSourceControlBranchesWidget::CreateToolBar()
{
#if ENGINE_MAJOR_VERSION >= 5
FSlimHorizontalToolBarBuilder ToolBarBuilder(nullptr, FMultiBoxCustomization::None);
#else
FToolBarBuilder ToolBarBuilder(nullptr, FMultiBoxCustomization::None);
#endif

ToolBarBuilder.AddToolBarButton(
FUIAction(
FExecuteAction::CreateLambda([this]() { RequestBranchesRefresh(); })),
NAME_None,
LOCTEXT("SourceControl_RefreshButton", "Refresh"),
LOCTEXT("SourceControl_RefreshButton_Tooltip", "Refreshes branches from revision control provider."),
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 1
FSlateIcon(FAppStyle::GetAppStyleSetName(), "SourceControl.Actions.Refresh"));
#else
FSlateIcon(FEditorStyle::GetStyleSetName(), "SourceControl.Actions.Refresh"));
#endif

return ToolBarBuilder.MakeWidget();
}
Expand Down

0 comments on commit 31b1bb9

Please sign in to comment.