2#include <score/command/SettingsCommand.hpp>
3#include <score/plugins/UuidKey.hpp>
5#include <ossia/detail/for_each_in_tuple.hpp>
10#include <score_lib_base_export.h>
16class SettingsDelegateFactory;
34template <
typename Parameter>
38 using parameter_type = Parameter;
39 using model_type =
typename Parameter::model_type;
40 using data_type =
typename Parameter::param_type;
41 using argument_type =
typename boost::call_traits<data_type>::param_type;
49#if !defined(__EMSCRIPTEN__)
50template <
typename T,
typename Model>
51void setupDefaultSettings(QSettings& set,
const T& tuple, Model& model)
53 ossia::for_each_in_tuple(tuple, [&](
auto& e) {
54 using type = std::remove_reference_t<
decltype(e)>;
55 using data_type =
typename type::data_type;
56 using param_type =
typename type::parameter_type;
60 if(!set.contains(e.key))
62 set.setValue(e.key, QVariant::fromValue(e.def));
63 (model.*param_type::init)(e.def);
68 auto val = set.value(e.key).template value<data_type>();
69 (model.*param_type::init)(val);
74template <
typename T,
typename Model>
75void setupDefaultSettings(QSettings&,
const T& tuple, Model& model)
77 ossia::for_each_in_tuple(tuple, [&](
auto& e) {
78 using type = std::remove_reference_t<
decltype(e)>;
79 using data_type =
typename type::data_type;
80 using param_type =
typename type::parameter_type;
81 (model.*param_type::set)(e.def);
87#define SETTINGS_PARAMETER_IMPL(Name) const score::sp<Model::p_##Name> Name
89#define SCORE_SETTINGS_COMMAND(ModelType, Name) \
90 struct Set##ModelType##Name final \
91 : public score::SettingsCommand<ModelType::p_##Name> \
93 static constexpr const bool is_deferred = false; \
94 SCORE_SETTINGS_COMMAND_DECL(Set##ModelType##Name) \
97#define SCORE_SETTINGS_PARAMETER(ModelType, Name) SCORE_SETTINGS_COMMAND(ModelType, Name)
99#define SCORE_SETTINGS_DEFERRED_COMMAND(ModelType, Name) \
100 struct Set##ModelType##Name final \
101 : public score::SettingsCommand<ModelType::p_##Name> \
103 static constexpr const bool is_deferred = true; \
104 SCORE_SETTINGS_COMMAND_DECL(Set##ModelType##Name) \
107#define SCORE_SETTINGS_DEFERRED_PARAMETER(ModelType, Name) \
108 SCORE_SETTINGS_DEFERRED_COMMAND(ModelType, Name)
110#define SCORE_SETTINGS_PROPERTY(Type, Name) \
112 Type, Name, &W_ThisType::get##Name, &W_ThisType::set##Name, W_Notify, \
113 &W_ThisType::Name##Changed) \
116 using param_type = Type; \
117 using model_type = W_ThisType; \
118 static const constexpr auto name = #Name; \
119 static const constexpr auto get = &W_ThisType::get##Name; \
120 static const constexpr auto set = &W_ThisType::set##Name; \
121 static const constexpr auto notify = &W_ThisType::Name##Changed; \
122 static const constexpr auto init = &W_ThisType::init##Name; \
125#define SCORE_SETTINGS_PARAMETER_HPP(Export, Type, Name) \
127 Type get##Name() const; \
128 void init##Name(Type); \
129 void set##Name(Type); \
130 void Name##Changed(Type arg) E_SIGNAL2(Export##S, Export, Name##Changed, arg); \
131 SCORE_SETTINGS_PROPERTY(Type, Name) \
134#define SCORE_SETTINGS_PARAMETER_CPP(Type, ModelType, Name) \
135 Type ModelType::get##Name() const \
140 void ModelType::init##Name(Type val) \
144 Name##Changed(val); \
146 void ModelType::set##Name(Type val) \
148 if(val == m_##Name) \
154 s.setValue(Parameters::Name.key, QVariant::fromValue(m_##Name)); \
155 Name##Changed(val); \
158#define SCORE_PROJECTSETTINGS_PARAMETER_CPP(Type, ModelType, Name) \
159 Type ModelType::get##Name() const \
164 void ModelType::init##Name(Type val) \
167 Name##Changed(val); \
169 void ModelType::set##Name(Type val) \
171 if(val == m_##Name) \
174 init##Name(std::move(val)); \
Definition UuidKey.hpp:345
Definition SettingsDelegateModel.hpp:18
Base toolkit upon which the software is built.
Definition Application.cpp:83