Support not hiding when superceded when embedding; if next item is not embedded this works to overlay

This commit is contained in:
Steve Streeting 2024-07-03 11:59:37 +01:00
parent e13e24643e
commit 46cd0c93c2
3 changed files with 11 additions and 7 deletions

View File

@ -52,12 +52,15 @@ void UMenuBase::RemovedFromStack(UMenuStack* Parent)
PreviousFocusWidget.Reset();
}
void UMenuBase::SupercededInStack()
void UMenuBase::SupercededInStack(UMenuBase* ByMenu)
{
SavePreviousFocus();
if (bEmbedInParentContainer)
RemoveFromParent();
{
if (bHideWhenSuperceded)
RemoveFromParent();
}
else
{
if (bHideWhenSuperceded)
@ -85,7 +88,7 @@ void UMenuBase::EmbedInParent()
void UMenuBase::Open(bool bIsRegain)
{
if (ParentStack.IsValid() && bEmbedInParentContainer)
if (ParentStack.IsValid() && bEmbedInParentContainer && bHideWhenSuperceded)
EmbedInParent();
else
AddToViewport();

View File

@ -204,7 +204,7 @@ void UMenuStack::PushMenuByObject(UMenuBase* NewMenu)
if (Menus.Num() > 0)
{
auto Top = Menus.Last();
Top->SupercededInStack();
Top->SupercededInStack(NewMenu);
// We keep this allocated, to restore later on back
}
Menus.Add(NewMenu);

View File

@ -39,8 +39,9 @@ protected:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Layout")
bool bEmbedInParentContainer = true;
/// Whether to hide this menu when it's superceded by another in the stack. This property is only relevant
/// when bEmbedInParentContainer = false, since only one menu can be embedded at once.
/// Whether to hide this menu when it's superceded by another in the stack.
/// If you set this to "false" when bEmbedInParentContainer=true, then the superceding menu should have its
/// own bEmbedInParentContainer set to false in order to overlay on top of this one.
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Behavior")
bool bHideWhenSuperceded = true;
@ -92,7 +93,7 @@ public:
void AddedToStack(UMenuStack* Parent);
void RemovedFromStack(UMenuStack* Parent);
void SupercededInStack();
void SupercededInStack(UMenuBase* ByMenu);
void RegainedFocusInStack();
void InputModeChanged(EInputMode OldMode, EInputMode NewMode);
};