Skip to content
Snippets Groups Projects
Select Git revision
  • 4798c4d8773f1940d692c8e522d4e4040e3f5705
  • main default
  • feature/3D_rendering
  • feature/cave-support
  • feature/study
5 results

SDasherWidget.cpp

Blame
  • SDasherWidget.cpp 13.64 KiB
    #include "SDasherWidget.h"
    #include "SlateOptMacros.h"
    #include "Styling/CoreStyle.h"
    #include "Brushes/SlateColorBrush.h"
    #include "Rendering/DrawElements.h"
    #include "DasherInterface.h"
    
    #include "Components/SlateWrapperTypes.h"
    
    BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION
    
    
    // ++ This is needed in order to use the localization macro LOCTEXT
    #define LOCTEXT_NAMESPACE "SStandardSlateWidget"
    
    //Set the state if we're in the editor or not.
    void SDasherWidget::SetEditor(bool EditorState)
    {
    	IsEditor = EditorState;
    }
    
    //Event Handlers
    //Mouse position saved for mouse Input
    FReply SDasherWidget::HandleMouseMoveEvent(const FGeometry& Geometry, const FPointerEvent& MouseEvent)
    {
    	if (CurrentlyUsingVectorInput) return FReply::Unhandled();
    	//The mouse event only contains the Screen Space Position
    	CursorPosition = Geometry.AbsoluteToLocal(MouseEvent.GetScreenSpacePosition());
    	return FReply::Handled();
    }
    
    FReply SDasherWidget::HandleMouseDownEvent(const FGeometry& Geometry, const FPointerEvent& MouseEvent)
    {
    	if (CurrentlyUsingVectorInput)
    	{
    		CurrentlyUsingVectorInput = false;
    		return FReply::Handled().LockMouseToWidget(AsShared());
    	}
    	DasherMainInterface->KeyDown(FDateTime::Now().GetSecond() + FDateTime::Now().GetMillisecond(), 100); //100 is the keycode for LMB
    	MouseDownListeners.ExecuteIfBound();
    	return FReply::Handled().LockMouseToWidget(AsShared());
    }
    
    FReply SDasherWidget::HandleMouseUpEvent(const FGeometry& Geometry, const FPointerEvent& MouseEvent)
    {
    	if (CurrentlyUsingVectorInput)
    	{
    		CurrentlyUsingVectorInput = false;
    		return FReply::Handled().ReleaseMouseLock();
    	}
    	DasherMainInterface->KeyUp(FDateTime::Now().GetSecond() + FDateTime::Now().GetMillisecond(), 100); //100 is the keycode for LMB
        MouseUpListeners.ExecuteIfBound();
    	return FReply::Handled().ReleaseMouseLock();
    }
    
    FReply SDasherWidget::HandleMouseDoubleClickEvent(const FGeometry& Geometry, const FPointerEvent& MouseEvent)
    {
    	if(CurrentlyUsingVectorInput)
    	{
    		CurrentlyUsingVectorInput = false;
    		return FReply::Handled();
    	}
    	DasherMainInterface->KeyUp(FDateTime::Now().GetSecond() + FDateTime::Now().GetMillisecond(), 100); //100 is the keycode for LMB
    	return FReply::Handled();
    }
    
    //Set in the HandleMouseMoveEvent or via Set InputVector
    //See tick for geometry things that could be use to modify this.
    FVector2D SDasherWidget::GetCursorPosition()
    {