Sign in to follow this  
null54

Changing FileType plugin UI based on the Document properties

Recommended Posts

There are some cases where it would be useful to allow FileType plugins to disable or change parts of their UI based on the properties the current Document (such as Size,  layer count, Metadata etc).

For example, if I added cube map support to to DDS FileType Plus the accompanying checkbox would only apply to images with 6 layers.

 

While I can set the checkbox description to state that requirement and ignore it if the images do not meet it, I think it would be more user friendly (and easier lo localize) if there was a way to uncheck and disable the checkbox when the image does not have 6 layers.

 

Example:

Spoiler

protected override void OnUpdateSaveConfigUIForDocument(ControlInfo configUI, Document document)
{
    if (document.Layers.Count != 6)
    {
        BooleanProperty prop = configUI.FindControlForPropertyName(PropertyNames.CubeMaps).Property as BooleanProperty;

        prop.Value = false;
        prop.ReadOnly = true;
    }
}

Share this post


Link to post
Share on other sites

One of my plugins has a different default based on the size of the image.

 

protected override PropertyCollection OnCreatePropertyCollection()
{
    List<Property> props = new List<Property>();

    if (EnvironmentParameters.SourceSurface.Width < 1000)
    {
        props.Add(new Int32Property(PropertyNames.Amount1, 10, 0, 100));
    }
    else
    {
        props.Add(new Int32Property(PropertyNames.Amount1, 50, 0, 100));
    }

    return new PropertyCollection(props);
}

That answers half your question.  I don't know about filetype plugins; I've never made one.

Share this post


Link to post
Share on other sites
10 minutes ago, BoltBait said:

One of my plugins has a different default based on the size of the image.

 

Interesting, I was unaware the EnvironmentParameters are defined in OnCreatePropertyCollection.

I updated the first post to remove the Effect plugin code.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this