summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--adw/CMakeLists.txt1
-rw-r--r--adw/include/turns/adw/switchrow.hpp80
-rw-r--r--adw/src/switchrow.cpp72
-rw-r--r--adw/src/wrap_init.cpp3
-rw-r--r--app/ch.arknet.Turns.gschema.xml5
-rw-r--r--ui/include/turns/ui/widgets/preferences.hpp3
-rw-r--r--ui/res/ui.cmb12
-rw-r--r--ui/src/init.cpp2
-rw-r--r--ui/src/widgets/preferences.cpp4
9 files changed, 178 insertions, 4 deletions
diff --git a/adw/CMakeLists.txt b/adw/CMakeLists.txt
index ce0323f..f1ac616 100644
--- a/adw/CMakeLists.txt
+++ b/adw/CMakeLists.txt
@@ -5,6 +5,7 @@ add_library("adw"
"src/preferencesdialog.cpp"
"src/preferencespage.cpp"
"src/preferencesrow.cpp"
+ "src/switchrow.cpp"
"src/toast.cpp"
"src/toastoverlay.cpp"
"src/wrap_init.cpp"
diff --git a/adw/include/turns/adw/switchrow.hpp b/adw/include/turns/adw/switchrow.hpp
new file mode 100644
index 0000000..ed5190a
--- /dev/null
+++ b/adw/include/turns/adw/switchrow.hpp
@@ -0,0 +1,80 @@
+#ifndef TURNS_ADW_SWITCH_ROW_HPP
+#define TURNS_ADW_SWITCH_ROW_HPP
+
+#include "helpers/gobj_mixin.hpp"
+#include "turns/adw/actionrow.hpp"
+#include "turns/adw/helpers/properties.hpp"
+
+#include <glibmm/class.h>
+#include <glibmm/refptr.h>
+#include <glibmm/ustring.h>
+
+#include <gtkmm/widget.h>
+
+using AdwSwitchRow = struct _AdwSwitchRow;
+
+namespace turns::adw
+{
+ struct SwitchRow final : adw::ActionRow,
+ helpers::gobj_mixin<SwitchRow, AdwSwitchRow>
+ {
+ struct Class : Glib::Class
+ {
+ using BaseClassParent = AdwActionRowClass;
+ using BaseClassType = struct AdwSwitchRowClass;
+ using BaseObjectType = AdwSwitchRow;
+ using CppClassParent = adw::ActionRow;
+ using CppObjectType = SwitchRow;
+
+ auto init() -> Glib::Class const &;
+ auto static class_init_function(void * gclass, void * data) -> void;
+ auto static wrap_new(GObject * object) -> Glib::ObjectBase *;
+ };
+
+ using BaseObjectType = Class::BaseObjectType;
+ using BaseClassType = Class::BaseClassType;
+ using CppObjectType = Class::CppObjectType;
+ using CppClassType = Class;
+
+ using helpers::gobj_mixin<CppObjectType, BaseObjectType>::gobj;
+ using helpers::gobj_mixin<CppObjectType, BaseObjectType>::gobj_copy;
+
+ explicit SwitchRow();
+ SwitchRow(SwitchRow const & other) = delete;
+ SwitchRow(SwitchRow && other) noexcept = default;
+
+ auto operator=(SwitchRow const & other) noexcept -> SwitchRow & = delete;
+ auto operator=(SwitchRow && other) noexcept -> SwitchRow & = default;
+
+ auto static get_type() -> GType;
+ auto static get_base_type() -> GType;
+
+ auto get_active(this auto && self) noexcept;
+
+ auto get_active(Gtk::Widget & widget) noexcept -> CppObjectType &;
+
+ auto property_active(this auto && self);
+
+ protected:
+ explicit SwitchRow(Glib::ConstructParams const & params);
+ explicit SwitchRow(BaseObjectType * gobj);
+ };
+
+ auto SwitchRow::get_active(this auto && self) noexcept
+ {
+ return self.property_active().value();
+ }
+
+ auto SwitchRow::property_active(this auto && self)
+ {
+ return helpers::make_property_proxy<bool>(self, "active");
+ }
+
+} // namespace turns::adw
+
+namespace Glib
+{
+ auto wrap(AdwSwitchRow * object, bool copy = false) -> Glib::RefPtr<turns::adw::SwitchRow>;
+} // namespace Glib
+
+#endif \ No newline at end of file
diff --git a/adw/src/switchrow.cpp b/adw/src/switchrow.cpp
new file mode 100644
index 0000000..8e9508d
--- /dev/null
+++ b/adw/src/switchrow.cpp
@@ -0,0 +1,72 @@
+#include "turns/adw/switchrow.hpp"
+
+#include "turns/adw/actionrow.hpp"
+
+#include <glibmm/class.h>
+#include <glibmm/object.h>
+#include <glibmm/objectbase.h>
+#include <glibmm/refptr.h>
+#include <glibmm/wrap.h>
+
+#include <adwaita.h>
+#include <gio/gio.h>
+#include <glib-object.h>
+
+namespace turns::adw
+{
+ namespace
+ {
+ auto constinit _class = SwitchRow::Class{};
+ } // namespace
+
+ auto SwitchRow::Class::init() -> Glib::Class const &
+ {
+ if (!gtype_)
+ {
+ gtype_ = adw_switch_row_get_type();
+ }
+ return *this;
+ }
+
+ auto SwitchRow::Class::wrap_new(GObject * object) -> Glib::ObjectBase *
+ {
+ return new SwitchRow(ADW_SWITCH_ROW(object));
+ }
+
+ SwitchRow::SwitchRow()
+ : Glib::ObjectBase{nullptr}
+ , adw::ActionRow{Glib::ConstructParams{_class.init()}}
+ {
+ }
+
+ auto SwitchRow::get_type() -> GType
+ {
+ return _class.init().get_type();
+ }
+
+ auto SwitchRow::get_base_type() -> GType
+ {
+ return adw_switch_row_get_type();
+ }
+
+ SwitchRow::SwitchRow(Glib::ConstructParams const & params)
+ : adw::ActionRow{params}
+ {
+ }
+
+ SwitchRow::SwitchRow(BaseObjectType * gobj)
+ : Glib::ObjectBase{nullptr}
+ , adw::ActionRow(ADW_ACTION_ROW(gobj))
+ {
+ }
+
+} // namespace turns::adw
+
+namespace Glib
+{
+ auto wrap(AdwSwitchRow * object, bool copy) -> Glib::RefPtr<turns::adw::SwitchRow>
+ {
+ return Glib::make_refptr_for_instance<turns::adw::SwitchRow>(
+ dynamic_cast<turns::adw::SwitchRow *>(Glib::wrap_auto(G_OBJECT(object), copy)));
+ }
+} // namespace Glib \ No newline at end of file
diff --git a/adw/src/wrap_init.cpp b/adw/src/wrap_init.cpp
index 6998f90..f77dacd 100644
--- a/adw/src/wrap_init.cpp
+++ b/adw/src/wrap_init.cpp
@@ -6,6 +6,7 @@
#include "turns/adw/preferencesdialog.hpp"
#include "turns/adw/preferencespage.hpp"
#include "turns/adw/preferencesrow.hpp"
+#include "turns/adw/switchrow.hpp"
#include "turns/adw/toast.hpp"
#include "turns/adw/toastoverlay.hpp"
@@ -30,6 +31,7 @@ namespace turns::adw
WRAP_CLASS(PreferencesDialog, preferences_dialog);
WRAP_CLASS(PreferencesPage, preferences_page);
WRAP_CLASS(PreferencesRow, preferences_row);
+ WRAP_CLASS(SwitchRow, switch_row);
WRAP_CLASS(ToastOverlay, toast_overlay);
ENSURE_TYPE(ActionRow);
@@ -39,6 +41,7 @@ namespace turns::adw
ENSURE_TYPE(PreferencesDialog);
ENSURE_TYPE(PreferencesPage);
ENSURE_TYPE(PreferencesRow);
+ ENSURE_TYPE(SwitchRow);
ENSURE_TYPE(ToastOverlay);
}
} // namespace turns::adw \ No newline at end of file
diff --git a/app/ch.arknet.Turns.gschema.xml b/app/ch.arknet.Turns.gschema.xml
index bffe837..d764608 100644
--- a/app/ch.arknet.Turns.gschema.xml
+++ b/app/ch.arknet.Turns.gschema.xml
@@ -16,5 +16,10 @@
<summary>Secret Disposition Color</summary>
<description>The color used to shade secret participants.</description>
</key>
+ <key name="skip-defeated" type="b">
+ <default>false</default>
+ <summary>Skip Defeated Participants</summary>
+ <description>Whether or not defeated participants shall be skipped while stepping through the turn order.</description>
+ </key>
</schema>
</schemalist> \ No newline at end of file
diff --git a/ui/include/turns/ui/widgets/preferences.hpp b/ui/include/turns/ui/widgets/preferences.hpp
index 749d4fd..449957d 100644
--- a/ui/include/turns/ui/widgets/preferences.hpp
+++ b/ui/include/turns/ui/widgets/preferences.hpp
@@ -2,6 +2,7 @@
#define TURNS_UI_WIDGETS_PREFERENCES_HPP
#include "turns/adw/preferencespage.hpp"
+#include "turns/adw/switchrow.hpp"
#include "turns/ui/widgets/template_widget.hpp"
#include <glibmm/refptr.h>
@@ -26,6 +27,7 @@ namespace turns::ui::widgets
"friendly_color_button",
"hostile_color_button",
"secret_color_button",
+ "skip_defeated",
};
explicit preferences(Glib::RefPtr<Gio::Settings> settings = {});
@@ -43,6 +45,7 @@ namespace turns::ui::widgets
Gtk::ColorDialogButton * m_friendly_color_button{};
Gtk::ColorDialogButton * m_hostile_color_button{};
Gtk::ColorDialogButton * m_secret_color_button{};
+ adw::SwitchRow * m_skip_defeated{};
};
} // namespace turns::ui::widgets
diff --git a/ui/res/ui.cmb b/ui/res/ui.cmb
index 2538784..a3f5dd8 100644
--- a/ui/res/ui.cmb
+++ b/ui/res/ui.cmb
@@ -70,8 +70,8 @@
(6,1,"AdwPreferencesPage","gtkmm__CustomObject_preferences",None,None,None,None,None,None,None),
(6,2,"AdwPreferencesGroup","colors",1,None,None,None,None,None,None),
(6,3,"AdwActionRow",None,2,None,None,None,None,None,None),
- (6,4,"AdwActionRow","hostile",2,None,None,None,1,None,None),
- (6,5,"AdwActionRow","secret",2,None,None,None,2,None,None),
+ (6,4,"AdwActionRow",None,2,None,None,None,1,None,None),
+ (6,5,"AdwActionRow",None,2,None,None,None,2,None,None),
(6,7,"GtkColorDialogButton","friendly_color_button",3,None,None,None,-1,None,None),
(6,10,"GtkColorDialogButton","hostile_color_button",4,None,None,None,1,None,None),
(6,11,"GtkColorDialogButton","secret_color_button",5,None,None,None,1,None,None),
@@ -80,7 +80,9 @@
(6,14,"GtkColorDialog",None,11,None,None,None,-1,None,None),
(6,15,"GtkButton","hostile_reset_button",4,None,None,None,1,None,None),
(6,16,"GtkButton","friendly_reset_button",3,None,None,None,1,None,None),
- (6,17,"GtkButton","secret_reset_button",5,None,None,None,1,None,None)
+ (6,17,"GtkButton","secret_reset_button",5,None,None,None,1,None,None),
+ (6,18,"AdwPreferencesGroup","control",1,None,None,None,1,None,None),
+ (6,19,"AdwSwitchRow","skip_defeated",18,None,None,None,-1,None,None)
</object>
<object_property>
(1,1,"AdwApplicationWindow","content",None,None,None,None,None,2,None,None,None,None),
@@ -207,7 +209,9 @@
(6,16,"GtkButton","icon-name","process-stop-symbolic",None,None,None,None,None,None,None,None,None),
(6,16,"GtkWidget","valign","center",None,None,None,None,None,None,None,None,None),
(6,17,"GtkButton","icon-name","process-stop-symbolic",None,None,None,None,None,None,None,None,None),
- (6,17,"GtkWidget","valign","center",None,None,None,None,None,None,None,None,None)
+ (6,17,"GtkWidget","valign","center",None,None,None,None,None,None,None,None,None),
+ (6,18,"AdwPreferencesGroup","title","Control",None,None,None,None,None,None,None,None,None),
+ (6,19,"AdwPreferencesRow","title","Skip defeated",None,None,None,None,None,None,None,None,None)
</object_property>
<object_data>
(1,1,"GtkWidget",2,2,None,1,None,None,None,None),
diff --git a/ui/src/init.cpp b/ui/src/init.cpp
index 8d48ced..f8c9e35 100644
--- a/ui/src/init.cpp
+++ b/ui/src/init.cpp
@@ -1,6 +1,7 @@
#include "turns/ui/init.hpp"
#include "turns/ui/widgets/participant_row.hpp"
+#include "turns/ui/widgets/preferences.hpp"
#include "turns/ui/widgets/turn_order_view.hpp"
namespace turns::ui
@@ -9,6 +10,7 @@ namespace turns::ui
auto register_types() -> void
{
static_cast<void>(widgets::participant_row{{}});
+ static_cast<void>(widgets::preferences{{}});
static_cast<void>(widgets::turn_order_view{{}});
}
diff --git a/ui/src/widgets/preferences.cpp b/ui/src/widgets/preferences.cpp
index 187da2e..3af7d15 100644
--- a/ui/src/widgets/preferences.cpp
+++ b/ui/src/widgets/preferences.cpp
@@ -1,5 +1,6 @@
#include "turns/ui/widgets/preferences.hpp"
+#include "turns/adw/switchrow.hpp"
#include "turns/ui/widgets/template_widget.hpp"
#include <sigc++/functors/mem_fun.h>
@@ -36,6 +37,7 @@ namespace turns::ui::widgets
, m_friendly_color_button{get_widget<Gtk::ColorDialogButton>("friendly_color_button")}
, m_hostile_color_button{get_widget<Gtk::ColorDialogButton>("hostile_color_button")}
, m_secret_color_button{get_widget<Gtk::ColorDialogButton>("secret_color_button")}
+ , m_skip_defeated{get_widget<adw::SwitchRow>("skip_defeated")}
{
if (!m_settings)
{
@@ -59,6 +61,8 @@ namespace turns::ui::widgets
bind_reset(key, m_secret_reset_button);
bind_setting(key, m_secret_color_button);
}
+
+ m_settings->bind("skip-defeated", m_skip_defeated->property_active());
}
auto preferences::bind_reset(Glib::ustring const & key, Gtk::Button * button) -> void