Compare commits
	
		
			10 commits
		
	
	
		
			
				ee19b389b0
			
			...
			
				124f15c213
			
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
							
							
								
							
							
	
	
		
			
		
	
	124f15c213 | 
						
						
							|||
| 
							
							
								
							
							
	
	
		
			
		
	
	abf68d7ad3 | 
						
						
							|||
| 
							
							
								
							
							
	
	
		
			
		
	
	031445743c | 
						
						
							|||
| 
							
							
								
							
							
	
	
		
			
		
	
	14144c9ce4 | 
						
						
							|||
| 
							
							
								
							
							
	
	
		
			
		
	
	33ba0995fd | 
						
						
							|||
| 
							
							
								
							
							
	
	
		
			
		
	
	9515077e1e | 
						
						
							|||
| 
							
							
								
							
							
	
	
		
			
		
	
	8af5d23737 | 
						
						
							|||
| 
							
							
								
							
							
	
	
		
			
		
	
	ae19d387f6 | 
						
						
							|||
| 
							
							
								
							
							
	
	
		
			
		
	
	91180411ab | 
						
						
							|||
| 
							
							
								
							
							
	
	
		
			
		
	
	ae3c7d496a | 
						
						
							
					 6 changed files with 95 additions and 15 deletions
				
			
		
							
								
								
									
										3
									
								
								.gitmodules
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.gitmodules
									
										
									
									
										vendored
									
									
								
							| 
						 | 
					@ -1,3 +1,6 @@
 | 
				
			||||||
[submodule "external/assimp"]
 | 
					[submodule "external/assimp"]
 | 
				
			||||||
	path = external/assimp
 | 
						path = external/assimp
 | 
				
			||||||
	url = https://github.com/assimp/assimp.git
 | 
						url = https://github.com/assimp/assimp.git
 | 
				
			||||||
 | 
					[submodule "external/spdlog"]
 | 
				
			||||||
 | 
						path = external/spdlog
 | 
				
			||||||
 | 
						url = https://github.com/gabime/spdlog.git
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -60,6 +60,14 @@ else ()
 | 
				
			||||||
endif ()
 | 
					endif ()
 | 
				
			||||||
add_subdirectory(external/assimp EXCLUDE_FROM_ALL)
 | 
					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
 | 
				
			||||||
        hello_world.hpp
 | 
					        hello_world.hpp
 | 
				
			||||||
