Skip to content

Commit

Permalink
Replace dv_gui_opengl with libgui
Browse files Browse the repository at this point in the history
  • Loading branch information
dvsku committed Jun 4, 2024
1 parent a6ff403 commit 11c2c3f
Show file tree
Hide file tree
Showing 42 changed files with 81 additions and 88 deletions.
14 changes: 4 additions & 10 deletions dependencies/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,14 @@ SET(FETCHCONTENT_QUIET OFF)
SET(FETCHCONTENT_UPDATES_DISCONNECTED ON)

###############################################################################
# dv_gui_opengl

SET(DV_GUI_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
SET(DV_GUI_BUILD_OPENGL2 OFF CACHE BOOL "" FORCE)
SET(DV_GUI_BUILD_OPENGL3 ON CACHE BOOL "" FORCE)
# libgui

FetchContent_Declare(
dv_gui_opengl
URL https://github.com/dvsku/dv_gui_opengl/archive/d8a0c3459843a86e6f09a05df67fe8526b6d883c.zip
libgui
URL https://github.com/dvsku/libgui/archive/refs/heads/master.zip
)

FetchContent_MakeAvailable(dv_gui_opengl)

SET(DV_GUI_INCLUDES "${dv_gui_opengl_SOURCE_DIR}/include" PARENT_SCOPE)
FetchContent_MakeAvailable(libgui)

###############################################################################
# devue_plugin_core
Expand Down
8 changes: 4 additions & 4 deletions source/devue_app/src/devue_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ using namespace devue;
using namespace devue::core;

INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR lpCmdLine, INT nCmdShow) {
dvsku::dv_util_log::settings log_settings;
log_settings.level = dvsku::dv_util_log::level::debug;
dvsku::util_log::settings log_settings;
log_settings.level = dvsku::util_log::level::debug;

dvsku::dv_util_log::init(log_settings);
dvsku::util_log::init(log_settings);

dvsku::dv_window_settings settings;
dvsku::gui_window_settings settings;
settings.width = 1360U;
settings.height = 768U;
settings.title = "devue";
Expand Down
6 changes: 3 additions & 3 deletions source/devue_app/src/dv_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ using namespace dvsku;
///////////////////////////////////////////////////////////////////////////////
// PUBLIC

dv_app::dv_app(const dvsku::dv_window_settings& settings)
: dv_window(settings), m_components(&m_systems)
dv_app::dv_app(const dvsku::gui_window_settings& settings)
: gui_window(settings), m_components(&m_systems)
{
m_scene_render_target = std::make_shared<dv_multisample_frame_buffer>(settings.width, settings.height);
}
Expand Down Expand Up @@ -422,7 +422,7 @@ dvsku::uuid dv_app::create_checkerboard_texture() {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
};

dvsku::uuid uuid = dv_util_uuid::create("checkerboard");
dvsku::uuid uuid = util_uuid::create("checkerboard");

try {
if (m_systems.texture.textures.contains(uuid))
Expand Down
6 changes: 3 additions & 3 deletions source/devue_app/src/dv_app.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
#include "systems/dv_systems.hpp"
#include "rendering/dv_render_target.hpp"

#include <dv_gui_opengl/dv_gui_opengl.hpp>
#include <libgui.hpp>
#include <memory>

namespace devue {
class dv_app : public dvsku::dv_window {
class dv_app : public dvsku::gui_window {
public:
dv_app(const dvsku::dv_window_settings& settings);
dv_app(const dvsku::gui_window_settings& settings);
~dv_app();

private:
Expand Down
2 changes: 1 addition & 1 deletion source/devue_app/src/gui/base/dv_comp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "systems/dv_systems.hpp"

#include <dv_gui_opengl/dv_gui_opengl.hpp>
#include <libgui.hpp>
#include <imgui/imgui.h>
#include <imgui/imgui_internal.h>
#include <imgui/misc/cpp/imgui_stdlib.h>
Expand Down
8 changes: 4 additions & 4 deletions source/devue_app/src/gui/components/dv_comp_console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ using namespace devue;
dv_comp_console::dv_comp_console(dv_systems* systems, dv_components* components)
: dv_comp(systems, components)
{
dvsku::dv_util_log::create_source("gui_console", &m_text);
dvsku::util_log::create_source("gui_console", &m_text);
}

dv_comp_console::~dv_comp_console() {
dvsku::dv_util_log::remove_source("gui_console");
dvsku::util_log::remove_source("gui_console");
}

dvsku::dv_command_state dv_comp_console::render() {
dvsku::gui_command_state dv_comp_console::render() {
bool* visible = &m_systems->command.is_set_to_execute(dv_commands::flag_show_console);

if(ImGui::Begin("Console##Window", visible, ImGuiWindowFlags_HorizontalScrollbar)) {
Expand All @@ -22,5 +22,5 @@ dvsku::dv_command_state dv_comp_console::render() {
}
ImGui::End();

return dvsku::dv_command_state::repeat;
return dvsku::gui_command_state::repeat;
}
2 changes: 1 addition & 1 deletion source/devue_app/src/gui/components/dv_comp_console.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace devue {
~dv_comp_console();

public:
dvsku::dv_command_state render();
dvsku::gui_command_state render();

private:
std::stringstream m_text;
Expand Down
4 changes: 2 additions & 2 deletions source/devue_app/src/gui/components/dv_comp_texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using namespace devue;
dv_comp_texture::dv_comp_texture(dv_systems* systems, dv_components* components)
: dv_comp(systems, components) {}

dvsku::dv_command_state dv_comp_texture::render() {
dvsku::gui_command_state dv_comp_texture::render() {
bool* visible = &m_systems->command.is_set_to_execute(dv_commands::flag_show_texture);

std::string name = m_texture_name.empty() ?
Expand Down Expand Up @@ -55,7 +55,7 @@ dvsku::dv_command_state dv_comp_texture::render() {
m_requested_focus = false;
}

return dvsku::dv_command_state::repeat;
return dvsku::gui_command_state::repeat;
}

void dv_comp_texture::set_texture(dvsku::uuid uuid, const std::string& name) {
Expand Down
2 changes: 1 addition & 1 deletion source/devue_app/src/gui/components/dv_comp_texture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace devue {
dv_comp_texture(dv_systems* systems, dv_components* components);

public:
dvsku::dv_command_state render();
dvsku::gui_command_state render();
void set_texture(dvsku::uuid uuid, const std::string& name);

private:
Expand Down
4 changes: 2 additions & 2 deletions source/devue_app/src/gui/modals/dv_modal_about.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ using namespace devue;
dv_modal_about::dv_modal_about(dv_systems* systems, dv_components* components)
: dv_comp(systems, components) {}

dvsku::dv_command_state dv_modal_about::render() {
dvsku::gui_command_state dv_modal_about::render() {
bool* visible = &m_systems->command.is_set_to_execute(dv_commands::flag_show_modal_about);

ImVec2 pos = ImGui::GetMainViewport()->GetCenter();
Expand Down Expand Up @@ -37,5 +37,5 @@ dvsku::dv_command_state dv_modal_about::render() {
ImGui::EndPopup();
}

return dvsku::dv_command_state::repeat;
return dvsku::gui_command_state::repeat;
}
2 changes: 1 addition & 1 deletion source/devue_app/src/gui/modals/dv_modal_about.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ namespace devue {
dv_modal_about(dv_systems* systems, dv_components* components);

public:
dvsku::dv_command_state render();
dvsku::gui_command_state render();
};
}
12 changes: 6 additions & 6 deletions source/devue_app/src/gui/modals/dv_modal_import.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ void dv_modal_import::set_materials_path(const std::string& path) {
m_materials_path = path;
}

dvsku::dv_command_state dv_modal_import::render() {
dvsku::dv_command_state status = dvsku::dv_command_state::repeat;
dvsku::gui_command_state dv_modal_import::render() {
dvsku::gui_command_state status = dvsku::gui_command_state::repeat;

ImGui::OpenPopup("Import##Popup");

Expand All @@ -43,7 +43,7 @@ dvsku::dv_command_state dv_modal_import::render() {

ImGui::SameLine();
if (ImGui::Button("Select##File", ImVec2(120, 0))) {
auto selected = dvsku::dv_util_dialog::open_file("Import model", m_file_path, m_systems->plugin.get_model_file_types());
auto selected = dvsku::util_dialog::open_file("Import model", m_file_path, m_systems->plugin.get_model_file_types());

// By default set texture folder to be the same
// as the file
Expand All @@ -57,7 +57,7 @@ dvsku::dv_command_state dv_modal_import::render() {

ImGui::SameLine();
if (ImGui::Button("Select##Materials", ImVec2(120, 0))) {
std::string dir = dvsku::dv_util_dialog::select_dir("Select material folder", m_materials_path);
std::string dir = dvsku::util_dialog::select_dir("Select material folder", m_materials_path);

if (!dir.empty())
set_materials_path(dir);
Expand All @@ -78,7 +78,7 @@ dvsku::dv_command_state dv_modal_import::render() {
m_systems->model.import(m_file_path, m_materials_path);
reset();
ImGui::CloseCurrentPopup();
status = dvsku::dv_command_state::finished;
status = dvsku::gui_command_state::finished;
}

if (is_path_empty)
Expand All @@ -90,7 +90,7 @@ dvsku::dv_command_state dv_modal_import::render() {
if (ImGui::Button("Cancel", ImVec2(120, 0))) {
reset();
ImGui::CloseCurrentPopup();
status = dvsku::dv_command_state::finished;
status = dvsku::gui_command_state::finished;
}

ImGui::PopID();
Expand Down
2 changes: 1 addition & 1 deletion source/devue_app/src/gui/modals/dv_modal_import.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace devue {
void set_materials_path(const std::string& path);

public:
dvsku::dv_command_state render();
dvsku::gui_command_state render();

private:
bool m_keep_materials = false;
Expand Down
8 changes: 4 additions & 4 deletions source/devue_app/src/gui/modals/dv_modal_plugins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ using namespace devue;
dv_modal_plugins::dv_modal_plugins(dv_systems* systems, dv_components* components)
: dv_comp(systems, components) {}

dvsku::dv_command_state dv_modal_plugins::render() {
dvsku::gui_command_state dv_modal_plugins::render() {
bool* visible = &m_systems->command.is_set_to_execute(dv_commands::flag_show_modal_plugins);

ImVec2 pos = ImGui::GetMainViewport()->GetCenter();
Expand Down Expand Up @@ -47,7 +47,7 @@ dvsku::dv_command_state dv_modal_plugins::render() {
for (size_t i = 0; i < plugin.supported_model_types.size(); i++) {
ss << plugin.supported_model_types[i].name << " ";
ss << "(";
ss << dvsku::dv_util_string::replace(plugin.supported_model_types[i].extensions, ";", " ");
ss << dvsku::util_string::replace(plugin.supported_model_types[i].extensions, ";", " ");
ss << ")";

if (i != plugin.supported_model_types.size() - 1)
Expand All @@ -60,7 +60,7 @@ dvsku::dv_command_state dv_modal_plugins::render() {
for (size_t i = 0; i < plugin.supported_texture_types.size(); i++) {
ss << plugin.supported_texture_types[i].name << " ";
ss << "(";
ss << dvsku::dv_util_string::replace(plugin.supported_texture_types[i].extensions, ";", " ");
ss << dvsku::util_string::replace(plugin.supported_texture_types[i].extensions, ";", " ");
ss << ")";

if (i != plugin.supported_texture_types.size() - 1)
Expand Down Expand Up @@ -155,5 +155,5 @@ dvsku::dv_command_state dv_modal_plugins::render() {
ImGui::EndPopup();
}

return dvsku::dv_command_state::repeat;
return dvsku::gui_command_state::repeat;
}
2 changes: 1 addition & 1 deletion source/devue_app/src/gui/modals/dv_modal_plugins.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace devue {
dv_modal_plugins(dv_systems* systems, dv_components* components);

public:
dvsku::dv_command_state render();
dvsku::gui_command_state render();

private:
dvsku::uuid m_current_plugin_id = 0U;
Expand Down
10 changes: 5 additions & 5 deletions source/devue_app/src/systems/dv_sys_command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ dv_sys_command::dv_sys_command(dv_systems* systems)
bool dv_sys_command::prepare(dv_components* components) {
if (!m_systems || !components) return false;

set_command(dv_commands::flag_show_console, dvsku::dv_command([components] {
set_command(dv_commands::flag_show_console, dvsku::gui_command([components] {
return components->console.render();
}));

set_command(dv_commands::flag_show_texture, dvsku::dv_command([components] {
set_command(dv_commands::flag_show_texture, dvsku::gui_command([components] {
return components->texture.render();
}));

set_command(dv_commands::flag_show_modal_import, dvsku::dv_command([components] {
set_command(dv_commands::flag_show_modal_import, dvsku::gui_command([components] {
return components->modal_import.render();
}));

set_command(dv_commands::flag_show_modal_plugins, dvsku::dv_command([components] {
set_command(dv_commands::flag_show_modal_plugins, dvsku::gui_command([components] {
return components->modal_plugins.render();
}));

set_command(dv_commands::flag_show_modal_about, dvsku::dv_command([components] {
set_command(dv_commands::flag_show_modal_about, dvsku::gui_command([components] {
return components->modal_about.render();
}));

Expand Down
4 changes: 2 additions & 2 deletions source/devue_app/src/systems/dv_sys_command.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <dv_gui_opengl/dv_gui_opengl.hpp>
#include <libgui/systems/gui_sys_command.hpp>
#include <map>

namespace devue {
Expand All @@ -15,7 +15,7 @@ namespace devue {
flag_show_modal_about
};

class dv_sys_command : public dvsku::dv_sys_command<dv_commands> {
class dv_sys_command : public dvsku::gui_sys_command<dv_commands> {
public:
dv_sys_command() = delete;
dv_sys_command(dv_systems* systems);
Expand Down
2 changes: 1 addition & 1 deletion source/devue_app/src/systems/dv_sys_properties.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <dv_gui_opengl/dv_gui_opengl.hpp>
#include <libutil.hpp>
#include <unordered_map>
#include <typeindex>

Expand Down
3 changes: 1 addition & 2 deletions source/devue_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ TARGET_INCLUDE_DIRECTORIES(devue_core PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src")
TARGET_INCLUDE_DIRECTORIES(devue_core PUBLIC "${DEVUE_PLUGIN_CORE_INCLUDES}")
TARGET_INCLUDE_DIRECTORIES(devue_core PUBLIC "${DEVUE_LIBRARIES_DIR}")
TARGET_INCLUDE_DIRECTORIES(devue_core PUBLIC "${DEVUE_LIBRARIES_DIR}/glm/include")
TARGET_INCLUDE_DIRECTORIES(devue_core PUBLIC "${DV_GUI_INCLUDES}")

TARGET_LINK_LIBRARIES(devue_core PUBLIC dv_gui_opengl3)
TARGET_LINK_LIBRARIES(devue_core PUBLIC libgui_opengl3)
TARGET_LINK_LIBRARIES(devue_core PUBLIC resources)
4 changes: 2 additions & 2 deletions source/devue_core/src/exceptions/dv_exception.hpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#pragma once

#include <dv_utilities.hpp>
#include <libutil.hpp>
#include <stdexcept>

namespace devue::core {
#define DV_THROW_EXCEPTION(fmt, ...) \
throw devue::core::dv_exception(dvsku::dv_util_string::format(fmt, __VA_ARGS__))
throw devue::core::dv_exception(dvsku::util_string::format(fmt, __VA_ARGS__))

class dv_exception : public std::runtime_error {
public:
Expand Down
2 changes: 1 addition & 1 deletion source/devue_core/src/models/pdo/dv_mesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "glm/vec3.hpp"

#include <dv_utilities.hpp>
#include <libutil.hpp>
#include <string>
#include <vector>

Expand Down
2 changes: 1 addition & 1 deletion source/devue_core/src/models/pdo/dv_model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "models/pdo/dv_material.hpp"
#include "models/pdo/dv_vertex.hpp"

#include <dv_utilities.hpp>
#include <libutil.hpp>
#include <string>
#include <filesystem>
#include <vector>
Expand Down
2 changes: 1 addition & 1 deletion source/devue_core/src/scene/dv_camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ using namespace devue::core;
using namespace dvsku;

dv_camera::dv_camera() {
uuid = dv_util_uuid::create();
uuid = util_uuid::create();

// Call transformations to apply initial values
translate(0.0f, 0.0f);
Expand Down
2 changes: 1 addition & 1 deletion source/devue_core/src/scene/dv_camera.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "glm/vec3.hpp"
#include "glm/matrix.hpp"

#include <dv_utilities.hpp>
#include <libutil.hpp>

namespace devue::core {
class dv_camera {
Expand Down
2 changes: 1 addition & 1 deletion source/devue_core/src/scene/dv_scene.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "scene/dv_camera.hpp"
#include "scene/dv_scene_grid.hpp"

#include <dv_utilities.hpp>
#include <libutil.hpp>
#include <unordered_map>

namespace devue::core {
Expand Down
Loading

0 comments on commit 11c2c3f

Please sign in to comment.