removed bounds properties from Overlay so it only lives in Overlay2D

This commit is contained in:
ZappoMan 2014-02-16 13:39:01 -08:00
parent 78f4df912d
commit d101f19e40
3 changed files with 1 additions and 48 deletions

View file

@ -33,42 +33,6 @@ Overlay::~Overlay() {
}
void Overlay::setProperties(const QScriptValue& properties) {
QScriptValue bounds = properties.property("bounds");
if (bounds.isValid()) {
QRect boundsRect;
boundsRect.setX(bounds.property("x").toVariant().toInt());
boundsRect.setY(bounds.property("y").toVariant().toInt());
boundsRect.setWidth(bounds.property("width").toVariant().toInt());
boundsRect.setHeight(bounds.property("height").toVariant().toInt());
setBounds(boundsRect);
} else {
QRect oldBounds = getBounds();
QRect newBounds = oldBounds;
if (properties.property("x").isValid()) {
newBounds.setX(properties.property("x").toVariant().toInt());
} else {
newBounds.setX(oldBounds.x());
}
if (properties.property("y").isValid()) {
newBounds.setY(properties.property("y").toVariant().toInt());
} else {
newBounds.setY(oldBounds.y());
}
if (properties.property("width").isValid()) {
newBounds.setWidth(properties.property("width").toVariant().toInt());
} else {
newBounds.setWidth(oldBounds.width());
}
if (properties.property("height").isValid()) {
newBounds.setHeight(properties.property("height").toVariant().toInt());
} else {
newBounds.setHeight(oldBounds.height());
}
setBounds(newBounds);
//qDebug() << "set bounds to " << getBounds();
}
QScriptValue color = properties.property("color");
if (color.isValid()) {
QScriptValue red = color.property("red");

View file

@ -32,21 +32,11 @@ public:
// getters
bool getVisible() const { return _visible; }
int getX() const { return _bounds.x(); }
int getY() const { return _bounds.y(); }
int getWidth() const { return _bounds.width(); }
int getHeight() const { return _bounds.height(); }
const QRect& getBounds() const { return _bounds; }
const xColor& getColor() const { return _color; }
float getAlpha() const { return _alpha; }
// setters
void setVisible(bool visible) { _visible = visible; }
void setX(int x) { _bounds.setX(x); }
void setY(int y) { _bounds.setY(y); }
void setWidth(int width) { _bounds.setWidth(width); }
void setHeight(int height) { _bounds.setHeight(height); }
void setBounds(const QRect& bounds) { _bounds = bounds; }
void setColor(const xColor& color) { _color = color; }
void setAlpha(float alpha) { _alpha = alpha; }
@ -54,7 +44,6 @@ public:
protected:
QGLWidget* _parent;
QRect _bounds; // where on the screen to draw
float _alpha;
xColor _color;
bool _visible; // should the overlay be drawn at all

View file

@ -118,7 +118,7 @@ unsigned int Overlays::getOverlayAtPoint(const glm::vec2& point) {
while (i.hasPrevious()) {
i.previous();
unsigned int thisID = i.key();
Overlay* thisOverlay = i.value();
Overlay2D* thisOverlay = static_cast<Overlay2D*>(i.value());
if (thisOverlay->getVisible() && thisOverlay->getBounds().contains(point.x, point.y, false)) {
return thisID;
}