|
1 | 1 | #pragma once
|
2 | 2 |
|
| 3 | +#include<utki/shared_ref.hpp> |
| 4 | +#include<tml/tree.hpp> |
| 5 | + |
3 | 6 | namespaceruis {
|
4 | 7 |
|
5 |
| -classstyle_sheet |
| 8 | +classstyle_value_base |
6 | 9 | {
|
| 10 | +utki::shared_ref<style_sheet> owner_sheet; |
7 | 11 | public:
|
| 12 | +virtual~style_value_base() =default; |
| 13 | + |
| 14 | +virtualvoidreload(const tml::forest& desc) = 0; |
8 | 15 | };
|
9 | 16 |
|
10 |
| -template<typename value_type> |
11 |
| -classstyle_value |
| 17 | +classstyle_sheet |
12 | 18 | {
|
13 |
| -public: |
14 |
| -utki::shared_ref<style_sheet> ss; |
| 19 | +std::shared_ptr<style_value_base>get(std::string_view style_name); |
15 | 20 |
|
16 |
| -value_type value; |
| 21 | +// TODO: weak_ptr cache and reload cached values |
| 22 | + |
| 23 | +public: |
| 24 | +template<typename value_type> |
| 25 | +utki::shared_ref<value_type>get( |
| 26 | +std::string_view style_name,// |
| 27 | +const value_type& default_value |
| 28 | +) |
| 29 | +{ |
| 30 | +// TODO: |
| 31 | +} |
17 | 32 | };
|
18 | 33 |
|
19 | 34 | template<typename value_type>
|
20 | 35 | classstyled
|
21 | 36 | {
|
22 |
| -std::shared_ptr<style_value> value; |
23 |
| -value_type cur_value; |
| 37 | +std::variant< |
| 38 | +utki::shared_ref<style_value>, |
| 39 | +value_type> value; |
24 | 40 |
|
25 | 41 | public:
|
26 | 42 | styled(value_type value) :
|
27 |
| -cur_value(std::move(value)) |
| 43 | +value(std::move(value)) |
28 | 44 | {}
|
29 | 45 |
|
30 |
| -const value_type&get() |
| 46 | +const value_type&get()constnoexcept |
31 | 47 | {
|
32 |
| -this->cur_value; |
33 |
| -} |
34 |
| - |
35 |
| -voidreload() |
36 |
| -{ |
37 |
| -if(!this->value){ |
38 |
| -return; |
39 |
| -} |
40 |
| - |
41 | 48 | // TODO:
|
42 | 49 | }
|
43 | 50 | };
|
|