New release 2.0 alpha.
Hi,
I could not do everything that I had planned, because I had only a few hours in a week for that.
Notice that version 2.0 is incompatible with 1.XX edition, because most of classes are renamed and some are deleted. This same with properties.
All changes mostly affect to three controls (BGRAButton, BGRAPanel, BGRALabel) of which I am the author (except BGRALabel). I created copy of them and renamed to TBCButton, TBCPanel and TBCLabel. Old controls are still on palette, but they are deprecated and will be deleted in future (when all demos will be moved to new one). Wiki pages will be updated on stable version.
Major changes:- Refactoring - I merged often used general classes and packed them to BCTypes unit (previous name was bgracontrolstypes). So you find here TBCBorder, TBCBackground etc. Notice that I am using new naming style - instead of TBGRAControls prefix I am using now TBC prefix which is shorter and differ from BGRA Bitmap package classes. I encourage others to change . Custom Drawn package has similar naming style (TCD)
- Framework - this include three units:
- BCTypes - mentioned above,
- BCBaseCtrls - own descendants of TGraphicControl and TCustomControl with some basic functionality like begin/end update and debug tools. For now TBCButoon, TBCLabel and TBCPanel inherits from this classes. But you are free to use and expand them. I notify that there already exists unit bgragraphicontrol. I don't know what to do with it, maybe it could be renamed to TBCGraphicControlEx and inherit from TBCGraphicControl?
- BCTools (previous name was bgractrlstools) - This unit include methods for rendering borders, backgrounds, texts etc. They works with classes from BCTypes unit. Important here are two new words which I figure out . What is difference between render and draw? I noticed that the key for creating efficient controls is prepare graphic only when it is needed. You don't have to calculate all gradients and effects on each control repaint (which can occur even few times on a minute). Practically you should prepare control (I call this "render") only when size or property is changed otherwise graphic should be only copy from bitmap to canvas in draw method. Base classes from BCBaseCtrls has virtual method RenderControl which is called only when control should be render (e.g. on resize). You can override this method and call it in other cases. With this trick I reduced CPU consumption by 300-400% in BCButton.
- Design styles manager - BCButton, BCLabel and BCPanel has many switchers (gradients, borders, opacity, shadows etc.). Now you can save your theme to the file and assign it later. Styles manager can be activated from objects inspector (AssignStyle property) or on double click on control or in context menu -> Assign style. Style is mix of INI and DFM/LFM format. Style file has two sections, [HEADER] with info such author, description and [PROPERTIES] where properties tree are stored. Styles manager load and save properties similar like lazarus do with visual forms properties in LFM style. If you want to have style manager in own component, you should inherit from TBCStyleGraphicControl or TBCStyleCustomControl from BCBaseCtrls unit. Or if you want only use read and write mechanism you should look at unit BCRTTI.pas (methods LoadStyle, SaveStyle). I have ported all code from "BGRA Button gallery" wiki to styles file. Styles files are in "style" directory of bgra controls package.
Note: Controls does NOT use styles files at runtime and they are NOT compiled in! They are only used by styles manager at design time to read properties from file and rewrite it to selected control.
Detail changes:- BCButton
- Style manager
- Most of the code has been rewritten - faster drawing, smaller memory usage
- Some properties are renamed (e.g. BodyClicked -> StateClicked)
- Use framework methods for render background, border and text (this added for example word wrap support)
- New default theme (lainz theme from BGRA Button Gallery)
- BCPanel
- Style manager
- Use framework methods for render (this added for example: customizable border, double gradient, word wrap and others)
- BCLabel
- Style manager
- This is really a new component. Previous component (which is still on palette) was as modified copy of TBGRAButton code with some extra functionality (like word wrap). But now all this extra functionality is in framework, so I created new simple control based on framework (code reduced from 1000 lines to 300). Framework add some extra functionality (like border). Old BGRALabel should be deprecated and deleted in future
TODO:- I am thinking about documentation for this package. I have never used FPDoc, but it should be tool which can create diagrams and descriptions from some preformatted pascal comments and should easily publish this in some standard formats (like wiki, html, etc) which could be transferred to BGRA Controls wiki page or sourceforge.
- Some text edit control is missing. If nobody working on it, I can try do this (with customizable switchers like BCButton)
New version is available only from git/svn repo. If you find a bug, please report on which repo, because I worked on git and maybe I didn't move all changes to svn repo.
Regards and sorry for my english, it was hard to explain everything in my non-native language