PixelBullet  0.0.1
A C++ game engine
Loading...
Searching...
No Matches
imgui_layer.h
1#pragma once
2
3#include "pixelbullet/application/layer.h"
4
5#include <imgui.h>
6
7#include <array>
8#include <cstdint>
9#include <filesystem>
10#include <memory>
11#include <string_view>
12
13namespace pixelbullet
14{
15class Graphics;
16class ImGuiLayer;
18class Window;
19} // namespace pixelbullet
20
21namespace pixelbullet::application_internal
22{
24} // namespace pixelbullet::application_internal
25
26namespace pixelbullet
27{
28
30{
31 std::array<ImVec4, ImGuiCol_COUNT> colors{};
32 ImGuiStyle base_style{};
33 std::filesystem::path font_path;
34 float font_size_pixels = 13.0f;
35 std::filesystem::path icon_font_path;
36 float icon_font_size_pixels = 13.0f;
37 ImWchar icon_font_range_min = 0;
38 ImWchar icon_font_range_max = 0;
39 std::filesystem::path mono_font_path;
40 float mono_font_size_pixels = 13.0f;
41 float style_scale = 1.0f;
42};
43
44class ImGuiLayer : public Layer, public UiFrameLayer
45{
46public:
47 ImGuiLayer(Window& window, Graphics& graphics);
48 ImGuiLayer(Window& window, Graphics& graphics, std::filesystem::path settings_path);
49 ~ImGuiLayer();
50
51 virtual void OnAttach() override;
52 virtual void OnDetach() override;
53 virtual pixelbullet::core::EventResult OnEvent(pixelbullet::core::Event& e) override;
54
55 bool BeginUiFrame() override;
56 void CancelUiFrame() override;
57
58 bool Begin();
59 void CancelFrame();
60 void End(const RenderFrameContext& frame_context);
61 ImTextureID GetRenderTargetTexture(std::string_view name);
62
63 void BlockEvents(bool block);
64
65 void SetAppearance(const ImGuiAppearanceConfig& appearance);
66 void SetTheme();
67 void SetSettingsPath(std::filesystem::path settings_path);
68 void ClearSettings();
69 void LoadSettingsFromDisk(const std::filesystem::path& settings_path);
70 void SaveSettings();
71 void SaveSettingsToDisk(const std::filesystem::path& settings_path);
72
73 uint32_t GetActiveWidgetID() const;
74 ImFont* GetMonospaceFont() const noexcept;
75
76private:
78
79 struct Impl;
80 std::unique_ptr<Impl> impl_;
81};
82
83} // namespace pixelbullet
Host-facing graphics subsystem shell.
Definition graphics.h:21
Definition imgui_layer.h:45
Definition render_frame_context.h:15
Definition layer.h:17
Definition window.h:30
Definition imgui_texture_integration_access_internal.h:10
Definition event.h:108
Definition imgui_layer.h:30
Definition imgui_layer_internal.h:23