InputModeRequests now use less-than operator to sort

This commit is contained in:
2026-04-21 04:24:35 -04:00
parent 9787522ef6
commit ec983951fe
2 changed files with 67 additions and 48 deletions

View File

@@ -34,10 +34,7 @@ struct FlxInputModeRequest
FlxInputModeRequest() = default;
bool operator == (const FlxInputModeRequest &Other) const;
// True if this request wants any high-priority resource:
// keyboard focus, the mouse pointer, or input blocking.
bool IsHighPrio() const { return Focus != nullptr || ShowPointer || BlockInput; }
bool operator < (const FlxInputModeRequest &Other) const;
UPROPERTY(BlueprintReadWrite)
UUserWidget* Widget = nullptr;
@@ -73,19 +70,14 @@ private:
int32 NextSequenceNumber = 0;
public:
using View = TArrayView<FlxInputModeRequest>;
// Get the requests array.
const TArray<FlxInputModeRequest> &GetRequests() const { return Requests; }
// Sanity check a request to see if it is reasonable.
static bool SanityCheck(const FlxInputModeRequest &Request);
// Divide Requests into a high-priority slice and a low-priority slice.
void SplitHighLow(View &High, View &Low);
// Apply a request. Replaces any previous request by the same widget.
void Request(const FlxInputModeRequest &NewRequest);
void Request(const FlxInputModeRequest &NewRequest, bool UpdateSequence = true);
// Find the specified widget, and modify the 'EnableInputComponent'
// flag. Adds the widget if it's not already present.
@@ -96,4 +88,11 @@ public:
// Remove any requests by dead widgets or widgets with no parents.
void GarbageCollect();
private:
// Find specified widget. If not present, returns Requests.Num()
int32 FindWidget(UUserWidget *Widget);
// Move item at Index to its proper place in the array by priority.
void BubbleItem(int32 Index);
};