mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-21 20:08:40 +03:00
Added Screen space reflections and Editor UI refactoring
This commit is contained in:
26
Editor/src/Misc/ImGuiTextHelper.h
Normal file
26
Editor/src/Misc/ImGuiTextHelper.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <src/Vendors/imgui/imgui.h>
|
||||
|
||||
void ImGuiTextSTD(const std::string& label, std::string& value)
|
||||
{
|
||||
char buffer[256];
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
std::strncpy(buffer, value.c_str(), sizeof(buffer));
|
||||
if (ImGui::InputText(label.c_str(), buffer, sizeof(buffer)))
|
||||
{
|
||||
|
||||
value = std::string(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
void ImGuiTextMultiline(const std::string& label, std::string& value)
|
||||
{
|
||||
char buffer[256];
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
std::strncpy(buffer, value.c_str(), sizeof(buffer));
|
||||
if (ImGui::InputTextMultiline(label.c_str(), buffer, sizeof(buffer)))
|
||||
{
|
||||
value = std::string(buffer);
|
||||
}
|
||||
}
|
||||
38
Editor/src/Misc/InterfaceFonts.cpp
Normal file
38
Editor/src/Misc/InterfaceFonts.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#pragma once
|
||||
#include "InterfaceFonts.h"
|
||||
#include <src/Vendors/imgui/imgui.h>
|
||||
#include <src/Resource/FontAwesome5.h>
|
||||
|
||||
std::map<Fonts, ImFont*> FontManager::mFonts = std::map<Fonts, ImFont*>();
|
||||
|
||||
void FontManager::LoadFonts()
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||
static const ImWchar icons_ranges[] = { ICON_MIN_FA, ICON_MAX_FA, 0 };
|
||||
ImFontConfig icons_config; icons_config.MergeMode = true; icons_config.PixelSnapH = true;
|
||||
|
||||
mFonts[Normal] = io.Fonts->AddFontFromFileTTF("resources/Fonts/fa-solid-900.ttf", 11.0f, &icons_config, icons_ranges);
|
||||
mFonts[Bold] = io.Fonts->AddFontFromFileTTF("resources/Fonts/OpenSans-Bold.ttf", 16.0);
|
||||
mFonts[LargeBold] = io.Fonts->AddFontFromFileTTF("resources/Fonts/OpenSans-Regular.ttf", 32);
|
||||
mFonts[Title] = io.Fonts->AddFontFromFileTTF("resources/Fonts/OpenSans-Bold.ttf", 50.0);
|
||||
mFonts[SubTitle] = io.Fonts->AddFontFromFileTTF("resources/Fonts/OpenSans-Regular.ttf", 24.0);
|
||||
ImGui::GetIO().Fonts->AddFontDefault();
|
||||
icons_config.MergeMode = true;
|
||||
mFonts[BigIcon] = io.Fonts->AddFontFromFileTTF("resources/Fonts/fa-solid-900.ttf", 42.0f, &icons_config, icons_ranges);
|
||||
}
|
||||
|
||||
ImFont* FontManager::GetFont(Fonts font)
|
||||
{
|
||||
return mFonts[font];
|
||||
}
|
||||
|
||||
UIFont::UIFont(Fonts font)
|
||||
{
|
||||
ImGuiFont = FontManager::GetFont(font);
|
||||
ImGui::PushFont(ImGuiFont);
|
||||
}
|
||||
|
||||
UIFont::~UIFont()
|
||||
{
|
||||
ImGui::PopFont();
|
||||
}
|
||||
28
Editor/src/Misc/InterfaceFonts.h
Normal file
28
Editor/src/Misc/InterfaceFonts.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
|
||||
enum Fonts {
|
||||
Normal, Bold, LargeBold, Icons, BigIcon, Title, SubTitle
|
||||
};
|
||||
|
||||
class ImFont;
|
||||
|
||||
// Help class that automatically push and pops itself when
|
||||
// Reaching end of scope
|
||||
class UIFont {
|
||||
private:
|
||||
ImFont* ImGuiFont;
|
||||
public:
|
||||
UIFont(Fonts font);
|
||||
~UIFont();
|
||||
};
|
||||
|
||||
class FontManager {
|
||||
private:
|
||||
static std::map < Fonts, ImFont*> mFonts;
|
||||
|
||||
public:
|
||||
static void LoadFonts();
|
||||
static ImFont* GetFont(Fonts font);
|
||||
};
|
||||
Reference in New Issue
Block a user