Skip to content

Commit

Permalink
Example
Browse files Browse the repository at this point in the history
  • Loading branch information
benui-dev committed May 17, 2023
1 parent 43e9aec commit 608c1f6
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 1 deletion.
Binary file removed Content/WBP_Another.uasset
Binary file not shown.
Binary file added Content/WBP_ComplexExample.uasset
Binary file not shown.
Binary file added Content/WBP_ListExample.uasset
Binary file not shown.
21 changes: 21 additions & 0 deletions Source/SlateExample/Slate/ExampleComplex/ExampleComplexWidget.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include "ExampleComplexWidget.h"
#include "SExampleComplexWidget.h"

void UExampleComplexWidget::ReleaseSlateResources(bool bReleaseChildren)
{
Super::ReleaseSlateResources(bReleaseChildren);

MyExampleComplexWidget.Reset();
}

void UExampleComplexWidget::SynchronizeProperties()
{
Super::SynchronizeProperties();
}

TSharedRef<SWidget> UExampleComplexWidget::RebuildWidget()
{
MyExampleComplexWidget = SNew(SExampleComplexWidget);

return MyExampleComplexWidget.ToSharedRef();
}
22 changes: 22 additions & 0 deletions Source/SlateExample/Slate/ExampleComplex/ExampleComplexWidget.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#pragma once

#include "CoreMinimal.h"
#include "Components/Widget.h"
#include "ExampleComplexWidget.generated.h"

UCLASS()
class UExampleComplexWidget : public UWidget
{
private:
GENERATED_BODY()
public:
virtual void ReleaseSlateResources(bool bReleaseChildren) override;
virtual void SynchronizeProperties() override;

protected:
//~ Begin UWidget Interface
virtual TSharedRef<SWidget> RebuildWidget() override;
//~ End UWidget Interface

TSharedPtr<class SExampleComplexWidget> MyExampleComplexWidget;
};
46 changes: 46 additions & 0 deletions Source/SlateExample/Slate/ExampleComplex/SExampleComplexWidget.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include "SExampleComplexWidget.h"
#include "SlateOptMacros.h"
#include "Widgets/Images/SImage.h"

BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION

void SExampleComplexWidget::Construct(const FArguments& InArgs)
{
TSharedPtr<SHorizontalBox> Box = SNew(SHorizontalBox);
ChildSlot
[
Box.ToSharedRef()
];

auto& FirstSlot = Box->AddSlot()
.AutoWidth()
.Padding(5);

FirstSlot[ SNew(SImage) ];

/*
ChildSlot
[
SNew(SHorizontalBox)
+ SHorizontalBox::Slot()
.AutoWidth()
.Padding(5)
[
SNew(SImage)
]
+ SHorizontalBox::Slot()
.FillWidth(1.0f)
.Padding(10)
[
SNew(SBox)
.MinDesiredWidth(200)
[
SNew(SButton)
.Text(NSLOCTEXT("Ex","Click","Click me"))
]
]
];
*/
}

END_SLATE_FUNCTION_BUILD_OPTIMIZATION
18 changes: 18 additions & 0 deletions Source/SlateExample/Slate/ExampleComplex/SExampleComplexWidget.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#pragma once

#include "CoreMinimal.h"
#include "Widgets/SCompoundWidget.h"

class SExampleComplexWidget : public SCompoundWidget
{
public:
SLATE_BEGIN_ARGS(SExampleComplexWidget)
{} //
SLATE_END_ARGS()

void Construct(const FArguments& InArgs);
protected:
FSlateFontInfo Font;

TSharedPtr<STextBlock> TextBlock;
};
2 changes: 1 addition & 1 deletion Source/SlateExample/Slate/ExampleList/SExampleListWidget.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include "CoreMinimal.h"
#include "Widgets/SLeafWidget.h"
#include "Widgets/SCompoundWidget.h"

class SExampleListWidget : public SCompoundWidget
{
Expand Down

0 comments on commit 608c1f6

Please sign in to comment.