2017-03-26 20:32:57 +00:00
|
|
|
// Distributed under the MIT License (MIT) (see accompanying LICENSE file)
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2017-04-22 15:38:04 +00:00
|
|
|
#include "ImGuiInputState.h"
|
|
|
|
|
2017-03-26 20:32:57 +00:00
|
|
|
#include <Widgets/SLeafWidget.h>
|
|
|
|
|
2017-04-22 15:38:04 +00:00
|
|
|
|
2017-03-26 20:32:57 +00:00
|
|
|
class FImGuiModuleManager;
|
|
|
|
|
2017-04-22 15:38:04 +00:00
|
|
|
// Slate widget for rendering ImGui output and storing Slate inputs.
|
2017-03-26 20:32:57 +00:00
|
|
|
class SImGuiWidget : public SLeafWidget
|
|
|
|
{
|
2017-08-19 20:19:38 +00:00
|
|
|
typedef SLeafWidget Super;
|
|
|
|
|
2017-03-26 20:32:57 +00:00
|
|
|
public:
|
|
|
|
|
|
|
|
SLATE_BEGIN_ARGS(SImGuiWidget)
|
|
|
|
{}
|
|
|
|
SLATE_ARGUMENT(FImGuiModuleManager*, ModuleManager)
|
|
|
|
SLATE_END_ARGS()
|
|
|
|
|
|
|
|
void Construct(const FArguments& InArgs);
|
|
|
|
|
2017-04-22 15:38:04 +00:00
|
|
|
~SImGuiWidget();
|
|
|
|
|
|
|
|
const FImGuiInputState& GetInputState() const { return InputState; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
// SWidget overrides
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
virtual bool SupportsKeyboardFocus() const override { return true; }
|
|
|
|
|
|
|
|
virtual FReply OnKeyChar(const FGeometry& MyGeometry, const FCharacterEvent& CharacterEvent) override;
|
|
|
|
|
|
|
|
virtual FReply OnKeyDown(const FGeometry& MyGeometry, const FKeyEvent& KeyEvent) override;
|
|
|
|
|
|
|
|
virtual FReply OnKeyUp(const FGeometry& MyGeometry, const FKeyEvent& KeyEvent) override;
|
|
|
|
|
|
|
|
virtual FReply OnMouseButtonDown(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
|
|
|
|
|
|
|
|
virtual FReply OnMouseButtonDoubleClick(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
|
|
|
|
|
|
|
|
virtual FReply OnMouseButtonUp(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
|
|
|
|
|
|
|
|
virtual FReply OnMouseWheel(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
|
|
|
|
|
|
|
|
virtual FReply OnMouseMove(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
|
|
|
|
|
2017-03-26 20:32:57 +00:00
|
|
|
private:
|
|
|
|
|
2017-08-19 20:19:38 +00:00
|
|
|
FORCEINLINE void CopyModifierKeys(const FInputEvent& InputEvent);
|
|
|
|
|
2017-04-22 15:38:04 +00:00
|
|
|
void OnPostImGuiUpdate();
|
|
|
|
|
2017-03-26 20:32:57 +00:00
|
|
|
virtual int32 OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyClippingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& WidgetStyle, bool bParentEnabled) const override;
|
|
|
|
|
|
|
|
virtual FVector2D ComputeDesiredSize(float) const override;
|
|
|
|
|
|
|
|
FImGuiModuleManager* ModuleManager = nullptr;
|
|
|
|
|
|
|
|
mutable TArray<FSlateVertex> VertexBuffer;
|
|
|
|
mutable TArray<SlateIndex> IndexBuffer;
|
2017-04-22 15:38:04 +00:00
|
|
|
|
|
|
|
FImGuiInputState InputState;
|
2017-03-26 20:32:57 +00:00
|
|
|
};
|