Stream Chat Unreal SDK
Loading...
Searching...
No Matches
WidgetUtil.h
1// Copyright 2022 Stream.IO, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Blueprint/WidgetTree.h"
6#include "Components/Widget.h"
7
8class UMenuAnchor;
9
10namespace WidgetUtil
11{
12UWidget* GetTypedParentWidget(const UWidget*, const TSubclassOf<UWidget>);
13UWidget* GetTypedChildWidget(const UWidget*, const TSubclassOf<UWidget>);
14
15template <class T>
16T* GetTypedParentWidget(const UWidget* Widget)
17{
18 static_assert(TIsDerivedFrom<T, UWidget>::IsDerived, "T must be derived from UWidget");
19 return static_cast<T*>(GetTypedParentWidget(Widget, T::StaticClass()));
20}
21template <class T>
22T* GetTypedChildWidget(const UWidget* Widget)
23{
24 static_assert(TIsDerivedFrom<T, UWidget>::IsDerived, "T must be derived from UWidget");
25 return static_cast<T*>(GetTypedChildWidget(Widget, T::StaticClass()));
26}
27
34FString TruncateWithEllipsis(const FString&, uint32 MaxWidth, const FSlateFontInfo& FontInfo);
35
36uint32 HashStringWithMax(const FString&, uint32 Max = 16);
37
38FLinearColor ChooseColorForString(const FString&);
39
40void HideDefaultMenuBackground(UMenuAnchor* Anchor);
41
42} // namespace WidgetUtil