From a6b6e0d5bf330481bd9b1e988b012d2b08155385 Mon Sep 17 00:00:00 2001 From: Pcornat Date: Mon, 16 Mar 2026 21:10:46 +0100 Subject: [PATCH] =?UTF-8?q?Habilet=C3=A9=20labels=20in=20struct?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app_win_2_back.cpp | 13 +++++++++---- app_win_2_back.hpp | 13 +++++++++++-- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/app_win_2_back.cpp b/app_win_2_back.cpp index ef6bf75..f96fd31 100644 --- a/app_win_2_back.cpp +++ b/app_win_2_back.cpp @@ -169,10 +169,15 @@ namespace gui_to_app { return; } debug_button = app_builder->get_widget("debug_button"); - hab_labels.base = app_builder->get_widget("habilete_label_base"); - hab_labels.carac = app_builder->get_widget("habilete_label_carac"); - hab_labels.mat = app_builder->get_widget("habilete_label_materiel"); - hab_labels.total = app_builder->get_widget("habilete_label_total"); + hab_labels = CaracInterface{ + { + "habilete_label_base", + "habilete_label_carac", + "habilete_label_materiel", + "habilete_label_total" + }, + app_builder + }; debug_button->signal_clicked().connect(sigc::mem_fun(*this, &AppWin2Back::debug_button_clicked), false); } diff --git a/app_win_2_back.hpp b/app_win_2_back.hpp index 249d9bb..c51b7fb 100644 --- a/app_win_2_back.hpp +++ b/app_win_2_back.hpp @@ -5,6 +5,7 @@ #include #include +#include #include #include @@ -15,18 +16,26 @@ namespace learn_gtkmm4 { } namespace Gtk { - class Builder; class Label; class Button; } namespace gui_to_app { template - struct CaracInterface { + struct CaracInterface final { T *base{ nullptr }; T *carac{ nullptr }; T *mat{ nullptr }; T *total{ nullptr }; + + CaracInterface() = default; + + explicit CaracInterface(const std::array &list, + const Glib::RefPtr &builder) : + base(builder->get_widget(list[0].data())), + carac(builder->get_widget(list[1].data())), + mat(builder->get_widget(list[2].data())), + total(builder->get_widget(list[3].data())) {} }; class AppWin2Back final : public Gtk::Application {