1.14.0.5
Coherent HB for UE4
A modern user interface library for games
HummingbirdWidget.h
1 /*
2 This file is part of Hummingbird, modern user interface library for
3 games. Release $RELEASE$. Build $VERSION$ for $LICENSEE$.
4 
5 Copyright (c) 2012-2018 Coherent Labs AD and/or its licensors. All
6 rights reserved in all media.
7 
8 The coded instructions, statements, computer programs, and/or related
9 material (collectively the "Data") in these files contain confidential
10 and unpublished information proprietary Coherent Labs and/or its
11 licensors, which is protected by United States of America federal
12 copyright law and by international treaties.
13 
14 This software or source code is supplied under the terms of a license
15 agreement and nondisclosure agreement with Coherent Labs Limited and may
16 not be copied, disclosed, or exploited except in accordance with the
17 terms of that agreement. The Data may not be disclosed or distributed to
18 third parties, in whole or in part, without the prior written consent of
19 Coherent Labs Limited.
20 
21 COHERENT LABS MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS
22 SOURCE CODE FOR ANY PURPOSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
23 HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
24 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25 MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE
26 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER, ITS AFFILIATES,
27 PARENT COMPANIES, LICENSORS, SUPPLIERS, OR CONTRIBUTORS BE LIABLE FOR
28 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
32 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33 ANY WAY OUT OF THE USE OR PERFORMANCE OF THIS SOFTWARE OR SOURCE CODE,
34 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 */
36 #pragma once
37 
38 #include <Sound/SoundAttenuation.h>
39 #include "Runtime/UMG/Public/Components/Widget.h"
40 #include "SHummingbirdWidget.h"
41 #include "HummingbirdEventHelpers.h"
42 #include "HummingbirdViewListener.h"
43 #include "HummingbirdAudioWrapper.h"
44 
45 #include "HummingbirdWidget.generated.h"
46 
47 namespace cohtml
48 {
49 class View;
50 }
51 
53 UCLASS(meta=(DisplayName = "Hummingbird Widget"))
54 class HUMMINGBIRDPLUGIN_API UHummingbirdWidget : public UWidget
55 {
56  GENERATED_UCLASS_BODY()
57 
58 public:
59  virtual ~UHummingbirdWidget();
60  virtual TSharedRef<SWidget> RebuildWidget() override;
61  virtual void SynchronizeProperties() override;
62 #if WITH_EDITOR
63  virtual const FText GetPaletteCategory() override;
64 #endif
65 
66 protected:
67  TSharedPtr<SHummingbirdWidget> CoherentWidget;
68 
69 private:
70  void OnViewCreated(cohtml::View* View);
71 
72  friend class THummingbirdViewListener<UHummingbirdWidget>;
73 
74  // During destruction we will lose the ref to the slate widget
75  // which means that can't access its view (which will be in the process of destruction, yet still alive).
76  // We need the view so that we can replay any events left over in async mode so store it here.
77  // In other words - this is only used during destruction and shouldn't even be used directly, use GetView() instead
78  cohtml::View* CachedView;
79 
80 public:
82  UPROPERTY(BlueprintReadWrite, Category = "View")
83  AActor* Owner;
84 
85  // BASE COMPONENT COPY START
86 
90  UFUNCTION(BlueprintCallable, Category = "Audio")
91  void SetSoundAttenuation(const FSoundAttenuationSettings& Settings);
92 
94  UPROPERTY(BlueprintAssignable)
95  FHBReadyForBindingsSignature ReadyForBindings;
96 
98  UPROPERTY(BlueprintAssignable)
99  FHBBindingsReleasedSignature BindingsReleased;
100 
102  UPROPERTY(BlueprintAssignable)
103  FHBScriptingReady HBScriptingReady;
104 
106  UFUNCTION(BlueprintCallable, Category = "View")
107  bool IsReadyToCreateView() const;
108 
110  UFUNCTION(BlueprintCallable, Category = "View")
111  bool IsReadyForBindings() const;
112 
114  UFUNCTION(BlueprintCallable, Category = "View")
115  bool HasRequestedView() const;
116 
118  UFUNCTION(BlueprintCallable, Category = "View")
119  void ShowPaintRects(bool show);
120 
122  UFUNCTION(BlueprintCallable, Category = "View")
123  void Load(const FString& path);
124 
126  UFUNCTION(BlueprintCallable, Category = "View")
127  void Reload();
128 
130  UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "View", DisplayName = "Enable Complex CSS Selector Support")
131  bool bEnableComplexCSSSupport;
132 
134  UFUNCTION(BlueprintCallable, Category = "View")
135  UTextureRenderTarget2D* GetRenderTexture() const;
136 
137  UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "View", AdvancedDisplay)
138  TEnumAsByte<enum TextureFilter> Filter;
139 
141  UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "View")
142  bool bReceiveInput;
143 
147  UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "View")
148  bool bGammaCorrectedMaterial;
149 
151  UFUNCTION(BlueprintCallable, Category = "ViewScripting")
152  UHummingbirdJSEvent* CreateJSEvent();
153 
155  UFUNCTION(BlueprintCallable, Category = "ViewScripting")
156  void TriggerJSEvent(const FString& name, UHummingbirdJSEvent* eventData) const;
157 
158  inline cohtml::View* GetView() const
159  {
160  if (CoherentWidget.IsValid())
161  {
162  return CoherentWidget->GetView();
163  }
164  return CachedView;
165  }
166 
167  virtual void BeginDestroy() override;
168  virtual void ReleaseSlateResources(bool bReleaseChildren) override;
169 
170 private:
171  void OnAudioStreamCreated(int Id, int BitDepth, int Channels, float SamplingRate);
172  void OnAudioStreamClosed(int Id);
173  void OnAudioStreamPlay(int Id);
174  void OnAudioStreamPause(int Id);
175  void OnAudioDataReceived(int Id, int Samples, float** Pcm, int Channels);
176  void OnAudioStreamEnded(int Id);
177  void OnAudioStreamVolumeChanged(int Id, float Volume);
178 
179  THummingbirdAudioWrapper<AActor> AudioWrapper;
180 
181  void SetReadyForBindings();
182 
183  bool NeedsViewRecreation() const;
184 
185  TUniquePtr<THummingbirdViewListener<UHummingbirdWidget>> Listener;
186  bool bIsReadyForBindings;
187  cohtml::ViewSettings LastSavedViewSettings;
188 
189  // BASE COMPONENT COPY END
190 
191  // COMPONENT COPY BEGIN. DON'T COPY WIDTH AND HEIGHT
192 public:
194  UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "View")
195  FString URL;
196 
197  // COMPONENT COPY END
198 };
Definition: HummingbirdJSEvent.h:51
Definition: HummingbirdWidget.h:54
Definition: HummingbirdFColorBinder.h:41