Skip to content

Commit

Permalink
Update libgui ver
Browse files Browse the repository at this point in the history
  • Loading branch information
dvsku committed Jun 18, 2024
1 parent 6bd13d7 commit e491b48
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 78 deletions.
2 changes: 1 addition & 1 deletion dependencies/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
55 changes: 7 additions & 48 deletions source/src/dt_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
#include <imgui/imgui_internal.h>

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);
}
Expand All @@ -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();

Expand Down
4 changes: 2 additions & 2 deletions source/src/dt_app.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
#include <libgui.hpp>

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;
Expand Down
2 changes: 1 addition & 1 deletion source/src/dvsku_toolkit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions source/src/gui/dt_comp_pack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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 });
Expand Down
12 changes: 6 additions & 6 deletions source/src/gui/dt_comp_unpack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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 });
Expand Down
6 changes: 3 additions & 3 deletions source/src/gui/dt_modal_errors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
#include "dt_app.hpp"

using namespace dvsku_toolkit;
using namespace dvsku;
using namespace libgui;

///////////////////////////////////////////////////////////////////////////////
// PUBLIC

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");

Expand Down
2 changes: 1 addition & 1 deletion source/src/gui/dt_modal_errors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};
}
4 changes: 2 additions & 2 deletions source/src/systems/dt_sys_command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}));
}
Expand Down
6 changes: 3 additions & 3 deletions source/src/systems/dt_sys_command.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "systems/dt_system_base.hpp"

#include <libgui/systems/gui_sys_command.hpp>
#include <libgui/systems/sys_command.hpp>

namespace dvsku_toolkit {
class dt_app;
Expand All @@ -11,7 +11,7 @@ namespace dvsku_toolkit {
flag_show_error_window
};

class dt_sys_command : public dt_system_base, public dvsku::gui_sys_command<dt_commands> {
class dt_sys_command : public dt_system_base, public libgui::sys_command<dt_commands> {
public:
dt_sys_command() = delete;
dt_sys_command(const dt_sys_command&) = delete;
Expand All @@ -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_commands>() {};
: dt_system_base(app), libgui::sys_command<dt_commands>() {};

public:
void prepare();
Expand Down
2 changes: 1 addition & 1 deletion source/src/systems/dt_sys_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
8 changes: 4 additions & 4 deletions source/src/systems/dt_sys_core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit e491b48

Please sign in to comment.