diff --git a/dependencies/CMakeLists.txt b/dependencies/CMakeLists.txt index a76b861..e0b846d 100644 --- a/dependencies/CMakeLists.txt +++ b/dependencies/CMakeLists.txt @@ -8,7 +8,7 @@ SET(FETCHCONTENT_UPDATES_DISCONNECTED ON) FetchContent_Declare( libgui - URL https://github.com/dvsku/libgui/archive/refs/heads/master.zip + URL https://github.com/dvsku/libgui/archive/8ec3c50d4b067fab36311b3c8c486c90528bc41f.zip ) FetchContent_MakeAvailable(libgui) diff --git a/source/src/dt_app.cpp b/source/src/dt_app.cpp index 2d6be76..41284c8 100644 --- a/source/src/dt_app.cpp +++ b/source/src/dt_app.cpp @@ -4,13 +4,13 @@ #include using namespace dvsku_toolkit; -using namespace dvsku; +using namespace libgui; /////////////////////////////////////////////////////////////////////////////// // PUBLIC -dt_app::dt_app(const dvsku::gui_window_settings& settings) - : gui_window(settings), m_systems(*this), m_gui(*this) +dt_app::dt_app(const libgui::window_settings& settings) + : window(settings), m_systems(*this), m_gui(*this) { set_resizable(false); } @@ -29,51 +29,10 @@ dt_gui_mngr& dt_app::get_gui() { bool dt_app::prepare() { set_borderless(); - ImFontConfig config; - config.FontDataOwnedByAtlas = false; - config.RasterizerMultiply = 1.2f; - config.SizePixels = 13.0f; - - ImGuiIO& io = ImGui::GetIO(); - - // Add default font - io.Fonts->AddFontFromMemoryTTF(AVERAGE_MONO, (int)AVERAGE_MONO_LEN, 13.0f, &config); - - // Add font awesome - config.MergeMode = true; - static const ImWchar icon_ranges[] = { ICON_MIN_FA, ICON_MAX_FA, 0 }; - io.Fonts->AddFontFromMemoryTTF(FONTAWESOME_SOLID, (int)FONTAWESOME_SOLID_LEN, 13.0f, &config, icon_ranges); - - // Build fonts - io.Fonts->Build(); - - ImGuiStyle& style = ImGui::GetStyle(); - ImVec4* colors = style.Colors; - - style.TabRounding = 0.0f; - style.TabBarBorderSize = 2.0f; - style.DockingSeparatorSize = 1.0f; - style.WindowBorderSize = 0.0f; - style.WindowMenuButtonPosition = ImGuiDir_Right; - - colors[ImGuiCol_WindowBg] = ImVec4(0.14118f, 0.14118f, 0.14118f, 1.00f); - colors[ImGuiCol_ChildBg] = ImVec4(0.14118f, 0.14118f, 0.14118f, 1.00f); - colors[ImGuiCol_PopupBg] = ImVec4(0.14118f, 0.14118f, 0.14118f, 1.00f); - colors[ImGuiCol_TitleBg] = ImVec4(0.12157f, 0.12157f, 0.12157f, 1.00f); - colors[ImGuiCol_TitleBgActive] = ImVec4(0.12157f, 0.12157f, 0.12157f, 1.00f); - colors[ImGuiCol_FrameBg] = ImVec4(0.12157f, 0.12157f, 0.12157f, 1.00f); - colors[ImGuiCol_FrameBgHovered] = ImVec4(0.12157f, 0.12157f, 0.12157f, 1.00f); - colors[ImGuiCol_FrameBgActive] = ImVec4(0.12157f, 0.12157f, 0.12157f, 1.00f); - colors[ImGuiCol_Button] = ImVec4(0.29020f, 0.24314f, 0.61176f, 1.00f); - colors[ImGuiCol_ButtonHovered] = ImLerp(colors[ImGuiCol_Button], ImVec4(1.0f, 1.0f, 1.0f, 1.00f), 0.1f); - colors[ImGuiCol_ButtonActive] = ImLerp(colors[ImGuiCol_Button], ImVec4(0.0f, 0.0f, 0.0f, 1.00f), 0.2f); - colors[ImGuiCol_PlotHistogram] = ImVec4(0.29020f, 0.24314f, 0.61176f, 1.00f); - colors[ImGuiCol_CheckMark] = ImVec4(0.29020f, 0.24314f, 0.61176f, 1.00f); - colors[ImGuiCol_Tab] = ImVec4(0.18039f, 0.18039f, 0.18039f, 1.00f); - colors[ImGuiCol_TabHovered] = ImVec4(0.29020f, 0.24314f, 0.61176f, 1.00f); - colors[ImGuiCol_TabUnfocused] = ImVec4(0.18039f, 0.18039f, 0.18039f, 1.00f); - colors[ImGuiCol_TabActive] = ImVec4(0.29020f, 0.24314f, 0.61176f, 1.00f); - colors[ImGuiCol_TabUnfocusedActive] = ImLerp(colors[ImGuiCol_TabActive], ImVec4(0.0f, 0.0f, 0.0f, 1.00f), 0.2f); + theme::add_font("default", 13.0f, { + font_average_mono, + font_fontawesome_solid + }); m_systems.command.prepare(); diff --git a/source/src/dt_app.hpp b/source/src/dt_app.hpp index a1c8dfd..b95757e 100644 --- a/source/src/dt_app.hpp +++ b/source/src/dt_app.hpp @@ -6,13 +6,13 @@ #include namespace dvsku_toolkit { - class dt_app : public dvsku::gui_window { + class dt_app : public libgui::window { public: dt_app() = delete; dt_app(const dt_app&) = delete; dt_app(dt_app&&) = delete; - dt_app(const dvsku::gui_window_settings& settings); + dt_app(const libgui::window_settings& settings); dt_app& operator=(const dt_app&) = delete; dt_app& operator=(dt_app&&) = delete; diff --git a/source/src/dvsku_toolkit.cpp b/source/src/dvsku_toolkit.cpp index d6b496c..99bc621 100644 --- a/source/src/dvsku_toolkit.cpp +++ b/source/src/dvsku_toolkit.cpp @@ -7,7 +7,7 @@ using namespace dvsku_toolkit; INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR lpCmdLine, INT nCmdShow) { try { - dvsku::gui_window_settings settings; + libgui::window_settings settings; settings.width = 600U; settings.height = 275U; settings.title = DT_APP_NAME; diff --git a/source/src/gui/dt_comp_pack.cpp b/source/src/gui/dt_comp_pack.cpp index 752334c..8a70805 100644 --- a/source/src/gui/dt_comp_pack.cpp +++ b/source/src/gui/dt_comp_pack.cpp @@ -15,7 +15,7 @@ dt_comp_pack::dt_comp_pack(dt_app& app) m_progress = 0.0f; m_app.get_systems().core.is_working = true; - m_app.set_taskbar_status(dvsku::gui_taskbar_status::normal); + m_app.set_taskbar_status(libgui::taskbar_status::normal); m_app.set_taskbar_progress(0U); }; m_context.finish_callback = [this](libevp::evp_result result) { @@ -26,14 +26,14 @@ dt_comp_pack::dt_comp_pack(dt_app& app) m_app.get_systems().core.has_errors = false; m_app.get_systems().core.errors = ""; - m_app.set_taskbar_status(dvsku::gui_taskbar_status::no_progress); + m_app.set_taskbar_status(libgui::taskbar_status::no_progress); m_app.set_taskbar_progress(0U); if (result.status == libevp::evp_result_status::ok) { - dvsku::util_sound::success(); + libgui::sound::success(); } else if (result.status == libevp::evp_result_status::error) { - dvsku::util_sound::warning(); + libgui::sound::warning(); if (!result.message.empty()) { m_app.get_systems().core.has_errors = true; @@ -65,7 +65,7 @@ void dt_comp_pack::render() { ImGui::SameLine(0.0f, 5.0f); if (ImGui::Button("Select##Input", { 125.0f, 21.0f })) { - m_input = dvsku::util_dialog::select_dir("Input dir", m_input); + m_input = libgui::dialog::select_dir("Input dir", m_input); } ImGui::Indent(3.0f); @@ -77,7 +77,7 @@ void dt_comp_pack::render() { ImGui::SameLine(0.0f, 5.0f); if (ImGui::Button("Select##Output", { 125.0f, 21.0f })) { - m_output = dvsku::util_dialog::save_file("Output evp", m_output, true, { "EVP (*.evp)", "*.evp" }); + m_output = libgui::dialog::save_file("Output evp", m_output, true, { "EVP (*.evp)", "*.evp" }); } ImGui::Dummy({ 0.0f, 3.0f }); diff --git a/source/src/gui/dt_comp_unpack.cpp b/source/src/gui/dt_comp_unpack.cpp index 4ea995e..ec9d538 100644 --- a/source/src/gui/dt_comp_unpack.cpp +++ b/source/src/gui/dt_comp_unpack.cpp @@ -15,7 +15,7 @@ dt_comp_unpack::dt_comp_unpack(dt_app& app) m_progress = 0.0f; m_app.get_systems().core.is_working = true; - m_app.set_taskbar_status(dvsku::gui_taskbar_status::normal); + m_app.set_taskbar_status(libgui::taskbar_status::normal); m_app.set_taskbar_progress(0U); }; m_context.finish_callback = [this](libevp::evp_result result) { @@ -26,14 +26,14 @@ dt_comp_unpack::dt_comp_unpack(dt_app& app) m_app.get_systems().core.has_errors = false; m_app.get_systems().core.errors = ""; - m_app.set_taskbar_status(dvsku::gui_taskbar_status::no_progress); + m_app.set_taskbar_status(libgui::taskbar_status::no_progress); m_app.set_taskbar_progress(0U); if (result.status == libevp::evp_result_status::ok) { - dvsku::util_sound::success(); + libgui::sound::success(); } else if (result.status == libevp::evp_result_status::error) { - dvsku::util_sound::warning(); + libgui::sound::warning(); if (!result.message.empty()) { m_app.get_systems().core.has_errors = true; @@ -65,7 +65,7 @@ void dt_comp_unpack::render() { ImGui::SameLine(0.0f, 5.0f); if (ImGui::Button("Select##Input", { 125.0f, 21.0f })) { - m_input = dvsku::util_dialog::open_file("Input evp", m_input, { "EVP (*.evp)", "*.evp" }); + m_input = libgui::dialog::open_file("Input evp", m_input, { "EVP (*.evp)", "*.evp" }); } ImGui::Indent(3.0f); @@ -77,7 +77,7 @@ void dt_comp_unpack::render() { ImGui::SameLine(0.0f, 5.0f); if (ImGui::Button("Select##Output", { 125.0f, 21.0f })) { - m_output = dvsku::util_dialog::select_dir("Output dir", m_output); + m_output = libgui::dialog::select_dir("Output dir", m_output); } ImGui::Dummy({ 0.0f, 10.0f }); diff --git a/source/src/gui/dt_modal_errors.cpp b/source/src/gui/dt_modal_errors.cpp index 93ff1c0..5c77e59 100644 --- a/source/src/gui/dt_modal_errors.cpp +++ b/source/src/gui/dt_modal_errors.cpp @@ -2,7 +2,7 @@ #include "dt_app.hpp" using namespace dvsku_toolkit; -using namespace dvsku; +using namespace libgui; /////////////////////////////////////////////////////////////////////////////// // PUBLIC @@ -10,8 +10,8 @@ using namespace dvsku; dt_modal_errors::dt_modal_errors(dt_app& app) : dt_gui_base(app) {} -gui_command_state dt_modal_errors::render() { - gui_command_state state = gui_command_state::repeat; +command::state dt_modal_errors::render() { + command::state state = command::state::repeat; ImGui::OpenPopup("Errors##Modal"); diff --git a/source/src/gui/dt_modal_errors.hpp b/source/src/gui/dt_modal_errors.hpp index fc803bc..2fb94a4 100644 --- a/source/src/gui/dt_modal_errors.hpp +++ b/source/src/gui/dt_modal_errors.hpp @@ -17,6 +17,6 @@ namespace dvsku_toolkit { dt_modal_errors& operator=(dt_modal_errors&&) = delete; public: - dvsku::gui_command_state render(); + libgui::command::state render(); }; } \ No newline at end of file diff --git a/source/src/systems/dt_sys_command.cpp b/source/src/systems/dt_sys_command.cpp index 32fe58a..392b550 100644 --- a/source/src/systems/dt_sys_command.cpp +++ b/source/src/systems/dt_sys_command.cpp @@ -2,13 +2,13 @@ #include "dt_app.hpp" using namespace dvsku_toolkit; -using namespace dvsku; +using namespace libgui; /////////////////////////////////////////////////////////////////////////////// // PUBLIC void dt_sys_command::prepare() { - set_command(dt_commands::flag_show_error_window, gui_command([this]() { + set_command(dt_commands::flag_show_error_window, command([this]() { return m_app.get_gui().modal_errors.render(); })); } diff --git a/source/src/systems/dt_sys_command.hpp b/source/src/systems/dt_sys_command.hpp index 0ad8e75..8d9686e 100644 --- a/source/src/systems/dt_sys_command.hpp +++ b/source/src/systems/dt_sys_command.hpp @@ -2,7 +2,7 @@ #include "systems/dt_system_base.hpp" -#include +#include namespace dvsku_toolkit { class dt_app; @@ -11,7 +11,7 @@ namespace dvsku_toolkit { flag_show_error_window }; - class dt_sys_command : public dt_system_base, public dvsku::gui_sys_command { + class dt_sys_command : public dt_system_base, public libgui::sys_command { public: dt_sys_command() = delete; dt_sys_command(const dt_sys_command&) = delete; @@ -21,7 +21,7 @@ namespace dvsku_toolkit { dt_sys_command& operator=(dt_sys_command&&) = delete; dt_sys_command(dt_app& app) - : dt_system_base(app), gui_sys_command() {}; + : dt_system_base(app), libgui::sys_command() {}; public: void prepare(); diff --git a/source/src/systems/dt_sys_core.cpp b/source/src/systems/dt_sys_core.cpp index d3a9bc1..d6bc3fc 100644 --- a/source/src/systems/dt_sys_core.cpp +++ b/source/src/systems/dt_sys_core.cpp @@ -9,5 +9,5 @@ using namespace dvsku_toolkit; dt_sys_core::dt_sys_core(dt_app& app) : dt_system_base(app) { - app_version = dvsku::version(DT_VERSION_MAJOR, DT_VERSION_MINOR, DT_VERSION_REV); + app_version = libgui::version(DT_VERSION_MAJOR, DT_VERSION_MINOR, DT_VERSION_REV); }; \ No newline at end of file diff --git a/source/src/systems/dt_sys_core.hpp b/source/src/systems/dt_sys_core.hpp index ce98708..8f127f3 100644 --- a/source/src/systems/dt_sys_core.hpp +++ b/source/src/systems/dt_sys_core.hpp @@ -10,10 +10,10 @@ namespace dvsku_toolkit { class dt_sys_core : public dt_system_base { public: - dvsku::version app_version; - bool is_working = false; - bool has_errors = false; - std::string errors = ""; + libgui::version app_version; + bool is_working = false; + bool has_errors = false; + std::string errors = ""; std::mutex mutex;