xoreos  0.0.5
scrollbar.h
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 
25 #ifndef ENGINES_NWN_GUI_WIDGETS_SCROLLBAR_H
26 #define ENGINES_NWN_GUI_WIDGETS_SCROLLBAR_H
27 
28 #include <vector>
29 
31 
33 
35 
36 namespace Engines {
37 
38 namespace NWN {
39 
40 class GUI;
41 
44 public:
45  enum Type {
48  };
49 
50  Scrollbar(Type type);
51  ~Scrollbar();
52 
54  void setPosition(float x, float y, float z);
55 
57  void getPosition(float &x, float &y, float &z) const;
58 
60  bool isIn(float x, float y) const;
61 
63  void setLength(float length);
64 
65  float getWidth () const;
66  float getHeight() const;
67 
68  // Renderable
69  void calculateDistance();
71 
72 private:
73  struct Quad {
74  float vX[4], vY[4];
75  float tX[4], tY[4];
76  };
77 
79 
80  float _x;
81  float _y;
82  float _z;
83 
84  float _length;
85 
86  std::vector<Quad> _quads;
87 
89 
90  void createV();
91  void createH();
92 };
93 
95 class WidgetScrollbar : public NWNWidget {
96 public:
97  WidgetScrollbar(::Engines::GUI &gui, const Common::UString &tag,
98  Scrollbar::Type type, float range);
100 
101  void show();
102  void hide();
103 
104  void setPosition(float x, float y, float z);
105 
107  void setLength(float length);
108 
110  float getState() const;
112  void setState(float state);
113 
114  float getWidth () const;
115  float getHeight() const;
116 
117  float getBarPosition() const;
118 
119  void mouseDown(uint8 state, float x, float y);
120  void mouseMove(uint8 state, float x, float y);
121  void mouseWheel(uint8 state, int x, int y);
122 
123 private:
125 
126  bool _full;
127 
128  float _range;
129  float _length;
130  float _state;
131 
132  float _dragX;
133  float _dragY;
134  float _dragState;
135 
137 };
138 
139 } // End of namespace NWN
140 
141 } // End of namespace Engines
142 
143 #endif // ENGINES_NWN_GUI_WIDGETS_SCROLLBAR_H
std::vector< Quad > _quads
Definition: scrollbar.h:86
A NWN widget.
void mouseWheel(uint8 state, int x, int y)
A mouse wheel was used on the widget.
Definition: scrollbar.cpp:380
A class holding an UTF-8 string.
Definition: ustring.h:48
A NWN scrollbar widget.
Definition: scrollbar.h:95
bool isIn(float x, float y) const
Is the point within the scrollbar?
Definition: scrollbar.cpp:67
void getPosition(float &x, float &y, float &z) const
Get the current position of the scrollbar.
Definition: scrollbar.cpp:61
uint8_t uint8
Definition: types.h:200
void createH()
Create a horizontal scrollbar.
Definition: scrollbar.cpp:131
float getHeight() const
Get the scrollbar&#39;s height.
Definition: scrollbar.cpp:99
A NWN scrollbar model.
Definition: scrollbar.h:43
Base class for all widgets in NWN.
Definition: nwnwidget.h:45
void setLength(float length)
Set the length of the scrollbar, as a fraction of the range.
Definition: scrollbar.cpp:281
A handle to an Aurora texture.
void setState(float state)
Set the current state, as a fraction of the range.
Definition: scrollbar.cpp:301
void hide()
Hide the widget.
Definition: scrollbar.cpp:267
void render(Graphics::RenderPass pass)
Render the object.
Definition: scrollbar.cpp:112
void setLength(float length)
Set the scrollbar length.
Definition: scrollbar.cpp:76
A GUI element.
A GUI.
Definition: gui.h:43
float getState() const
Get the current state, as a fraction of the range.
Definition: scrollbar.cpp:297
RenderPass
Definition: types.h:97
void createV()
Create a vertical scrollbar.
Definition: scrollbar.cpp:187
void mouseMove(uint8 state, float x, float y)
The mouse was moved over the widget.
Definition: scrollbar.cpp:358
Graphics::Aurora::TextureHandle _texture
Definition: scrollbar.h:88
void setPosition(float x, float y, float z)
Set the current position of the scrollbar.
Definition: scrollbar.cpp:49
WidgetScrollbar(::Engines::GUI &gui, const Common::UString &tag, Scrollbar::Type type, float range)
Definition: scrollbar.cpp:244
void show()
Show the widget.
Definition: scrollbar.cpp:257
float getWidth() const
Get the scrollbar&#39;s width.
Definition: scrollbar.cpp:90
An element of the GUI.
Definition: guielement.h:33
float getHeight() const
Get the widget&#39;s height.
Definition: scrollbar.cpp:322
float getWidth() const
Get the widget&#39;s width.
Definition: scrollbar.cpp:318
void calculateDistance()
Calculate the object&#39;s distance.
Definition: scrollbar.cpp:108
#define pass
Definition: fft.cpp:257
A handle to a texture.
Definition: texturehandle.h:51
void setPosition(float x, float y, float z)
Set the widget&#39;s position.
Definition: scrollbar.cpp:275
void mouseDown(uint8 state, float x, float y)
A mouse button was pressed on the widget.
Definition: scrollbar.cpp:338