candlewick 0.6.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
17public:
18 using GuiBehavior = std::function<void(const RenderContext &)>;
19
20 GuiSystem(const RenderContext &renderer, GuiBehavior behav);
21
22 void addCallback(GuiBehavior cb) { _callbacks.push_back(std::move(cb)); }
23
24 void render(CommandBuffer &cmdBuf);
25
26 void release();
27
28 bool initialized() const { return m_initialized; }
29
30 std::vector<GuiBehavior> _callbacks;
31
32private:
33 bool init(const RenderContext &renderer);
34};
35
39void showCandlewickAboutWindow(bool *p_open = NULL, float wrap_width = 400.f);
40
41struct DirectionalLight;
42
45
47void guiAddLightControls(std::span<DirectionalLight> lights);
48
49void guiAddLightControls(std::span<DirectionalLight> lights, Uint32 numLights,
50 Uint32 start = 0);
51
54void guiAddDisableCheckbox(const char *label, entt::registry &reg,
55 entt::entity id, bool &flag);
56
58
62void guiAddFileDialog(SDL_Window *window, DialogFileType dialog_file_type,
63 std::string &filename);
65
67 const char *prefix = "cdw_screenshot", const char *extension = ".png",
69
70} // namespace candlewick
Definition CommandBuffer.h:17
std::vector< GuiBehavior > _callbacks
Definition GuiSystem.h:30
bool initialized() const
Definition GuiSystem.h:28
GuiSystem(const RenderContext &renderer, GuiBehavior behav)
void render(CommandBuffer &cmdBuf)
void addCallback(GuiBehavior cb)
Definition GuiSystem.h:22
std::function< void(const RenderContext &)> GuiBehavior
Definition GuiSystem.h:18
void showCandlewickAboutWindow(bool *p_open=NULL, float wrap_width=400.f)
Show an about window providing information about Candlewick.
Definition Camera.h:8
std::string generateMediaFilenameFromTimestamp(const char *prefix="cdw_screenshot", const char *extension=".png", DialogFileType file_type=DialogFileType::IMAGES)
void guiAddFileDialog(SDL_Window *window, DialogFileType dialog_file_type, std::string &filename)
Add a GUI button-text pair to select a file to save something to.
void guiAddDisableCheckbox(const char *label, entt::registry &reg, entt::entity id, bool &flag)
Adds an ImGui::Checkbox which toggles the Disable component on the entity.
DialogFileType
Definition GuiSystem.h:57
@ VIDEOS
Definition GuiSystem.h:57
@ IMAGES
Definition GuiSystem.h:57
void guiAddLightControls(DirectionalLight &light)
Adds a set of ImGui elements to control a DirectionalLight.
Definition LightUniforms.h:7
The RenderContext class provides a rendering context for a graphical application.
Definition RenderContext.h:20