Recent

Author Topic: Glass effect in Windows 10  (Read 904 times)

lainz

  • Hero Member
  • *****
  • Posts: 3699
  • Leandro Diaz
Glass effect in Windows 10
« on: June 25, 2020, 01:32:20 am »
Here is an unit that shows how to add blur to the entire window in Windows 10.

The problem is that LCL controls are not displayed nicely, but BGRAControls are working fine.

Attached project 'aerodemo.zip'.

Any ideas?

In the screenshot an image (looks good) displayed with BGRAControls, and the Exit button made with LCL (looks bad).

winni

  • Hero Member
  • *****
  • Posts: 1782
Re: Glass effect in Windows 10
« Reply #1 on: June 25, 2020, 08:06:51 am »
Hi!

If you want (or have to) use LCL buttons - that's what I do:

Use Speedbuttons
Create a nice BGRAbitmap
Draw the BGRAbitmap on the SpeedButton.glyph which is only a TBitmap

Winni


lainz

  • Hero Member
  • *****
  • Posts: 3699
  • Leandro Diaz
Re: Glass effect in Windows 10
« Reply #2 on: June 25, 2020, 02:25:37 pm »
Thanks. Is not just the button, but any LCL control that looks bad.

winni

  • Hero Member
  • *****
  • Posts: 1782
Re: Glass effect in Windows 10
« Reply #3 on: June 25, 2020, 03:09:08 pm »
Hi!

As long  as the  LCL control owns a  canvas you can draw anything you like.

That is the way I "misstreat" the SpeedButton:

* create a BGRAbitmap of the size of the SpeedButton and the color of the parent
* set the size of the SpeedButton.glyph to the size of the SpeedButton.
* paint something you like on the tmp bitmap
* draw the bitmap on the glyph


Code: Pascal  [Select][+][-]
  1. procedure TForm1.SpeedButton1Click(Sender: TObject);
  2.  var tmp : TBGRABitmap;
  3. begin
  4. tmp := TBGRABitmap.create (SpeedButton1.width,SpeedButton1.Height,self.Color);
  5. SpeedButton1.Glyph.SetSize(SpeedButton1.width,SpeedButton1.Height);
  6. tmp.RoundRectAntialias(0,0,SpeedButton1.width-1,SpeedButton1.Height-1,15,15,cssRed,2,cssBlue,[]);
  7. tmp.Draw(SpeedButton1.Glyph.Canvas,0,0,true);
  8. tmp.free;
  9. end;                

Result in attachment.

Winni

eljo

  • Sr. Member
  • ****
  • Posts: 408
Re: Glass effect in Windows 10
« Reply #4 on: June 25, 2020, 03:15:08 pm »
Here is an unit that shows how to add blur to the entire window in Windows 10.

The problem is that LCL controls are not displayed nicely, but BGRAControls are working fine.

Attached project 'aerodemo.zip'.

Any ideas?

In the screenshot an image (looks good) displayed with BGRAControls, and the Exit button made with LCL (looks bad).
To me, it looks like you have turned on some sort of transparency on the black(or default?) color and that is what you see. try to set the font color to an other dark color like blue and see if that helps at all.

PS.
  You might have better lack if you set the forms.color to RgbToColor(250,250,250); instead of pure black.
« Last Edit: June 25, 2020, 03:23:58 pm by eljo »

lainz

  • Hero Member
  • *****
  • Posts: 3699
  • Leandro Diaz
Re: Glass effect in Windows 10
« Reply #5 on: June 26, 2020, 05:40:22 pm »
Hi!

As long  as the  LCL control owns a  canvas you can draw anything you like.

That is the way I "misstreat" the SpeedButton:

* create a BGRAbitmap of the size of the SpeedButton and the color of the parent
* set the size of the SpeedButton.glyph to the size of the SpeedButton.
* paint something you like on the tmp bitmap
* draw the bitmap on the glyph


Code: Pascal  [Select][+][-]
  1. procedure TForm1.SpeedButton1Click(Sender: TObject);
  2.  var tmp : TBGRABitmap;
  3. begin
  4. tmp := TBGRABitmap.create (SpeedButton1.width,SpeedButton1.Height,self.Color);
  5. SpeedButton1.Glyph.SetSize(SpeedButton1.width,SpeedButton1.Height);
  6. tmp.RoundRectAntialias(0,0,SpeedButton1.width-1,SpeedButton1.Height-1,15,15,cssRed,2,cssBlue,[]);
  7. tmp.Draw(SpeedButton1.Glyph.Canvas,0,0,true);
  8. tmp.free;
  9. end;                

Result in attachment.

Winni

Thanks, I can use BGRAControls for that.

Here is an unit that shows how to add blur to the entire window in Windows 10.

The problem is that LCL controls are not displayed nicely, but BGRAControls are working fine.

Attached project 'aerodemo.zip'.

Any ideas?

In the screenshot an image (looks good) displayed with BGRAControls, and the Exit button made with LCL (looks bad).
To me, it looks like you have turned on some sort of transparency on the black(or default?) color and that is what you see. try to set the font color to an other dark color like blue and see if that helps at all.

PS.
  You might have better lack if you set the forms.color to RgbToColor(250,250,250); instead of pure black.

Well, the problem persists even changing clBlack to anything else.

 

TinyPortal © 2005-2018