Recent

Author Topic: What about AlphaControls?  (Read 33159 times)

HeDiBo

  • New Member
  • *
  • Posts: 44
What about AlphaControls and transparency?
« Reply #15 on: October 01, 2012, 07:46:37 pm »
Unfortunately, I cannot reveal too much about the inner workings of AlphaControls (I'm subject to its license agreement).

I studied the transparency issue. As it turns out, AlphaControls doesn't do real transparency, it does Blending. This means that it will use the bitmap of the parent of a control to mix in the blended percentage with the bitmap of the control itself. This is not slow, because from the beginning all bitmaps are copied and stored internally and all operations are done in memory in the copied bitmaps. Only the final result is painted on the canvas.
Kind regards ;-}
Dick

lainz

  • Guest
Re: What about AlphaControls?
« Reply #16 on: October 01, 2012, 08:08:12 pm »
Well if Custom Drawn donesn't fit I've no idea =)
Custom drawn makes the mistake of adding the DrawStyle property. With that it is no longer possible to make it a themed control. You could use Custom Drawn as a basis by inheriting new controls from it and hiding the DrawStyle property in the process. A bit confusing :-\
I've seen that in the newest demo you can switch from default OS theme and Skinned.
Which demo do you mean? AlphaControls?

You can not change the DrawStyle and always use the default. My idea was create an unique drawer that support loading from file (maybe a zip file that contains an ini file and all the bitmaps, like in AlphaControls).

I've implemented some load from ini with bgramultislicescaling just check it.

Yes in the AlphaControls demo, you can switch from Skined or OS default theme.

lainz

  • Guest
Re: What about AlphaControls and transparency?
« Reply #17 on: October 01, 2012, 08:19:27 pm »
Unfortunately, I cannot reveal too much about the inner workings of AlphaControls (I'm subject to its license agreement).

I studied the transparency issue. As it turns out, AlphaControls doesn't do real transparency, it does Blending. This means that it will use the bitmap of the parent of a control to mix in the blended percentage with the bitmap of the control itself. This is not slow, because from the beginning all bitmaps are copied and stored internally and all operations are done in memory in the copied bitmaps. Only the final result is painted on the canvas.


It's something like drawing the whole in a bitmap and then draw in the canvas.

I've seen that Windows does something like that with Windows 7 Explorer ToolBar. There are at least 2 resources in the msstyles, one for the toolbar background and other for the button. The toolbar resource is 100% equal to the toolbar background final result, is slice scaled (the image is 3px width, i don't remember height, so 1 px left and 1 px right for slice scaling, and I remember 3 px top and 3 px bottom, those are the borders).. well, the button resource is another bitmap with alpha, but when i do 'PutImage' with bgrabitmap it looks bad.. I need to use some blend mode, but I've no idea how to, so I think that the toolbar do the same trick to achieve the transparency: using blend modes.

The buttons are transparent and blended with the background.

If you see the toolbar with no themes, there are just '3d rectangles'. So I think that the drawing of the buttons are 'hidden' and only the toolbar area is repainted, like the whole canvas in AlphaSkin.

HeDiBo

  • New Member
  • *
  • Posts: 44
Re: What about AlphaControls?
« Reply #18 on: October 01, 2012, 08:20:04 pm »
I've implemented some load from ini with bgramultislicescaling just check it.
Where can I find this?
Yes in the AlphaControls demo, you can switch from Skinned or OS default theme.
That possibility already existed in the old demo.
Although the AlphaControls are specially crafted controls with skinning extensions, if you switch skinning off in the SkinManager, they act like the standard controls.
Kind regards ;-}
Dick

HeDiBo

  • New Member
  • *
  • Posts: 44
Re: What about AlphaControls and transparency?
« Reply #19 on: October 01, 2012, 08:23:37 pm »
If you see the toolbar with no themes, there are just '3d rectangles'. So I think that the drawing of the buttons are 'hidden' and only the toolbar area is repainted, like the whole canvas in AlphaSkin.
I don't think the whole canvas is repainted in AlphaControls. The code I looked at repainted only the invalidated rectangle.
Kind regards ;-}
Dick

lainz

  • Guest
Re: What about AlphaControls?
« Reply #20 on: October 02, 2012, 02:56:00 am »
I've implemented some load from ini with bgramultislicescaling just check it.
Where can I find this?
Yes in the AlphaControls demo, you can switch from Skinned or OS default theme.
That possibility already existed in the old demo.
Although the AlphaControls are specially crafted controls with skinning extensions, if you switch skinning off in the SkinManager, they act like the standard controls.


