UnrealImGui/Source/ImGui/Private/ImGuiContextProxy.h
Sebastian 35f2d342a0 Added support for ImGui context update and rendering:
- Added ImGui Module Manager that that implements module logic and manages other module resources.
- Added Texture Manager to manage texture resources and maps them to index that can be passed to ImGui context.
- Added Context Proxy that represents and manages a single ImGui context.
- Added Slate ImGui Widget to render ImGui output.
2017-03-26 21:32:57 +01:00

48 lines
1.3 KiB
C++

// Distributed under the MIT License (MIT) (see accompanying LICENSE file)
#pragma once
#include "ImGuiDrawData.h"
#include <imgui.h>
// Represents a single ImGui context. All the context updates should be done through this proxy. During update it
// broadcasts draw events to allow listeners draw their controls. After update it stores produced draw data.
// TODO: Add dynamically created contexts, so we can have a better support for multi-PIE.
class FImGuiContextProxy
{
public:
FImGuiContextProxy();
~FImGuiContextProxy();
FImGuiContextProxy(const FImGuiContextProxy&) = delete;
FImGuiContextProxy& operator=(const FImGuiContextProxy&) = delete;
FImGuiContextProxy(FImGuiContextProxy&&) = delete;
FImGuiContextProxy& operator=(FImGuiContextProxy&&) = delete;
// Get draw data from the last frame.
const TArray<FImGuiDrawList>& GetDrawData() const { return DrawLists; }
// Delegate called right before ending the frame to allows listeners draw their controls.
FSimpleMulticastDelegate& OnDraw() { return DrawEvent; }
// Tick to advance context to the next frame.
void Tick(float DeltaSeconds);
private:
void BeginFrame(float DeltaTime = 1.f / 60.f);
void EndFrame();
void UpdateDrawData(ImDrawData* DrawData);
TArray<FImGuiDrawList> DrawLists;
FSimpleMulticastDelegate DrawEvent;
bool bIsFrameStarted = false;
};