GUI Improvements with fonts and some underlying palette and bitmap code stuff

This commit is contained in:
Justin Scofield
2022-06-11 13:51:02 -04:00
parent ce9ac5383e
commit 0de51934ab
19 changed files with 2842 additions and 224 deletions

View File

@@ -6,9 +6,9 @@
#include <memory>
#include "Editor/Editor.h"
#include "Events/Event.h"
#include "Renderer.h"
#include "Editor/Editor.h"
#include "Window.h"
#include "imgui/backends/imgui_impl_sdl.h"
#include "imgui/backends/imgui_impl_sdlrenderer.h"
@@ -37,7 +37,7 @@ class Controller {
private:
Window window;
Renderer renderer;
View::Editor editor;
Editor::Editor editor;
bool active = false;
void quit() { active = false; }
friend int ::main(int argc, char** argv);

2192
src/Application/Core/Icons.h Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -22,11 +22,31 @@ void Renderer::Create(SDL_Window* window) {
// Create the ImGui and ImPlot contexts
ImGui::CreateContext();
// Initialize ImGui for SDL
ImGui_ImplSDL2_InitForSDLRenderer(window, renderer);
ImGui_ImplSDLRenderer_Init(renderer);
// Load available fonts
const ImGuiIO& io = ImGui::GetIO();
io.Fonts->AddFontFromFileTTF("assets/Fonts/Karla-Regular.ttf", 14.0f);
// merge in icons from Google Material Design
static const ImWchar icons_ranges[] = {ICON_MIN_MD, 0xf900, 0};
ImFontConfig icons_config;
icons_config.MergeMode = true;
icons_config.GlyphOffset.y = 5.0f;
icons_config.GlyphMinAdvanceX = 13.0f;
icons_config.PixelSnapH = true;
io.Fonts->AddFontFromFileTTF(FONT_ICON_FILE_NAME_MD, 18.0f, &icons_config,
icons_ranges);
io.Fonts->AddFontFromFileTTF("assets/Fonts/Roboto-Medium.ttf", 14.0f);
io.Fonts->AddFontFromFileTTF("assets/Fonts/Cousine-Regular.ttf", 14.0f);
io.Fonts->AddFontFromFileTTF("assets/Fonts/DroidSans.ttf", 16.0f);
Style::StyleColorsYaze();
// Build a new ImGui frame
ImGui_ImplSDLRenderer_NewFrame();
ImGui_ImplSDL2_NewFrame(window);
@@ -44,7 +64,6 @@ void Renderer::Destroy() {
renderer = nullptr;
}
} // namespace Core
} // namespace Application
} // namespace yaze

View File

