13#include <mplex/control/if.hpp>
14#include <mplex/functional/lift.hpp>
15#include <mplex/fundamental/integral.hpp>
25 template <
typename... T>
28 std::tuple<::Nui::Detail::ObservedAddReference_t<T>...>
observed;
34 template <
typename FunctionT,
typename... T>
37 using value_type = std::tuple<::Nui::Detail::ObservedAddReference_t<T>...>;
51 : Detail::StylePropertyEbo<T...>{std::forward_as_tuple(
observed)}
56 : Detail::StylePropertyEbo<T...>{std::make_tuple(std::move(
observed))}
61 : Detail::StylePropertyEbo<T...>{std::make_tuple(std::weak_ptr{
observed})}
65 : Detail::StylePropertyEbo<T...>{}
68 template <
typename GeneratorT>
72 : Detail::StylePropertyEbo<T...>{std::move(
observed).observedValues()}
76 template <
typename FunctionT>
78 template <
typename FunctionT,
typename T>
80 template <
typename FunctionT,
typename T>
82 template <
typename FunctionT,
typename T>
85 template <
typename FunctionT,
typename T>
88 template <
typename FunctionT,
typename GeneratorT,
typename... ObservedT>
97 constexpr static bool value =
true;
99 template <
typename FunctionT>
102 constexpr static bool value =
false;
104 template <
typename Property>
107 using type =
typename Property::value_type;
110 return prop.observed;
113 template <
typename FunctionT>
123 template <
typename IntegerSequence,
typename CurrentIndex,
typename... Properties>
126 template <
unsigned... Indices,
typename CurrentIndex,
typename Property,
typename... Properties>
128 std::integer_sequence<unsigned, Indices...>,
134 using type = mplex::lazy_if_vt<
137 mplex::lift<BuildObservedPropertyIndexList>,
138 std::integer_sequence<unsigned, Indices..., CurrentIndex::value>,
139 mplex::unsigned_<CurrentIndex::value + 1u>,
142 mplex::lift<BuildObservedPropertyIndexList>,
143 std::integer_sequence<unsigned, Indices...>,
144 mplex::unsigned_<CurrentIndex::value + 1u>,
148 template <
unsigned... Indices,
typename CurrentIndex>
151 using type = std::integer_sequence<unsigned, Indices...>;
154 template <
typename IndexList>
156 template <
unsigned... Indices>
159 constexpr static auto apply(
auto&& propertyTuple)
161 return std::tuple_cat(std::get<Indices>(propertyTuple).observed...);
181 auto operator=(
char const* value)
const
184 [name_ = std::string{
name}, value = std::string{value}]() {
185 return name_ +
":" + value;
193 [name_ = std::string{
name}, value = std::move(value)]() {
194 return name_ +
":" + value;
202 [name_ = std::string{
name}, &observedValue]() {
203 return name_ +
":" + observedValue.
value();
211 [name_ = std::string{
name}, observedValue = std::weak_ptr{observedValue.lock()}]() {
212 if (
auto shared = observedValue.lock(); shared)
213 return name_ +
":" + shared->value();
214 return std::string{};
216 std::move(observedValue)};
222 [name_ = std::string{
name}, observedValue = std::weak_ptr{observedValue}]() {
223 if (
auto shared = observedValue.lock(); shared)
224 return name_ +
":" + shared->value();
225 return std::string{};
227 std::move(observedValue)};
229 template <
typename FunctionT,
typename... ArgsT>
234 [name_ = std::string{
name}, gen = combinator.generator()]() {
235 return name_ +
":" + gen();
237 std::move(combinator)};
241 inline namespace Literals
243 static constexpr StyleProperty operator""_style(
char const* name, std::size_t)
251 template <
bool isStatic,
typename... Properties>
254 return [... props = std::forward<Properties>(props)]() {
256 std::stringstream sstr;
257 [&sstr](
auto const& head,
auto const&... tail) {
259 using expander =
int[];
260 const auto headStr = head();
262 (void)expander{0, (sstr << (headStr.empty() ?
"" :
";") << tail(), void(), 0)...};
271 template <
typename... Properties>
275 std::integer_sequence<unsigned>,
277 Properties...>::type>::apply(std::tie(props...));
281 template <
typename... Properties>
289 constexpr explicit Style(Properties&&... props)
290 : observedValues_{stripObserved(props...)}
291 , generateStyle_{makeStyleGenerator<
isStatic()>(std::forward<Properties>(props)...)}
296 return (Properties::isStatic() && ...);
301 return generateStyle_();
306 return std::move(generateStyle_);
311 return std::move(observedValues_);
316 std::function<std::string()> generateStyle_;
328 template <typename U>
335 template <
typename U>
342 template <
typename... T>
353 [&
style]<
typename... ObservedValueTypes>(ObservedValueTypes&&... obs) {
356 std::move(
style).ejectGenerator()));
358 std::move(
style).ejectObservedValues());
Definition attribute.hpp:15
Definition attribute_factory.hpp:283
std::string toString() const
Definition style.hpp:299
constexpr Style(Properties &&... props)
Definition style.hpp:289
Nui::Detail::FlatTupleTransform_t< Nui::Detail::TupleFilter_t< Detail::IsDynamicStyleProperty, Properties... >, Detail::StripPropertyObserved > ObservedValueList
Definition style.hpp:287
ObservedValueList ejectObservedValues() &&
Definition style.hpp:309
static constexpr bool isStatic()
Definition style.hpp:294
std::function< std::string()> ejectGenerator() &&
Definition style.hpp:304
ContainedT & value()
Definition observed_value.hpp:372
Definition observed_value_combinator.hpp:108
Definition observed_value_combinator.hpp:161
constexpr ObservedValueCombinatorWithGenerator< std::decay_t< RendererType >, ObservedValues... > generate(RendererType &&generator)
Definition observed_value_combinator.hpp:169
Definition observed_value.hpp:1283
Definition observed_value.hpp:1534
auto makeStyleGenerator(Properties &&... props)
Definition style.hpp:252
constexpr auto stripObserved(Properties &... props)
Definition style.hpp:272
Definition attribute_factory.hpp:20
struct Nui::Attributes::style_ style
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:1666
emscripten::val val
Definition val.hpp:5
std::integer_sequence< unsigned, Indices... > type
Definition style.hpp:151
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:145
static constexpr bool value
Definition style.hpp:97
std::tuple<> type
Definition style.hpp:116
static constexpr void * extract(StylePropertyImpl< FunctionT, void > &)
Definition style.hpp:117
static constexpr auto extract(Property &prop)
Definition style.hpp:108
typename Property::value_type type
Definition style.hpp:107
std::tuple<::Nui::Detail::ObservedAddReference_t< T >... > observed
Definition style.hpp:28
constexpr StylePropertyImpl(FunctionT generator, std::weak_ptr< Observed< U > > observed)
Definition style.hpp:55
constexpr StylePropertyImpl(FunctionT generator, Observed< U > const &observed)
Definition style.hpp:50
FunctionT generator
Definition style.hpp:39
constexpr StylePropertyImpl(FunctionT generator, std::nullptr_t)
Definition style.hpp:64
constexpr auto operator()() const
Definition style.hpp:44
static constexpr bool isStatic()
Definition style.hpp:40
std::tuple<::Nui::Detail::ObservedAddReference_t< T >... > value_type
Definition style.hpp:37
constexpr StylePropertyImpl(FunctionT generator, ObservedValueCombinatorWithGenerator< GeneratorT, T... > &&observed)
Definition style.hpp:69
constexpr StylePropertyImpl(FunctionT generator, std::shared_ptr< Observed< U > > observed)
Definition style.hpp:60
StyleProperty & operator=(StyleProperty &&) noexcept=delete
auto operator=(ObservedValueCombinatorWithGenerator< FunctionT, ArgsT... > &&combinator) const
Definition style.hpp:231
StyleProperty & operator=(StyleProperty const &)=delete
auto operator=(std::weak_ptr< Observed< std::string > > &&observedValue) const
Definition style.hpp:208
auto operator=(Observed< std::string > const &observedValue) const
Definition style.hpp:199
auto operator=(std::string value) const
Definition style.hpp:190
auto operator=(std::shared_ptr< Observed< std::string > > observedValue) const
Definition style.hpp:219
constexpr StyleProperty(char const *name)
Definition style.hpp:169
char const * name
Definition style.hpp:168
style_ & operator=(style_ &&) noexcept=delete
auto operator=(Style< T... > &&style) const
Definition style.hpp:344