Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Per-object opacity #4031

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Removed // BONGO
Commit history can be used to see who changed what. :-)
bjorn committed Aug 15, 2024
commit 1897839c58c398d79c524350a7071f58ec3e5a37
4 changes: 0 additions & 4 deletions src/libtiled/mapobject.cpp
Original file line number Diff line number Diff line change
@@ -312,7 +312,6 @@ QVariant MapObject::mapObjectProperty(Property property) const
case PositionProperty: return mPos;
case SizeProperty: return mSize;
case RotationProperty: return mRotation;
// BONGO
case OpacityProperty: return mOpacity;
case CellProperty: Q_ASSERT(false); break;
case ShapeProperty: return mShape;
@@ -377,7 +376,6 @@ MapObject *MapObject::clone() const
o->setShape(mShape);
o->setCell(mCell);
o->setRotation(mRotation);
// BONGO
o->setOpacity(mOpacity);
o->setVisible(mVisible);
o->setChangedProperties(mChangedProperties);
@@ -394,7 +392,6 @@ void MapObject::copyPropertiesFrom(const MapObject *object)
setShape(object->shape());
setCell(object->cell());
setRotation(object->rotation());
// BONGO
setOpacity(object->opacity());
setVisible(object->isVisible());
setProperties(object->properties());
@@ -435,7 +432,6 @@ void MapObject::syncWithTemplate()
if (!propertyChanged(MapObject::RotationProperty))
setRotation(base->rotation());

// BONGO
if (!propertyChanged(MapObject::OpacityProperty))
setOpacity(base->opacity());

3 changes: 0 additions & 3 deletions src/libtiled/mapobject.h
Original file line number Diff line number Diff line change
@@ -121,7 +121,6 @@ class TILEDSHARED_EXPORT MapObject : public Object
ShapeProperty = 1 << 11,
TemplateProperty = 1 << 12,
CustomProperties = 1 << 13,
// BONGO
OpacityProperty = 1 << 14,
AllProperties = 0xFF
};
@@ -202,7 +201,6 @@ class TILEDSHARED_EXPORT MapObject : public Object
qreal rotation() const;
void setRotation(qreal rotation);

// BONGO
qreal opacity() const;
void setOpacity(qreal opacity);

@@ -253,7 +251,6 @@ class TILEDSHARED_EXPORT MapObject : public Object
const ObjectTemplate *mObjectTemplate = nullptr;
ObjectGroup *mObjectGroup = nullptr;
qreal mRotation = 0.0;
// BONGO
qreal mOpacity = 1.0;
bool mVisible = true;
bool mTemplateBase = false;
1 change: 0 additions & 1 deletion src/libtiled/mapreader.cpp
Original file line number Diff line number Diff line change
@@ -1222,7 +1222,6 @@ std::unique_ptr<MapObject> MapReaderPrivate::readObject()
object->setPropertyChanged(MapObject::RotationProperty);
}