@@ -3,25 +3,27 @@
#include <SDL2/SDL.h>
#include "imgui/imgui.h"
#include "imgui/imgui_internal.h"
#include "Icons.h"
#include "Style.h"
#include "imgui/backends/imgui_impl_sdl.h"
#include "imgui/backends/imgui_impl_sdlrenderer.h"
#include "imgui/imgui.h"
#include "imgui/imgui_internal.h"
#include "imgui/misc/cpp/imgui_stdlib.h"
namespace yaze {
namespace Application {
namespace Core {
class Renderer {
public:
void Create(SDL_Window* window);
void Render();
void Destroy();
class Renderer {
public:
void Create(SDL_Window* window);
void Render();
void Destroy();
private:
SDL_Renderer* renderer = nullptr;
};
private:
SDL_Renderer* renderer = nullptr;
};
} // namespace Core
} // namespace Application

View File

@@ -0,0 +1,120 @@
#ifndef YAZE_APPLICATION_CORE_STYLE_H
#define YAZE_APPLCIATION_CORE_STYLE_H
#include "imgui/imgui.h"
#include "imgui/imgui_internal.h"
namespace yaze {
namespace Application {
namespace Core {
namespace Style {
inline static void StyleColorsYaze() {
ImGuiStyle *style = &ImGui::GetStyle();
ImVec4 *colors = style->Colors;
style->WindowPadding = ImVec2(10.f, 10.f);
style->FramePadding = ImVec2(10.f, 3.f);
style->CellPadding = ImVec2(4.f, 5.f);
style->ItemSpacing = ImVec2(10.f, 5.f);
style->ItemInnerSpacing = ImVec2(5.f, 5.f);
style->TouchExtraPadding = ImVec2(0.f, 0.f);
style->IndentSpacing = 20.f;
style->ScrollbarSize = 14.f;
style->GrabMinSize = 15.f;
style->WindowBorderSize = 0.f;
style->ChildBorderSize = 1.f;
style->PopupBorderSize = 1.f;
style->FrameBorderSize = 0.f;
style->TabBorderSize = 0.f;
style->WindowRounding = 0.f;
style->ChildRounding = 0.f;
style->FrameRounding = 5.4;
style->PopupRounding = 0.f;
style->ScrollbarRounding = 5.f;
ImVec4 alttpDarkGreen = ImVec4(0.18f, 0.26f, 0.18f, 1.0f);
ImVec4 alttpMidGreen = ImVec4(0.28f, 0.36f, 0.28f, 1.0f);
ImVec4 allttpLightGreen = ImVec4(0.36f, 0.45f, 0.36f, 1.0f);
ImVec4 allttpLightestGreen = ImVec4(0.49f, 0.57f, 0.49f, 1.0f);
ImVec4 alttpBlue = ImVec4(0.f, 0.f, 0.47f, 1.0f);
ImVec4 alttpBlueHover = ImVec4(0.f, 0.f, 0.57f, 1.0f);
ImVec4 alttpBlueActive = ImVec4(0.f, 0.f, 0.67f, 1.0f);
colors[ImGuiCol_MenuBarBg] = alttpDarkGreen;
colors[ImGuiCol_TitleBg] = alttpMidGreen;
colors[ImGuiCol_Header] = alttpDarkGreen;
colors[ImGuiCol_HeaderHovered] = allttpLightGreen;
colors[ImGuiCol_HeaderActive] = alttpMidGreen;
colors[ImGuiCol_TitleBgActive] = alttpDarkGreen;
colors[ImGuiCol_TitleBgCollapsed] = alttpMidGreen;
colors[ImGuiCol_Tab] = alttpDarkGreen;
colors[ImGuiCol_TabHovered] = alttpMidGreen;
colors[ImGuiCol_TabActive] = ImLerp(colors[ImGuiCol_HeaderActive],
colors[ImGuiCol_TitleBgActive], 0.60f);
colors[ImGuiCol_Button] = alttpMidGreen;
colors[ImGuiCol_ButtonHovered] = allttpLightestGreen;
colors[ImGuiCol_ButtonActive] = allttpLightGreen;
colors[ImGuiCol_ScrollbarBg] = ImVec4(0.36f, 0.45f, 0.36f, 0.60f);
colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.36f, 0.45f, 0.36f, 0.30f);
colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.36f, 0.45f, 0.36f, 0.40f);
colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.36f, 0.45f, 0.36f, 0.60f);
colors[ImGuiCol_Text] = ImVec4(0.90f, 0.90f, 0.90f, 1.00f);
colors[ImGuiCol_TextDisabled] = ImVec4(0.60f, 0.60f, 0.60f, 1.00f);
colors[ImGuiCol_WindowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.85f);
colors[ImGuiCol_ChildBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
colors[ImGuiCol_PopupBg] = ImVec4(0.11f, 0.11f, 0.14f, 0.92f);
colors[ImGuiCol_Border] = allttpLightGreen;
colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
colors[ImGuiCol_FrameBg] = ImVec4(0.43f, 0.43f, 0.43f, 0.39f);
colors[ImGuiCol_FrameBgHovered] = ImVec4(0.28f, 0.36f, 0.28f, 0.40f);
colors[ImGuiCol_FrameBgActive] = ImVec4(0.28f, 0.36f, 0.28f, 0.69f);
colors[ImGuiCol_CheckMark] = ImVec4(0.90f, 0.90f, 0.90f, 0.50f);
colors[ImGuiCol_SliderGrab] = ImVec4(1.00f, 1.00f, 1.00f, 0.30f);
colors[ImGuiCol_SliderGrabActive] = ImVec4(0.36f, 0.45f, 0.36f, 0.60f);
colors[ImGuiCol_Separator] = ImVec4(0.50f, 0.50f, 0.50f, 0.60f);
colors[ImGuiCol_SeparatorHovered] = ImVec4(0.60f, 0.60f, 0.70f, 1.00f);
colors[ImGuiCol_SeparatorActive] = ImVec4(0.70f, 0.70f, 0.90f, 1.00f);
colors[ImGuiCol_ResizeGrip] = ImVec4(1.00f, 1.00f, 1.00f, 0.10f);
colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.78f, 0.82f, 1.00f, 0.60f);
colors[ImGuiCol_ResizeGripActive] = ImVec4(0.78f, 0.82f, 1.00f, 0.90f);
colors[ImGuiCol_TabUnfocused] =
ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f);
colors[ImGuiCol_TabUnfocusedActive] =
ImLerp(colors[ImGuiCol_TabActive], colors[ImGuiCol_TitleBg], 0.40f);
colors[ImGuiCol_PlotLines] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
colors[ImGuiCol_PlotLinesHovered] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f);
colors[ImGuiCol_TableHeaderBg] = alttpDarkGreen;
colors[ImGuiCol_TableBorderStrong] = alttpMidGreen;
colors[ImGuiCol_TableBorderLight] =
ImVec4(0.26f, 0.26f, 0.28f, 1.00f); // Prefer using Alpha=1.0 here
colors[ImGuiCol_TableRowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
colors[ImGuiCol_TableRowBgAlt] = ImVec4(1.00f, 1.00f, 1.00f, 0.07f);
colors[ImGuiCol_TextSelectedBg] = ImVec4(0.00f, 0.00f, 1.00f, 0.35f);
colors[ImGuiCol_DragDropTarget] = ImVec4(1.00f, 1.00f, 0.00f, 0.90f);
colors[ImGuiCol_NavHighlight] = colors[ImGuiCol_HeaderHovered];
colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f);
colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.20f);
colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.20f, 0.20f, 0.20f, 0.35f);
}
} // namespace Style
} // namespace Core
} // namespace Application
} // namespace yaze
#endif

View File

@@ -12,8 +12,8 @@ void Window::Create() {
window = SDL_CreateWindow("Yet Another Zelda3 Editor", // window title
SDL_WINDOWPOS_UNDEFINED, // initial x position
SDL_WINDOWPOS_UNDEFINED, // initial y position
800, // width, in pixels
600, // height, in pixels
1200, // width, in pixels
800, // height, in pixels
SDL_WINDOW_RESIZABLE // window flags
);
}