Elaztek Developer Hub
Blamite Game Engine - blam!  00346.12.11.21.0529.blamite
The core library for the Blamite Game Engine.
theme_editor.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "../../debug_ui.h"
4 
8 
10 {
15  {
16  private:
17  int active_theme_index = -1;
18  std::string selected_theme = ENGINE_TEXT("choose");
19  std::string selected_metrics = ENGINE_TEXT("choose");
20  float global_ui_scale = 1.0f;
21 
22  public:
23  void Draw()
24  {
25  if (show)
26  {
27  if (ImGui::Begin("Theme Editor", &show))
28  {
29  if (ImGui::BeginCombo("theme", selected_theme.c_str()))
30  {
31  for (int i = 0; i < Blam::UI::Themes::GetColorSchemeList()->size(); i++)
32  {
34 
35  if (ImGui::Selectable(theme.name.c_str()))
36  {
37  selected_theme = theme.name;
38  active_theme_index = i;
39  theme.ApplyTheme();
40  }
41  }
43  }
44 
45  if (ImGui::BeginCombo("metrics", selected_metrics.c_str()))
46  {
47  for (int i = 0; i < Blam::UI::Themes::GetMetricsList()->size(); i++)
48  {
50 
51  if (ImGui::Selectable(metrics.name.c_str()))
52  {
53  selected_metrics = metrics.name;
54  active_theme_index = i;
55  metrics.ApplyMetrics();
56  }
57  }
59  }
60 
61  ImGuiIO& io = ImGui::GetIO();
62  ImFont* font_current = ImGui::GetFont();
63  if (ImGui::BeginCombo("imgui font", font_current->GetDebugName()))
64  {
65  for (int i = 0; i < io.Fonts->Fonts.Size; i++)
66  {
67  ImFont* font = io.Fonts->Fonts[i];
68  ImGui::PushID((void*)font);
69 
70  if (ImGui::Selectable(font->GetDebugName(), font == font_current))
71  {
72  io.FontDefault = font;
73  }
74 
75  ImGui::PopID();
76  }
78  }
80  Blam::DebugUI::Widgets::ShowHelpMarker(ENGINE_TEXT("imgui_theme_picker_font_info").c_str());
81 
82  ImGui::InputFloat("imgui ui scale", &global_ui_scale, 1.0f, 0.0f, 20.0f);
84  Blam::DebugUI::Widgets::ShowHelpMarker(ENGINE_TEXT("imgui_theme_editor_ui_scale_help_text").c_str());
85 
86  if (ImGui::Button("Update Scale"))
87  {
88  ImGui::GetStyle().ScaleAllSizes(global_ui_scale);
89  }
90 
91 
92  }
93  ImGui::End();
94  }
95  }
96  };
97 }
Blam::DebugUI::Widgets::ShowHelpMarker
BLAM void ShowHelpMarker(const char *desc)
Shows a help indicator.
Definition: widgets.cpp:7
ImGuiIO::FontDefault
ImFont * FontDefault
Definition: imgui.h:1362
Blam::UI::Themes::GetMetricsList
BLAM std::vector< BlamThemeMetrics > * GetMetricsList()
Retrieves the list of currently loaded theme metrics.
Definition: themes.cpp:456
themes.h
ImGui::End
IMGUI_API void End()
Definition: imgui.cpp:6016
ImGuiIO
Definition: imgui.h:1338
engine_text.h
ImGuiStyle::ScaleAllSizes
IMGUI_API void ScaleAllSizes(float scale_factor)
Definition: imgui.cpp:1171
ImGui::SameLine
IMGUI_API void SameLine(float offset_from_start_x=0.0f, float spacing=-1.0f)
Definition: imgui.cpp:7147
ImFont
Definition: imgui.h:2180
BlamColorScheme::name
std::string name
The name of the theme.
Definition: themes.h:31
Blam::UI::Themes::GetColorSchemeList
BLAM std::vector< BlamColorScheme > * GetColorSchemeList()
Retrieves the list of currently loaded color schemes.
Definition: themes.cpp:451
Blam::DebugUI::Windows::ModernThemeEditor
Class for the modern Theme Editor.
Definition: theme_editor.hpp:14
BlamThemeMetrics
Definition: themes.h:65
ImGuiIO::Fonts
ImFontAtlas * Fonts
Definition: imgui.h:1359
ImGui::Begin
IMGUI_API bool Begin(const char *name, bool *p_open=NULL, ImGuiWindowFlags flags=0)
Definition: imgui.cpp:5397
ImFontAtlas::Fonts
ImVector< ImFont * > Fonts
Definition: imgui.h:2167
BlamColorScheme::ApplyTheme
void ApplyTheme()
Applies the theme to the engine UI.
Definition: BlamColorScheme.cpp:13
ImFont::GetDebugName
const char * GetDebugName() const
Definition: imgui.h:2211
ImGui::GetFont
IMGUI_API ImFont * GetFont()
Definition: imgui.cpp:6867
ImGui::GetIO
IMGUI_API ImGuiIO & GetIO()
Definition: imgui.cpp:3300
ImGui::BeginCombo
IMGUI_API bool BeginCombo(const char *label, const char *preview_value, ImGuiComboFlags flags=0)
Definition: imgui_widgets.cpp:1416
ImGui::Selectable
IMGUI_API bool Selectable(const char *label, bool selected=false, ImGuiSelectableFlags flags=0, const ImVec2 &size=ImVec2(0, 0))
Definition: imgui_widgets.cpp:5469
Blam::DebugUI::ImGUIDrawingGroup::show
bool show
Controls whether or not the group should be shown. May not be used in all groups.
Definition: debug_ui.h:362
BlamColorScheme
Class representing a Blam Color Scheme.
Definition: themes.h:28
Blam::DebugUI::ImGUIDrawingGroup
Class representing an ImGUI drawing group/draw list item.
Definition: debug_ui.h:359
ImGui::PopID
IMGUI_API void PopID()
Definition: imgui.cpp:7026
ImGui::EndCombo
IMGUI_API void EndCombo()
Definition: imgui_widgets.cpp:1522
ImGui::GetStyle
IMGUI_API ImGuiStyle & GetStyle()
Definition: imgui.cpp:3306
Blam::DebugUI::Windows::ModernThemeEditor::Draw
void Draw()
Draws the contents of the group.
Definition: theme_editor.hpp:23
ENGINE_TEXT
#define ENGINE_TEXT(string_id)
Definition: engine_text.h:7
config.h
Blam::DebugUI::Windows
Legacy namespace to contain data for the legacy ImGUI console.
Definition: ui.h:14
BlamThemeMetrics::ApplyMetrics
void ApplyMetrics()
Applies the metrics to the engine UI.
Definition: BlamThemeMetrics.cpp:6
BlamThemeMetrics::name
std::string name
The name of the theme metrics.
Definition: themes.h:68
ImVector::Size
int Size
Definition: imgui.h:1229
ImGui::InputFloat
IMGUI_API bool InputFloat(const char *label, float *v, float step=0.0f, float step_fast=0.0f, const char *format="%.3f", ImGuiInputTextFlags flags=0)
Definition: imgui_widgets.cpp:2975
font
io.Fonts->AddFontFromMemoryCompressedTTF(compressed_data, compressed_data_size, size_pixels,...) font
Definition: README.txt:86
ImGui::PushID
IMGUI_API void PushID(const char *str_id)
Definition: imgui.cpp:6995
ImGui::Button
IMGUI_API bool Button(const char *label, const ImVec2 &size=ImVec2(0, 0))
Definition: imgui_widgets.cpp:644