#include <Component.h>
Inheritance diagram for pge::gui::Component:
Public Member Functions | |
Component (int x, int y, int width, int height) | |
Constructor. | |
virtual | ~Component (void) |
Destructor. | |
void | render (void) |
Called when the object should render itself. | |
void | setBackgroundColor (const Vector4f &color) |
Vector4f | getBackgroundColor (void) |
void | setPosition (Vector2i position) |
Vector2i | getPosition (void) |
void | setDimension (const Vector2i &dimension) |
Vector2i | getDimension (void) |
void | setTextureEnabled (bool texEnabled) |
bool | isTextureEnabled (void) |
void | setTexture (Texture *texture) |
Static Public Member Functions | |
Vector2i | convertToGLCoords (const Vector2i &coords) |
Vector2i | convertToGLCoords (int x, int y) |
Private Attributes | |
Vector2i | m_position |
Vector2i | m_dimension |
Vector4f | m_backgroundColor |
Texture * | m_texture |
bool | m_textureEnabled |
|
Constructor.
Definition at line 19 of file Component.cpp. References m_backgroundColor, m_dimension, m_position, m_texture, and m_textureEnabled.
00019 { 00020 m_position = Vector2i(x, y); 00021 m_dimension = Vector2i(width, height); 00022 m_backgroundColor = Vector4f(1.0f, 1.0f, 1.0f, 1.0f); 00023 m_texture = NULL; 00024 m_textureEnabled = false; 00025 00026 } |
|
Destructor.
Definition at line 34 of file Component.cpp.
00034 { 00035 } |
|
Definition at line 193 of file Component.cpp.
00193 {
00194 return Vector2i(x, CoreEngine::getInstance()->getResolutionHeight() - y);
00195 }
|
|
Definition at line 183 of file Component.cpp. References pge::Vector2i::m_v.
00183 {
00184 return Vector2i(coords.m_v[0], CoreEngine::getInstance()->getResolutionHeight() - coords.m_v[1]);
00185 }
|
|
Definition at line 103 of file Component.cpp. References m_backgroundColor.
00103 { 00104 return m_backgroundColor; 00105 } |
|
Definition at line 143 of file Component.cpp. References m_dimension. Referenced by pge::gui::TextBox::render().
00143 { 00144 return m_dimension; 00145 } |
|
Definition at line 123 of file Component.cpp. References m_position. Referenced by pge::gui::TextEdit::render(), and pge::gui::TextBox::render().
00123 { 00124 return m_position; 00125 } |
|
Definition at line 163 of file Component.cpp. References m_textureEnabled.
00163 { 00164 return m_textureEnabled; 00165 } |
|
Called when the object should render itself.
Implements pge::IRenderableObject. Reimplemented in pge::gui::TextBox, and pge::gui::TextEdit. Definition at line 43 of file Component.cpp. References m_backgroundColor, m_dimension, m_position, m_texture, m_textureEnabled, pge::Vector2i::m_v, and pge::Vector4f::m_v.
00043 { 00044 // Render the background of the component 00045 00046 // Handle texturing 00047 if(m_textureEnabled) { 00048 renderer::setTexture(m_texture); 00049 } else { 00050 renderer::setTextureUnitEnabled(GL_TEXTURE0, false); 00051 } 00052 00053 // If alpha is not 1.0f, then enable blending 00054 if(m_backgroundColor.m_v[3] != 1.0f) { 00055 renderer::setBlendingEnabled(true); 00056 renderer::setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 00057 } 00058 00059 // Render background as colored quad. 00060 renderer::color4f(m_backgroundColor); 00061 00062 if(m_textureEnabled) { 00063 glBegin(GL_QUADS); 00064 renderer::vertex2i(Component::convertToGLCoords(m_position.m_v[0], m_position.m_v[1]), 0.0f, 0.0f); 00065 renderer::vertex2i(Component::convertToGLCoords(m_position.m_v[0], m_position.m_v[1] + m_dimension.m_v[1]), 00066 0.0f, 1.0f); 00067 renderer::vertex2i(Component::convertToGLCoords(m_position.m_v[0] + m_dimension.m_v[0], m_position.m_v[1] 00068 + m_dimension.m_v[1]), 1.0f, 1.0f); 00069 renderer::vertex2i(Component::convertToGLCoords(m_position.m_v[0] + m_dimension.m_v[0], m_position.m_v[1]), 00070 1.0f, 0.0f); 00071 glEnd(); 00072 } else { 00073 glBegin(GL_QUADS); 00074 renderer::vertex2i(Component::convertToGLCoords(m_position.m_v[0], m_position.m_v[1])); 00075 renderer::vertex2i(Component::convertToGLCoords(m_position.m_v[0], m_position.m_v[1] + m_dimension.m_v[1])); 00076 renderer::vertex2i(Component::convertToGLCoords(m_position.m_v[0] + m_dimension.m_v[0], m_position.m_v[1] 00077 + m_dimension.m_v[1])); 00078 renderer::vertex2i(Component::convertToGLCoords(m_position.m_v[0] + m_dimension.m_v[0], m_position.m_v[1])); 00079 glEnd(); 00080 } 00081 if(m_backgroundColor.m_v[3] != 1.0f) { 00082 renderer::setBlendingEnabled(false); 00083 renderer::color4f(1.0f, 1.0f, 1.0f, 1.0f); 00084 } 00085 } |
|
Definition at line 93 of file Component.cpp. References m_backgroundColor. Referenced by pge::gui::Console::Console(), and pge::gui::SceneAnalyseGUI::SceneAnalyseGUI().
00093 { 00094 m_backgroundColor = color; 00095 } |
|
Definition at line 133 of file Component.cpp. References m_dimension.
00133 { 00134 m_dimension = dimension; 00135 } |
|
Definition at line 113 of file Component.cpp. References m_position.
00113 { 00114 m_position = position; 00115 } |
|
Definition at line 173 of file Component.cpp. References m_texture.
00173 { 00174 m_texture = texture; 00175 } |
|
Definition at line 153 of file Component.cpp. References m_textureEnabled.
00153 { 00154 m_textureEnabled = texEnabled; 00155 } |
|
Definition at line 71 of file Component.h. Referenced by Component(), getBackgroundColor(), render(), and setBackgroundColor(). |
|
Definition at line 70 of file Component.h. Referenced by Component(), getDimension(), render(), and setDimension(). |
|
Definition at line 69 of file Component.h. Referenced by Component(), getPosition(), render(), and setPosition(). |
|
Definition at line 72 of file Component.h. Referenced by Component(), render(), and setTexture(). |
|
Definition at line 73 of file Component.h. Referenced by Component(), isTextureEnabled(), render(), and setTextureEnabled(). |