Advertisement
Guest User

Untitled

a guest
Jun 1st, 2017
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.21 KB | None | 0 0
  1. //CustomWidget .h
  2.  
  3. /**
  4.  * CustomWidget should be derived from every UUserWidget in this project
  5.  */
  6. UCLASS()
  7. class PROJECT_API UCustomWidget : public UUserWidget
  8. {
  9.     GENERATED_BODY()
  10.    
  11. public:
  12.     virtual void NativeTick(const FGeometry& InGeometry, float DeltaTime) override;
  13.    
  14.     FVector2D GetPositionInViewport() const;
  15.  
  16.     TSharedPtr<SWidget> GetWidget() { return MyWidget.Pin(); };
  17.  
  18.     FVector2D GetSize() { return AbsoluteSize; };
  19.  
  20.     virtual FWidgetSpace GetSpace();
  21.  
  22.     bool IsWidgetOverlapping(UCustomWidget* Widget);
  23.  
  24. protected:
  25.     FVector2D AbsolutePosition;
  26.     FVector2D AbsoluteSize;
  27.    
  28. };
  29.  
  30. //FocusableWidget.h
  31.  
  32. /**
  33.  * FocusableWidget is a widget which defines its custom Focus and Unfocus Function. These functions will be called through AUISystem
  34.  */
  35. UCLASS()
  36. class THEPASSENGER_API UFocusableWidget : public UCustomWidget
  37. {
  38.     GENERATED_BODY()
  39.  
  40. public:
  41.     UFocusableWidget(const FObjectInitializer& ObjInitializer)
  42.     {
  43.         bIsFocused = false;
  44.         bInteractable = true;
  45.     }
  46.  
  47.     virtual void Focus() { bIsFocused = true; };
  48.     virtual void UnFocus() { bIsFocused = false; };
  49.  
  50.     virtual void Interact() {};
  51.  
  52.     bool IsFocused() { return bIsFocused; }
  53.  
  54. protected:
  55.     bool bIsFocused;
  56.     bool bInteractable;
  57. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement