13 #include <mplex/control/if.hpp>
14 #include <mplex/functional/lift.hpp>
15 #include <mplex/fundamental/integral.hpp>
26 template <
typename... T>
29 std::tuple<::Nui::Detail::ObservedAddReference_t<T>...>
observed;
35 template <
typename FunctionT,
typename... T>
38 using value_type = std::tuple<::Nui::Detail::ObservedAddReference_t<T>...>;
52 : Detail::StylePropertyEbo<T...>{std::forward_as_tuple(
observed)}
57 : Detail::StylePropertyEbo<T...>{std::make_tuple(std::move(
observed))}
62 : Detail::StylePropertyEbo<T...>{std::make_tuple(std::weak_ptr{
observed})}
66 : Detail::StylePropertyEbo<T...>{}
69 template <
typename GeneratorT>
73 : Detail::StylePropertyEbo<T...>{std::move(
observed).observedValues()}
77 template <
typename FunctionT>
79 template <
typename FunctionT,
typename T>
81 template <
typename FunctionT,
typename T>
83 template <
typename FunctionT,
typename T>
86 template <
typename FunctionT,
typename T>
89 template <
typename FunctionT,
typename GeneratorT,
typename... ObservedT>
98 constexpr
static bool value =
true;
100 template <
typename FunctionT>
103 constexpr
static bool value =
false;
105 template <
typename Property>
108 using type =
typename Property::value_type;
111 return prop.observed;
114 template <
typename FunctionT>
124 template <
typename IntegerSequence,
typename CurrentIndex,
typename... Properties>
127 template <
unsigned... Indices,
typename CurrentIndex,
typename Property,
typename... Properties>
129 std::integer_sequence<unsigned, Indices...>,
135 using type = mplex::lazy_if_vt<
138 mplex::lift<BuildObservedPropertyIndexList>,
139 std::integer_sequence<unsigned, Indices..., CurrentIndex::value>,
140 mplex::unsigned_<CurrentIndex::value + 1u>,
143 mplex::lift<BuildObservedPropertyIndexList>,
144 std::integer_sequence<unsigned, Indices...>,
145 mplex::unsigned_<CurrentIndex::value + 1u>,
149 template <
unsigned... Indices,
typename CurrentIndex>
152 using type = std::integer_sequence<unsigned, Indices...>;
155 template <
typename IndexList>
157 template <
unsigned... Indices>
160 constexpr
static auto apply(
auto&& propertyTuple)
162 return std::tuple_cat(std::get<Indices>(propertyTuple).observed...);
177 [name_ = std::string{
name}, value = std::string{value}]() {
178 return name_ +
":" + value;
185 [name_ = std::string{
name}, value = std::move(value)]() {
186 return name_ +
":" + value;
193 [name_ = std::string{
name}, &observedValue]() {
194 return name_ +
":" + observedValue.
value();
201 [name_ = std::string{
name}, observedValue = std::weak_ptr{observedValue.lock()}]() {
202 if (
auto shared = observedValue.lock(); shared)
203 return name_ +
":" + shared->value();
204 return std::string{};
206 std::move(observedValue)};
211 [name_ = std::string{
name}, observedValue = std::weak_ptr{observedValue}]() {
212 if (
auto shared = observedValue.lock(); shared)
213 return name_ +
":" + shared->value();
214 return std::string{};
216 std::move(observedValue)};
218 template <
typename FunctionT,
typename... ArgsT>
222 [name_ = std::string{
name}, gen = combinator.generator()]() {
223 return name_ +
":" + gen();
225 std::move(combinator)};
229 inline namespace Literals
231 static constexpr
StyleProperty operator"" _style(
char const* name, std::size_t)
239 template <
bool isStatic,
typename... Properties>
242 return [... props = std::forward<Properties>(props)]() {
244 std::stringstream sstr;
245 [&sstr](
auto const& head,
auto const&... tail) {
246 using expander =
int[];
247 const auto headStr = head();
249 (void)expander{0, (sstr << (headStr.empty() ?
"" :
";") << tail(), void(), 0)...};
258 template <
typename... Properties>
262 std::integer_sequence<unsigned>,
264 Properties...>::type>::apply(std::tie(props...));
268 template <
typename... Properties>
276 constexpr
Style(Properties&&... props)
283 return (Properties::isStatic() && ...);
288 return generateStyle_();
293 return std::move(generateStyle_);
298 return std::move(observedValues_);
303 std::function<std::string()> generateStyle_;
308 template <
typename U>
314 template <
typename U>
320 template <
typename... T>
330 [&
style]<
typename... ObservedValueTypes>(ObservedValueTypes&&... obs) {
333 std::move(
style).ejectGenerator()));
335 std::move(
style).ejectObservedValues());
Definition: attribute.hpp:15
Definition: attribute_factory.hpp:235
Definition: style.hpp:270
std::string toString() const
Definition: style.hpp:286
constexpr static bool isStatic()
Definition: style.hpp:281
constexpr Style(Properties &&... props)
Definition: style.hpp:276
Nui::Detail::FlatTupleTransform_t< Nui::Detail::TupleFilter_t< Detail::IsDynamicStyleProperty, Properties... >, Detail::StripPropertyObserved > ObservedValueList
Definition: style.hpp:274
ObservedValueList ejectObservedValues() &&
Definition: style.hpp:296
std::function< std::string()> ejectGenerator() &&
Definition: style.hpp:291
ContainedT const & value() const
Definition: observed_value.hpp:313
Definition: observed_value_combinator.hpp:109
Definition: observed_value_combinator.hpp:160
requires constexpr std::invocable< RendererType > ObservedValueCombinatorWithGenerator< RendererType, ObservedValues... > generate(RendererType &&generator)
Definition: observed_value_combinator.hpp:168
Definition: observed_value.hpp:1202
auto makeStyleGenerator(Properties &&... props)
Definition: style.hpp:240
constexpr auto stripObserved(Properties &... props)
Definition: style.hpp:259
Definition: attribute_factory.hpp:14
struct Nui::Attributes::style_ style
StylePropertyImpl(FunctionT generator, std::nullptr_t) -> StylePropertyImpl< FunctionT, void >
requires(std::is_same_v< T, AttributeFactory >||std::is_same_v< T, PropertyFactory >||std::is_same_v< T, EventFactory >) Detail
Definition: attribute_factory.hpp:583
typename TupleFilter< Predicate, T... >::type TupleFilter_t
Definition: tuple_filter.hpp:27
typename PickFirst< Ts... >::type PickFirst_t
Definition: pick_first.hpp:22
typename FlatTupleTransform< Tuple, Predicate >::type FlatTupleTransform_t
Definition: tuple_transform.hpp:31
typename UnpackObserved< T >::type UnpackObserved_t
Definition: observed_value.hpp:1583
concept IsObserved
Definition: observed_value.hpp:1451
emscripten::val val
Definition: val.hpp:5
std::integer_sequence< unsigned, Indices... > type
Definition: style.hpp:152
mplex::lazy_if_vt< IsDynamicStyleProperty< Property >::value, mplex::then_< mplex::lift< BuildObservedPropertyIndexList >, std::integer_sequence< unsigned, Indices..., CurrentIndex::value >, mplex::unsigned_< CurrentIndex::value+1u >, Properties... >, mplex::else_< mplex::lift< BuildObservedPropertyIndexList >, std::integer_sequence< unsigned, Indices... >, mplex::unsigned_< CurrentIndex::value+1u >, Properties... > > type
Definition: style.hpp:146
Definition: style.hpp:125
constexpr static bool value
Definition: style.hpp:98
std::tuple<> type
Definition: style.hpp:117
constexpr static void * extract(StylePropertyImpl< FunctionT, void > &)
Definition: style.hpp:118
Definition: style.hpp:107
constexpr static auto extract(Property &prop)
Definition: style.hpp:109
typename Property::value_type type
Definition: style.hpp:108
std::tuple<::Nui::Detail::ObservedAddReference_t< T >... > observed
Definition: style.hpp:29
constexpr StylePropertyImpl(FunctionT generator, Observed< U > const &observed)
Definition: style.hpp:51
FunctionT generator
Definition: style.hpp:40
constexpr static bool isStatic()
Definition: style.hpp:41
constexpr StylePropertyImpl(FunctionT generator, std::nullptr_t)
Definition: style.hpp:65
constexpr auto operator()() const
Definition: style.hpp:45
std::tuple<::Nui::Detail::ObservedAddReference_t< T >... > value_type
Definition: style.hpp:38
constexpr StylePropertyImpl(FunctionT generator, std::weak_ptr< Observed< U >> observed)
Definition: style.hpp:56
constexpr StylePropertyImpl(FunctionT generator, ObservedValueCombinatorWithGenerator< GeneratorT, T... > &&observed)
Definition: style.hpp:70
constexpr StylePropertyImpl(FunctionT generator, std::shared_ptr< Observed< U >> observed)
Definition: style.hpp:61
Definition: style.hpp:168
auto operator=(std::shared_ptr< Observed< std::string >> observedValue)
Definition: style.hpp:208
auto operator=(std::string value)
Definition: style.hpp:182
auto operator=(std::weak_ptr< Observed< std::string >> &&observedValue)
Definition: style.hpp:198
auto operator=(char const *value)
Definition: style.hpp:174
constexpr StyleProperty(char const *name)
Definition: style.hpp:170
auto operator=(Observed< std::string > const &observedValue)
Definition: style.hpp:190
auto operator=(ObservedValueCombinatorWithGenerator< FunctionT, ArgsT... > &&combinator)
Definition: style.hpp:219
char const * name
Definition: style.hpp:169
Definition: style.hpp:307