ScummVM API documentation
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 /*
23  * This code is based on the CRAB engine
24  *
25  * Copyright (c) Arvind Raja Yadav
26  *
27  * Licensed under MIT
28  *
29  */
30 
31 #ifndef CRAB_SLIDER_H
32 #define CRAB_SLIDER_H
33 
34 #include "crab/ui/Caption.h"
35 #include "crab/ui/ImageData.h"
36 #include "crab/ui/button.h"
37 
38 namespace Crab {
39 
40 namespace pyrodactyl {
41 namespace ui {
42 class Slider {
43  // The value of the slider and the backup
44  int _value, _backup;
45 
46  // The slider bar position and dimensions
47  ImageData _bar;
48 
49  // The slider knob
50  Button _knob;
51 
52  // Caption for the slider
53  Caption _caption;
54 
55  // The maximum and minimum values for the slider
56  int _max, _min;
57 
58  // Grey out?
59  bool _isGreyed;
60 
61 public:
62  Slider() {
63  _max = 100;
64  _min = 0;
65  _value = ((_max - _min) / 2);
66  _backup = _value;
67  _isGreyed = false;
68  }
69 
70  ~Slider() {}
71 
72  void load(rapidxml::xml_node<char> *node, const int &min, const int &max, const int &val);
73 
74  bool handleEvents(const Common::Event &event);
75 
76  void draw();
77 
78  int Value() { return _value; }
79  void value(const int val);
80 
81  void createBackup() {
82  _backup = _value;
83  }
84 
85  void restoreBackup() {
86  _value = _backup;
87  setUI();
88  }
89 
90  void setEnabled(bool enabled) {
91  _isGreyed = !enabled;
92  }
93 
94  void greyOut();
95 
96  void setUI();
97 };
98 } // End of namespace ui
99 } // End of namespace pyrodactyl
100 
101 } // End of namespace Crab
102 
103 #endif // CRAB_SLIDER_H
Definition: ImageData.h:40
Definition: lobject.h:59
Definition: events.h:199
Definition: Caption.h:41
Definition: moveeffect.h:37
Definition: button.h:86
Definition: slider.h:42