-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathStyle.h
73 lines (59 loc) · 1.53 KB
/
Style.h
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
#ifndef STYLE_H
#define STYLE_H
#include "Context.h"
template<typename TNormal, typename THover, typename TPressed>
struct ButtonStyle
{
typedef TNormal Normal;
typedef THover Hover;
typedef TPressed Pressed;
};
template<typename TNormal, typename THover, typename TFocused>
struct TextBoxStyle
{
typedef TNormal Normal;
typedef THover Hover;
typedef TFocused Focused;
};
template<typename TButtonStyle, typename TTextBoxStyle>
struct Style
{
typedef TButtonStyle ButtonStyle;
typedef TTextBoxStyle TextBoxStyle;
};
template<typename TTemplate>
struct skip_template
{
skip_template(const TTemplate &subject)
: subject(subject)
{
}
template<typename TContext>
auto build(const TContext &context) const
{
const auto &noop_context = change_operation<Operation::Noop>(context);
const auto &result = subject.build(noop_context);
return change_operation<get_operation_v<TContext>>(result);
}
TTemplate subject;
};
struct skip_template_decorator
{
};
template<class TTemplate>
auto operator|(const TTemplate &t, const skip_template_decorator &)
{
return skip_template<TTemplate>(t);
}
constexpr skip_template_decorator skip;
template<typename TContext, typename TTemplates>
auto expand_templates(const TContext &context, const TTemplates &t)
{
return t.build(context);
}
template<typename TContext, typename TTemplate, typename ...TTemplates>
auto expand_templates(const TContext &context, const TTemplate &t, const TTemplates &... templates)
{
return expand_templates(expand_templates(context, templates...), t);
}
#endif // STYLE_H