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
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (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, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef AGS_SHARED_GUI_GUI_SLIDER_H
24 #define AGS_SHARED_GUI_GUI_SLIDER_H
25 
26 #include "ags/lib/std/vector.h"
27 #include "ags/shared/gui/gui_object.h"
28 
29 namespace AGS3 {
30 namespace AGS {
31 namespace Shared {
32 
33 class GUISlider : public GUIObject {
34 public:
35 	GUISlider();
36 
37 	// Tells if the slider is horizontal (otherwise - vertical)
38 	bool IsHorizontal() const;
39 	bool IsOverControl(int x, int y, int leeway) const override;
40 
41 	// Operations
42 	void Draw(Bitmap *ds) override;
43 
44 	// Events
45 	bool OnMouseDown() override;
46 	void OnMouseMove(int xp, int yp) override;
47 	void OnMouseUp() override;
48 
49 	// Serialization
50 	void ReadFromFile(Stream *in, GuiVersion gui_version) override;
51 	void WriteToFile(Stream *out) const override;
52 	void ReadFromSavegame(Stream *in, GuiSvgVersion svg_ver) override;
53 	void WriteToSavegame(Stream *out) const override;
54 
55 	// TODO: these members are currently public; hide them later
56 public:
57 	int32_t MinValue;
58 	int32_t MaxValue;
59 	int32_t Value;
60 	int32_t BgImage;
61 	int32_t HandleImage;
62 	int32_t HandleOffset;
63 	bool    IsMousePressed;
64 
65 private:
66 	// The following variables are not persisted on disk
67 	// Cached coordinates of slider handle
68 	Rect    _cachedHandle;
69 };
70 
71 } // namespace Shared
72 } // namespace AGS
73 } // namespace AGS3
74 
75 #endif
76