BGRAControls

From Lazarus wiki
Jump to navigationJump to search

Overview

As many people know, Lazarus GTK doesn't have full alpha support. I created set of components which use TBGRABitmap for drawing icons, so it partialy solve problem with alpha in GTK. But this components set is not only GTK patch but have more fancy components which using power of BGRABitmap package.

Related Articles

BGRAButton Gallery - Gallery of buttons with source code to use in your projects with BGRAButton.

Installation

BGRABitmap: http://wiki.lazarus.freepascal.org/BGRABitmap

BGRAControls: http://sourceforge.net/projects/bgracontrols/files/

You need lazarus 0.9.31 from SVN (revision >= 29834).

You need install BGRABitmap package first (it is as requied package in my package).

Install like others components by selecting bgracontrols.lpk from "Package->Open package file". This set of components is crossplatform (tested on linux GTK and windows) but if you want use BGRABitmap drawing only for GTK then install package with -dGTK_ONLY switch in package compiler options. With this switch it use default lazarus drawing for other interfaces than GTK.

Using

Drop TBGRAImageList or TBGRASpeedButton from "BGRA controls" palette and use like normal component. Example: Add icons, drop TToolBar and assign BGRAImageList to Toolbar. Images property in object inspector.

TBGRAImageList

Before:

before-TImageList.png

After:

after-TBGRAImageList.png

Component which inherit from TImageList. So each control (tested on TToolBar and TTreeView) which using TImageList.Draw method for drawing icons, automatically can have alpha support. Just use this component instead of TImageList.

TBGRASpeedButton

BGRASpeedButton.png

Component which inherit from TSpeedButton and draw glyph using TBGRABitmap.

TBGRAButton

bgrabutton.png

Customizable graphic component which using only BGRABitmap functions for drawing. Demo project included in package.

Functionality:

  • Gradients
  • Double gradients
  • Rounding
  • Border style, width and color
  • Drop down list
  • Glyph
  • States (normal, hover, clicked)
  • Caption with shadow
  • Full alpha and antialias support
  • Can work as Image if no caption is set (have no stretch function yet)

ToDO:

I wanted add "container" functionality (like TPanel) so this same component could be used as toolbar with childs but TCustomControl have no transparency.

I created task for this issue in forum: http://www.lazarus.freepascal.org/index.php/topic,12933.0.html

And mailing list: http://lists.lazarus.freepascal.org/pipermail/lazarus/2011-April/062683.html

I try report this as a bug. Instead, I created TBGRAPanel with similar gradient functionality (but very limited).

TBGRAPanel

Simple TPanel descendant which can have gradient background. Created especially for TBGRAButton (for creating nice looking toolbar for bgrabuttons).