Lazarus

Programming => Graphics => Graphics and Multimedia => BGRABitmap and LazPaint => Topic started by: HeDiBo on September 25, 2012, 03:07:44 pm

Title: Bug in TBCPanel?
Post by: HeDiBo on September 25, 2012, 03:07:44 pm
This is the situation:
The main form contains a TBCPanel with a gradient (Background.Style=bbsGradient). On top of this panel is placed another TBCPanel, Background.Style=bbsColor, Background.ColorOpacity=0.

In stead of showing the color of the underlying TBCPanel, the new panel shows the color of the main form. Which is pretty useless, as you can imagine. A sample project is attached.

Any ideas?

Regards,
Dick

Title: Re: Bug in TBCPanel?
Post by: circular on September 25, 2012, 04:20:22 pm
I suppose TBCPanel is not a transparent control. So the opacity cannot really be used.

You need to use a TBGRAGraphicControl to have full support of transparency.
Title: Re: Bug in TBCPanel?
Post by: HeDiBo on September 25, 2012, 05:33:05 pm
I suppose TBCPanel is not a transparent control.

If TBCPanel is not a transparent control, what should Background.ColorOpacity=0 accomplish?
And what should Background.Style=bbsClear do?

If I change the color of the main form, the panel changes its color too %). If Background.ColorOpacity = 127, the main form's color shines thru :o. I think that proves that it was meant to be able to be transparent. If it were not transparent, how else would it get its changing color?

The problem is probably using the wrong property. I.e. using the Owner property, where the Parent property should be used.
Title: Re: Bug in TBCPanel?
Post by: circular on September 25, 2012, 05:36:20 pm
Maybe Dibo can help with that.
Title: Re: Bug in TBCPanel?
Post by: HeDiBo on September 25, 2012, 05:44:24 pm
Thank you for your reply. We'll await DiBo's comment then.
By the way, I immensely appreciate all the work you do for the BGRA project. :)
Title: Re: Bug in TBCPanel?
Post by: Dibo on September 25, 2012, 06:28:14 pm
BCPanel is not transparent, because it inherit from lazarus TCustomControl and this kind of control don't have transparent (I think this is OS limit)
BCPanel.Background property has opacity and bsClear property because this property class is a part of BGRA Controls framework which is used by other controls from this package (like BCButton, BCLabel etc). So for now opacity doesn't work in BCPanel, but maybe will work in future (when it appear in TCustomControl )
Title: Re: Bug in TBCPanel?
Post by: HeDiBo on September 26, 2012, 12:54:04 pm
@Dibo:
The color of the main form does show in a TBCPanel with Background.Style=bbsClear. That means it's at least partly transparent. Is that just a fluke, or is that by design?

By the way: great work on these BGRA controls 8-)

Title: Another bug in TBCPanel?
Post by: HeDiBo on September 26, 2012, 01:34:11 pm
This is another problem with transparency.
When a TBCPanel is placed on top of other controls, and has rounded corners (e.g. Rounding.RoundX and Y = 30), the underlying controls do not show in the corners, rather the color of the form shows, making this setup almost useless.
Have a look at the attached project.
Title: Re: Bug in TBCPanel?
Post by: circular on September 26, 2012, 02:41:16 pm
Well no, not almost useless. It can be useful for a nice design.

Oh but when testing it, the background under the panel is not filled correctly. See screenshot.

Maybe it would be useful to add a "backgroundundercolor" property, until tranparency is handled, and that would fill to replace the transparent background.
Title: Re: Bug in TBCPanel?
Post by: HeDiBo on September 26, 2012, 03:07:13 pm
Well no, not almost useless. It can be useful for a nice design.
With useless, I only meant the rounding effect. Not the whole panel of course.

It's only nice with rounding, if the panel happens to be directly placed on the form. A panel placed on another panel, for instance, will not give the desired effect, unless the underlying panel has the same color as the form.

I do not like the "backgroundundercolor" property. You have to remember to change it if the underlying control changes color. Sometimes you may not know what the color is (eg. if the panel is placed on a constantly changing image), a movie for instance.

I cannot reproduce the error you show, If the panel is placed on the form, the rounding goes OK. Check my test project.
Title: Re: Bug in TBCPanel?
Post by: circular on September 26, 2012, 03:38:52 pm
Well no, not almost useless. It can be useful for a nice design.
With useless, I only meant the rounding effect. Not the whole panel of course.
I meant the rounding is still useful.

Quote
It's only nice with rounding, if the panel happens to be directly placed on the form. A panel placed on another panel, for instance, will not give the desired effect, unless the underlying panel has the same color as the form.

I do not like the "backgroundundercolor" property.
This solves the problem.

Quote
You have to remember to change it if the underlying control changes color.
That's a better solution than having a random background color.

Quote
Sometimes you may not know what the color is (eg. if the panel is placed on a constantly changing image), a movie for instance.
You'll have to be reasonable.
Title: Re: Bug in TBCPanel?
Post by: HeDiBo on September 26, 2012, 05:10:57 pm
You'll have to be reasonable.

