Skip to content

Layer Comps

Dennis Kehrig edited this page Aug 10, 2013 · 6 revisions

Status

  • [08/09/13] Summary of meeting between Tim Riot and Dennis Kehrig

Questions & Conclusions

Should switching to a different layer comp affect files in the root of the -assets folder or not?

The conclusion was that it should because the root folder should always represent the state in layers panel at any given time.

Other than that, there should be a subfolder for layer comps that contains the assets as they appear in the given comp (due to different effects or changes of visibility of a layer that is a child of an exported group player).

Should the comp folders be created and maintained for all layer comps all the time or not?

While Photoshop allows setting a layer comp ID when requesting a pixmap, it is not possible (unless the documentation is incomplete) to request the document info for a certain layer comp only. This would be necessary to retrieve the bounds for a layer comp, which is necessary to scale assets properly. The conclusion therefore was to only generate a comp folder and its assets when the user explicitly switches to a comp, in which case the bounds also become available as part of the imageChanged event. As a refinement, this action should be delayed until the user stopped selecting layer comps for a certain threshold. Tim mentioned 300ms, but that may be too short.

Open question: Should the currently selected layer comp's folder be updated automatically or only after selecting the comp again?

Note that selecting the already selected layer comp also results in the appropriate event from Photoshop, so it would be possible for us to regenerate the comp's assets then.

When modifying the pixels of a layer, Photoshop does not change the selected layer comp, but when toggling the visibility of a layer or deleting one, "Last Document State" gets selected. Right now, it would be up to Generator to decide whether a change caused the current comp to be unselected or not - Photoshop only informs us about "Last Document State" being selected again when the user selects it explicitly. Knowing which comp is active is vital when the appropriate folders should be updated automatically.

Should user-generated files in a comp's folder be safe from being deleted?

Take the following scenario: Layer comp A is created and exported User switches to layer comp B User deletes layer "bar.png" User saves the file User restarts Photoshop User opens the file User switches to layer comp A Generator would find "bar.png" in the comp's folder. Should it be deleted to make sure the folder represents the layer comp's state? At this point, Generator does not know anymore that it generated this file since the corresponding layer is gone and no additional meta data is being stored anyway. Consequently, if "bar.png" should be deleted, any other files the user placed in the comp's folder would be deleted as well.

The conclusion was to delete all files that don't belong to the layer comp, since Tim deemed it unlikely that somebody would actually do that. Dennis was worried about this, but is fine with it as long as we generally recommend not putting anything into -assets.

Should selecting any layer comp result in creating the appropriate folder or should the comp need a special name?

Dennis' concerns were that somebody might want to use layer comps for reasons unrelated to Generator, and couldn't turn off asset generation when switching comps if no special name was needed. This may be even more annoying when the folder is synced using Dropbox. The conclusion was to require users to opt in by naming a comp "foo/", defining the directory to create for this comp. We decided that names like "foo/bar/" should not be allowed due to possible conflicts between layer comps (one named "foo/", the other "foo/bar/"). Also, lacking modifiers that affect the folder's content, only one folder name per comp is allowed (meaning that "foo/, bar/" would be illegal).

What information does Photoshop send with regards to layer comps?

When opening a document with layer comps, Photoshop includes them in the document info:

   "comps": [
        {
            "id": 434155916,
            "added": true,
            "name": "foo/",
            "position": true,
            "visibility": true,
            "appearance": true
        }
    ]

When adding a new comp, the same data as above is included, so Generator could detect this by seeing that the comp ID is new.

When deleting a comp, Photoshop informs us like so:

    "comps": [
        {
            "id": 1794309976,
            "removed": true
        }
    ]

When switching to a comp, Photoshop tells us about it, alongside the changes to the layers:

    "layers": [
        {
            "id": 2,
            "metaDataOnly": true
        },
        {
            "id": 3,
            "bounds": {
                "top": 118,
                "left": 166,
                "bottom": 294,
                "right": 385
            },
            "visible": true
        }
    ],
    "comps": [
        {
            "id": 820884986,
            "applied": true
        }
    ]

When explicitely switching to "Last Document State", Photoshop tells us so, too:

    "comps": [
        {
            "id": 0,
            "applied": true
        }
    ]

However, when modifying the document such that Photoshop switches back to "Last Document State", it doesn't tell us explicitly.