First try to interact with buttons and CharacterSheet

This commit is contained in:
Pcornat 2026-02-06 17:26:09 +01:00
commit f4cbc2558b
Signed by: Pcornat
GPG key ID: E0326CC678A00BDD
3 changed files with 193 additions and 117 deletions

View file

@ -8,7 +8,8 @@
#include <billy_objects.hpp>
#include <character_sheet.hpp>
#include <gtkmm/switch.h>
// #include <gtkmm/label.h>
#include <gtkmm/checkbutton.h>
namespace learn_gtkmm4 {
class HelloWorld;
@ -16,7 +17,7 @@ namespace learn_gtkmm4 {
namespace Gtk {
class Builder;
class Switch;
class Label;
}
namespace gui_to_app {
@ -34,39 +35,56 @@ namespace gui_to_app {
void on_activate() final;
private:
using selection_button = Gtk::CheckButton;
using buttons_obj_container = std::unordered_set<selection_button *>;
struct SwitchSignalHelper {
AppWin2Back &app;
const character::billyEnums obj;
Gtk::Switch *switch_{ nullptr };
selection_button *switch_{ nullptr };
bool on_stack{ false };
[[nodiscard]] bool signal_handler(const bool flag) const noexcept {
switch_->set_state(app.switch_signal_handler(flag, obj));
return true;
}
void signal_handler() noexcept;
};
friend struct SwitchSignalHelper;
/*!
*
* @return true: failed, false: success
*/
bool switches_procedure();
void on_quit() noexcept;
bool switch_signal_handler(bool flag, const character::billyEnums &obj) noexcept;
bool insert_obj(const character::billyEnums &obj) noexcept;
bool erase_obj(const character::billyEnums &obj) noexcept;
Glib::RefPtr<Gtk::Builder> app_builder;
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 };
selection_button *sword_switch{ nullptr };
selection_button *lance_switch{ nullptr };
selection_button *morgen_switch{ nullptr };
selection_button *bow_switch{ nullptr };
Gtk::Switch *chainmail_switch{ nullptr };
Gtk::Switch *cookpot_switch{ nullptr };
Gtk::Switch *pamphlet_switch{ nullptr };
Gtk::Switch *medkit_switch{ nullptr };
selection_button *chainmail_switch{ nullptr };
selection_button *cookpot_switch{ nullptr };
selection_button *pamphlet_switch{ nullptr };
selection_button *medkit_switch{ nullptr };
Gtk::Switch *fourche_switch{ nullptr };
Gtk::Switch *dagger_switch{ nullptr };
Gtk::Switch *rock_kit_switch{ nullptr };
Gtk::Switch *sack_switch{ nullptr };
selection_button *fourche_switch{ nullptr };
selection_button *dagger_switch{ nullptr };
selection_button *rock_kit_switch{ nullptr };
selection_button *sack_switch{ nullptr };
Gtk::Label *hab_base{ nullptr };
Gtk::Label *hab_carac{ nullptr };
Gtk::Label *hab_mat{ nullptr };
Gtk::Label *hab_total{ nullptr };
std::array<SwitchSignalHelper, 12> signal_handlers{
SwitchSignalHelper{ .app = *this, .obj = character::weapons::Sword },
@ -85,6 +103,8 @@ namespace gui_to_app {
SwitchSignalHelper{ .app = *this, .obj = character::tools::SackOfGrain },
};
buttons_obj_container selection_buttons;
character::BillyObjects gestionnaire{};
character::CharacterSheet sheet{};
};