xoreos  0.0.5
portrait.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_PORTRAIT_H
26 #define ENGINES_NWN_GUI_WIDGETS_PORTRAIT_H
27 
28 #include <vector>
29 
31 
33 
35 
37 
38 namespace Common {
39  class UString;
40 }
41 
42 namespace Engines {
43 
44 namespace NWN {
45 
48 public:
49  enum Size {
50  kSizeHuge = 0,
57  };
58 
59  Portrait(const Common::UString &name, Size size, float border = 0.0f,
60  float bR = 1.0f, float bG = 1.0f, float bB = 1.0f, float bA = 1.0f);
61  ~Portrait();
62 
63  float getWidth () const;
64  float getHeight() const;
65 
67  void setPortrait(const Common::UString &name);
68 
70  void setBorderColor(float bR, float bG, float bB, float bA);
71 
73  void setPosition(float x, float y, float z);
74 
76  void getPosition(float &x, float &y, float &z) const;
77 
79  bool isIn(float x, float y) const;
80 
81  // Renderable
82  void calculateDistance();
84  void renderImmediate(const glm::mat4 &parentTransform);
85 
86 private:
87  struct Quad {
88  float vX[4], vY[4];
89  float tX[4], tY[4];
90  };
91 
93 
95 
96  float _border;
97  float _x;
98  float _y;
99  float _width;
100  float _height;
101 
102  float _bR;
103  float _bG;
104  float _bB;
105  float _bA;
106 
108  std::vector<Quad> _qBorder;
109 
115 
116  void setSize();
117  void createBorder();
118 };
119 
121 class PortraitWidget : public NWNWidget {
122 public:
123  PortraitWidget(::Engines::GUI &gui, const Common::UString &tag,
124  const Common::UString &name, Portrait::Size size, float border = 0.0f,
125  float bR = 1.0f, float bG = 1.0f, float bB = 1.0f, float bA = 1.0f);
126  ~PortraitWidget();
127 
128  void show();
129  void hide();
130 
131  void mouseDown(uint8 state, float x, float y);
132  void mouseWheel(uint8 state, int x, int y);
133 
134  void setPosition(float x, float y, float z);
135 
136  void setPortrait(const Common::UString &name);
137  void setBorderColor(float bR, float bG, float bB, float bA);
138 
139  float getWidth () const;
140  float getHeight() const;
141 
142  void setTag(const Common::UString &tag);
143 
144 private:
146 };
147 
148 } // End of namespace NWN
149 
150 } // End of namespace Engines
151 
152 #endif // ENGINES_NWN_GUI_WIDGETS_PORTRAIT_H
A NWN widget.
Graphics::Aurora::TextureHandle _texture
Definition: portrait.h:92
void setBorderColor(float bR, float bG, float bB, float bA)
Definition: portrait.cpp:344
Shader renderable, a class for easier managing of a collection of items (surface, material...
Definition: 2dafile.h:39
A class holding an UTF-8 string.
Definition: ustring.h:48
uint8_t uint8
Definition: types.h:200
float getWidth() const
Get the scrollbar&#39;s width.
Definition: portrait.cpp:113
Base class for all widgets in NWN.
Definition: nwnwidget.h:45
float getHeight() const
Get the widget&#39;s height.
Definition: portrait.cpp:352
Common::ScopedPtr< Graphics::Shader::ShaderRenderable > _borderRenderable
Definition: portrait.h:114
void calculateDistance()
Calculate the object&#39;s distance.
Definition: portrait.cpp:160
PortraitWidget(::Engines::GUI &gui, const Common::UString &tag, const Common::UString &name, Portrait::Size size, float border=0.0f, float bR=1.0f, float bG=1.0f, float bB=1.0f, float bA=1.0f)
Definition: portrait.cpp:293
A handle to an Aurora texture.
std::vector< Quad > _qBorder
Definition: portrait.h:108
void getPosition(float &x, float &y, float &z) const
Get the current position of the portrait.
Definition: portrait.cpp:140
Portrait(const Common::UString &name, Size size, float border=0.0f, float bR=1.0f, float bG=1.0f, float bB=1.0f, float bA=1.0f)
Definition: portrait.cpp:51
void renderImmediate(const glm::mat4 &parentTransform)
For shader based systems, don&#39;t sort anything, render this right_now.
Definition: portrait.cpp:196
A GUI element.
A GUI.
Definition: gui.h:43
Common::ScopedPtr< Graphics::Shader::ShaderMaterial > _borderMaterial
Definition: portrait.h:112
RenderPass
Definition: types.h:97
void setPosition(float x, float y, float z)
Set the current position of the portrait.
Definition: portrait.cpp:121
void show()
Show the widget.
Definition: portrait.cpp:305
Common::ScopedPtr< Graphics::Shader::ShaderRenderable > _renderable
Definition: portrait.h:113
void render(Graphics::RenderPass pass)
Render the object.
Definition: portrait.cpp:163
void setPortrait(const Common::UString &name)
Definition: portrait.cpp:340
float getHeight() const
Get the scrollbar&#39;s height.
Definition: portrait.cpp:117
An element of the GUI.
Definition: guielement.h:33
void setBorderColor(float bR, float bG, float bB, float bA)
Set border color.
Definition: portrait.cpp:254
void mouseWheel(uint8 state, int x, int y)
A mouse wheel was used on the widget.
Definition: portrait.cpp:328
Common::ScopedPtr< Graphics::Shader::ShaderMaterial > _material
Definition: portrait.h:111
A NWN portrait model.
Definition: portrait.h:47
void setPosition(float x, float y, float z)
Set the widget&#39;s position.
Definition: portrait.cpp:333
void setTag(const Common::UString &tag)
Set the widget&#39;s tag.
Definition: portrait.cpp:356
void hide()
Hide the widget.
Definition: portrait.cpp:315
void setPortrait(const Common::UString &name)
Set the current portrait.
Definition: portrait.cpp:225
A NWN portrait widget.
Definition: portrait.h:121
bool isIn(float x, float y) const
Is the point within the portrait?
Definition: portrait.cpp:146
#define pass
Definition: fft.cpp:257
Common::ScopedPtr< Graphics::Shader::ShaderSurface > _surface
Definition: portrait.h:110
A handle to a texture.
Definition: texturehandle.h:51
float getWidth() const
Get the widget&#39;s width.
Definition: portrait.cpp:348
void mouseDown(uint8 state, float x, float y)
A mouse button was pressed on the widget.
Definition: portrait.cpp:323