Recent

Author Topic: Custom Drawn Controls advances  (Read 150815 times)

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Custom Drawn Controls advances
« on: November 11, 2011, 06:40:20 am »
Hello,

I'd like to announce that I have been advancing a lot with the Lazarus Custom Drawn Controls Package in the last days, so now the following controls are already basically functional (but not feature complete):

TCDButton, TCDCheckBox, TCDGroupBox, TCDScrollBar, TCDEdit, TCDPageControl, TCDTrackBar, TCDProgressBar

One of my near term goals is adding at least the Report style of TCDListView, so I am working a lot on this control too (and on TCDScrollBar which is uses).

This set of controls allows a full customization of the look and full reliability on the look and behavior of the control across all Lazarus widgetsets.

For screenshots and for more information please see the wiki:

http://wiki.lazarus.freepascal.org/Lazarus_Custom_Drawn_Controls#How_do_these_components_work.3F

The custom drawn controls can be found in the Lazarus source tree in the directory lazarus/components/customdrawn, although I plan on moving them to the LCL in the future when they will be utilized by the future customdrawn widgetset of Lazarus.

Patches are welcome =)

thanks,
Felipe Monteiro de Carvalho

lainz

  • Guest
Re: Custom Drawn Controls advances
« Reply #1 on: November 11, 2011, 02:24:01 pm »
You're the master of custom controls.

Edit: So when you add those to the LCL we can use it to make new controls using the existing code without a package dependency?
« Last Edit: November 11, 2011, 03:01:07 pm by lainz »

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: Custom Drawn Controls advances
« Reply #2 on: November 11, 2011, 04:50:46 pm »
You're the master of custom controls.

Patches are welcome ;)

Quote
Edit: So when you add those to the LCL we can use it to make new controls using the existing code without a package dependency?

Yes.

BlueIcaro

  • Hero Member
  • *****
  • Posts: 791
    • Blog personal
Re: Custom Drawn Controls advances
« Reply #3 on: November 12, 2011, 12:35:32 pm »
I was looking the wiki page, and it's a nice work!!!
I can't wait to test them
/BlueIcaro

jarto

  • Full Member
  • ***
  • Posts: 106
Re: Custom Drawn Controls advances
« Reply #4 on: November 12, 2011, 01:53:11 pm »

Patches are welcome ;)


Great work. Looks promising!

Not a patch, but you probably should add PrepareCurrentDrawer(); to the end of TGroupBox.Create.
I can't get TEdit to work. If I click on it, and type anything, the text goes blank. No caret is shown either.

Both are tested on Ubuntu.

circular

  • Hero Member
  • *****
  • Posts: 4181
    • Personal webpage
Re: Custom Drawn Controls advances
« Reply #5 on: November 12, 2011, 03:22:06 pm »
Nice work.  :)

I noticed some black pixels on some controls, sometimes the rendering is not perfect apparently.

When you finish some elements, they could be added to BGRAControls with some adjustments if it gives more possibilities.   8-)
Conscience is the debugger of the mind

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: Custom Drawn Controls advances
« Reply #6 on: November 13, 2011, 07:48:07 am »
I noticed some black pixels on some controls, sometimes the rendering is not perfect apparently.

Which controls exactly and which widgetset?

Quote
When you finish some elements, they could be added to BGRAControls with some adjustments if it gives more possibilities.   8-)

I think that the best would be if you instead rebase to implement BGRAControls as a drawer of Lazarus Custom Controls.

This way we can share all the generic non-drawing code. Think about it: 2 implementations of caret, 2 implementations of selection of text, 2 implementations of button click handling, etc, why? We can share the non-visual code completely.

BGRAControls could be implemented as a drawer for Lazarus Custom Drawn Controls. Remember that the Lazarus Custom Drawn Controls will be inside the LCL, so it will be in the core of Lazarus.

Let me know what you think =)

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: Custom Drawn Controls advances
« Reply #7 on: November 13, 2011, 08:32:49 am »
I can't get TEdit to work. If I click on it, and type anything, the text goes blank. No caret is shown either.

Umm, there were some regressions on TCDEdit ... I am fixing them.

Caret drawing is fixed in rev 33502

The text dissapears in LCL-Qt and LCL-Gtk2 when you type ... no idea why yet. It does not do that in LCL-Carbon and LCL-Win32 which are the widgetsets I tested the most sofar.

Edit: I fixed a bunch of stuff in TCDEdit, but there is still a bug in GetTextExtentExPoint in LCL-Qt and LCL-Gtk2 which I am fixing. After fixing this then it should work normally like in other widgetsets.

Edit2: Already fixed GetTextExtentExPoint in LCL-Qt and LCL-Gtk2
« Last Edit: November 13, 2011, 12:33:16 pm by felipemdc »

jarto

  • Full Member
  • ***
  • Posts: 106
Re: Custom Drawn Controls advances
« Reply #8 on: November 13, 2011, 10:37:01 am »
I pulled the latest Lazarus source from svn an hour ago. TCDEdit works well in both gtk2 and qt. Great work :-)

circular

  • Hero Member
  • *****
  • Posts: 4181
    • Personal webpage
Re: Custom Drawn Controls advances
« Reply #9 on: November 14, 2011, 07:17:04 pm »
I think that the best would be if you instead rebase to implement BGRAControls as a drawer of Lazarus Custom Controls.
Can you explain how this would work exactly ?
Conscience is the debugger of the mind

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: Custom Drawn Controls advances
« Reply #10 on: November 14, 2011, 09:06:20 pm »
Can you explain how this would work exactly ?

Can your library render the final image to a TCanvas?

circular

  • Hero Member
  • *****
  • Posts: 4181
    • Personal webpage
Re: Custom Drawn Controls advances
« Reply #11 on: November 15, 2011, 07:19:53 am »
Yes.
Conscience is the debugger of the mind

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: Custom Drawn Controls advances
« Reply #12 on: November 15, 2011, 07:40:39 am »
So it is very easy, just write a drawer unit and class just like any other drawer:

See for example the WinCE drawer:

http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/components/customdrawn/customdrawn_wince.pas?view=markup&root=lazarus

circular

  • Hero Member
  • *****
  • Posts: 4181
    • Personal webpage
Re: Custom Drawn Controls advances
« Reply #13 on: November 15, 2011, 08:38:04 am »
I see. Well this cannot be merged with BGRAControls, but this can provide an alternative look for CD controls. But it is not really adapted to BGRABitmap, because the principle of it is to render everything in a TBGRABitmap and then draw it on the screen. Here each part is drawn separately. The drawer interface could be adapted, but anyway, I'm not sure it would bring anything new. BGRABitmap is not a style, it's a rendering system, so it can render many different styles. It is possible to add some styles to custom drawn controls which use specific BGRABitmap functions, but this would be some extra developpement that would be parallel to BGRAControls.
Conscience is the debugger of the mind

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: Custom Drawn Controls advances
« Reply #14 on: November 15, 2011, 08:52:19 am »
Do you need support for setting a different style for each control or only setting the style for all controls would be enough?

If limiting to the same style for all controls then it would be quite easy, just add whatever you need to your drawer class, only 1 instace of it exists in the system, so at program startup you can configure it to whatever you want.

If you need support for a different style for each control, then a possible solution would be simply implementing many DrawStyles, not only 1. Make 1 basic and then other styles which just inherit from the basic one and set your sub-style properties.

What is the size of your style information? Only a couple of choices or do you need it extremely detailed? Which information it includes exactly?

 

TinyPortal © 2005-2018