Jump to content

Pointers for a Color Wheel with Alpha Selector


Recommended Posts

Hi guys,

 

I'm not new to C, but I'm completely green when it comes to Paint.NET plug-ins and the .NET framework.

 

I was hoping that someone could give me guidance in achieving a color picker that also features an alpha selector for the simple plug-in I've been working on. The plugin is practically finished, and is entirely rigged up to work to spec on the back-end, but the small amount of alpha value manipulation I perform is currently nixed because of the way the default color wheel/picker for plugins functions. I've been following the development guidelines on the forums, such as this thread: https://forums.getpaint.net/topic/109990-how-to-write-an-effect-plugin-tutorialsresources/ as well as the great information over at boltbait.com for CodeLab, all of which has helped me get used to most details regarding plug-in development relatively quickly. The one thing I can't seem to find much on however, albeit, I can understand as this kind of assistance can easily become tedious/complicated very quickly, is how to customize the UI elements of your plugin further than what CodeLab allows for by default.

 

I built 90% of my plug-in with CodeLab and then did some debugging and tweaking in Visual Studio, both of which were ultimately no problem, but I am now stuck because I just need to add a simple extra bar to the left or right of the RGB bars for the default color picker element and I'm mostly at a loss as to how to do that. My two color pickers initialize based on the currently selected Primary and Secondary colors in the main color picker, but their Alpha values are totally ignored and always set to 255, hence this requirement. From the bit of poking around I did, I know I could an integer slider from 0 to 255 below the color picker and intercept the assignment of the "Amount" variables that CodeLab uses to have the slider set to the actual alpha of the selected colors by default, and then overwrite the 255 value with the actual Alpha value when I retrieve the pickers value.

 

protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
{
    Amount1 = ColorBgra.FromOpaqueInt32(newToken.GetProperty<Int32Property>(PropertyNames.Amount1).Value);
    Amount2 = ColorBgra.FromOpaqueInt32(newToken.GetProperty<Int32Property>(PropertyNames.Amount2).Value);
    // Alter Amount 1 and 2 here
    Amount3 = newToken.GetProperty<BooleanProperty>(PropertyNames.Amount3).Value;
    Amount4 = newToken.GetProperty<BooleanProperty>(PropertyNames.Amount4).Value;
    Amount5 = newToken.GetProperty<BooleanProperty>(PropertyNames.Amount5).Value;
    Amount6 = newToken.GetProperty<BooleanProperty>(PropertyNames.Amount6).Value;

    base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
}

 

But this is crappy because its a bit hacky, doesn't show the change in Alpha on the rectangle preview of the color wheel/picker, and when implemented using CodeLab (only way I know how right now) it puts a separator between the color picker and the slider (normally this is fine as its supposed to be another section but in this case I'd want them grouped. In particular, I see what the color picker comes from one of Paint.NET's own classes:

using ColorWheelControl = PaintDotNet.ColorBgra;
...
ColorWheelControl Amount1 = ColorBgra.FromBgr(0, 0, 0); // [PrimaryColor] Source Color (Translate From)
ColorWheelControl Amount2 = ColorBgra.FromBgr(255, 255, 255); // [SecondaryColor] Destination Color (Translate To)

Is there a way I can my my own version of this "widget", or extend the functionality of the current one? If not, is there a somewhat simple or at least logical way I can still use this built in class and just tack on another slider right next to the current ones, unlike how I'd have to with I'm sure this is probably a bit into the realm of .NET framework in general and understanding the implementation of form controls, its just that the only other mention of something like this I've found is what's essentially "concept art" by another user on the forum:

 

https://forums.getpaint.net/topic/28112-indirectui-colorwheel-with-alpha-selector/

 

Funny enough, this is exactly what I want. Its basically the programs main color picker just without the pallet and the HSV info, particularly in that it is linked with the square color preview and shows the transparency. I've seen much more detailed or reorganized plugin's developed by others in the past that suggest to me that this should be possible. So does anyone have the knowledge to point me to a tutorial for this, get me started, give me a direction, etc? Or at the very least know a good resource where I can learn how to modify the menus within Visual Basic  effectively (I see where some of the manipulation is as I pointed out earlier but I'm obviously completely oblivious when it comes to a lot of the intricacies, naming conversion, back-end behavior, etc. so that I can get passed the limitations of CodeLab despite how convenient and effective it has been for me so far? I see they added slider style presets which aren't mentioned on their site (it notes that in CodeLab you can't theme a slider even though you now can), but the alpha scale checkboard pattern isn't one of the options. The writer(s) for that site mention that you can at least skin the sliders different ways with in VS, they just don't mention how.

 

Sorry this was a bit wordy, thanks for any help to the Paint.NET noob.

Link to comment
Share on other sites

18 minutes ago, oblivioncth said:

Is there a way I can my my own version of this "widget", or extend the functionality of the current one?

 

No, there is not. That is, if you're using IndirectUI (paint.net's "UI Framework" for effects), you can only used what's provided. CodeLab "exposes" about 98% of IndirectUI functionalities. So what you're seeing in CodeLab is about the extent of customization.

 

Otherwise you need to create your own UI from scratch with standard WinForms controls, or maybe use Midora's OptionBased library.

 

39 minutes ago, oblivioncth said:

it puts a separator between the color picker and the slider

 

If you leave the Description for the control blank, there won't be a separator.

 

23 minutes ago, oblivioncth said:

like this I've found is what's essentially "concept art" by another user on the forum: 

 

That's not concept art; that's the OptionBased library I mentioned. It's a little more complicated than IndirectUI, but offers more flexibility. If you want to see example code for using it take a look at my Graph Paper plugin. The source code is posted.

 

32 minutes ago, oblivioncth said:

I see they added slider style presets which aren't mentioned on their site (it notes that in CodeLab you can't theme a slider even though you now can), but the alpha scale checkboard pattern isn't one of the options. The writer(s) for that site mention that you can at least skin the sliders different ways with in VS, they just don't mention how.

 