// BONGO
const qreal opacity = atts.value(QLatin1String("opacity")).toDouble(&ok);
if (ok) {
object->setOpacity(opacity);
2 changes: 0 additions & 2 deletions src/libtiled/maprenderer.cpp
Original file line number Diff line number Diff line change
@@ -452,8 +452,6 @@ void CellRenderer::render(const Cell &cell, const QPointF &screenPos, const QSiz
fragment.scaleX = size.width() / imageRect.width();
fragment.scaleY = size.height() / imageRect.height();
fragment.rotation = 0;
// fragment.opacity = 1;
// BONGO
fragment.opacity = cell.getOpacity();

const auto fillMode = tile->tileset()->fillMode();
1 change: 0 additions & 1 deletion src/libtiled/maptovariantconverter.cpp
Original file line number Diff line number Diff line change
@@ -586,7 +586,6 @@ QVariant MapToVariantConverter::toVariant(const MapObject &object) const
if (notTemplateInstance || object.propertyChanged(MapObject::RotationProperty))
objectVariant[QStringLiteral("rotation")] = object.rotation();

// BONGO
if (notTemplateInstance || object.propertyChanged(MapObject::OpacityProperty))
objectVariant[QStringLiteral("opacity")] = object.opacity();

1 change: 0 additions & 1 deletion src/libtiled/mapwriter.cpp
Original file line number Diff line number Diff line change
@@ -756,7 +756,6 @@ void MapWriterPrivate::writeObject(QXmlStreamWriter &w,
if (shouldWrite(rotation != 0.0, isTemplateInstance, mapObject.propertyChanged(MapObject::RotationProperty)))
w.writeAttribute(QStringLiteral("rotation"), QString::number(rotation));

// BONGO
const qreal opacity = mapObject.opacity();
if (shouldWrite(opacity != 1.0, isTemplateInstance, mapObject.propertyChanged(MapObject::OpacityProperty)))
w.writeAttribute(QStringLiteral("opacity"), QString::number(opacity));
2 changes: 1 addition & 1 deletion src/libtiled/tilelayer.h
Original file line number Diff line number Diff line change
@@ -123,7 +123,7 @@ class TILEDSHARED_EXPORT Cell
void setRotatedHexagonal120(bool v) { v ? _flags |= RotatedHexagonal120 : _flags &= ~RotatedHexagonal120; }

void rotate(RotateDirection direction);
// BONGO

float getOpacity() const { return _opacity; }
void setOpacity(float mOpacity) { _opacity = mOpacity; }

2 changes: 0 additions & 2 deletions src/libtiled/varianttomapconverter.cpp
Original file line number Diff line number Diff line change
@@ -722,7 +722,6 @@ std::unique_ptr<MapObject> VariantToMapConverter::toMapObject(const QVariantMap
const qreal width = variantMap[QStringLiteral("width")].toReal();
const qreal height = variantMap[QStringLiteral("height")].toReal();
const qreal rotation = variantMap[QStringLiteral("rotation")].toReal();
// BONGO
const qreal opacity = variantMap[QStringLiteral("opacity")].toReal();

QString className = variantMap[QStringLiteral("class")].toString();
@@ -740,7 +739,6 @@ std::unique_ptr<MapObject> VariantToMapConverter::toMapObject(const QVariantMap
object->setPropertyChanged(MapObject::RotationProperty);
}

// BONGO
if (variantMap.contains(QLatin1String("opacity"))) {
object->setOpacity(opacity);
object->setPropertyChanged(MapObject::OpacityProperty);
1 change: 0 additions & 1 deletion src/plugins/lua/luaplugin.cpp
Original file line number Diff line number Diff line change
@@ -730,7 +730,6 @@ void LuaWriter::writeMapObject(const Tiled::MapObject *mapObject)
mWriter.writeKeyAndValue("width", mapObject->width());
mWriter.writeKeyAndValue("height", mapObject->height());
mWriter.writeKeyAndValue("rotation", mapObject->rotation());
// BONGO
mWriter.writeKeyAndValue("opacity", mapObject->opacity());

if (!mapObject->cell().isEmpty())
1 change: 0 additions & 1 deletion src/tiled/editablemapobject.cpp
Original file line number Diff line number Diff line change
@@ -190,7 +190,6 @@ void EditableMapObject::setRotation(qreal rotation)
setMapObjectProperty(MapObject::RotationProperty, rotation);
}

// BONGO
void EditableMapObject::setOpacity(qreal opacity)
{
setMapObjectProperty(MapObject::OpacityProperty, opacity);
4 changes: 0 additions & 4 deletions src/tiled/editablemapobject.h
Original file line number Diff line number Diff line change
@@ -63,7 +63,6 @@ class EditableMapObject : public EditableObject
Q_PROPERTY(qreal height READ height WRITE setHeight)
Q_PROPERTY(QSizeF size READ size WRITE setSize)
Q_PROPERTY(qreal rotation READ rotation WRITE setRotation)
// BONGO
Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity)
Q_PROPERTY(bool visible READ isVisible WRITE setVisible)
Q_PROPERTY(QJSValue polygon READ polygon WRITE setPolygon)
@@ -116,7 +115,6 @@ class EditableMapObject : public EditableObject
qreal height() const;
QSizeF size() const;
qreal rotation() const;
// BONGO
qreal opacity() const;
bool isVisible() const;
QJSValue polygon() const;
@@ -153,7 +151,6 @@ public slots:
void setHeight(qreal height);
void setSize(QSizeF size);
void setRotation(qreal rotation);
// BONGO
void setOpacity(qreal opacity);
void setVisible(bool visible);
void setPolygon(QJSValue polygon);
@@ -225,7 +222,6 @@ inline qreal EditableMapObject::rotation() const
return mapObject()->rotation();
}

// BONGO
inline qreal EditableMapObject::opacity() const
{
return mapObject()->opacity();
1 change: 0 additions & 1 deletion src/tiled/mapobjectitem.cpp
Original file line number Diff line number Diff line change
@@ -89,7 +89,6 @@ void MapObjectItem::syncWithMapObject()

setPos(pixelPos);
setRotation(mObject->rotation());
// BONGO
setOpacity(mObject->opacity());

if (mBoundingRect != bounds) {
1 change: 0 additions & 1 deletion src/tiled/objectselectionitem.cpp
Original file line number Diff line number Diff line change
@@ -110,7 +110,6 @@ void MapObjectOutline::syncWithMapObject(const MapRenderer &renderer)

setPos(pixelPos);
setRotation(mObject->rotation());
// BONGO
setOpacity(mObject->opacity());
setFlag(QGraphicsItem::ItemIgnoresTransformations,
mObject->shape() == MapObject::Point);
1 change: 0 additions & 1 deletion src/tiled/objectselectiontool.cpp
Original file line number Diff line number Diff line change
@@ -1658,7 +1658,6 @@ void ObjectSelectionTool::saveSelectionState()
mapObject->size(),
mapObject->polygon(),
mapObject->rotation(),
// BONGO
mapObject->opacity()
};
mMovingObjects.append(object);
1 change: 0 additions & 1 deletion src/tiled/objectselectiontool.h
Original file line number Diff line number Diff line change
@@ -167,7 +167,6 @@ class ObjectSelectionTool : public AbstractObjectTool
QSizeF oldSize;
QPolygonF oldPolygon;
qreal oldRotation;
// BONGO
qreal oldOpacity;
};

3 changes: 0 additions & 3 deletions src/tiled/propertybrowser.cpp
Original file line number Diff line number Diff line change
@@ -846,7 +846,6 @@ void PropertyBrowser::addMapObjectProperties()

flippingProperty->setAttribute(QLatin1String("flagNames"), mFlippingFlagNames);

// BONGO
QtVariantProperty *opacityProperty = addProperty(OpacityProperty, QMetaType::Double, tr("Opacity"), groupProperty);
opacityProperty->setAttribute(QLatin1String("minimum"), 0.0);
opacityProperty->setAttribute(QLatin1String("maximum"), 1.0);
@@ -1302,7 +1301,6 @@ QUndoCommand *PropertyBrowser::applyMapObjectValueTo(PropertyId id, const QVaria
val.toDouble());
}
break;
// BONGO
case OpacityProperty:{
command = new ChangeMapObject(mDocument, mapObject,
MapObject::OpacityProperty,
@@ -1926,7 +1924,6 @@ void PropertyBrowser::updateProperties()
if (mapObject->cell().flippedVertically())
flippingFlags |= 2;
mIdToProperty[FlippingProperty]->setValue(flippingFlags);
// BONGO
mIdToProperty[OpacityProperty]->setValue(mapObject->opacity());
}

1 change: 0 additions & 1 deletion src/tmxviewer/tmxviewer.cpp
Original file line number Diff line number Diff line change
@@ -65,7 +65,6 @@ class MapObjectItem : public QGraphicsItem

setPos(pixelPos);
setRotation(mapObject->rotation());
// BONGO
setOpacity(mapObject->opacity());
}