candlewick 0.10.0
A tiny cross-platform renderer based on SDL3
Loading...
Searching...
No Matches
GuiSystem.h
Go to the documentation of this file.
1
3#include "Core.h"
4#include <functional>
5#include <span>
6#include <entt/entity/fwd.hpp>
7#include <SDL3/SDL_stdinc.h>
8
9struct SDL_Window;
10
11namespace candlewick {
12
13class GuiSystem {
14 RenderContext const *m_renderer;
15 bool m_initialized = false;
16 std::function<void(const RenderContext &)> m_callback;
17
18 bool init();
19
20public:
21 using GuiBehavior = std::function<void(const RenderContext &)>;
22
23 GuiSystem(const RenderContext &renderer, GuiBehavior behav);
24 GuiSystem(GuiSystem &&other) noexcept
25 : m_renderer{other.m_renderer}
26 , m_initialized(other.m_initialized)
27 , m_callback(std::move(other.m_callback)) {
28 other.m_renderer = nullptr;
29 other.m_initialized = false;
30 }
31
32 void render(CommandBuffer &cmdBuf);
33
34 void release();
35
36 bool initialized() const { return m_initialized; }
37};
38
40
44 const char *prefix, std::string &out, const char *extension = ".png",
46
48namespace gui {
50 void showCandlewickAboutWindow(bool *p_open = NULL, float wrap_width = 400.f);
51
54
56 void addLightControls(std::span<DirectionalLight> lights);
57
58 void addLightControls(std::span<DirectionalLight> lights, Uint32 numLights,
59 Uint32 start = 0);
60
63 void addDisableCheckbox(const char *label, entt::registry &reg,
64 entt::entity id, bool &flag);
65
69 void addFileDialog(SDL_Window *window, DialogFileType dialog_file_type,
70 std::string &filename);
71} // namespace gui
72
73} // namespace candlewick
Definition CommandBuffer.h:16
bool initialized() const
Definition GuiSystem.h:36
GuiSystem(GuiSystem &&other) noexcept
Definition GuiSystem.h:24
GuiSystem(const RenderContext &renderer, GuiBehavior behav)
void render(CommandBuffer &cmdBuf)
std::function< void(const RenderContext &)> GuiBehavior
Definition GuiSystem.h:21
GUI utilities.
Definition DebugScene.h:148
void addDisableCheckbox(const char *label, entt::registry &reg, entt::entity id, bool &flag)
Adds an ImGui::Checkbox which toggles the Disable component on the entity.
void addLightControls(DirectionalLight &light)
Adds a set of ImGui elements to control a DirectionalLight.
void showCandlewickAboutWindow(bool *p_open=NULL, float wrap_width=400.f)
Show an about window providing information about Candlewick.
void addFileDialog(SDL_Window *window, DialogFileType dialog_file_type, std::string &filename)
Add a GUI button-text pair to select a file to save something to.
Definition Camera.h:8
void generateMediaFilenameFromTimestamp(const char *prefix, std::string &out, const char *extension=".png", DialogFileType file_type=DialogFileType::IMAGES)
Set input/output string to a generated filename computed from a timestamp.
DialogFileType
Definition GuiSystem.h:39
@ VIDEOS
Definition GuiSystem.h:39
@ IMAGES
Definition GuiSystem.h:39
Definition LightUniforms.h:7
The RenderContext class provides a rendering context for a graphical application.
Definition RenderContext.h:36