0
mirror of https://github.com/sampletext32/ParkanPlayground.git synced 2025-08-06 02:56:33 +03:00

create NResUI

This commit is contained in:
bird_egop
2024-11-15 19:06:44 +03:00
parent 0c39485188
commit 1091605e2d
22 changed files with 869 additions and 100 deletions

View File

@@ -0,0 +1,39 @@
using System.Numerics;
using ImGuiNET;
using NResUI.Abstractions;
namespace NResUI.ImGuiUI;
public abstract class ImGuiModalPanel : IImGuiPanel
{
protected abstract string ImGuiId { get; }
private bool _shouldOpen = false;
public virtual void Open()
{
_shouldOpen = true;
}
protected abstract void OnImGuiRenderContent();
public void OnImGuiRender()
{
// this is a ImGui stack fix. Because menubars and some other controls use their separate stack context,
// The panel gets rendered on it's own, at the root of the stack, and with _shouldOpen we control, if the panel should open this frame.
if (_shouldOpen)
{
ImGui.OpenPopup(ImGuiId, ImGuiPopupFlags.AnyPopupLevel);
_shouldOpen = false;
}
ImGui.SetNextWindowSize(new Vector2(600, 400));
if (ImGui.BeginPopup(ImGuiId, ImGuiWindowFlags.NoResize))
{
OnImGuiRenderContent();
ImGui.EndPopup();
}
}
}