Nebula
Loading...
Searching...
No Matches
imguicontext.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
11//------------------------------------------------------------------------------
13#include "coregraphics/buffer.h"
15#include "input/inputevent.h"
19#include "imguiinputhandler.h"
21#include "frame/framecode.h"
22#include "util/delegate.h"
23
24#define IMGUI_DEFINE_MATH_OPERATORS
25#include "imgui.h"
26
27struct ImDrawData;
28struct ImFont;
29struct ImVec2;
30namespace Dynui
31{
32
33extern ImGuiKey NebulaToImguiKeyCodes[];
35extern const char* EditorUIPath;
36
49
51constexpr int ImGuiWindowEchoFrames = 3;
52
54{
56 uint layer : 8 = 0;
57 uint mip : 4 = 0;
58 uint useAlpha : 1 = 1;
59 uint useRange : 1 = 0;
61 uint red : 1 = 1;
62 uint green : 1 = 1;
63 uint blue : 1 = 1;
64 uint alpha : 1 = 1;
65 uint splat : 1 = 0;
67 uint tonemap : 1 = 0; // tonemap HDR (float and BC6H) textures instead of clipping them, LDR textures are unaffected
68 float exposure = 1.0f; // linear exposure scale used when tonemapping
69};
70
72
79
80
81extern ImFont* ImguiFont;
82extern ImFont* ImguiBoldFont;
83extern ImFont* ImguiItFont;
84
86{
88public:
92 virtual ~ImguiContext();
93
95 static void Create();
97 static void Discard();
98
100 static void SetRectSize(SizeT width, SizeT height);
101
103 static bool HandleInput(const Input::InputEvent& event);
104
107 static void SetKeyCallback(Util::Delegate<bool(Input::Key::Code, bool, Input::Modifier::Code)> callback);
108
110 static void OnViewportResized(const uint framescriptHash, SizeT width, SizeT height);
112 static void NewFrame(const Graphics::FrameContext& ctx);
113
115 static void EndFrame(const Graphics::FrameContext& ctx);
116
118 static void PresentWindow(const CoreGraphics::WindowId window, IndexT frameIndex, IndexT bufferIndex);
119
121 static ImGuiStyle& GetBaseStyle();
123 static float GetStyleScale();
125 static void ApplyBaseStyle();
126
127private:
128 static void RecoverImGuiContextErrors();
129
132};
133
135void ImGuiCloseButton(bool& toggle, int id);
137bool ImGuiToggleButton(const char* label, bool toggle);
139void ImGuiSpinner(const char* label, float radius = 10.0f, float thickness = 3.0f);
140
141} // namespace Dynui
static ImGuiStyle & GetBaseStyle()
get the unscaled base style, call ApplyBaseStyle after modifying it
Definition imguicontext.cc:1100
static void EndFrame(const Graphics::FrameContext &ctx)
called after frame
Definition imguicontext.cc:1329
static void SetKeyCallback(Util::Delegate< bool(Input::Key::Code, bool, Input::Modifier::Code)> callback)
the keys a text field did not take.
Definition imguicontext.cc:660
static void PresentWindow(const CoreGraphics::WindowId window, IndexT frameIndex, IndexT bufferIndex)
draw and show a window ImGui made for a window dragged out of the main window. Not for the main windo...
Definition imguicontext.cc:583
static float GetStyleScale()
get the content scale applied on top of the base style
Definition imguicontext.cc:1109
static void ApplyBaseStyle()
copy the base style into the active ImGui style, scaled by the content scale
Definition imguicontext.cc:1118
static void Create()
Create context.
Definition imguicontext.cc:694
static void NewFrame(const Graphics::FrameContext &ctx)
called before frame
Definition imguicontext.cc:1251
static void OnViewportResized(const uint framescriptHash, SizeT width, SizeT height)
called if the window size has changed
Definition imguicontext.cc:1242
static void SetRectSize(SizeT width, SizeT height)
set the screen dimensions to use when rendering the UI (all vertices will be mapped to these values)
ImguiContext()
constructor
Definition imguicontext.cc:668
static bool HandleInput(const Input::InputEvent &event)
handle event
Definition imguicontext.cc:1176
static void Discard()
Discard context.
Definition imguicontext.cc:1131
static void RecoverImGuiContextErrors()
Definition imguicontext.cc:500
static Util::Delegate< bool(Input::Key::Code, bool, Input::Modifier::Code)> keyCallback
the keys a text field did not take
Definition imguicontext.h:131
Definition graphicscontext.h:175
An ID allocator associates an id with a slice in an N number of arrays.
Definition idallocator.h:39
The input events of the Input subsystems.
Definition inputevent.h:25
Code
key codes
Definition key.h:25
Nebula's dynamic array class.
Definition array.h:61
Nebula delegate class, allows to store a function, method or lambda call into a C++ object for later ...
Definition delegate.h:39
Imgui Profiler UI.
Definition imguiconsole.cc:195
ImGuiKey NebulaToImguiKeyCodes[]
Definition imguicontext.cc:37
constexpr int ImGuiWindowEchoFrames
how many frames after ImGui moved or resized a window its own change can still come back
Definition imguicontext.h:51
ImFont * ImguiItFont
Definition imguicontext.cc:228
void SetImguiTextureIdData(Ids::Id32 id, const ImguiTextureId &data)
Set imgui texture data.
Definition imguicontext.cc:1354
void ImGuiCloseButton(bool &toggle, int id)
Helper function to recreate the ImGUI close button used for windows and tabs.
Definition imguicontext.cc:1372
void ImGuiSpinner(const char *label, float radius, float thickness)
Helper function to produce a spinner.
Definition imguicontext.cc:1430
Ids::IdAllocator< ImguiTextureId > ImguiTextureIdAllocator(0xFFF)
Definition imguicontext.h:71
ImFont * ImguiFont
Definition imguicontext.cc:226
void DeallocateImguiTextureId(Ids::Id32 id)
Deallocate imgui texture.
Definition imguicontext.cc:1363
bool ImGuiToggleButton(const char *label, bool toggle)
Helper function for toggle buttons.
Definition imguicontext.cc:1409
Ids::Id32 AllocateImguiTextureId(const ImguiTextureId &data)
Allocate imgui texture.
Definition imguicontext.cc:1339
Util::Array< Util::String > ImguiDragAndDropFiles
Definition imguicontext.cc:35
const char * EditorUIPath
Definition imguicontext.cc:36
ImFont * ImguiBoldFont
Definition imguicontext.cc:227
uint32_t Id32
Definition id.h:138
uint32_t Code
Definition modifier.h:21
A resource table declares a list of resources (ResourceTable in DX12, DescriptorSet in Vulkan).
texture type
Definition texture.h:25
Definition window.h:25
The platform side of a secondary ImGui viewport.
Definition imguicontext.h:39
int ownPosFrame
The frame the window was last moved or resized by ImGui itself.
Definition imguicontext.h:46
CoreGraphics::WindowId wnd
Definition imguicontext.h:40
int ownSizeFrame
Definition imguicontext.h:47
Definition imguicontext.h:54
CoreGraphics::TextureId nebulaHandle
Definition imguicontext.h:55
uint useRange
Definition imguicontext.h:59
uint tonemap
Definition imguicontext.h:67
uint green
Definition imguicontext.h:62
uint mip
Definition imguicontext.h:57
float exposure
Definition imguicontext.h:68
uint alpha
Definition imguicontext.h:64
float rangeMin
Definition imguicontext.h:60
uint blue
Definition imguicontext.h:63
uint useAlpha
Definition imguicontext.h:58
uint pointFilter
Definition imguicontext.h:66
uint layer
Definition imguicontext.h:56
uint splat
Definition imguicontext.h:65
float rangeMax
Definition imguicontext.h:60
uint red
Definition imguicontext.h:61
Definition graphicsserver.h:63
int SizeT
Definition types.h:50
unsigned int uint
Definition types.h:41
int IndexT
Definition types.h:49