summaryrefslogtreecommitdiff
path: root/adw/include/adwaitamm/spinrow.hpp
blob: f5e02b646512bc32ddc587ebd240a512ea7cc96e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/**
 * @author Felix Morgner (felix.morgner@gmail.com)
 * @copyright Copyright (c) 2025
 * SPDX-License-Identifier: LGPL-2.1-or-later
 */

#ifndef LIBADWAITAMM_SPIN_ROW_HPP
#define LIBADWAITAMM_SPIN_ROW_HPP

#include "adwaitamm/actionrow.hpp"
#include "adwaitamm/helpers/gobj_mixin.hpp"

#include <glibmm/object.h>
#include <glibmm/propertyproxy.h>
#include <glibmm/refptr.h>
#include <glibmm/signalproxy.h>

#include <gtkmm/adjustment.h>
#include <gtkmm/spinbutton.h>

#include <glib-object.h>

#define _ADWAITA_INSIDE
#include <adw-spin-row.h>
#undef _ADWAITA_INSIDE

using AdwSpinRow = struct _AdwSpinRow;

namespace Adwaita
{
  struct SpinRow final : ActionRow,
                         helpers::gobj_mixin<SpinRow, AdwSpinRow>
  {
    using BaseObjectType = AdwSpinRow;
    using BaseClassType = AdwSpinRowClass;
    using CppObjectType = struct SpinRow;
    using CppClassType = struct SpinRow_Class;
    using helpers::gobj_mixin<CppObjectType, BaseObjectType>::gobj;
    using helpers::gobj_mixin<CppObjectType, BaseObjectType>::gobj_copy;

#pragma mark - Special Member Functions
    SpinRow(Gtk::Adjustment & adjustment, double climb_rate, unsigned int digits);
    SpinRow(double min, double max, double step);
    SpinRow(SpinRow const & other) = delete;
    SpinRow(SpinRow && other) noexcept = default;

    auto operator=(SpinRow const & other) noexcept -> SpinRow & = delete;
    auto operator=(SpinRow && other) noexcept -> SpinRow & = default;

#pragma mark - GObject Support
    auto static get_type() -> GType;
    auto static get_base_type() -> GType;

#pragma mark - Functions
    auto configure(Gtk::Adjustment & adjustment, double climb_rate, unsigned int digits) -> void;
    auto update() -> void;

#pragma mark - Getters
    [[nodiscard]] auto get_adjustment() const -> Glib::RefPtr<Gtk::Adjustment>;
    [[nodiscard]] auto get_climb_rate() const -> double;
    [[nodiscard]] auto get_digits() const -> unsigned int;
    [[nodiscard]] auto get_numeric() const -> bool;
    [[nodiscard]] auto get_snap_to_ticks() const -> bool;
    [[nodiscard]] auto get_update_policy() const -> Gtk::SpinButton::UpdatePolicy;
    [[nodiscard]] auto get_value() const -> double;
    [[nodiscard]] auto get_wrap() const -> bool;

#pragma mark - Setters
    auto set_adjustment(Gtk::Adjustment & value) -> void;
    auto set_climb_rate(double value) -> void;
    auto set_digits(unsigned int value) -> void;
    auto set_numeric(bool value) -> void;
    auto set_range(double min, double max) -> void;
    auto set_snap_to_ticks(bool value) -> void;
    auto set_update_policy(Gtk::SpinButton::UpdatePolicy value) -> void;
    auto set_value(double value) -> void;
    auto set_wrap(bool value) -> void;

#pragma mark - Properties
    [[nodiscard]] auto property_adjustment() -> Glib::PropertyProxy<Glib::RefPtr<Gtk::Adjustment>>;
    [[nodiscard]] auto property_adjustment() const -> Glib::PropertyProxy_ReadOnly<Glib::RefPtr<Gtk::Adjustment>>;
    [[nodiscard]] auto property_climb_rate() -> Glib::PropertyProxy<double>;
    [[nodiscard]] auto property_climb_rate() const -> Glib::PropertyProxy_ReadOnly<double>;
    [[nodiscard]] auto property_digits() -> Glib::PropertyProxy<unsigned int>;
    [[nodiscard]] auto property_digits() const -> Glib::PropertyProxy_ReadOnly<unsigned int>;
    [[nodiscard]] auto property_numeric() -> Glib::PropertyProxy<bool>;
    [[nodiscard]] auto property_numeric() const -> Glib::PropertyProxy_ReadOnly<bool>;
    [[nodiscard]] auto property_snap_to_ticks() -> Glib::PropertyProxy<bool>;
    [[nodiscard]] auto property_snap_to_ticks() const -> Glib::PropertyProxy_ReadOnly<bool>;
    [[nodiscard]] auto property_update_policy() -> Glib::PropertyProxy<Gtk::SpinButton::UpdatePolicy>;
    [[nodiscard]] auto property_update_policy() const -> Glib::PropertyProxy_ReadOnly<Gtk::SpinButton::UpdatePolicy>;
    [[nodiscard]] auto property_value() -> Glib::PropertyProxy<double>;
    [[nodiscard]] auto property_value() const -> Glib::PropertyProxy_ReadOnly<double>;
    [[nodiscard]] auto property_wrap() -> Glib::PropertyProxy<bool>;
    [[nodiscard]] auto property_wrap() const -> Glib::PropertyProxy_ReadOnly<bool>;

#pragma mark - Signals
    auto signal_input() -> Glib::SignalProxy<int(double &)>;
    auto signal_output() -> Glib::SignalProxy<bool()>;
    auto signal_wrapped() -> Glib::SignalProxy<void()>;

  protected:
    friend SpinRow_Class;

#pragma mark - Internal Constructors
    explicit SpinRow(Glib::ConstructParams const & params);
    explicit SpinRow(BaseObjectType * gobj);
  };

}  // namespace Adwaita

namespace Glib
{
  auto wrap(AdwSpinRow * object, bool copy = false) -> Adwaita::SpinRow *;
}  // namespace Glib

#endif