You can find that in SVN repo of BGRAControls\customdrawn_win7\ as example drawer (it needs Custom Drawn for Lazarus 1.0). The unit is in the bgracontrols svn root 'slicescaling.pas'.

lainz

  • Guest
Re: What about AlphaControls?
« Reply #21 on: October 06, 2012, 02:23:11 am »
Some days with no response, someone has tested something?

circular

  • Hero Member
  • *****
  • Posts: 4471
    • Personal webpage
Re: What about AlphaControls?
« Reply #22 on: October 08, 2012, 10:41:49 pm »
No, but I was thinking that it would be possible to make panels transparent by using what HeDiBo was talking about, i.e. looking for controls that are behind in Z order, and ask them to draw themselves on the virtualscreen. It could be done by testing the type of the object behind, and calling the right function, with the virtual screen bitmap as a parameter, as well as the relative coordinates of the component, something like that.
Conscience is the debugger of the mind

lainz

  • Guest
Re: What about AlphaControls?
« Reply #23 on: October 09, 2012, 09:40:18 am »
No, but I was thinking that it would be possible to make panels transparent by using what HeDiBo was talking about, i.e. looking for controls that are behind in Z order, and ask them to draw themselves on the virtualscreen. It could be done by testing the type of the object behind, and calling the right function, with the virtual screen bitmap as a parameter, as well as the relative coordinates of the component, something like that.

Besides the type of control, for example if it is a button, you need to pass the 'state'
.

circular

  • Hero Member
  • *****
  • Posts: 4471
    • Personal webpage
Re: What about AlphaControls?
« Reply #24 on: October 09, 2012, 11:23:15 am »
Well, a control is supposed to know in which state it is, no?
Conscience is the debugger of the mind

lainz

  • Guest
Re: What about AlphaControls?
« Reply #25 on: October 09, 2012, 03:27:43 pm »
Well, a control is supposed to know in which state it is, no?

Oh those will be new controls? Or there is a way to get the state of the native LCL controls?

HeDiBo

  • New Member
  • *
  • Posts: 44
States of partly hidden controls
« Reply #26 on: October 09, 2012, 05:26:34 pm »
Oh those will be new controls? Or there is a way to get the state of the native LCL controls?
There's not much state to know really. Buttons that are covered by other controls cannot be down, neither can they have focus nor be default. So only Enabled and Visible remain and they're simply TControl properties.

In order to ask a control to redraw itself, you do not need to know its type. Just call TControl(the_pertinent_control).Refresh (or Repaint). But I realize now that's probably not what you mean  :-\.

I think this discussion is going the wrong way. Where Lainz wants his controls to be tested and others discuss how to implement transparency, I started this discussion to contribute to a more general design scheme, where controls are governed by a theme that can be changed dynamically by the end-user. I'm not a graphics programmer. So, I do not understand what sliced ping images are. I do not want to know (unless at a certain stage I need to). For now I would like to start a community effort to design a general framework allowing controls in that framework to become themed. Transparency is only a very small part of that.

The BC components (TBCLabel, TBCButton and TBCPanel) give an idea, but I think it can be done better. Controls should not contain a style by themselves, but be governed by a style manager. Then changing the style in the style manager changes the style of all controls governed by it dynamically.

Controls should have a ControlType property. In that way the skinning rules of one control (for instance the skin of a panel) can be applied to another control (for instance a list box). That's the way AlphaControls makes a control transparent: it assigns the CheckBox control type (why in AlphaControls checkboxes are considered transparent I don't know).
Kind regards ;-}
Dick

lainz

  • Guest
Re: What about AlphaControls?
« Reply #27 on: October 09, 2012, 08:32:45 pm »
Well I really I'm not using any of the things I've programmed / contributted to bgrabitmap is just for fun for me.

edit: i've used, but not now, else it has no sense  %)
« Last Edit: October 11, 2012, 08:57:33 am by lainz »

lainz

  • Guest
Re: What about AlphaControls?
« Reply #28 on: October 15, 2012, 01:08:21 am »
That can be done with BGRAButton easily, for the background using a BGRAVirtualScreen with a pattern texture or generated.

BTW I like the 9-SliceScaling it rocks =)

PD: Alpha can be set too, in this case I've used the default image alpha, but can be any.

fbadriawan

  • New Member
  • *
  • Posts: 15
Re: What about AlphaControls?
« Reply #29 on: November 26, 2012, 02:10:27 am »
Are there any progress of this topic??????

 

TinyPortal © 2005-2018