11
11
12
12
namespace cycfi ::elements
13
13
{
14
- template <typename Subject >
15
- class sprite_button_styler : public proxy <Subject>
14
+ template <typename Base >
15
+ class sprite_button_styler : public Base
16
16
{
17
17
public:
18
18
19
- using base_type = proxy<Subject>;
20
-
21
- sprite_button_styler (Subject subject);
19
+ using Base::Base;
22
20
23
21
void draw (context const & ctx) override ;
24
22
};
@@ -27,63 +25,71 @@ namespace cycfi::elements
27
25
concepts::MomentaryButton Base = basic_button
28
26
, concepts::SpriteSubject Styler
29
27
>
30
- inline proxy<sprite_button_styler<remove_cvref_t <Styler>>, Base>
31
- momentary_button (Styler&& s)
32
- {
33
- using styler_type = sprite_button_styler<remove_cvref_t <Styler>>;
34
- return {styler_type{std::forward<Styler>(s)}};
35
- }
28
+ inline proxy<remove_cvref_t <Styler>, sprite_button_styler<Base>>
29
+ momentary_button (Styler&& s);
36
30
37
31
template <
38
32
concepts::ToggleButton Base = basic_toggle_button
39
33
, concepts::SpriteSubject Styler
40
34
>
41
- inline proxy<sprite_button_styler<remove_cvref_t <Styler>>, Base>
42
- toggle_button (Styler&& s)
43
- {
44
- using styler_type = sprite_button_styler<remove_cvref_t <Styler>>;
45
- return {styler_type{std::forward<Styler>(s)}};
46
- }
35
+ inline proxy<remove_cvref_t <Styler>, sprite_button_styler<Base>>
36
+ toggle_button (Styler&& s);
47
37
48
38
template <
49
39
concepts::LatchingButton Base = basic_latching_button
50
40
, concepts::SpriteSubject Styler
51
41
>
52
- inline proxy<sprite_button_styler<remove_cvref_t <Styler>>, Base>
53
- latching_button (Styler&& s)
54
- {
55
- using styler_type = sprite_button_styler<remove_cvref_t <Styler>>;
56
- return {styler_type{std::forward<Styler>(s)}};
57
- }
42
+ inline proxy<remove_cvref_t <Styler>, sprite_button_styler<Base>>
43
+ latching_button (Styler&& s);
58
44
59
45
// --------------------------------------------------------------------------
60
46
// Inlines
61
47
// --------------------------------------------------------------------------
62
48
63
- template <typename Subject>
64
- inline sprite_button_styler<Subject>::sprite_button_styler(Subject subject)
65
- : base_type{std::move (subject)}
66
- {}
67
-
68
- template <typename Subject>
69
- inline void sprite_button_styler<Subject>::draw(context const & ctx)
49
+ template <typename Base>
50
+ inline void sprite_button_styler<Base>::draw(context const & ctx)
70
51
{
71
- auto btn = find_parent<basic_button*>(ctx);
72
- if (!btn)
73
- return ;
74
-
75
- auto sp = find_subject<sprite*>(this );
76
- if (sp)
52
+ if (auto sp = find_subject<sprite*>(this ))
77
53
{
78
- auto value = btn ->value ();
79
- auto hilite = btn ->hilite ();
54
+ auto value = this ->value ();
55
+ auto hilite = this ->hilite ();
80
56
if (!ctx.enabled && sp->num_frames () > 4 )
81
57
sp->index (4 ); // disabled
82
58
else
83
59
sp->index ((value? 2 : 0 ) + hilite); // enabled
84
- sp-> draw (ctx);
60
+ Base:: draw (ctx);
85
61
}
86
62
}
63
+
64
+ template <
65
+ concepts::MomentaryButton Base
66
+ , concepts::SpriteSubject Styler
67
+ >
68
+ inline proxy<remove_cvref_t <Styler>, sprite_button_styler<Base>>
69
+ momentary_button (Styler&& s)
70
+ {
71
+ return {std::forward<Styler>(s)};
72
+ }
73
+
74
+ template <
75
+ concepts::ToggleButton Base
76
+ , concepts::SpriteSubject Styler
77
+ >
78
+ inline proxy<remove_cvref_t <Styler>, sprite_button_styler<Base>>
79
+ toggle_button (Styler&& s)
80
+ {
81
+ return {std::forward<Styler>(s)};
82
+ }
83
+
84
+ template <
85
+ concepts::LatchingButton Base
86
+ , concepts::SpriteSubject Styler
87
+ >
88
+ inline proxy<remove_cvref_t <Styler>, sprite_button_styler<Base>>
89
+ latching_button (Styler&& s)
90
+ {
91
+ return {std::forward<Styler>(s)};
92
+ }
87
93
}
88
94
89
95
#endif
0 commit comments