| 
						 | 
					@ -67,7 +75,7 @@ add_executable(LearnGtk4 main.cpp
 | 
				
			||||||
        app_win_2_back.hpp
 | 
					        app_win_2_back.hpp
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
set_target_properties(LearnGtk4 assimp PROPERTIES
 | 
					set_target_properties(LearnGtk4 assimp spdlog_header_only PROPERTIES
 | 
				
			||||||
        CXX_STANDARD 17
 | 
					        CXX_STANDARD 17
 | 
				
			||||||
        CXX_STANDARD_REQUIRED ON
 | 
					        CXX_STANDARD_REQUIRED ON
 | 
				
			||||||
        CXX_EXTENSIONS OFF
 | 
					        CXX_EXTENSIONS OFF
 | 
				
			||||||
| 
						 | 
					@ -78,4 +86,4 @@ target_compile_definitions(LearnGtk4 PUBLIC $<$<CONFIG:Debug>:_GLIBCXX_DEBUG>)
 | 
				
			||||||
target_compile_definitions(assimp 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)
 | 
					target_link_libraries(LearnGtk4 PkgConfig::GTKMM4 assimp spdlog_header_only)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,8 @@
 | 
				
			||||||
#include "app_win_2_back.hpp"
 | 
					#include "app_win_2_back.hpp"
 | 
				
			||||||
#include "hello_world.hpp"
 | 
					#include "hello_world.hpp"
 | 
				
			||||||
#include <iostream>
 | 
					 | 
				
			||||||
#include <glibmm/miscutils.h>
 | 
					#include <glibmm/miscutils.h>
 | 
				
			||||||
 | 
					#include <gtkmm/switch.h>
 | 
				
			||||||
 | 
					#include <spdlog/spdlog.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace gui_to_app {
 | 
					namespace gui_to_app {
 | 
				
			||||||
    AppWin2Back::AppWin2Back() : Gtk::Application("org.billy_adventures.character_sheet", Flags::HANDLES_OPEN) {
 | 
					    AppWin2Back::AppWin2Back() : Gtk::Application("org.billy_adventures.character_sheet", Flags::HANDLES_OPEN) {
 | 
				
			||||||
| 
						 | 
					@ -15,12 +16,12 @@ namespace gui_to_app {
 | 
				
			||||||
                const auto builder = Gtk::Builder::create_from_file("menu_bar.ui");
 | 
					                const auto builder = Gtk::Builder::create_from_file("menu_bar.ui");
 | 
				
			||||||
                return builder->get_object<Gio::Menu>("menu");
 | 
					                return builder->get_object<Gio::Menu>("menu");
 | 
				
			||||||
            } catch (const std::exception &e) {
 | 
					            } catch (const std::exception &e) {
 | 
				
			||||||
                std::cerr << e.what() << '\n';
 | 
					                spdlog::error("Error occurred while loader menu bar: {}", e.what());
 | 
				
			||||||
                return nullptr;
 | 
					                return nullptr;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }();
 | 
					        }();
 | 
				
			||||||
        if (!menu_bar) {
 | 
					        if (!menu_bar) {
 | 
				
			||||||
            std::cerr << "Error occured while loading menu bar's.\n";
 | 
					            spdlog::error("Error occured while loading menu bar's.");
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            set_menubar(menu_bar);
 | 
					            set_menubar(menu_bar);
 | 
				
			||||||
            add_action("quit", sigc::mem_fun(*this, &AppWin2Back::on_quit));
 | 
					            add_action("quit", sigc::mem_fun(*this, &AppWin2Back::on_quit));
 | 
				
			||||||
| 
						 | 
					@ -35,17 +36,17 @@ namespace gui_to_app {
 | 
				
			||||||
    void AppWin2Back::on_activate() {
 | 
					    void AppWin2Back::on_activate() {
 | 
				
			||||||
        Application::on_activate();
 | 
					        Application::on_activate();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const auto 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) {
 | 
				
			||||||
                std::cerr << e.what() << std::endl;
 | 
					                spdlog::critical("Error occurred while loading Window's UI: {}", e.what());
 | 
				
			||||||
                quit();
 | 
					                quit();
 | 
				
			||||||
                return nullptr;
 | 
					                return nullptr;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }();
 | 
					        }();
 | 
				
			||||||
        if (!app_builder) {
 | 
					        if (!app_builder) {
 | 
				
			||||||
            std::cerr << "Error while loading UI.\n";
 | 
					            spdlog::critical("Error while loading UI");
 | 
				
			||||||
            quit();
 | 
					            quit();
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					@ -55,16 +56,65 @@ namespace gui_to_app {
 | 
				
			||||||
            main_window->set_show_menubar(true);
 | 
					            main_window->set_show_menubar(true);
 | 
				
			||||||
            main_window->set_visible(true);
 | 
					            main_window->set_visible(true);
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
 | 
					            spdlog::critical("Error while getting window from builder");
 | 
				
			||||||
            on_quit();
 | 
					            on_quit();
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        sword_switch = app_builder->get_widget<Gtk::Switch>("sword_switch");
 | 
				
			||||||
 | 
					        lance_switch = app_builder->get_widget<Gtk::Switch>("lance_switch");
 | 
				
			||||||
 | 
					        morgen_switch = app_builder->get_widget<Gtk::Switch>("morgenstern_switch");
 | 
				
			||||||
 | 
					        bow_switch = app_builder->get_widget<Gtk::Switch>("arc_switch");
 | 
				
			||||||
 | 
					        chainmail_switch = app_builder->get_widget<Gtk::Switch>("chainmail_switch");
 | 
				
			||||||
 | 
					        cookpot_switch = app_builder->get_widget<Gtk::Switch>("cookingpot_switch");
 | 
				
			||||||
 | 
					        pamphlet_switch = app_builder->get_widget<Gtk::Switch>("pamphlet_tourist_switch");
 | 
				
			||||||
 | 
					        medkit_switch = app_builder->get_widget<Gtk::Switch>("medkit_switch");
 | 
				
			||||||
 | 
					        fourche_switch = app_builder->get_widget<Gtk::Switch>("fourche_switch");
 | 
				
			||||||
 | 
					        dagger_switch = app_builder->get_widget<Gtk::Switch>("dagger_switch");
 | 
				
			||||||
 | 
					        rock_kit_switch = app_builder->get_widget<Gtk::Switch>("rock_kit_switch");
 | 
				
			||||||
 | 
					        sack_switch = app_builder->get_widget<Gtk::Switch>("sack_switch");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        const auto test_result = [this]() -> std::vector<const char *> {
 | 
				
			||||||
 | 
					            const std::array test_ptrs{
 | 
				
			||||||
 | 
					                std::pair{ "sword_switch", sword_switch == nullptr },
 | 
				
			||||||
 | 
					                std::pair{ "lance_switch", lance_switch == nullptr },
 | 
				
			||||||
 | 
					                std::pair{ "morgen_switch", morgen_switch == nullptr },
 | 
				
			||||||
 | 
					                std::pair{ "bow_switch", bow_switch == nullptr },
 | 
				
			||||||
 | 
					                std::pair{ "chainmail_switch", chainmail_switch == nullptr },
 | 
				
			||||||
 | 
					                std::pair{ "cookpot_switch", cookpot_switch == nullptr },
 | 
				
			||||||
 | 
					                std::pair{ "pamphlet_switch", pamphlet_switch == nullptr },
 | 
				
			||||||
 | 
					                std::pair{ "medkit_switch", medkit_switch == nullptr },
 | 
				
			||||||
 | 
					                std::pair{ "fourche_switch", fourche_switch == nullptr },
 | 
				
			||||||
 | 
					                std::pair{ "dagger_switch", dagger_switch == nullptr },
 | 
				
			||||||
 | 
					                std::pair{ "rock_kit_switch", rock_kit_switch == nullptr },
 | 
				
			||||||
 | 
					                std::pair{ "sack_switch", sack_switch == nullptr },
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            std::vector<const char *> local_test_result;
 | 
				
			||||||
 | 
					            local_test_result.reserve(test_ptrs.size());
 | 
				
			||||||
 | 
					            std::for_each(test_ptrs.cbegin(),
 | 
				
			||||||
 | 
					                test_ptrs.cend(),
 | 
				
			||||||
 | 
					                [&local_test_result](const auto &a) {
 | 
				
			||||||
 | 
					                    if (a.second) {
 | 
				
			||||||
 | 
					                        local_test_result.emplace_back(a.first);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
 | 
					            return local_test_result;
 | 
				
			||||||
 | 
					        }();
 | 
				
			||||||
 | 
					        if (!test_result.empty()) {
 | 
				
			||||||
 | 
					            spdlog::critical("Error occurred, at least one switch is not available. See logs below");
 | 
				
			||||||
 | 
					            for (const auto result: test_result) {
 | 
				
			||||||
 | 
					                spdlog::critical(result);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            on_quit();
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void AppWin2Back::on_quit() {
 | 
					    void AppWin2Back::on_quit() noexcept {
 | 
				
			||||||
        auto windows = get_windows();
 | 
					        auto windows = get_windows();
 | 
				
			||||||
        for (auto *window: windows) {
 | 
					        for (auto *window: windows) {
 | 
				
			||||||
            window->set_visible(false);
 | 
					            window->set_visible(false);
 | 
				
			||||||
 | 
					            delete window;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        quit();
 | 
					        quit();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
} // gui_to_app
 | 
					} // gui_to_app
 | 
				
			||||||
| 
						 | 
					@ -8,8 +8,12 @@ namespace learn_gtkmm4 {
 | 
				
			||||||
    class HelloWorld;
 | 
					    class HelloWorld;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace gui_to_app {
 | 
					namespace Gtk {
 | 
				
			||||||
 | 
					    class Builder;
 | 
				
			||||||
 | 
					    class Switch;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace gui_to_app {
 | 
				
			||||||
    class AppWin2Back final : public Gtk::Application {
 | 
					    class AppWin2Back final : public Gtk::Application {
 | 
				
			||||||
    public:
 | 
					    public:
 | 
				
			||||||
        ~AppWin2Back() noexcept final = default;
 | 
					        ~AppWin2Back() noexcept final = default;
 | 
				
			||||||
| 
						 | 
					@ -24,11 +28,25 @@ namespace gui_to_app {
 | 
				
			||||||
        void on_activate() final;
 | 
					        void on_activate() final;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private:
 | 
					    private:
 | 
				
			||||||
        void on_quit();
 | 
					        void on_quit() noexcept;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Glib::RefPtr<Gtk::Builder> app_builder;
 | 
				
			||||||
        learn_gtkmm4::HelloWorld *main_window{ nullptr };
 | 
					        learn_gtkmm4::HelloWorld *main_window{ nullptr };
 | 
				
			||||||
    };
 | 
					        Gtk::Switch *sword_switch{ nullptr };
 | 
				
			||||||
 | 
					        Gtk::Switch *lance_switch{ nullptr };
 | 
				
			||||||
 | 
					        Gtk::Switch *morgen_switch{ nullptr };
 | 
				
			||||||
 | 
					        Gtk::Switch *bow_switch{ nullptr };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Gtk::Switch *chainmail_switch{ nullptr };
 | 
				
			||||||
 | 
					        Gtk::Switch *cookpot_switch{ nullptr };
 | 
				
			||||||
 | 
					        Gtk::Switch *pamphlet_switch{ nullptr };
 | 
				
			||||||
 | 
					        Gtk::Switch *medkit_switch{ nullptr };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Gtk::Switch *fourche_switch{ nullptr };
 | 
				
			||||||
 | 
					        Gtk::Switch *dagger_switch{ nullptr };
 | 
				
			||||||
 | 
					        Gtk::Switch *rock_kit_switch{ nullptr };
 | 
				
			||||||
 | 
					        Gtk::Switch *sack_switch{ nullptr };
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
} // gui_to_app
 | 
					} // gui_to_app
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif //LEARNGTK4_APP_WIN_2_BACK_HPP
 | 
					#endif //LEARNGTK4_APP_WIN_2_BACK_HPP
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										1
									
								
								external/spdlog
									
										
									
									
										vendored
									
									
										Submodule
									
								
							
							
						
						
									
										1
									
								
								external/spdlog
									
										
									
									
										vendored
									
									
										Submodule
									
								
							| 
						 | 
					@ -0,0 +1 @@
 | 
				
			||||||
 | 
					Subproject commit 27cb4c76708608465c413f6d0e6b8d99a4d84302
 | 
				
			||||||
| 
						 | 
					@ -343,7 +343,7 @@
 | 
				
			||||||
                                  </object>
 | 
					                                  </object>
 | 
				
			||||||
                                </child>
 | 
					                                </child>
 | 
				
			||||||
                                <child>
 | 
					                                <child>
 | 
				
			||||||
                                  <object class="GtkSwitch" id="chaimail_switch">
 | 
					                                  <object class="GtkSwitch" id="chainmail_switch">
 | 
				
			||||||
                                    <property name="halign">end</property>
 | 
					                                    <property name="halign">end</property>
 | 
				
			||||||
                                    <property name="hexpand">1</property>
 | 
					                                    <property name="hexpand">1</property>
 | 
				
			||||||
                                  </object>
 | 
					                                  </object>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue