mirror of
https://github.com/overte-org/overte.git
synced 2025-07-29 18:25:25 +02:00
removed bounds properties from Overlay so it only lives in Overlay2D
This commit is contained in:
parent
78f4df912d
commit
d101f19e40
3 changed files with 1 additions and 48 deletions
|
@ -33,42 +33,6 @@ Overlay::~Overlay() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Overlay::setProperties(const QScriptValue& properties) {
|
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");
|
QScriptValue color = properties.property("color");
|
||||||
if (color.isValid()) {
|
if (color.isValid()) {
|
||||||
QScriptValue red = color.property("red");
|
QScriptValue red = color.property("red");
|
||||||
|
|
|
@ -32,21 +32,11 @@ public:
|
||||||
|
|
||||||
// getters
|
// getters
|
||||||
bool getVisible() const { return _visible; }
|
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; }
|
const xColor& getColor() const { return _color; }
|
||||||
float getAlpha() const { return _alpha; }
|
float getAlpha() const { return _alpha; }
|
||||||
|
|
||||||
// setters
|
// setters
|
||||||
void setVisible(bool visible) { _visible = visible; }
|
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 setColor(const xColor& color) { _color = color; }
|
||||||
void setAlpha(float alpha) { _alpha = alpha; }
|
void setAlpha(float alpha) { _alpha = alpha; }
|
||||||
|
|
||||||
|
@ -54,7 +44,6 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QGLWidget* _parent;
|
QGLWidget* _parent;
|
||||||
QRect _bounds; // where on the screen to draw
|
|
||||||
float _alpha;
|
float _alpha;
|
||||||
xColor _color;
|
xColor _color;
|
||||||
bool _visible; // should the overlay be drawn at all
|
bool _visible; // should the overlay be drawn at all
|
||||||
|
|
|
@ -118,7 +118,7 @@ unsigned int Overlays::getOverlayAtPoint(const glm::vec2& point) {
|
||||||
while (i.hasPrevious()) {
|
while (i.hasPrevious()) {
|
||||||
i.previous();
|
i.previous();
|
||||||
unsigned int thisID = i.key();
|
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)) {
|
if (thisOverlay->getVisible() && thisOverlay->getBounds().contains(point.x, point.y, false)) {
|
||||||
return thisID;
|
return thisID;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue