You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
~added isEmpty property to details categories for showing stub categories ~styling support to show them properly #jira UE-195683 #rb ronald.koppers [CL 28073151 by karen jirak in ue5-main branch]
191 lines
5.4 KiB
C++
191 lines
5.4 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
#include "DetailsViewStyle.h"
|
|
|
|
FDetailsViewStyle::FDetailsViewStyle()
|
|
{
|
|
}
|
|
|
|
FDetailsViewStyle::FDetailsViewStyle(
|
|
const FDetailsViewStyleKey& InKey,
|
|
float InTopCategoryPadding) :
|
|
FSlateWidgetStyle(),
|
|
Key(InKey),
|
|
TopCategoryPadding(InTopCategoryPadding)
|
|
{
|
|
Initialize(Key);
|
|
}
|
|
|
|
FMargin FDetailsViewStyle::GetTablePadding(bool bIsScrollBarNeeded) const
|
|
{
|
|
if (bIsScrollBarNeeded)
|
|
{
|
|
return TablePaddingWithScrollbar;
|
|
}
|
|
return TablePaddingWithNoScrollbar;
|
|
}
|
|
|
|
void FDetailsViewStyle::Initialize(const FDetailsViewStyle* Style)
|
|
{
|
|
if ( Style )
|
|
{
|
|
Key = Style->Key;
|
|
TopCategoryPadding = Style->TopCategoryPadding;
|
|
TablePaddingWithScrollbar = Style->TablePaddingWithScrollbar;
|
|
TablePaddingWithNoScrollbar = Style->TablePaddingWithNoScrollbar;
|
|
}
|
|
}
|
|
|
|
FDetailsViewStyle::FDetailsViewStyle(FDetailsViewStyleKey& InKey) :
|
|
FSlateWidgetStyle(),
|
|
Key(InKey)
|
|
{
|
|
Initialize(Key);
|
|
}
|
|
|
|
void FDetailsViewStyle::Initialize(FDetailsViewStyleKey& InKey)
|
|
{
|
|
if (const FDetailsViewStyle** Style = StyleKeyToStyleTemplateMap.Find(InKey.GetName()))
|
|
{
|
|
Initialize( *Style );
|
|
}
|
|
}
|
|
|
|
FDetailsViewStyle::FDetailsViewStyle(FDetailsViewStyle& InStyle) :
|
|
FDetailsViewStyle(InStyle.Key, InStyle.TopCategoryPadding )
|
|
{
|
|
}
|
|
|
|
FDetailsViewStyle::FDetailsViewStyle(const FDetailsViewStyle& InStyle) :
|
|
FDetailsViewStyle(InStyle.Key, InStyle.TopCategoryPadding )
|
|
{
|
|
}
|
|
|
|
FMargin FDetailsViewStyle::GetOuterCategoryRowPadding() const
|
|
{
|
|
return FMargin(0, TopCategoryPadding, 0, 1);
|
|
}
|
|
|
|
FMargin FDetailsViewStyle::GetRowPadding(bool bIsOuterCategory) const
|
|
{
|
|
return bIsOuterCategory ?
|
|
FMargin(0, TopCategoryPadding, 0, 1) :
|
|
FMargin(0, 0, 0, 1);
|
|
}
|
|
|
|
bool FDetailsViewStyle::operator==(FDetailsViewStyle& OtherLayoutType) const
|
|
{
|
|
return Key == OtherLayoutType.Key;
|
|
}
|
|
|
|
FDetailsViewStyle& FDetailsViewStyle::operator=(FDetailsViewStyleKey& OtherLayoutTypeKey)
|
|
{
|
|
if (const FDetailsViewStyle* Style = GetStyle(OtherLayoutTypeKey))
|
|
{
|
|
Initialize(OtherLayoutTypeKey, Style->TopCategoryPadding);
|
|
}
|
|
return *this;
|
|
}
|
|
|
|
const FName FDetailsViewStyle::GetTypeName() const
|
|
{
|
|
return Key.GetName();
|
|
}
|
|
|
|
const FSlateBrush* FDetailsViewStyle::GetBackgroundImageForCategoryRow(
|
|
const bool bShowBorder,
|
|
const bool bIsInnerCategory,
|
|
const bool bIsCategoryExpanded) const
|
|
{
|
|
static const FSlateBrush* InnerCategoryRowBrush = FAppStyle::Get().GetBrush("DetailsView.CategoryMiddle");
|
|
static const FSlateBrush* ClassicStyleTopLevelCategoryRowBrush = FAppStyle::Get().GetBrush("DetailsView.CategoryTop");
|
|
static const FSlateBrush* CardStyleTopLevelCategoryCollapsedScrollBarNeededRowBrush = FAppStyle::Get().GetBrush("DetailsView.CardHeaderRounded");
|
|
static const FSlateBrush* CardStyleTopLevelCategoryExpandedScrollBarNeededRowBrush = FAppStyle::Get().GetBrush("DetailsView.CardHeaderTopRounded");
|
|
|
|
if (bShowBorder)
|
|
{
|
|
if (bIsInnerCategory)
|
|
{
|
|
return InnerCategoryRowBrush;
|
|
}
|
|
|
|
const bool bIsCardStyle = Key == FDetailsViewStyleKeys::Card();
|
|
|
|
if (!bIsCardStyle)
|
|
{
|
|
return ClassicStyleTopLevelCategoryRowBrush;
|
|
}
|
|
if (!bIsCategoryExpanded)
|
|
{
|
|
return CardStyleTopLevelCategoryCollapsedScrollBarNeededRowBrush;
|
|
}
|
|
return CardStyleTopLevelCategoryExpandedScrollBarNeededRowBrush;
|
|
}
|
|
|
|
return nullptr;
|
|
}
|
|
|
|
void FDetailsViewStyle::InitializeDetailsViewStyles()
|
|
{
|
|
static FDetailsViewStyle CardStyle{FDetailsViewStyleKeys::Card(), 8.0f};
|
|
CardStyle.TablePaddingWithScrollbar = FMargin(8, 0, 20, 8);
|
|
CardStyle.TablePaddingWithNoScrollbar = FMargin(8, 0, 8, 8);
|
|
StyleKeyToStyleTemplateMap.Add(FDetailsViewStyleKeys::Card().GetName(), &CardStyle);
|
|
|
|
static FDetailsViewStyle DefaultStyle{FDetailsViewStyleKeys::Default(), 0.0f };
|
|
StyleKeyToStyleTemplateMap.Add(FDetailsViewStyleKeys::Default().GetName(), &DefaultStyle);
|
|
|
|
static FDetailsViewStyle ClassicStyle{FDetailsViewStyleKeys::Classic(), 0.0f };
|
|
StyleKeyToStyleTemplateMap.Add(FDetailsViewStyleKeys::Classic().GetName(), &ClassicStyle);
|
|
}
|
|
|
|
const FSlateBrush* FDetailsViewStyle::GetBackgroundImageForScrollBarWell(
|
|
const bool bShowBorder,
|
|
const bool bIsInnerCategory,
|
|
const bool bIsCategoryExpanded,
|
|
const bool bIsScrollBarNeeded) const
|
|
{
|
|
static const FSlateBrush* InnerCategoryWellBrush = FAppStyle::Get().GetBrush("DetailsView.CategoryMiddle");
|
|
static const FSlateBrush* ClassicStyleTopLevelCategoryRowBrush = FAppStyle::Get().GetBrush("DetailsView.CategoryTop");
|
|
static const FSlateBrush* CardStyleCollapsedScrollBarNeededWellBrush = FAppStyle::Get().GetBrush("DetailsView.CardHeaderRightSideRounded");
|
|
static const FSlateBrush* CardStyleExpandedScrollBarNeededWellBrush = FAppStyle::Get().GetBrush("DetailsView.CardHeaderTopRightSideRounded");
|
|
|
|
if (bShowBorder)
|
|
{
|
|
if (bIsInnerCategory)
|
|
{
|
|
return InnerCategoryWellBrush;
|
|
}
|
|
const bool bIsCardStyle = this->Key == FDetailsViewStyleKeys::Card();
|
|
|
|
if (!bIsCardStyle)
|
|
{
|
|
return ClassicStyleTopLevelCategoryRowBrush;
|
|
}
|
|
if (!bIsCategoryExpanded){
|
|
return CardStyleCollapsedScrollBarNeededWellBrush;
|
|
}
|
|
return CardStyleExpandedScrollBarNeededWellBrush;
|
|
}
|
|
|
|
return nullptr;
|
|
}
|
|
|
|
void FDetailsViewStyle::Initialize(
|
|
FDetailsViewStyleKey& InKey,
|
|
const float InTopCategoryPadding)
|
|
{
|
|
Key = InKey;
|
|
TopCategoryPadding = InTopCategoryPadding;
|
|
}
|
|
|
|
const FDetailsViewStyle* FDetailsViewStyle::GetStyle(const FDetailsViewStyleKey& Key)
|
|
{
|
|
const FDetailsViewStyle** StylePtr = StyleKeyToStyleTemplateMap.Find(Key.GetName());
|
|
StylePtr = StylePtr ?
|
|
StylePtr :
|
|
StyleKeyToStyleTemplateMap.Find(FDetailsViewStyleKeys::Default().GetName());
|
|
|
|
return StylePtr ? *StylePtr : nullptr;
|
|
} |