forked from aseprite/aseprite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstateful_style.h
More file actions
74 lines (61 loc) · 1.76 KB
/
stateful_style.h
File metadata and controls
74 lines (61 loc) · 1.76 KB
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
74
// Aseprite CSS Library
// Copyright (C) 2013 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
#ifndef CSS_STATEFUL_STYLE_H_INCLUDED
#define CSS_STATEFUL_STYLE_H_INCLUDED
#pragma once
#include "css/rule.h"
#include "css/state.h"
#include "css/style.h"
#include "css/value.h"
namespace css {
class StatefulStyle {
public:
static const char kSeparator = ':';
StatefulStyle() : m_style(NULL) { }
StatefulStyle(const Style& style) : m_style(&style) { }
StatefulStyle(const State& state) {
operator+=(state);
}
StatefulStyle(const Style& style, const States& states) :
m_style(&style) {
operator+=(states);
}
const Style& style() const { return *m_style; }
const States& states() const { return m_states; }
StatefulStyle& setStyle(const Style& style) {
m_style = &style;
return *this;
}
StatefulStyle& operator+=(const State& state) {
m_states += state;
return *this;
}
StatefulStyle& operator+=(const States& states) {
m_states += states;
return *this;
}
private:
const Style* m_style;
States m_states;
};
inline StatefulStyle operator+(const Style& style, const State& state) {
StatefulStyle styleState;
styleState.setStyle(style);
styleState += state;
return styleState;
}
inline StatefulStyle operator+(const StatefulStyle& styleState, const State& state) {
StatefulStyle styleState2 = styleState;
styleState2 += state;
return styleState2;
}
inline StatefulStyle operator+(const StatefulStyle& styleState, const States& states) {
StatefulStyle styleState2 = styleState;
styleState2 += states;
return styleState2;
}
} // namespace css
#endif