Compare commits
6 commits
eb2bfdfce1
...
a67eb0d0b5
| Author | SHA1 | Date | |
|---|---|---|---|
|
a67eb0d0b5 |
|||
|
9f479dc808 |
|||
|
6ec7ddc655 |
|||
|
db3113b288 |
|||
|
259df75dfc |
|||
|
21b278d148 |
8 changed files with 41 additions and 59 deletions
6
.gitmodules
vendored
6
.gitmodules
vendored
|
|
@ -1,6 +0,0 @@
|
||||||
[submodule "external/assimp"]
|
|
||||||
path = external/assimp
|
|
||||||
url = https://github.com/assimp/assimp.git
|
|
||||||
[submodule "external/spdlog"]
|
|
||||||
path = external/spdlog
|
|
||||||
url = https://github.com/gabime/spdlog.git
|
|
||||||
|
|
@ -58,28 +58,19 @@ if (${ENABLE_COVERAGE})
|
||||||
list(APPEND LINKER_FLAGS gcov)
|
list(APPEND LINKER_FLAGS gcov)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
option(BUILD_SHARED_LIBS "Build package with shared libraries." ON)
|
fetchcontent_declare(
|
||||||
option(ASSIMP_NO_EXPORT "Disable Assimp's export functionality." ON)
|
spdlog
|
||||||
option(ASSIMP_INSTALL "Disable this if you want to use assimp as a submodule." OFF)
|
GIT_REPOSITORY https://github.com/gabime/spdlog.git
|
||||||
option(ASSIMP_BUILD_ZLIB "Build your own zlib" OFF)
|
GIT_TAG v1.17.0
|
||||||
option(ASSIMP_BUILD_TESTS "If the test suite for Assimp is built in addition to the library." OFF)
|
GIT_SHALLOW ON
|
||||||
option(ASSIMP_WARNINGS_AS_ERRORS "Treat all warnings as errors." OFF)
|
)
|
||||||
option(ASSIMP_INSTALL_PDB "Install MSVC debug files." OFF)
|
set(SPDLOG_ENABLE_PCH ON)
|
||||||
option(ASSIMP_INJECT_DEBUG_POSTFIX "Inject debug postfix in .a/.so/.dll lib names" OFF)
|
set(SPDLOG_BUILD_WARNINGS ON)
|
||||||
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
set(SPDLOG_PREVENT_CHILD_FD ON)
|
||||||
option(ASSIMP_INJECT_DEBUG_POSTFIX "Inject debug postfix in .a/.so/.dll lib names" ON)
|
set(SPDLOG_NO_THREAD_ID ON)
|
||||||
else ()
|
set(SPDLOG_NO_TLS ON)
|
||||||
option(ASSIMP_INJECT_DEBUG_POSTFIX "Inject debug postfix in .a/.so/.dll lib names" OFF)
|
set(SPDLOG_NO_ATOMIC_LEVELS ON)
|
||||||
endif ()
|
fetchcontent_makeavailable(spdlog)
|
||||||
add_subdirectory(external/assimp EXCLUDE_FROM_ALL)
|
|
||||||
|
|
||||||
option(SPDLOG_ENABLE_PCH "Build static or shared library using precompiled header to speed up compilation time" ON)
|
|
||||||
option(SPDLOG_BUILD_WARNINGS "Enable compiler warnings" ON)
|
|
||||||
option(SPDLOG_PREVENT_CHILD_FD "Prevent from child processes to inherit log file descriptors" ON)
|
|
||||||
option(SPDLOG_NO_THREAD_ID "prevent spdlog from querying the thread id on each log call if thread id is not needed" ON)
|
|
||||||
option(SPDLOG_NO_TLS "prevent spdlog from using thread local storage" ON)
|
|
||||||
option(SPDLOG_NO_ATOMIC_LEVELS "prevent spdlog from using of std::atomic log levels (use only if your code never modifies log levels concurrently" ON)
|
|
||||||
add_subdirectory(external/spdlog EXCLUDE_FROM_ALL)
|
|
||||||
|
|
||||||
add_executable(LearnGtk4 main.cpp
|
add_executable(LearnGtk4 main.cpp
|
||||||
hello_world.cpp
|
hello_world.cpp
|
||||||
|
|
@ -88,15 +79,14 @@ add_executable(LearnGtk4 main.cpp
|
||||||
app_win_2_back.hpp
|
app_win_2_back.hpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set_target_properties(LearnGtk4 assimp spdlog_header_only PROPERTIES
|
set_target_properties(LearnGtk4 spdlog_header_only PROPERTIES
|
||||||
CXX_STANDARD 17
|
CXX_STANDARD 23
|
||||||
CXX_STANDARD_REQUIRED ON
|
CXX_STANDARD_REQUIRED ON
|
||||||
CXX_EXTENSIONS OFF
|
CXX_EXTENSIONS OFF
|
||||||
INTERPROCEDURAL_OPTIMIZATION ON
|
INTERPROCEDURAL_OPTIMIZATION ON
|
||||||
)
|
)
|
||||||
|
|
||||||
target_compile_definitions(LearnGtk4 PUBLIC $<$<CONFIG:Debug>:_GLIBCXX_DEBUG>)
|
target_compile_definitions(LearnGtk4 PUBLIC $<$<CONFIG:Debug>:_GLIBCXX_DEBUG>)
|
||||||
target_compile_definitions(assimp PUBLIC $<$<CONFIG:Debug>:_GLIBCXX_DEBUG>)
|
|
||||||
target_compile_options(LearnGtk4 PUBLIC ${COMPILE_FLAGS})
|
target_compile_options(LearnGtk4 PUBLIC ${COMPILE_FLAGS})
|
||||||
target_link_options(LearnGtk4 PUBLIC ${LINKER_OPTIONS})
|
target_link_options(LearnGtk4 PUBLIC ${LINKER_OPTIONS})
|
||||||
target_link_libraries(LearnGtk4 PkgConfig::GTKMM4 assimp spdlog_header_only BillySheet)
|
target_link_libraries(LearnGtk4 PkgConfig::GTKMM4 spdlog_header_only BillySheet)
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,16 @@
|
||||||
#include "app_win_2_back.hpp"
|
#include "app_win_2_back.hpp"
|
||||||
#include "hello_world.hpp"
|
#include "hello_world.hpp"
|
||||||
|
|
||||||
#include <glibmm/miscutils.h>
|
#include <glibmm/miscutils.h>
|
||||||
#include <gtkmm/switch.h>
|
#include <gtkmm/switch.h>
|
||||||
#include <spdlog/spdlog.h>
|
#include <spdlog/spdlog.h>
|
||||||
|
|
||||||
|
#include <ranges>
|
||||||
|
|
||||||
namespace gui_to_app {
|
namespace gui_to_app {
|
||||||
|
namespace ranges = std::ranges;
|
||||||
|
namespace views = std::views;
|
||||||
|
|
||||||
AppWin2Back::AppWin2Back() : Gtk::Application("org.billy_adventures.character_sheet", Flags::HANDLES_OPEN) {
|
AppWin2Back::AppWin2Back() : Gtk::Application("org.billy_adventures.character_sheet", Flags::HANDLES_OPEN) {
|
||||||
Glib::set_application_name("Billy's character sheet");
|
Glib::set_application_name("Billy's character sheet");
|
||||||
}
|
}
|
||||||
|
|
@ -36,7 +42,7 @@ namespace gui_to_app {
|
||||||
void AppWin2Back::on_activate() {
|
void AppWin2Back::on_activate() {
|
||||||
Application::on_activate();
|
Application::on_activate();
|
||||||
|
|
||||||
app_builder = [this]() -> Glib::RefPtr<Gtk::Builder> {
|
app_builder = [this] -> Glib::RefPtr<Gtk::Builder> {
|
||||||
try {
|
try {
|
||||||
return Gtk::Builder::create_from_file("window_ui.ui");
|
return Gtk::Builder::create_from_file("window_ui.ui");
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
|
|
@ -73,7 +79,7 @@ namespace gui_to_app {
|
||||||
rock_kit_switch = app_builder->get_widget<Gtk::Switch>("rock_kit_switch");
|
rock_kit_switch = app_builder->get_widget<Gtk::Switch>("rock_kit_switch");
|
||||||
sack_switch = app_builder->get_widget<Gtk::Switch>("sack_switch");
|
sack_switch = app_builder->get_widget<Gtk::Switch>("sack_switch");
|
||||||
|
|
||||||
const auto test_result = [this]() -> std::vector<const char *> {
|
const auto test_result = [this] -> std::vector<const char *> {
|
||||||
const std::array test_ptrs{
|
const std::array test_ptrs{
|
||||||
std::pair{ "sword_switch", sword_switch == nullptr },
|
std::pair{ "sword_switch", sword_switch == nullptr },
|
||||||
std::pair{ "lance_switch", lance_switch == nullptr },
|
std::pair{ "lance_switch", lance_switch == nullptr },
|
||||||
|
|
@ -88,16 +94,12 @@ namespace gui_to_app {
|
||||||
std::pair{ "rock_kit_switch", rock_kit_switch == nullptr },
|
std::pair{ "rock_kit_switch", rock_kit_switch == nullptr },
|
||||||
std::pair{ "sack_switch", sack_switch == nullptr },
|
std::pair{ "sack_switch", sack_switch == nullptr },
|
||||||
};
|
};
|
||||||
std::vector<const char *> local_test_result;
|
|
||||||
local_test_result.reserve(test_ptrs.size());
|
return ranges::to<std::vector<const char *> >(
|
||||||
std::for_each(test_ptrs.cbegin(),
|
test_ptrs
|
||||||
test_ptrs.cend(),
|
| views::filter([](const auto &a) { return a.second; })
|
||||||
[&local_test_result](const auto &a) {
|
| views::keys
|
||||||
if (a.second) {
|
);
|
||||||
local_test_result.emplace_back(a.first);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return local_test_result;
|
|
||||||
}();
|
}();
|
||||||
if (!test_result.empty()) {
|
if (!test_result.empty()) {
|
||||||
spdlog::critical("Error occurred, at least one switch is not available. See logs below");
|
spdlog::critical("Error occurred, at least one switch is not available. See logs below");
|
||||||
|
|
@ -107,16 +109,15 @@ namespace gui_to_app {
|
||||||
on_quit();
|
on_quit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// TODO: interaction avec la CharacterSheet
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppWin2Back::on_quit() noexcept {
|
void AppWin2Back::on_quit() noexcept {
|
||||||
auto windows = get_windows();
|
ranges::for_each(get_windows() | views::filter([](const auto windows) { return windows != nullptr; }),
|
||||||
for (auto *window: windows) {
|
[](auto *window) {
|
||||||
if (window != nullptr) {
|
window->set_visible(false);
|
||||||
window->set_visible(false);
|
delete window;
|
||||||
delete window;
|
});
|
||||||
}
|
|
||||||
}
|
|
||||||
quit();
|
quit();
|
||||||
}
|
}
|
||||||
} // gui_to_app
|
} // gui_to_app
|
||||||
|
|
|
||||||
1
external/assimp
vendored
1
external/assimp
vendored
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit f6c62605c76001ac37f1d86da9922ef61e65501d
|
|
||||||
1
external/spdlog
vendored
1
external/spdlog
vendored
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit 27cb4c76708608465c413f6d0e6b8d99a4d84302
|
|
||||||
|
|
@ -3,5 +3,6 @@
|
||||||
|
|
||||||
namespace learn_gtkmm4 {
|
namespace learn_gtkmm4 {
|
||||||
HelloWorld::HelloWorld(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &builder) :
|
HelloWorld::HelloWorld(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &builder) :
|
||||||
Gtk::ApplicationWindow(cobject), m_builder(builder) {}
|
Gtk::ApplicationWindow(cobject), m_builder(builder) {
|
||||||
|
}
|
||||||
} // learn_gtkmm4
|
} // learn_gtkmm4
|
||||||
|
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
|
|
||||||
namespace learn_gtkmm4 {
|
namespace learn_gtkmm4 {
|
||||||
|
|
||||||
class HelloWorld final : public Gtk::ApplicationWindow {
|
class HelloWorld final : public Gtk::ApplicationWindow {
|
||||||
public:
|
public:
|
||||||
using Gtk::ApplicationWindow::BaseObjectType;
|
using Gtk::ApplicationWindow::BaseObjectType;
|
||||||
|
|
@ -19,7 +18,6 @@ namespace learn_gtkmm4 {
|
||||||
protected:
|
protected:
|
||||||
Glib::RefPtr<Gtk::Builder> m_builder;
|
Glib::RefPtr<Gtk::Builder> m_builder;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // learn_gtkmm4
|
} // learn_gtkmm4
|
||||||
|
|
||||||
#endif //LEARNGTK4_HELLO_WORLD_HPP
|
#endif //LEARNGTK4_HELLO_WORLD_HPP
|
||||||
|
|
|
||||||
4
main.cpp
4
main.cpp
|
|
@ -1,6 +1,6 @@
|
||||||
#include "app_win_2_back.hpp"
|
#include "app_win_2_back.hpp"
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(const int argc, char *argv[]) {
|
||||||
auto app = gui_to_app::AppWin2Back::create();
|
const auto app = gui_to_app::AppWin2Back::create();
|
||||||
return app->run(argc, argv);
|
return app->run(argc, argv);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue