Working on new root canvas stuff

This commit is contained in:
2026-04-21 21:26:06 -04:00
parent ec983951fe
commit 8e5d43fd24
13 changed files with 492 additions and 333 deletions

View File

@@ -3,9 +3,12 @@
#include "CoreMinimal.h"
#include "Engine/HitResult.h"
#include "GameFramework/PlayerController.h"
#include "InputModeRequest.h"
#include "UObject/ObjectKey.h"
#include "PlayerControllerBase.generated.h"
class UlxRootCanvasPanel;
class UWidget;
UCLASS(BlueprintType, Blueprintable)
class INTEGRATION_API AlxPlayerControllerBase : public APlayerController
{
@@ -55,9 +58,6 @@ private:
public:
// Input stack overrides: unsorted, append-on-push.
virtual void PushInputComponent(UInputComponent* InInputComponent) override;
virtual bool PopInputComponent(UInputComponent* InInputComponent) override;
virtual void BuildInputStack(TArray<UInputComponent*>& InputStack) override;
// Read UUserWidget::InputComponent via reflection. The field is
@@ -65,12 +65,14 @@ public:
// FProperty so we always see the current value without caching it.
static class UInputComponent* GetWidgetInputComponent(class UUserWidget *Widget);
// Blueprint-facing entry point. Looks like a method on UUserWidget
// (thanks to DefaultToSelf + HideSelfPin): the widget self-binds,
// we find its owning PlayerController, and register the request.
UFUNCTION(BlueprintCallable, Category = "Luprex|Input Mode",
meta = (DefaultToSelf = "Widget", HideSelfPin = "true", EnableInputComponent = "true"))
static void WidgetRequestInputMode(class UUserWidget *Widget, bool ShowPointer, bool BlockInput, class UWidget *Focus, bool EnableInputComponent);
// Restore focus back to the window that is in front, if it wants focus.
UFUNCTION(BlueprintCallable, meta = (WorldContext = "Context"), Category = "Luprex|Root Canvas")
static void RestoreFocusToFrontWidget(const UObject *Context);
// Add a widget to the root canvas at ZOrder 0 with default slot flags.
UFUNCTION(BlueprintCallable, Category = "Luprex|Root Canvas",
meta = (DefaultToSelf = "Widget", HideSelfPin = "true"))
static void AddWidgetToRoot(class UUserWidget *Widget);
// Get the player controller, cast to AlxPlayerControllerBase.
static AlxPlayerControllerBase *FromContext(const UObject *Context);
@@ -78,13 +80,19 @@ public:
UPROPERTY()
FHitResult CurrentLookAt;
// Input mode requests - see InputModeRequest.h for an explanation.
UPROPERTY()
FlxInputModeRequests InputModeRequests;
// The last widget whose focus request was granted.
TObjectKey<UWidget> LastWidgetGrantedFocus;
// The last input mode request whose focus request was granted.
// The single top-level UUserWidget added to the viewport. All
// top-level UI widgets are children of RootCanvas inside it.
UPROPERTY()
int32 LastRequestGrantedFocus = 0;
UUserWidget *RootWidget = nullptr;
// The root canvas panel inside RootWidget. Children of this
// canvas are the top-level widgets; their slots carry both
// layout and input-mode configuration.
UPROPERTY()
UlxRootCanvasPanel *RootCanvas = nullptr;
// The viewport client uses this to notify us that the user
// clicked on a focusable widget.