mirror of
https://github.com/kevinporetti/UnrealImGui.git
synced 2025-01-18 08:20:32 +00:00
Added to ImGui Context Proxy information about context display size.
This commit is contained in:
parent
f8e689561f
commit
cfc76ea286
@ -63,6 +63,7 @@ FImGuiContextProxy::FImGuiContextProxy(const FString& InName, FSimpleMulticastDe
|
|||||||
|
|
||||||
// Use pre-defined canvas size.
|
// Use pre-defined canvas size.
|
||||||
IO.DisplaySize = { DEFAULT_CANVAS_WIDTH, DEFAULT_CANVAS_HEIGHT };
|
IO.DisplaySize = { DEFAULT_CANVAS_WIDTH, DEFAULT_CANVAS_HEIGHT };
|
||||||
|
DisplaySize = ImGuiInterops::ToVector2D(IO.DisplaySize);
|
||||||
|
|
||||||
// When GetTexData is called for the first time it builds atlas texture and copies mouse cursor data to context.
|
// When GetTexData is called for the first time it builds atlas texture and copies mouse cursor data to context.
|
||||||
// When multiple contexts share atlas then only the first one will get mouse data. A simple workaround is to use
|
// When multiple contexts share atlas then only the first one will get mouse data. A simple workaround is to use
|
||||||
@ -151,6 +152,7 @@ void FImGuiContextProxy::Tick(float DeltaSeconds)
|
|||||||
// beforehand).
|
// beforehand).
|
||||||
bHasActiveItem = ImGui::IsAnyItemActive();
|
bHasActiveItem = ImGui::IsAnyItemActive();
|
||||||
MouseCursor = ImGuiInterops::ToSlateMouseCursor(ImGui::GetMouseCursor());
|
MouseCursor = ImGuiInterops::ToSlateMouseCursor(ImGui::GetMouseCursor());
|
||||||
|
DisplaySize = ImGuiInterops::ToVector2D(ImGui::GetIO().DisplaySize);
|
||||||
|
|
||||||
// Begin a new frame and set the context back to a state in which it allows to draw controls.
|
// Begin a new frame and set the context back to a state in which it allows to draw controls.
|
||||||
BeginFrame(DeltaSeconds);
|
BeginFrame(DeltaSeconds);
|
||||||
|
@ -49,8 +49,13 @@ public:
|
|||||||
// Set this context as current ImGui context.
|
// Set this context as current ImGui context.
|
||||||
void SetAsCurrent() { ImGui::SetCurrentContext(Context.Get()); }
|
void SetAsCurrent() { ImGui::SetCurrentContext(Context.Get()); }
|
||||||
|
|
||||||
|
// Context display size (read once per frame during context update and cached here for easy access).
|
||||||
|
const FVector2D& GetDisplaySize() const { return DisplaySize; }
|
||||||
|
|
||||||
|
// Whether this context has an active item (read once per frame during context update and cached here for easy access).
|
||||||
bool HasActiveItem() const { return bHasActiveItem; }
|
bool HasActiveItem() const { return bHasActiveItem; }
|
||||||
|
|
||||||
|
// Cursor type desired by this context (this is updated during ImGui frame and cached here during context update, before it is reset).
|
||||||
EMouseCursor::Type GetMouseCursor() const { return MouseCursor; }
|
EMouseCursor::Type GetMouseCursor() const { return MouseCursor; }
|
||||||
|
|
||||||
// Delegate called right before ending the frame to allows listeners draw their controls.
|
// Delegate called right before ending the frame to allows listeners draw their controls.
|
||||||
@ -72,6 +77,8 @@ private:
|
|||||||
|
|
||||||
TUniquePtr<ImGuiContext> Context;
|
TUniquePtr<ImGuiContext> Context;
|
||||||
|
|
||||||
|
FVector2D DisplaySize = FVector2D::ZeroVector;
|
||||||
|
|
||||||
EMouseCursor::Type MouseCursor = EMouseCursor::None;
|
EMouseCursor::Type MouseCursor = EMouseCursor::None;
|
||||||
bool bHasActiveItem = false;
|
bool bHasActiveItem = false;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user