Esempio n. 1
0
void graphicsLayerActorSetSublayers(GraphicsLayerActor* layer, GraphicsLayerActorList& subLayers)
{
    if (!subLayers.size()) {
        graphicsLayerActorRemoveAll(layer);
        return;
    }

    ClutterActor* newParentActor = CLUTTER_ACTOR(layer);
    for (size_t i = 0; i < subLayers.size(); ++i) {
        ClutterActor* childActor = CLUTTER_ACTOR(subLayers[i].get());
        ClutterActor* oldParentActor = clutter_actor_get_parent(childActor);
        if (oldParentActor) {
            if (oldParentActor == newParentActor)
                continue;
            clutter_actor_remove_child(oldParentActor, childActor);
        }
        clutter_actor_add_child(newParentActor, childActor);
    }
}
Esempio n. 2
0
// Each GraphicsLayer has the corresponding layer in the platform port.
// So whenever the list of child layer changes, the list of GraphicsLayerActor should be updated accordingly.
void GraphicsLayerClutter::updateSublayerList()
{
    GraphicsLayerActorList newSublayers;
    const Vector<GraphicsLayer*>& childLayers = children();

    if (childLayers.size() > 0) {
        size_t numChildren = childLayers.size();
        for (size_t i = 0; i < numChildren; ++i) {
            GraphicsLayerClutter* curChild = static_cast<GraphicsLayerClutter*>(childLayers[i]);
            GraphicsLayerActor* childLayer = curChild->layerForSuperlayer();
            g_assert(GRAPHICS_LAYER_IS_ACTOR(childLayer));
            newSublayers.append(childLayer);
        }

        for (size_t i = 0; i < newSublayers.size(); i++) {
            ClutterActor* layerActor = CLUTTER_ACTOR(newSublayers[i].get());
            ClutterActor* parentActor = clutter_actor_get_parent(layerActor);
            if (parentActor)
                clutter_container_remove_actor(CLUTTER_CONTAINER(parentActor), layerActor);
        }
    }

    graphicsLayerActorSetSublayers(m_layer.get(), newSublayers);
}