Recent

Author Topic: BGRA Themes - Themed controls for Lazarus  (Read 4450 times)

lainz

  • Hero Member
  • *****
  • Posts: 4470
    • https://lainz.github.io/
BGRA Themes - Themed controls for Lazarus
« on: December 29, 2018, 05:46:26 pm »
BGRA Themes is a GUI component suite for LCL made with BGRABitmap.

* 2019 Feb 2, moved to BGRAControls
https://github.com/bgrabitmap/bgracontrols

Themes
There are 3 themes to choose: Default (TBGRATheme), Color (TBGRAColorTheme) or Image (TBGRAImageTheme). But of course you can create your own themes.

How it works
Drop a control (currently only button) and drop one of the three themes available. Link them in the button with the property 'Theme'.
If you do by code then call 'Invalidate' in your Form to update the painting.
The Image Theme requires to call a method called 'LoadResources' than points to an ini file containing the details about the images you will be using to paint your controls.

Advantages
* Less memory usage on properties and images. Everything is inside the Theme and instanced only once.
* Separate logic and painting in each control. The theme is the one that draws the controls.
* You can switch between themes easily. Just change the property Theme on the controls and call Invalidate on the form. That's all.

Future of this project:
* Port Custom Drawn Controls (Progress Bar, Edit, Tab Control, Radio Button, Check Box). In fact this way of theming is inspired on Custom Drawn way.
* Add more controls (Toggle Button and many more).
« Last Edit: February 09, 2019, 06:23:32 pm by Lainz »

zeljko

  • Hero Member
  • *****
  • Posts: 1596
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: BGRA Themes - Themed controls for Lazarus
« Reply #1 on: December 29, 2018, 06:30:40 pm »
Nice work :)

circular

  • Hero Member
  • *****
  • Posts: 4221
    • Personal webpage
Re: BGRA Themes - Themed controls for Lazarus
« Reply #2 on: December 31, 2018, 06:04:23 pm »
That's cool. I am wondering if it would be possible to merge with TBCButton. Like TBCButton would have by default a custom theme.
Conscience is the debugger of the mind

lainz

  • Hero Member
  • *****
  • Posts: 4470
    • https://lainz.github.io/
Re: BGRA Themes - Themed controls for Lazarus
« Reply #3 on: December 31, 2018, 08:19:04 pm »
Hi, that's a good idea. We just need to create a theme with all the properties that bcbutton currently have and point the current drawing to that theme.

I made something like that for bgracontrols but is not installed by default. It assigns all properties to the button from the theme that just wraps a bcbutton inside from where to copy the properties.

Theme.bcbutton.color for example is copied to bcbutton.color.
The other way is removing the properties from bcbutton and call draw method from theme component.

 

TinyPortal © 2005-2018