Coherent UI for Unreal Engine 4  2.5.5.0
A modern user interface library for games
 All Classes Functions Variables Pages
SCoherentInputForward.h
1 /*
2 This file is part of Coherent UI, modern user interface library for
3 games.
4 
5 Copyright (c) 2012-2014 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 "Coherent/UI/InputEvents.h"
39 
40 #include "CoherentUIBackwardsCompatibility.h"
41 
42 #if defined (COHERENT_UI_UE4_4_5_SUPPORT)
43 #include "Slate.h"
44 #else
45 #include "SlateBasics.h"
46 #endif
47 
48 #include "SCompoundWidget.h"
49 #include "SCoherentInputForward.generated.h"
50 
51 namespace Coherent
52 {
53  namespace UI
54  {
55  class View;
56  }
57 }
58 
60 
61 DECLARE_MULTICAST_DELEGATE_OneParam(FCoherentInputWidgetMouseButtonDown, const FKey&);
62 DECLARE_MULTICAST_DELEGATE_OneParam(FCoherentInputWidgetMouseButtonUp, const FKey&);
63 DECLARE_MULTICAST_DELEGATE_OneParam(FCoherentInputWidgetKeyDown, const FKey&);
64 DECLARE_MULTICAST_DELEGATE_OneParam(FCoherentInputWidgetKeyUp, const FKey&);
65 
66 UENUM()
67 enum EInputWidgetRaycastQuality
68 {
69  RQ_Fast UMETA(DisplayName="Fast"),
70  RQ_Balanced UMETA(DisplayName="Balanced"),
71  RQ_Accurate UMETA(DisplayName="Accurate"),
72  RQ_MAX,
73 };
74 
75 UENUM()
76 enum EInputWidgetLineTraceMode
77 {
78  InputLineTrace_Single UMETA(DisplayName = "Single object trace"),
79  InputLineTrace_Multi UMETA(DisplayName = "Multiple objects trace"),
80  InputLineTrace_MAX
81 };
82 
83 class SCoherentInputForward : public SCompoundWidget
84 {
85 public:
86  SLATE_BEGIN_ARGS(SCoherentInputForward) {}
87  SLATE_ARGUMENT(TWeakObjectPtr<AActor>, Owner)
88  SLATE_END_ARGS()
89 
90  COHERENTUIPLUGIN_API virtual ~SCoherentInputForward();
91  COHERENTUIPLUGIN_API void Construct(const FArguments& InArgs);
92 
93  COHERENTUIPLUGIN_API virtual FReply OnMouseMove(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
94  COHERENTUIPLUGIN_API virtual FReply OnMouseButtonDown(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
95  COHERENTUIPLUGIN_API virtual FReply OnMouseButtonDoubleClick( const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
96  COHERENTUIPLUGIN_API virtual FReply OnMouseButtonUp( const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
97  COHERENTUIPLUGIN_API virtual FReply OnMouseWheel(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
98  COHERENTUIPLUGIN_API virtual FReply OnDragDetected( const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
99 #if defined (COHERENT_UI_UE4_4_5_SUPPORT)
100  COHERENTUIPLUGIN_API virtual FReply OnKeyDown(const FGeometry& MyGeometry, const FKeyboardEvent& KeyEvent) override;
101  COHERENTUIPLUGIN_API virtual FReply OnKeyUp(const FGeometry& MyGeometry, const FKeyboardEvent& KeyEvent) override;
102 #else
103  COHERENTUIPLUGIN_API virtual FReply OnKeyDown(const FGeometry& MyGeometry, const FKeyEvent& KeyEvent) override;
104  COHERENTUIPLUGIN_API virtual FReply OnKeyUp(const FGeometry& MyGeometry, const FKeyEvent& KeyEvent) override;
105 #endif
106  COHERENTUIPLUGIN_API virtual FReply OnKeyChar(const FGeometry& MyGeometry, const FCharacterEvent& InCharacterEvent) override;
107  COHERENTUIPLUGIN_API virtual bool SupportsKeyboardFocus() const override;
108 
109 #if defined (COHERENT_UI_UE4_4_5_SUPPORT)
110  COHERENTUIPLUGIN_API virtual FReply OnKeyboardFocusReceived(const FGeometry& MyGeometry, const FKeyboardFocusEvent& InKeyboardFocusEvent) override;
111  COHERENTUIPLUGIN_API virtual void OnKeyboardFocusLost(const FKeyboardFocusEvent& InKeyboardFocusEvent) override;
112  COHERENTUIPLUGIN_API virtual void OnKeyboardFocusChanging(const FWeakWidgetPath& PreviousFocusPath, const FWidgetPath& NewWidgetPath) override;
113 #else
114  COHERENTUIPLUGIN_API virtual FReply OnFocusReceived(const FGeometry& MyGeometry, const FFocusEvent& InKeyboardFocusEvent) override;
115  COHERENTUIPLUGIN_API virtual void OnFocusChanging(const FWeakWidgetPath& PreviousFocusPath, const FWidgetPath& NewWidgetPath) override;
116  COHERENTUIPLUGIN_API virtual void OnFocusLost(const FFocusEvent& InKeyboardFocusEvent) override;
117 #endif
118 
119  COHERENTUIPLUGIN_API void SetRaycastCollisionGroup(ECollisionChannel CollisionChannel);
120  COHERENTUIPLUGIN_API void SetRaycastTextureAddressMode(TextureAddress TextureAddressMode);
121  COHERENTUIPLUGIN_API void SetRaycastQuality(EInputWidgetRaycastQuality RaycastQuality);
122  COHERENTUIPLUGIN_API void SetRaycastUVChannel(uint32 UVChannel);
123 
124  DEPRECATED(4.6, "SetForceAcceptInputEvents is deprecated. Use SetAlwaysAcceptMouseInputEvents instead.")
125  COHERENTUIPLUGIN_API void SetForceAcceptInputEvents(bool Accept);
126  COHERENTUIPLUGIN_API void SetAlwaysAcceptMouseInputEvents(bool bAccept);
127  COHERENTUIPLUGIN_API void SetPropagateKeyboardEvents(bool bPropagate);
128  COHERENTUIPLUGIN_API void SetLineTraceMode(EInputWidgetLineTraceMode Mode);
129 
130  COHERENTUIPLUGIN_API void RefocusView(UCoherentBaseComponent* NewFocusedView);
131 
132  FCoherentInputWidgetMouseButtonDown OnCoherentInputWidgetMouseButtonDown;
133  FCoherentInputWidgetMouseButtonUp OnCoherentInputWidgetMouseButtonUp;
134  FCoherentInputWidgetKeyDown OnCoherentInputWidgetKeyDown;
135  FCoherentInputWidgetKeyUp OnCoherentInputWidgetKeyUp;
136 
137 private:
138  Coherent::UI::KeyEventData MakeKeyEvent(const FInputEvent& Event, Coherent::UI::KeyEventData::EventType Type);
139  void ProcessKeyEvent(const FInputEvent& Event, Coherent::UI::KeyEventData::EventType Type);
140 
141  void GetMouseDataFromFPointerEvent(Coherent::UI::MouseEventData& Data, const FGeometry& MyGeometry, const FPointerEvent& MouseEvent, Coherent::UI::MouseEventData::EventType EventType);
142 
143  FReply OnMouseEvent(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent, Coherent::UI::MouseEventData::EventType EventType);
144 
145  FReply DiscardViewFocus(Coherent::UI::MouseEventData::EventType EventType);
146 
147 private:
148  ECollisionChannel RaycastCollisionChannel;
149  TextureAddress RaycastTextureAddressMode;
150  EInputWidgetRaycastQuality RaycastQuality;
151  uint32 UVChannel;
152  bool bHasKeyboardFocus;
153  bool bAlwaysAcceptMouseInputEvents;
154  bool bPropagateKeyboardEvents;
155  TEnumAsByte<EInputWidgetLineTraceMode> LineTraceMode;
156 
157  TWeakObjectPtr<AActor> OwnerActor;
158  TWeakObjectPtr<UCoherentBaseComponent> FocusedViewComponent;
159 };
Definition: CoherentBaseComponent.h:76