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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
|
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef TITANIC_PET_SLIDER_H
#define TITANIC_PET_SLIDER_H
#include "titanic/support/rect.h"
#include "titanic/support/string.h"
#include "titanic/core/game_object.h"
namespace Titanic {
enum SliderOrientation { ORIENTATION_HORIZONTAL = 1, ORIENTATION_VERTICAL = 2 };
class CPetControl;
class CPetSlider {
private:
int _orientation;
Rect _bounds;
Rect _slidingRect;
int _thumbWidth;
int _thumbHeight;
int _sliderOffset;
bool _thumbFocused;
Rect _dirtyArea;
private:
/**
* Center the center position of the slider's thumb
*/
Point getThumbCentroidPos() const;
/**
* Returns true if the passed point is within the thumb
*/
bool thumbContains(const Point &pt) const;
/**
* Gets the area the slider's thumbnail covers
*/
Rect getThumbRect() const;
/**
* Calculates the slider offset at the specificed position
*/
int calcSliderOffset(const Point &pt) const;
protected:
/**
* Get the position to draw the background at
*/
Point getBackgroundDrawPos();
/**
* Get the position to draw the slider thumbnail at
*/
Point getThumbDrawPos();
/**
* Returns true if the passed point falls within the slider's bounds
*/
bool containsPt(const Point &pt) const { return _bounds.contains(pt); }
public:
CPetSlider();
virtual ~CPetSlider() {}
/**
* Setup the background
*/
virtual void setupBackground(const CString &name, CPetControl *petControl) {}
/**
* Setup the thumb
*/
virtual void setupThumb(const CString &name, CPetControl *petControl) {}
/**
* Setup the background
*/
virtual void setupBackground2(const CString &name, CPetControl *petControl) {}
/**
* Setup the thumb
*/
virtual void setupThumb2(const CString &name, CPetControl *petControl) {}
/**
* Reset the slider
*/
virtual void reset(const CString &name) {}
/**
* Draw the slider
*/
virtual void draw(CScreenManager *screenManager) {}
/**
* Reset the dirty area
*/
virtual Rect clearDirtyArea();
/**
* Checks whether the slider is highlighted
*/
virtual bool checkThumb(const Point &pt);
/**
* Resets the thumb focused flag
*/
virtual bool resetThumbFocus();
/**
* Handles dragging the slider
*/
virtual bool MouseDragMoveMsg(const Point &pt);
/**
* Called when a slider drag ends
*/
virtual bool MouseDragEndMsg(const Point &pt) { return true; }
/**
* Handles mouse button up messaes
*/
virtual bool MouseButtonUpMsg(const Point &pt);
virtual bool proc13() { return false; }
virtual bool proc14() { return false; }
virtual bool contains(const Point &pt) const;
/**
* Returns the slider offset in pixels
*/
virtual double getOffsetPixels() const;
/**
* Sets the slider offset
*/
virtual void setSliderOffset(double offset);
/**
* Set a new slider offset in pixels
*/
virtual void setOffsetPixels(int offset);
/**
* Enables a given orientation
*/
void setOrientation(SliderOrientation orientation);
/**
* Set the bounds for the slider
*/
void setBounds(const Rect &r) { _bounds = r; }
/**
* Set the sliding bounds for the slider
*/
void setSlidingBounds(const Rect &r) { _slidingRect = r; }
/**
* Set the size of the slider thumb
*/
void setThumbSize(const Point &pt) {
_thumbWidth = pt.x;
_thumbHeight = pt.y;
}
/**
* Move the slider
*/
void translate(const Point &pt) {
_bounds.translate(pt.x, pt.y);
_slidingRect.translate(pt.x, pt.y);
}
/**
* Change the current position of a slider by a step amount
*/
void stepPosition(int direction);
};
class CPetSoundSlider : public CPetSlider {
public:
CGameObject *_background;
CGameObject *_thumb;
public:
CPetSoundSlider() : CPetSlider(), _background(nullptr),
_thumb(0) {}
/**
* Setup the background
*/
virtual void setupBackground(const CString &name, CPetControl *petControl);
/**
* Setup the thumb
*/
virtual void setupThumb(const CString &name, CPetControl *petControl);
/**
* Setup the background
*/
virtual void setupBackground2(const CString &name, CPetControl *petControl);
/**
* Setup the thumb
*/
virtual void setupThumb2(const CString &name, CPetControl *petControl);
/**
* Draw the slider
*/
virtual void draw(CScreenManager *screenManager);
};
} // End of namespace Titanic
#endif /* TITANIC_PET_SLIDER_H */
|