You're right. A better example would be a panel overlapping two other panels, each with a different color. Unless you think the "backgroundundercolor" property should have 4 values, one for each corner. And even then, if the color in the underlying panel at one of the corners is not solid, you still have a problem.

So, I still think there should be real transparency.

A very good solution is to specify transparency in the "skin". Have a look at these AlphaControls http://www.alphaskins.com/dwnld.php (http://www.alphaskins.com/dwnld.php). In these controls if you give the panel (class TsPanel) a skin "CHECKBOX" the panel is totally transparent.

This may be a thing to consider: in order to implement themes, it is a good idea to make the skinning properties dynamically loadable at run time. To see how powerful that is, download the demo program from the same web page. In "Visible Components" select "Panels". Then in the "SkinSection" drop down box, select CHECKBOX. Notice that the groupbox and one of the panels become transparent.

Title: Re: Bug in TBCPanel?
Post by: circular on September 26, 2012, 06:11:47 pm
I did not mean that there should be transparency. The "BackgroundUnderColor" could go with "BackgroundUnderFill" boolean, so that it could be deactivated if transparency is implemented, and in the meantime would allow TBCPanel to be used with round corners for example.

The AlphaControls you are talking about work only under Windows, right ?

Just tested, AlphaControls are amazing.
Title: Re: Bug in TBCPanel?
Post by: Dibo on September 26, 2012, 07:17:39 pm
I always wanted create set of controls based not on "programmatically drawing", but on "sliced" PNG pictures (like TBGRAImageButton created by lainz from BGRA Controls package). This should give a similar effect like AlphaControls. The only limitation in that kind of controls is your imagination and of course photoshop / gimp skills ;) . But there is no time. I must wait for project where I will need this solutions (this same was with BGRA Controls)
Title: AlphaControl vs sliced png images
Post by: HeDiBo on September 26, 2012, 08:33:51 pm
I always wanted create set of controls based not on "programmatically drawing", but on "sliced" PNG pictures (like TBGRAImageButton created by lainz from BGRA Controls package). This should give a similar effect like AlphaControls.

Please, Dibo, have a look at the demo program of AlphaControls on a Windows machine (http://www.alphaskins.com/sfiles/askindemo.zip (http://www.alphaskins.com/sfiles/askindemo.zip)). Shouldn't take more than a couple of minutes from your valuable time. Then you get an idea, why sliced png images (whatever they may be :-\) is only part of the solution.
Title: Re: Bug in TBCPanel?
Post by: lainz on September 26, 2012, 10:14:18 pm
Hi HeDibo, Dibo has the reason, or both *Dibo has it =)

See attached image. I pick the most complex at my reason.

The other part of the solution is easier than Slice scaling? Fading & animations: I've already played with that with TBGRAImageButton. But not to much to presume..
Title: Re: Bug in TBCPanel?
Post by: circular on September 26, 2012, 10:55:34 pm
This is really beautiful !  :o :)
Title: Re: Bug in TBCPanel?
Post by: HeDiBo on September 27, 2012, 12:21:22 am
See attached image. I pick the most complex at my reason.

The other part of the solution is easier than Slice scaling? Fading & animations: I've already played with that with TBGRAImageButton. But not to much to presume..
Hi Lainz,
Have you run the AlphaControls demo?
I don't want to disappoint you, but the beautiful objects you produced, can be done with AlphaControls without any coding. And I'm afraid it will look even better. And it can be themed by the end user, just by selecting a different skin from  the main menu.

Download the demo and have a look at the pascal source. There you see what can be accomplished with very little coding indeed.

I'm saying all this, because I would like the GRA controls to evolve to a stage AlphaControls is in now. For the time being, I'll use GRA controls gratefully as they are. My current projects don't need fancy theming. I just wanted to show you all, what could be possible. But you also have to know that AlphaControls took several years of development before it reached this stage. Let it be an inspiration to GRA developers. I may become one too.

Title: Re: Bug in TBCPanel?
Post by: lainz on September 27, 2012, 01:22:40 am
Quote
Hi Lainz,
Have you run the AlphaControls demo?

I've seen AlphaControls demo a year or two ago. And this new one, I've picked the picture from that example.

Code: [Select]
I don't want to disappoint you, but the beautiful objects you produced, can be done with AlphaControls without any coding. And I'm afraid it will look even better. And it can be themed by the end user, just by selecting a different skin from  the main menu.

Download the demo and have a look at the pascal source. There you see what can be accomplished with very little coding indeed.

I'm saying all this, because I would like the GRA controls to evolve to a stage AlphaControls is in now. For the time being, I'll use GRA controls gratefully as they are. My current projects don't need fancy theming. I just wanted to show you all, what could be possible. But you also have to know that AlphaControls took several years of development before it reached this stage. Let it be an inspiration to GRA developers. I may become one too.

