Stream Chat Unreal SDK
Loading...
Searching...
No Matches
MessageWidget.h
1// Copyright 2022 Stream.IO, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Channel/Message.h"
6#include "Components/Overlay.h"
7#include "CoreMinimal.h"
8#include "MessageHoverMenuWidget.h"
9#include "Reaction/MessageReactionsWidget.h"
10#include "StreamWidget.h"
11#include "TextBubbleWidget.h"
12#include "TimestampWidget.h"
13
14#include "MessageWidget.generated.h"
15
19UCLASS()
20class STREAMCHATUI_API UMessageWidget final : public UStreamWidget
21{
22 GENERATED_BODY()
23
24public:
25 explicit UMessageWidget();
26 UFUNCTION(BlueprintCallable, Category = "Stream Chat")
27 void Setup(const FMessage& InMessage, EMessageSide InSide, EMessagePosition InPosition);
28
29protected:
30 UPROPERTY(meta = (BindWidgetOptional))
31 UTextBubbleWidget* TextBubble;
32
33 // Should contain whatever needs to be horizontally aligned
34 UPROPERTY(meta = (BindWidgetOptional))
35 UVerticalBox* AlignPanel;
36
37 // Where the mouse hover menu will be spawned
38 UPROPERTY(meta = (BindWidgetOptional))
39 UContentWidget* HoverMenuTargetPanel;
40
41 // Where the reactions will be spawned
42 UPROPERTY(meta = (BindWidgetOptional))
43 UContentWidget* ReactionsTargetPanel;
44
45 // Where the timestamp will (maybe) be spawned
46 UPROPERTY(meta = (BindWidgetOptional))
47 UContentWidget* TimestampTargetPanel;
48
49 // Where the avatar will (maybe) be spawned
50 UPROPERTY(meta = (BindWidgetOptional))
51 UContentWidget* AvatarTargetPanel;
52
53 UPROPERTY(EditDefaultsOnly, NoClear, Category = Defaults)
54 TSubclassOf<UMessageHoverMenuWidget> MouseHoverMenuWidgetClass = UMessageHoverMenuWidget::StaticClass();
55
56 UPROPERTY(EditDefaultsOnly, NoClear, Category = Defaults)
57 TSubclassOf<UMessageReactionsWidget> ReactionsWidgetClass = UMessageReactionsWidget::StaticClass();
58
59 UPROPERTY(EditDefaultsOnly, NoClear, Category = Defaults)
60 TSubclassOf<UAvatarWidget> AvatarWidgetClass = UAvatarWidget::StaticClass();
61
62 UPROPERTY(EditDefaultsOnly, NoClear, Category = Defaults)
63 TSubclassOf<UTimestampWidget> TimestampWidgetClass = UTimestampWidget::StaticClass();
64
65 UPROPERTY(EditDefaultsOnly, Category = Defaults)
66 int32 AvatarSize = 36;
67
68 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Setup)
69 FMessage Message;
70 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Setup)
71 EMessagePosition Position;
72 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Setup)
73 EMessageSide Side;
74
75private:
76 virtual void OnSetup() override;
77
78 virtual void NativeOnMouseEnter(const FGeometry& InGeometry, const FPointerEvent& InMouseEvent) override;
79 virtual void NativeOnMouseLeave(const FPointerEvent& InMouseEvent) override;
80
81 bool ShouldDisplayHoverMenu() const;
82
83 // Only valid while hovered
84 UPROPERTY(Transient)
85 UMessageHoverMenuWidget* MouseHoverMenu;
86
87 // Only valid if message has reactions
88 UPROPERTY(Transient)
89 UMessageReactionsWidget* Reactions;
90};
Shown when mouse hovers over message.
Definition: MessageHoverMenuWidget.h:23
Encapsulates a text bubble, reactions and the mouse hover menu for a message.
Definition: MessageWidget.h:21
Represents a Stream Chat message.
Definition: Message.h:66