mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
visual look changes
This commit is contained in:
75
uilayer.cpp
75
uilayer.cpp
@@ -28,6 +28,8 @@ http://mozilla.org/MPL/2.0/.
|
||||
GLFWwindow *ui_layer::m_window{nullptr};
|
||||
ImGuiIO *ui_layer::m_imguiio{nullptr};
|
||||
bool ui_layer::m_cursorvisible;
|
||||
ImFont *ui_layer::font_default{nullptr};
|
||||
ImFont *ui_layer::font_mono{nullptr};
|
||||
|
||||
ui_panel::ui_panel(std::string const &Identifier, bool const Isopen) : m_name(Identifier), is_open(Isopen) {}
|
||||
|
||||
@@ -83,10 +85,14 @@ void ui_expandable_panel::render_contents()
|
||||
|
||||
void ui_log_panel::render_contents()
|
||||
{
|
||||
ImGui::PushFont(ui_layer::font_mono);
|
||||
|
||||
for (const std::string &s : log_scrollback)
|
||||
ImGui::TextUnformatted(s.c_str());
|
||||
if (ImGui::GetScrollY() == ImGui::GetScrollMaxY())
|
||||
ImGui::SetScrollHereY(1.0f);
|
||||
|
||||
ImGui::PopFont();
|
||||
}
|
||||
|
||||
ui_layer::~ui_layer() {}
|
||||
@@ -122,9 +128,64 @@ ui_layer::ui_layer()
|
||||
m_logpanel.size = { 700, 400 };
|
||||
}
|
||||
|
||||
static ImVec4 imvec_lerp(const ImVec4& a, const ImVec4& b, float t)
|
||||
{
|
||||
return ImVec4(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t, a.z + (b.z - a.z) * t, a.w + (b.w - a.w) * t);
|
||||
}
|
||||
|
||||
void ui_layer::imgui_style()
|
||||
{
|
||||
ImGui::StyleColorsDark();
|
||||
ImVec4* colors = ImGui::GetStyle().Colors;
|
||||
|
||||
colors[ImGuiCol_Text] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
|
||||
colors[ImGuiCol_TextDisabled] = ImVec4(0.35f, 0.35f, 0.35f, 1.00f);
|
||||
colors[ImGuiCol_WindowBg] = ImVec4(0.04f, 0.04f, 0.04f, 0.94f);
|
||||
colors[ImGuiCol_ChildBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
|
||||
colors[ImGuiCol_PopupBg] = ImVec4(0.06f, 0.06f, 0.06f, 0.94f);
|
||||
colors[ImGuiCol_Border] = ImVec4(0.31f, 0.34f, 0.31f, 0.50f);
|
||||
colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
|
||||
colors[ImGuiCol_FrameBg] = ImVec4(0.21f, 0.28f, 0.17f, 0.54f);
|
||||
colors[ImGuiCol_FrameBgHovered] = ImVec4(0.42f, 0.64f, 0.23f, 0.40f);
|
||||
colors[ImGuiCol_FrameBgActive] = ImVec4(0.42f, 0.64f, 0.23f, 0.67f);
|
||||
colors[ImGuiCol_TitleBg] = ImVec4(0.03f, 0.03f, 0.03f, 1.00f);
|
||||
colors[ImGuiCol_TitleBgActive] = ImVec4(0.21f, 0.28f, 0.17f, 1.00f);
|
||||
colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.00f, 0.00f, 0.00f, 0.51f);
|
||||
colors[ImGuiCol_MenuBarBg] = ImVec4(0.10f, 0.10f, 0.10f, 1.00f);
|
||||
colors[ImGuiCol_ScrollbarBg] = ImVec4(0.01f, 0.01f, 0.01f, 0.53f);
|
||||
colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.22f, 0.22f, 0.22f, 1.00f);
|
||||
colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.29f, 0.29f, 0.29f, 1.00f);
|
||||
colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.36f, 0.36f, 0.36f, 1.00f);
|
||||
colors[ImGuiCol_CheckMark] = ImVec4(0.42f, 0.64f, 0.23f, 1.00f);
|
||||
colors[ImGuiCol_SliderGrab] = ImVec4(0.37f, 0.53f, 0.25f, 1.00f);
|
||||
colors[ImGuiCol_SliderGrabActive] = ImVec4(0.42f, 0.64f, 0.23f, 1.00f);
|
||||
colors[ImGuiCol_Button] = ImVec4(0.42f, 0.64f, 0.23f, 0.40f);
|
||||
colors[ImGuiCol_ButtonHovered] = ImVec4(0.42f, 0.64f, 0.23f, 1.00f);
|
||||
colors[ImGuiCol_ButtonActive] = ImVec4(0.37f, 0.54f, 0.19f, 1.00f);
|
||||
colors[ImGuiCol_Header] = ImVec4(0.42f, 0.64f, 0.23f, 0.31f);
|
||||
colors[ImGuiCol_HeaderHovered] = ImVec4(0.42f, 0.64f, 0.23f, 0.80f);
|
||||
colors[ImGuiCol_HeaderActive] = ImVec4(0.42f, 0.64f, 0.23f, 1.00f);
|
||||
colors[ImGuiCol_SeparatorHovered] = ImVec4(0.29f, 0.41f, 0.18f, 0.78f);
|
||||
colors[ImGuiCol_SeparatorActive] = ImVec4(0.29f, 0.41f, 0.18f, 1.00f);
|
||||
colors[ImGuiCol_ResizeGrip] = ImVec4(0.42f, 0.64f, 0.23f, 0.25f);
|
||||
colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.42f, 0.64f, 0.23f, 0.67f);
|
||||
colors[ImGuiCol_ResizeGripActive] = ImVec4(0.42f, 0.64f, 0.23f, 0.95f);
|
||||
colors[ImGuiCol_PlotLines] = ImVec4(0.43f, 0.43f, 0.43f, 1.00f);
|
||||
colors[ImGuiCol_PlotLinesHovered] = ImVec4(0.29f, 0.24f, 0.71f, 1.00f);
|
||||
colors[ImGuiCol_PlotHistogram] = ImVec4(0.40f, 0.16f, 0.47f, 1.00f);
|
||||
colors[ImGuiCol_PlotHistogramHovered] = ImVec4(0.39f, 0.18f, 0.52f, 1.00f);
|
||||
colors[ImGuiCol_TextSelectedBg] = ImVec4(0.42f, 0.64f, 0.23f, 0.35f);
|
||||
colors[ImGuiCol_DragDropTarget] = ImVec4(0.52f, 0.18f, 0.52f, 0.90f);
|
||||
colors[ImGuiCol_NavHighlight] = ImVec4(0.42f, 0.64f, 0.23f, 1.00f);
|
||||
colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f);
|
||||
colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.56f, 0.56f, 0.56f, 0.20f);
|
||||
colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.56f, 0.56f, 0.56f, 0.35f);
|
||||
|
||||
colors[ImGuiCol_Separator] = colors[ImGuiCol_Border];
|
||||
colors[ImGuiCol_Tab] = imvec_lerp(colors[ImGuiCol_Header], colors[ImGuiCol_TitleBgActive], 0.80f);
|
||||
colors[ImGuiCol_TabHovered] = colors[ImGuiCol_HeaderHovered];
|
||||
colors[ImGuiCol_TabActive] = imvec_lerp(colors[ImGuiCol_HeaderActive], colors[ImGuiCol_TitleBgActive], 0.60f);
|
||||
colors[ImGuiCol_TabUnfocused] = imvec_lerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f);
|
||||
colors[ImGuiCol_TabUnfocusedActive] = imvec_lerp(colors[ImGuiCol_TabActive], colors[ImGuiCol_TitleBg], 0.40f);
|
||||
}
|
||||
|
||||
bool ui_layer::init(GLFWwindow *Window)
|
||||
@@ -148,7 +209,17 @@ bool ui_layer::init(GLFWwindow *Window)
|
||||
0,
|
||||
};
|
||||
|
||||
m_imguiio->Fonts->AddFontFromFileTTF("fonts/dejavusansmono.ttf", 13.0f, nullptr, &ranges[0]);
|
||||
if (FileExists("fonts/dejavusans.ttf"))
|
||||
font_default = m_imguiio->Fonts->AddFontFromFileTTF("fonts/dejavusans.ttf", 13.0f, nullptr, &ranges[0]);
|
||||
if (FileExists("fonts/dejavusansmono.ttf"))
|
||||
font_mono = m_imguiio->Fonts->AddFontFromFileTTF("fonts/dejavusansmono.ttf", 13.0f, nullptr, &ranges[0]);
|
||||
|
||||
if (!font_default && !font_mono)
|
||||
font_default = font_mono = m_imguiio->Fonts->AddFontDefault();
|
||||
else if (!font_default)
|
||||
font_default = font_mono;
|
||||
else if (!font_mono)
|
||||
font_mono = font_default;
|
||||
|
||||
imgui_style();
|
||||
ImGui_ImplGlfw_InitForOpenGL(m_window);
|
||||
|
||||
Reference in New Issue
Block a user