Of course, in Lazarus this can be done with Custom Drawn, without any coding if we create a proper drawer.
Title: Re: Bug in TBCPanel?
Post by: HeDiBo on September 27, 2012, 11:10:15 am
Of course, in Lazarus this can be done with Custom Drawn, without any coding if we create a proper drawer.
I'm sorry. That's a gross underestimation of what AlphaControls can do :o
Title: Re: Bug in TBCPanel?
Post by: lainz on September 27, 2012, 08:08:00 pm
Of course, in Lazarus this can be done with Custom Drawn, without any coding if we create a proper drawer.
I'm sorry. That's a gross underestimation of what AlphaControls can do :o

Maybe  :D

If you really want to help, check Custom Drawn, Custom Drawn Windows 7 Drawer (that comes with BGRAControls . is not finished). Then try to create fixes to custom drawn (those controls are not finished too).

The cool images is the easy, you can find great free images searching 'windows 7 msstyles' in google and opening the .msstyles files with ResourceHacker.
Title: Re: Bug in TBCPanel?
Post by: lainz on September 28, 2012, 05:14:27 am
I've downloaded the full AlphaSkin demo (around 50 mb) and it has an editor. As no surprise, inside the skins there are png and bmp images and an Ini file called 'options.dat'.

In the bmp the background is clFuchsia and the 'alpha' channel is stored in a grayscale right to each resource.

The resources has only 3 stages: normal, hover and pressed, so I suposse than the disabled stage is a grayscale effect. (btw with BGRABitmap those can be converted to PNG with alpha withouth any problems). http://wiki.lazarus.freepascal.org/BGRABitmap_tutorial_5

Edit: also with LazPaint :P you separate the grayscale into another bitmap, then load mask from file and voila =)

It has not resources for High DPI. So, some controls are available only at 96 dpi (checkboxes, radio buttons, tickmarcks, arrows, maximize, minimize, restore and exit button) and most fonts has fixed sizes (at least in the demo), lower than my Windows configuration (120 dpi).
Title: Re: Bug in TBCPanel?
Post by: circular on September 28, 2012, 11:41:57 am
So lainz you mean that AlphaSkin works with 9-slice scaling ?

About the 3 stages, may be AlphaSkin add intermediate images by blending 2 stages.
Title: Re: Bug in TBCPanel?
Post by: lainz on September 28, 2012, 11:57:53 am
So lainz you mean that AlphaSkin works with 9-slice scaling ?

About the 3 stages, may be AlphaSkin add intermediate images by blending 2 stages.

Yes.

Most of skinned applications works with that (now I remember Ares, Winamp..). The biggest example in OS is Windows itself. Also i've seen that Android uses it.

I'dont know in the example i've seen only a disabled tab.. but it isn't gray, the rest of the controls are enabled.
Title: Alphacontrols?
Post by: HeDiBo on September 28, 2012, 01:38:02 pm
It has not resources for High DPI. So, some controls are available only at 96 dpi (checkboxes, radio buttons, tickmarcks, arrows, maximize, minimize, restore and exit button) and most fonts has fixed sizes (at least in the demo), lower than my Windows configuration (120 dpi).
All controls are governed by the DPI settings of the form, containers will scale properly, but checkboxes will not.
Fonts can be set to any of the available fonts in the Windows system and to any size.


I'dont know in the example i've seen only a disabled tab.. but it isn't gray, the rest of the controls are enabled.
The disabled state is shown by making the controls more transparent. See the attached picture.
Title: Re: Bug in TBCPanel?
Post by: HeDiBo on September 28, 2012, 01:52:09 pm
The resources has only 3 stages: normal, hover and pressed ...
The latest version of AlphaControls (8.80) has even a fifth state for buttons: Default. That's a good idea.
Title: Re: Bug in TBCPanel?
Post by: lainz on September 28, 2012, 05:28:13 pm
I see the more transparent for disabled.

The resources has only 3 stages: normal, hover and pressed ...
The latest version of AlphaControls (8.80) has even a fifth state for buttons: Default. That's a good idea.

Ok there is some demo for that? Or themes to get the images. In custom Drawn we have 5 state buttons too.
Title: Re: Bug in TBCPanel?
Post by: HeDiBo on September 30, 2012, 09:22:12 pm
Ok there is some demo for that? Or themes to get the images. In custom Drawn we have 5 state buttons too.
We're getting awfully off topic here. I started a new topic, where we can exchange ideas about this: http://lazarus.freepascal.org/index.php/topic,18423.0.html (http://lazarus.freepascal.org/index.php/topic,18423.0.html)
Title: Re: Bug in TBCPanel?
Post by: HeDiBo on September 30, 2012, 10:47:00 pm
Ok there is some demo for that? Or themes to get the images. In custom Drawn we have 5 state buttons too.
I answered in the new topic http://lazarus.freepascal.org/index.php/topic,18423.msg103937.html#msg103937 (http://lazarus.freepascal.org/index.php/topic,18423.msg103937.html#msg103937)
TinyPortal © 2005-2018