Recent

Author Topic: [CLOSED] BGRAControls  (Read 550085 times)

bambamns

  • Full Member
  • ***
  • Posts: 223
Re: BGRAControls
« Reply #465 on: May 21, 2012, 12:12:49 am »
Hi,

Does BGRAControls work with WinCe ?

I tried (today) to compile a simple test application with just a few labels but it can not be done.
Lazarus 1.8.4 + FPC 2.6.4 x86 (rebuild) and Lazarus 2.0, Windows 7 x64, unless otherwise specified

lainz

  • Guest
Re: BGRAControls
« Reply #466 on: May 21, 2012, 03:10:41 am »
I've no idea.

digeo

  • Jr. Member
  • **
  • Posts: 54
    • Digeotek
Re: BGRAControls
« Reply #467 on: May 21, 2012, 03:42:34 pm »
I think i made a good enough replica. Could be imroved with more time.

Use BGRAGraphicControl and draw all the text and gradient and borders.

A lot more coding but nice effect
« Last Edit: May 21, 2012, 03:50:33 pm by digeo »

digeo

  • Jr. Member
  • **
  • Posts: 54
    • Digeotek
Re: BGRAControls
« Reply #468 on: May 21, 2012, 11:13:13 pm »
I am trying to load png from file using:
Code: [Select]
bmp := TBGRABitmap.Create('emoticon_evilgrin.png');
bmp.Draw(canvas, 10, 10, True);
bmp.Free;
I receive sigsev error and program stops here (-->):
Code: [Select]
procedure TBGRADefaultBitmap.DoAlphaCorrection;
var
  p: PBGRAPixel;
  n: integer;
begin
  if CanvasAlphaCorrection then
  begin
    p := FData;
    for n := NbPixels - 1 downto 0 do
    begin
-->      if (longword(p^) and $FFFFFF <> 0) and (p^.alpha = 0) then
        p^.alpha := FCanvasOpacity;
      Inc(p);
    end;
  end;
  FAlphaCorrectionNeeded := False;
  InvalidateBitmap;
end;

No further messages. Any suggestions?

JD

  • Hero Member
  • *****
  • Posts: 1848
Re: BGRAControls
« Reply #469 on: May 21, 2012, 11:30:07 pm »
I think i made a good enough replica. Could be imroved with more time.

Use BGRAGraphicControl and draw all the text and gradient and borders.

A lot more coding but nice effect

I like what you did there. How did you do it? Can you provide some code snippets?
Windows - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe),
Linux Mint - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe)

mORMot; Zeos 8; SQLite, PostgreSQL & MariaDB; VirtualTreeView

digeo

  • Jr. Member
  • **
  • Posts: 54
    • Digeotek
Re: BGRAControls
« Reply #470 on: May 22, 2012, 08:54:23 am »
I am still trying to figure out how to draw the icons from a bgraimagelist onto the BGRAGraphicControl.

I use getimage from imagelist to load the icon into a bitmap value, but to convert from TBitmap to TBGRACustomBitmap.

I get errors with the draw procedure as I described above.

Dibo

  • Hero Member
  • *****
  • Posts: 1048
Re: BGRAControls
« Reply #471 on: May 23, 2012, 07:01:32 pm »
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 :P . 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 ;)

lainz

  • Guest
Re: BGRAControls
« Reply #472 on: May 23, 2012, 09:15:52 pm »
Everyone has frozen with your post =) Nice I'm testing it.

- New default theme (lainz theme from BGRA Button Gallery)

You'll make me cry like a child =)
« Last Edit: May 23, 2012, 09:31:54 pm by lainz »

Rails

  • Guest
Re: BGRAControls
« Reply #473 on: May 23, 2012, 09:52:08 pm »

Regards and sorry for my english, it was hard to explain everything in my non-native language ;)

Your English is fine. My Polish is nonexistent.

Great work.   8)


lainz

  • Guest
Re: BGRAControls
« Reply #474 on: May 24, 2012, 12:06:50 am »
Someone has tested it on Windows? I can't get the Font looks like in BGRAButton with 'TextCanvas' property.

Dibo

  • Hero Member
  • *****
  • Posts: 1048
Re: BGRAControls
« Reply #475 on: May 24, 2012, 01:16:49 am »
Yes, I expected this error. This is new property for me (not implemented by me). I saw that it only change font height (it get it from font, what does it mean?). I thought that RenderText from BCTools can do everything so I ignored it but forgot note it, sorry, can you explain what does it mean or apply patch (maybe it could be expanded in RenderText method?)?

Dibo

  • Hero Member
  • *****
  • Posts: 1048
Re: BGRAControls
« Reply #476 on: May 24, 2012, 01:26:06 am »
Everyone has frozen with your post =) Nice I'm testing it.

- New default theme (lainz theme from BGRA Button Gallery)

You'll make me cry like a child =)

:D . My style was ugly :P (my mind was focused on technical matters, not the artistic ;) )

Dibo

  • Hero Member
  • *****
  • Posts: 1048
Re: BGRAControls
« Reply #477 on: May 24, 2012, 01:41:57 am »

Regards and sorry for my english, it was hard to explain everything in my non-native language ;)

Your English is fine. My Polish is nonexistent.

Great work.   8)
Thanks .  My english knowledge is only from old computer games or programming documentation :) . How do you know that I'm Polish?
BTW I Invite you to euro 2012 (if you like football, because I don' t:P ) and sorry for our roads

lainz

  • Guest
Re: BGRAControls
« Reply #478 on: May 24, 2012, 01:48:31 am »
I know. I can program or design, not both things at the same time. If I program my designs sucks, If I design I can't manage to solve any problem =)

TextCanvas I've implemented to draw exactly like Windows default text drawing (only with font size 0 not for custom font sizes). I've seen that setting FontAntialias to True is very similar.

The thing is that the Drawing that is performed at design time is different that when I compile the program. See image attached, at the left a BGRAButton, at the middle a BCButton, and the other is a Windows button. PD: I've set the same caption for all just to visually compare them.
« Last Edit: May 24, 2012, 02:09:22 am by lainz »

Rails

  • Guest
Re: BGRAControls
« Reply #479 on: May 24, 2012, 01:55:02 am »

Regards and sorry for my english, it was hard to explain everything in my non-native language ;)

Your English is fine. My Polish is nonexistent.

Great work.   8)
Thanks .  My english knowledge is only from old computer games or programming documentation :) . How do you know that I'm Polish?
BTW I Invite you to euro 2012 (if you like football, because I don' t:P ) and sorry for our roads

You profile says your location is Poland.   :D

Thanks for the invite. I have not been to Poland, but would like to visit there someday. Alas, it won't be this year.


 

TinyPortal © 2005-2018