Temporary layers

I’m writing a script which has some filter-like behaviour, in that it shows a preview of what it’s going to do before you hit the button. (I don’t actually want to implement it as a filter because I want to maintain the current set of shapes; the point of the script is to allow the user to set some parameters for later post-processing.)

The way I’m currently implementing this is by creating a new layer if it doesn’t already exist called “Preview” and making it visible so the user can see the preview as well as their current paths. But I would really like to avoid having this layer written into the Glyphs file.

Is there a built-in way to have a temporary layer which is not serialised to disk? I know there is something called shadowLayers as part of the filter implementation, but I don’t understand what they are or how to user them. (And they may not be helpful anyway.)

Shadows are for filters. But why not a simple reporter in the View menu? Or what are you previewing?

Because it needs a UI to control the parameter settings. I suppose I might be able to split it into a reporter and a script, but it’s then harder to install.

You can do both in a general plugin. Add a window for the UI and add the methods for the reporter. Or add the extra UI to a reporter, should work too.

Just restore the original when you close the dialog? Basically only add a cancel button.
And there is a shadow layer property somewhere (not at my Mac right now, I’ll check it) to store the original outline (useful to continuously applying the filter when the user changes a setting).

Just restore the original when you close the dialog?

No, it’s a live preview which changes as you change glyphs. And I still want the original open paths to be visible and editable

This is why I asked if there was a way to have a temporary layer, not for alternative ways to solve the problem… :slight_smile:

You could just add a drawing callback to the layer. Similar to what I do with Skedge.
As I understand you want to keep the layer as is, and just draw a preview of your stuff into that same layer?

A reporter can also disable the original layer drawing, if you need that. Would need to ask Georg or Rainer if a general plugin or script can do that, too.

Can you be a bit more specific what you are trying to do.
From what I can see so far: this could be a reporter that draws the processed outlines and put the UI in the context menu (either directly (with an menuItem that contains a NSView or that opens a dialog).