Jump to content

Initializing IndirectUI Control Range to Canvas Dimensions?


MJW
 Share

Recommended Posts

Is there some rule or whatever to make the range of a control 0 to width-1 or height-1?

 

I was thinking of writing some plugins in VS instead of CodeLab to achieve that result, then realized I didn't even know whether it could be done. Having arbitrary, and necessarily large, ranges for controls whose only valid values are within the canvas lacks polish.

 

While I'm at it, is there any organized documentation of IndirectUI? I only know that controls can be linked and disabled because Simon Brown started a thread about it.

Link to comment
Share on other sites

My dream plugin uses a Gaussian blur to create a dream like picture. The thing I never liked was the fact that the default blur level (10) looks great on 800x600 pictures but you can't really see the effect on my camera's pictures 2560x1920. I solved it by having a different default based on the picture size:

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);
}
And, you're right, CodeLab can't do something like this.
  • Upvote 2

Click to play:
j.pngs.pngd.pnga.pngp.png
Download: BoltBait's Plugin Pack | CodeLab | and how about a Computer Dominos Game

Link to comment
Share on other sites

Thank you, ArgusMagnus and BoltBait! I looked at the CodeLab generated code, but couldn't see how to the get the surface size from the arguments passed to the property routines. I should have thought of using EnvironmentParameters (though I wouldn't have been sure the surface size was valid at the time OnCreateConfigUI and OnCreatePropertyCollection are called). I'll probably give it a try today.

Edited by MJW
Link to comment
Share on other sites

I remembered wrong, OnCreatePropertyCollection is the place to do it.

You can even get the selection, If memory serves rigt it was with the this.GetSelection(EnvironmentParameters.SourceSurface.Bounds).GetIntBounds() method. (Im writing from my phone, so I cant check right now)

Edited by ArgusMagnus

My batch Image Processor: https://imagenator.codeplex.com

Link to comment
Share on other sites

I'm concerned about something. Suppose the plugin is used on a 1000x1000 window, and the control is set to 800. Then, in the same PDN session, the next time it's used on a 500x500 window. The control value is usually the same as the previous setting, so since there seems to be no way to programmatically reset the current control value, unless IndirectIU clamps it itself, it would seem like the value would be out of range. Past experience makes me think IndirectIU might throw an exception.

Edited by MJW
Link to comment
Share on other sites

I'm concerned about something. Suppose the plugin is used on a 1000x1000, and the control is set to 800. Then, in the same PDN session, the next time it's used on a 500x500 window. The control value is usually the same as the previous setting, so since there seems to be no way to programmatically reset the current control value, unless IndirectIU clamps it itself, it would seem like the value would be out of range. Past experience  makes me think IndirectIU might throw an exception.

Seems like an experiment you could try in just a few minutes.

Click to play:
j.pngs.pngd.pnga.pngp.png
Download: BoltBait's Plugin Pack | CodeLab | and how about a Computer Dominos Game

Link to comment
Share on other sites

Here is another scenario for you:

1000x1000 image, run the effect at 800. Resize the image to 100x100, press Ctrl-F to repeat your effect.

And another:

Open 2 images, 1000x1000 and 100x100.

Select the large image and run your effect at 800.

Switch to the smaller image and run your effect again.

Click to play:
j.pngs.pngd.pnga.pngp.png
Download: BoltBait's Plugin Pack | CodeLab | and how about a Computer Dominos Game

Link to comment
Share on other sites

To my surprise, IndirectIU clamps the the value to the range when run with a smaller image. That's good news.

 

When run with repeat-effect on a smaller window, it appears to use both the old value and range (which is sort of what I expected). That should not be a problem.

Link to comment
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.

 Share

×
×
  • Create New...