Continue updating overlay key on edit

This commit is contained in:
Zach Pomerantz 2016-02-26 14:42:00 -08:00
parent 2cd6706a6a
commit 5995c3717f
4 changed files with 19 additions and 17 deletions

View file

@ -233,23 +233,19 @@ bool Overlays::editOverlay(unsigned int id, const QScriptValue& properties) {
Overlay::Pointer thisOverlay = getOverlay(id);
if (thisOverlay) {
thisOverlay->setProperties(properties);
if (thisOverlay->is3D()) {
render::ItemKey oldItemKey = render::payloadGetKey(thisOverlay);
thisOverlay->setProperties(properties);
render::ItemKey itemKey = render::payloadGetKey(thisOverlay);
if (itemKey != oldItemKey) {
auto itemID = thisOverlay->getRenderItemID();
if (render::Item::isValidID(itemID)) {
render::ScenePointer scene = qApp->getMain3DScene();
auto itemID = thisOverlay->getRenderItemID();
if (render::Item::isValidID(itemID)) {
render::ScenePointer scene = qApp->getMain3DScene();
const render::Item& item = scene->getItem(itemID);
if (item.getKey() != render::payloadGetKey(thisOverlay)) {
render::PendingChanges pendingChanges;
pendingChanges.resortItem(itemID, oldItemKey, itemKey);
pendingChanges.updateItem(itemID);
scene->enqueuePendingChanges(pendingChanges);
}
}
} else {
thisOverlay->setProperties(properties);
}
return true;

View file

@ -63,6 +63,13 @@ void Item::PayloadInterface::addStatusGetters(const Status::Getters& getters) {
}
}
void Item::update(const UpdateFunctorPointer& updateFunctor) {
if (updateFunctor) {
_payload->update(updateFunctor);
}
_key = _payload->getKey();
}
void Item::resetPayload(const PayloadPointer& payload) {
if (!payload) {
kill();

View file

@ -313,13 +313,11 @@ public:
Item() {}
~Item() {}
// Main scene / item managment interface Reset/Update/Kill
// Main scene / item managment interface reset/update/kill
void resetPayload(const PayloadPointer& payload);
void resetCell(ItemCell cell, bool _small) { _cell = cell; _key.setSmaller(_small); }
// Communicate the update to the payload
void update(const UpdateFunctorPointer& updateFunctor) { _payload->update(updateFunctor); _key = _payload->getKey(); }
// Forget the payload, key, and cell
void kill() { _payload.reset(); _key._flags.reset(); _cell = INVALID_CELL; }
void update(const UpdateFunctorPointer& updateFunctor); // communicate update to payload
void kill() { _payload.reset(); _key._flags.reset(); _cell = INVALID_CELL; } // forget the payload, key, cell
// Check heuristic key
const ItemKey& getKey() const { return _key; }

View file

@ -32,6 +32,7 @@ public:
}
void updateItem(ItemID id, const UpdateFunctorPointer& functor);
void updateItem(ItemID id) { updateItem(id, nullptr); }
void merge(PendingChanges& changes);