- better handling of edit mode click

This commit is contained in:
Mark Vejvoda 2012-07-26 07:06:12 +00:00
parent 8d6cdfb5db
commit 8dc59d74f7
2 changed files with 20 additions and 0 deletions

View File

@ -288,6 +288,24 @@ void GraphicLabel::init(int x, int y, int w, int h, bool centered, Vec3f textCol
this->wordWrap = wordWrap;
}
bool GraphicLabel::mouseMove(int x, int y) {
if(this->getVisible() == false) {
return false;
}
int useWidth = w;
if(text.length() > 0 && font3D != NULL) {
float lineWidth = (font3D->getTextHandler()->Advance(text.c_str()) * Font::scaleFontValue);
useWidth = (int)lineWidth;
}
return
x > this->x &&
y > this->y &&
x < this->x + useWidth &&
y < this->y + h;
}
bool GraphicLabel::getCenteredW() const {
bool result = (centered || centeredW == 1);
return result;

View File

@ -147,6 +147,8 @@ public:
GraphicLabel();
void init(int x, int y, int w=defW, int h=defH, bool centered= false, Vec3f textColor=GraphicComponent::customTextColor, bool wordWrap=false);
virtual bool mouseMove(int x, int y);
bool getCentered() const {return centered;}
void setCentered(bool centered) {this->centered= centered;}