LkEngine 0.1.2
 
Loading...
Searching...
No Matches
ThemeManagerPanel.h
1#pragma once
2
3#include "LkEngine/Renderer/UI/Panel.h"
4
5
6namespace LkEngine {
7
13 enum class ETheme
14 {
15 Dark,
16 Light,
17 GruvboxMaterial,
18 COUNT,
19 };
20 LK_ENUM_RANGE_BY_COUNT(ETheme, ETheme::COUNT);
21
22 namespace Enum
23 {
24 static const char* ToString(const ETheme Theme);
25 }
26
28 {
29 public:
31 ~LThemeManagerPanel() = default;
32
33 virtual void RenderUI(bool& IsOpen) override;
34 virtual void Render() override {}
35
36 static void SetTheme(const ETheme Theme);
37 static std::string GetCurrentThemeName() { return CurrentThemeName; }
38
39 static void LoadDefaultTheme();
40
41 static void SetSelectorEnabled(const bool InEnabled);
42 FORCEINLINE static bool IsSelectorEnabled() { return bSelectorEnabled; }
43
44 static bool SaveCurrentTheme();
45 static bool LoadSavedTheme(std::string_view ThemeName);
46
47 static void OnMouseButtonPressed(const FMouseButtonData& ButtonData);
48
49 public:
50 inline static std::string_view THEME_FILE_EXTENSION = "lktheme";
51 private:
52 virtual void SerializeToYaml(YAML::Emitter& Out) const override;
53 virtual void DeserializeFromYaml(const YAML::Node& Data) override;
54
55 static void LoadTheme(const ETheme Theme, ImVec4* Colors);
56 void LoadThemeFromYaml(const YAML::Node& Data);
57
58 void UI_SaveThemePopup();
59 void UI_SelectThemePopup();
60
61 void UI_ColorPicker();
62
63 static bool IsDefaultTheme(std::string_view InThemeName)
64 {
65 for (const ETheme Theme : TEnumRange<ETheme>())
66 {
67 if (InThemeName == Enum::ToString(Theme))
68 {
69 return true;
70 }
71 }
72
73 return false;
74 }
75
76 private:
77 inline static std::string CurrentThemeName{};
78 inline static bool bSelectorEnabled = false;
79 inline static std::filesystem::path ThemesDirectory{};
80
81 friend class LEditorLayer;
82
84 };
85
86 namespace Enum
87 {
88 static const char* ToString(const ETheme Theme)
89 {
90 switch (Theme)
91 {
92 case ETheme::Dark: return "Dark";
93 case ETheme::Light: return "Light";
94 case ETheme::GruvboxMaterial: return "GruvboxMaterial";
95 case ETheme::COUNT: LK_CORE_VERIFY(false, "Enum::ToString(const ETheme) failed");
96 }
97
98 LK_CORE_VERIFY(false, "Enum::ToString(const ETheme) failed for: {}", static_cast<int>(Theme));
99 return nullptr;
100 }
101 }
102
103}
Definition Panel.h:18
Definition ThemeManagerPanel.h:28
static bool SaveCurrentTheme()
Definition ThemeManagerPanel.cpp:163
#define LPANEL(...)
Definition CoreMacros.h:345
Definition Asset.h:11
ETheme
Definition ThemeManagerPanel.h:14
Definition MouseCodes.h:54
Definition Enum.h:246