The Slider styles don't apply to the ColorWheel control. They only apply to the TrackBar controls (Int Slider, Float Slider).

  • Like 1
  • Upvote 1
Link to comment
Share on other sites

1 hour ago, oblivioncth said:

I was hoping that someone could give me guidance in achieving a color picker that also features an alpha selector

 

I heard a rumor that the next release of Paint.NET will include this functionality.

  • Like 1
  • Upvote 1

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

9 hours ago, toe_head2001 said:

 

No, there is not. That is, if you're using IndirectUI (paint.net's "UI Framework" for effects), you can only used what's provided. CodeLab "exposes" about 98% of IndirectUI functionalities. So what you're seeing in CodeLab is about the extent of customization.

 

Otherwise you need to create your own UI from scratch with standard WinForms controls, or maybe use Midora's OptionBased library.

 

 

If you leave the Description for the control blank, there won't be a separator.

 

 

That's not concept art; that's the OptionBased library I mentioned. It's a little more complicated than IndirectUI, but offers more flexibility. If you want to see example code for using it take a look at my Graph Paper plugin. The source code is posted.

 

 

The Slider styles don't apply to the ColorWheel control. They only apply to the TrackBar controls (Int Slider, Float Slider).

 

Thanks for all of this clarification, its starting to give a me a good sense of things. I wasn't aware exactly what IndirectUI was until now but that makes total sense, its just the framework that exposes some pre-made UI options to plug-in creators, which also basically wraps up why CodeLab is setup the way it is.

 

This also confirms my suspicions that more back-end work with the .NET WinForm controls would need to be used to acheive this. I can start looking into that as well as the library you linked.

 

Great tip for leaving the description blank as that allows for a somewhat decent temporary solution until I can achieve something more robust.

 

Oh my apologizes I didn't realize as the way that Midora talked about it in that post made it sound like something he was considering implementing but hadn't yet, but I now realize that he was simply saying he was considering outsourcing that particular feature of his library as a standalone plugin. The link to your plugin source will also prove very helpful I'm sure.

 

In this regard, I was refering to the style for a potential separate Trackbar as you mentioned, forgive my phrasing, referring to the fact that even if I could get a TrackBar to be grouped in with the color picker (which I now can thanks to your tip) that it wouldn't have the alpha control style applied to it and wouldn't reflect its value on the color preview square.

 

Thanks again for all this, as it gives me a direction to go in order to figure out more on my own.

 

8 hours ago, BoltBait said:

 

I heard a rumor that the next release of Paint.NET will include this functionality.

 

Based on what I've learned from the above quote, I'm assuming that you mean that the next version may include an Alpha slider inclusive color picker as one of the options for the IndirectUI? Regardless of whether this happens or not, is there any kind of timeframe or development cycle schedule that Paint.NET tends to follow that gives a sens of how far along each release is? Or is just more of a "when its done" kind of thing on Rick's part?

 

While Midora's library looks very promising, it would be cool if this feature became part of the regular library as well.

 

Thanks to you too.

Link to comment
Share on other sites

If you wish to port your project to a WinForm plugin, there is a template here:

 

https://www.dropbox.com/s/uy1jfe84gem8b3k/PluginTemplate - updated Feb 2016.zip?dl=0

 

The date is... out of date  :)

 

Here's the how-to guide, which is also being refined: https://www.dropbox.com/s/2t6zbbm03x221t0/VS Plugin Template.pdf?dl=0

  • Like 1
  • Upvote 1
Link to comment
Share on other sites

15 hours ago, Ego Eram Reputo said:

If you wish to port your project to a WinForm plugin, there is a template here:

 

https://www.dropbox.com/s/uy1jfe84gem8b3k/PluginTemplate - updated Feb 2016.zip?dl=0

 

The date is... out of date  :)

 

Here's the how-to guide, which is also being refined: https://www.dropbox.com/s/2t6zbbm03x221t0/VS Plugin Template.pdf?dl=0

 

Ah nice! Thanks a bunch EER. This current plugin is pretty simple and while its effective it was also kind of an experiment for me in getting started on these plugins in case I want to make more. So for this one I'll just wait on Paint.NET to eventually update if they do end up putting this feature in; however, I can easily see myself wanting to do a more complicated plugin at some point that will need to make use of these.

Link to comment
Share on other sites

  • 1 month later...
On 7/22/2018 at 12:50 AM, BoltBait said:

 

I heard a rumor that the next release of Paint.NET will include this functionality.

 

No longer a rumor:

 

https://forums.getpaint.net/forum/45-preview-center/

 

Paint.NET v4.1 has a Colorwheel control with an alpha slider available to Plugin Developers.

 

CodeLab v4.0+ has support for these new Colorwheel controls.

 

  • 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

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...