ScummVM API documentation
pet_slider.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef TITANIC_PET_SLIDER_H
23 #define TITANIC_PET_SLIDER_H
24 
25 #include "titanic/support/rect.h"
26 #include "titanic/support/string.h"
27 #include "titanic/core/game_object.h"
28 
29 namespace Titanic {
30 
31 enum SliderOrientation { ORIENTATION_HORIZONTAL = 1, ORIENTATION_VERTICAL = 2 };
32 
33 class CPetControl;
34 
35 class CPetSlider {
36 private:
37  int _orientation;
38  Rect _bounds;
39  Rect _slidingRect;
40  int _thumbWidth;
41  int _thumbHeight;
42  int _sliderOffset;
43  bool _thumbFocused;
44  Rect _dirtyArea;
45 private:
49  Point getThumbCentroidPos() const;
50 
54  bool thumbContains(const Point &pt) const;
55 
59  Rect getThumbRect() const;
60 
64  int calcSliderOffset(const Point &pt) const;
65 protected:
70 
75 
79  bool containsPt(const Point &pt) const { return _bounds.contains(pt); }
80 public:
81  CPetSlider();
82  virtual ~CPetSlider() {}
83 
87  virtual void setupBackground(const CString &name, CPetControl *petControl) {}
88 
92  virtual void setupThumb(const CString &name, CPetControl *petControl) {}
93 
97  virtual void setupBackground2(const CString &name, CPetControl *petControl) {}
98 
102  virtual void setupThumb2(const CString &name, CPetControl *petControl) {}
103 
107  virtual void reset(const CString &name) {}
108 
112  virtual void draw(CScreenManager *screenManager) {}
113 
117  virtual Rect clearDirtyArea();
118 
122  virtual bool checkThumb(const Point &pt);
123 
127  virtual bool resetThumbFocus();
128 
132  virtual bool MouseDragMoveMsg(const Point &pt);
133 
137  virtual bool MouseDragEndMsg(const Point &pt) { return true; }
138 
142  virtual bool MouseButtonUpMsg(const Point &pt);
143 
144  virtual bool proc13() { return false; }
145  virtual bool proc14() { return false; }
146 
147 
148  virtual bool contains(const Point &pt) const;
149 
153  virtual double getOffsetPixels() const;
154 
158  virtual void setSliderOffset(double offset);
159 
163  virtual void setOffsetPixels(int offset);
164 
168  void setOrientation(SliderOrientation orientation);
169 
173  void setBounds(const Rect &r) { _bounds = r; }
174 
178  void setSlidingBounds(const Rect &r) { _slidingRect = r; }
179 
183  void setThumbSize(const Point &pt) {
184  _thumbWidth = pt.x;
185  _thumbHeight = pt.y;
186  }
187 
191  void translate(const Point &pt) {
192  _bounds.translate(pt.x, pt.y);
193  _slidingRect.translate(pt.x, pt.y);
194  }
195 
199  void stepPosition(int direction);
200 };
201 
202 class CPetSoundSlider : public CPetSlider {
203 public:
204  CGameObject *_background;
205  CGameObject *_thumb;
206 public:
207  CPetSoundSlider() : CPetSlider(), _background(nullptr),
208  _thumb(0) {}
209 
213  void setupBackground(const CString &name, CPetControl *petControl) override;
214 
218  void setupThumb(const CString &name, CPetControl *petControl) override;
219 
223  void setupBackground2(const CString &name, CPetControl *petControl) override;
224 
228  void setupThumb2(const CString &name, CPetControl *petControl) override;
229 
233  void draw(CScreenManager *screenManager) override;
234 };
235 
236 } // End of namespace Titanic
237 
238 #endif /* TITANIC_PET_SLIDER_H */
virtual void setupBackground2(const CString &name, CPetControl *petControl)
Definition: pet_slider.h:97
virtual bool MouseButtonUpMsg(const Point &pt)
void stepPosition(int direction)
bool contains(int16 x, int16 y) const
Definition: rect.h:210
void translate(const Point &pt)
Definition: pet_slider.h:191
Point getBackgroundDrawPos()
virtual bool checkThumb(const Point &pt)
virtual void setupBackground(const CString &name, CPetControl *petControl)
Definition: pet_slider.h:87
Definition: pet_slider.h:35
void translate(int16 dx, int16 dy)
Definition: rect.h:354
virtual void setupThumb2(const CString &name, CPetControl *petControl)
Definition: pet_slider.h:102
Definition: screen_manager.h:49
Definition: game_object.h:79
virtual void setSliderOffset(double offset)
void setSlidingBounds(const Rect &r)
Definition: pet_slider.h:178
virtual void setOffsetPixels(int offset)
Definition: pet_slider.h:202
virtual void setupThumb(const CString &name, CPetControl *petControl)
Definition: pet_slider.h:92
virtual double getOffsetPixels() const
Definition: rect.h:35
bool containsPt(const Point &pt) const
Definition: pet_slider.h:79
Definition: rect.h:45
Definition: arm.h:30
Definition: string.h:40
void setThumbSize(const Point &pt)
Definition: pet_slider.h:183
virtual void reset(const CString &name)
Definition: pet_slider.h:107
virtual bool MouseDragMoveMsg(const Point &pt)
int16 x
Definition: rect.h:46
virtual void draw(CScreenManager *screenManager)
Definition: pet_slider.h:112
void setBounds(const Rect &r)
Definition: pet_slider.h:173
int16 y
Definition: rect.h:47
virtual Rect clearDirtyArea()
virtual bool resetThumbFocus()
virtual bool MouseDragEndMsg(const Point &pt)
Definition: pet_slider.h:137
Definition: pet_control.h:45
void setOrientation(SliderOrientation orientation)