mirror of
https://github.com/sinbad/StevesUEHelpers.git
synced 2025-02-23 17:45:23 +00:00
Return the slot from InsertChildWidgetAt
This commit is contained in:
parent
e8aec1fd24
commit
0ccd90cdd8
@ -11,9 +11,9 @@ void UStevesBPL::SetWidgetFocus(UWidget* Widget)
|
||||
SetWidgetFocusProperly(Widget);
|
||||
}
|
||||
|
||||
void UStevesBPL::InsertChildWidgetAt(UPanelWidget* Parent, UWidget* Child, int AtIndex)
|
||||
UPanelSlot* UStevesBPL::InsertChildWidgetAt(UPanelWidget* Parent, UWidget* Child, int AtIndex)
|
||||
{
|
||||
StevesUiHelpers::InsertChildWidgetAt(Parent, Child, AtIndex);
|
||||
return StevesUiHelpers::InsertChildWidgetAt(Parent, Child, AtIndex);
|
||||
}
|
||||
|
||||
FStevesBalancedRandomStream UStevesBPL::MakeBalancedRandomStream(int64 Seed)
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "StevesBalancedRandomStream.h"
|
||||
|
||||
#include "StevesMathHelpers.h"
|
||||
#include "Components/PanelSlot.h"
|
||||
#include "StevesBPL.generated.h"
|
||||
|
||||
class UPanelWidget;
|
||||
@ -51,9 +52,10 @@ public:
|
||||
* @param Parent The container widget
|
||||
* @param Child The child widget to add
|
||||
* @param AtIndex The index at which the new child should exist
|
||||
* @returns The slot the child was inserted at
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category="StevesUEHelpers|UI")
|
||||
static void InsertChildWidgetAt(UPanelWidget* Parent, UWidget* Child, int AtIndex = 0);
|
||||
static UPanelSlot* InsertChildWidgetAt(UPanelWidget* Parent, UWidget* Child, int AtIndex = 0);
|
||||
|
||||
UFUNCTION(BlueprintPure, Category="StevesUEHelpers|Random", meta=(NativeMakeFunc))
|
||||
static FStevesBalancedRandomStream MakeBalancedRandomStream(int64 Seed);
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include "Components/PanelWidget.h"
|
||||
|
||||
void StevesUiHelpers::InsertChildWidgetAt(UPanelWidget* Parent, UWidget* Child, int AtIndex)
|
||||
UPanelSlot* StevesUiHelpers::InsertChildWidgetAt(UPanelWidget* Parent, UWidget* Child, int AtIndex)
|
||||
{
|
||||
checkf(AtIndex <= Parent->GetChildrenCount(), TEXT("Insertion index %d is greater than child count"), AtIndex);
|
||||
|
||||
@ -10,7 +10,7 @@ void StevesUiHelpers::InsertChildWidgetAt(UPanelWidget* Parent, UWidget* Child,
|
||||
const int OrigCount = Parent->GetChildrenCount();
|
||||
if (OrigCount == AtIndex)
|
||||
{
|
||||
Parent->AddChild(Child);
|
||||
return Parent->AddChild(Child);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -32,12 +32,13 @@ void StevesUiHelpers::InsertChildWidgetAt(UPanelWidget* Parent, UWidget* Child,
|
||||
Parent->RemoveChildAt(i);
|
||||
}
|
||||
// insert item
|
||||
Parent->AddChild(Child);
|
||||
auto Slot = Parent->AddChild(Child);
|
||||
// add back previous, reverse order
|
||||
for (int i = WidgetsToReplaceReversed.Num() - 1; i >= 0; --i)
|
||||
{
|
||||
Parent->AddChild(WidgetsToReplaceReversed[i]);
|
||||
}
|
||||
return Slot;
|
||||
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@ public:
|
||||
* @param Parent The container widget
|
||||
* @param Child The child widget to add
|
||||
* @param AtIndex The index at which the new child should exist
|
||||
* @returns The slot the child was inserted at
|
||||
*/
|
||||
static void InsertChildWidgetAt(UPanelWidget* Parent, UWidget* Child, int AtIndex = 0);
|
||||
static UPanelSlot* InsertChildWidgetAt(UPanelWidget* Parent, UWidget* Child, int AtIndex = 0);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user