xoreos  0.0.5
highlightable.cpp
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #include "src/events/events.h"
23 
24 namespace Graphics {
25 
26 namespace Aurora {
27 
28 Highlightable::Highlightable() : _highlightable(false), _isHighlighted(false),
29  _deltaR(0), _deltaG(0), _deltaB(0), _deltaA(0),
30  _upperBoundR(0), _upperBoundG(0), _upperBoundB(0), _upperBoundA(0),
31  _lowerBoundR(0), _lowerBoundG(0), _lowerBoundB(0), _lowerBoundA(0),
32  _prevIncTime(EventMan.getTimestamp()) {
33 
34 }
35 
37 
38 }
39 
41  return _highlightable;
42 }
43 
44 void Highlightable::setHighlightable(bool highlightable) {
45  _highlightable = highlightable;
46 }
47 
49  return _isHighlighted;
50 }
51 
52 void Highlightable::setHighlighted(bool hightlighted) {
53  _isHighlighted = hightlighted;
54 }
55 
56 void Highlightable::setHighlightDelta(float r, float g, float b, float a) {
57  _deltaR = r;
58  _deltaG = g;
59  _deltaB = b;
60  _deltaA = a;
61 }
62 
63 void Highlightable::setHighlightLowerBound(float r, float g, float b, float a) {
64  _lowerBoundR = r;
65  _lowerBoundG = g;
66  _lowerBoundB = b;
67  _lowerBoundA = a;
68 }
69 
70 void Highlightable::setHighlightUpperBound(float r, float g, float b, float a) {
71  _upperBoundR = r;
72  _upperBoundG = g;
73  _upperBoundB = b;
74  _upperBoundA = a;
75 }
76 
77 void Highlightable::getHighlightedLowerBound(float &r, float &g, float &b, float &a) const {
78  r = _lowerBoundR;
79  g = _lowerBoundG;
80  b = _lowerBoundB;
81  a = _lowerBoundA;
82 }
83 
85  _deltaR *= -1;
86  _deltaG *= -1;
87  _deltaB *= -1;
88  _deltaA *= -1;
89 }
90 
91 void Highlightable::incrementColor(float initialR, float initialG, float initialB, float initialA,
92  float &r, float &g, float &b, float &a) {
93  uint32 time = EventMan.getTimestamp();
94  float dt = (time - _prevIncTime) / 50.f;
95 
96  r = initialR + _deltaR * dt;
97  g = initialG + _deltaG * dt;
98  b = initialB + _deltaB * dt;
99  a = initialA + _deltaA * dt;
100 
101  if (_upperBoundR < r || _upperBoundG < g || _upperBoundB < b || _upperBoundA < a ||
102  _lowerBoundR > r || _lowerBoundG > g || _lowerBoundB > b || _lowerBoundA > a) {
104 
105  r = initialR;
106  g = initialG;
107  b = initialB;
108  a = initialA;
109  }
110 
111  _prevIncTime = time;
112 }
113 
114 } // End of namespace Aurora
115 
116 } // End of namespace Graphics
void setHighlighted(bool hightlighted)
void setHighlightable(bool highlightable)
The global events manager.
void setHighlightDelta(float r, float g, float b, float a)
Set how much the quad changes per render.
#define EventMan
Shortcut for accessing the events manager.
Definition: events.h:210
uint32_t uint32
Definition: types.h:204
void incrementColor(float initialR, float initialG, float initialB, float initialA, float &r, float &g, float &b, float &a)
void setHighlightUpperBound(float r, float g, float b, float a)
When any of the quad properties are greater than this bound, the signs of the delta floats will flip...
void setHighlightLowerBound(float r, float g, float b, float a)
When any of the quad properties are less than this bound, the signs of the delta floats will flip...
void getHighlightedLowerBound(float &r, float &g, float &b, float &a) const