Difference between revisions of "BGRAControls"

From Lazarus wiki
Jump to navigationJump to search
Line 119: Line 119:
  
 
Calculate and assign automatically the ''BitmapHeight''.
 
Calculate and assign automatically the ''BitmapHeight''.
 +
 +
Set automatically (with Boolean option) the Width & Height of control when bitmap changes. AutoUpdateSize:=Boolean;

Revision as of 23:51, 14 May 2011

Overview

Authors:

Dibo (package maintainer, TBGRAImageList, TBGRASpeedButton, TBGRAButton, TBGRAPanel)

Circular (TBGRAKnob, TBGRAFlashProgressBar)

Emerson Cavalcanti (TBGRAImageManipulation)

Lainz (TBGRAImageButton)

License: Modified LGPL.

As many people know, Lazarus GTK doesn't have full alpha support. I created a set of components which use TBGRABitmap for drawing icons, so it partially solves the problem with alpha in GTK. But this components set is not only a GTK patch but has more fancy components which are using the power of the 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/

Git repository: git://bgracontrols.git.sourceforge.net/gitroot/bgracontrols/bgracontrols

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

You need to install the BGRABitmap package first (it is a requiered package in my package).

Install like other 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 to use BGRABitmap drawing only for GTK then install the package with -dGTK_ONLY switch in package compiler options. With this switch it uses the default lazarus drawing for other interfaces than GTK. This switch doesn't work for components which are designed only for BGRABitmap features, like TBGRAButton or TBGRAPanel.

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 inherits from TImageList. So each control (tested on TToolBar and TTreeView) which is using TImageList.Draw method for drawing icons, automatically can have alpha support. Just use this component instead of TImageList.

TBGRASpeedButton

BGRASpeedButton.png

Component which inherits from TSpeedButton and draws the glyph using TBGRABitmap.

TBGRAButton

bgrabutton.png

Customizable graphic component which is using only BGRABitmap functions for drawing. This component is insensitive for -dGTK_ONLY switch. 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 (has no stretch function yet)

ToDO:

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

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

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

I tried to 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 a nice looking toolbar for bgrabuttons). This component is insensitive for -dGTK_ONLY switch

TBGRAKnob

BC-Bgraknob.png

Graphic knob component created by circular.

TBGRAFlashProgressBar

BC-Bgraflashprogressbar.png

Flash progressbar created by circular.

TBGRAImageManipulation

Graphic component created by Emerson Cavalcanti.

TBGRAImageButton

bgraimagebutton.png

Component used to create a button with 4 states from Bitmap.

The bitmap must contain the 4 states (from top to bottom, with the same Height) in the following order: normal, enter, pressed, disabled.

samplebgraimagebutton.png

<delphi>BitmapHeight:=36;</delphi>

ToDO:

Replace TBitmap with TBGRABitmap to implement alpha support.

Calculate and assign automatically the BitmapHeight.

Set automatically (with Boolean option) the Width & Height of control when bitmap changes. AutoUpdateSize:=Boolean;