Recent

Author Topic: Oval-Color button  (Read 2670 times)

bobonwhidbey

  • Hero Member
  • *****
  • Posts: 592
    • Double Dummy Solver - free download
Oval-Color button
« on: January 21, 2019, 06:55:45 pm »
I like to control the color and shape of buttons on my apps. I've written the attached TCustomPanel descendant OvalButton component that works well, but I am very open to suggestions for improvement.

One of the issues I had to deal with is wrapping text. The sysutils WrapText function did not work for me but I found a very nice WrapText function on line that seems to work very well, and it's included in the component's PAS file.

The amount of rounding in each corner is controlled by the "Rounding" property.

Comments welcomed.
« Last Edit: January 21, 2019, 06:58:31 pm by bobonwhidbey »
Lazarus 3.0RC2, FPC 3.2.2 x86_64-win64-win32/win64

Handoko

  • Hero Member
  • *****
  • Posts: 5151
  • My goal: build my own game engine using Lazarus
Re: Oval-Color button
« Reply #1 on: January 21, 2019, 06:59:42 pm »
Nice, but it will be nicer if the round edge is anti-aliased.

bobonwhidbey

  • Hero Member
  • *****
  • Posts: 592
    • Double Dummy Solver - free download
Re: Oval-Color button
« Reply #2 on: January 21, 2019, 07:05:35 pm »
I assume you're talking about the corners. They were drawn with the Arc function.

Here's an example with a thinner BevelWidth and also less Rounding.
Lazarus 3.0RC2, FPC 3.2.2 x86_64-win64-win32/win64

bobonwhidbey

  • Hero Member
  • *****
  • Posts: 592
    • Double Dummy Solver - free download
Re: Oval-Color button
« Reply #3 on: January 21, 2019, 09:13:40 pm »
When I create the button I placed:
Code: Pascal  [Select][+][-]
  1.   Canvas.AntialiasingMode := amOn;  
but that didn't seem to have any effect.  Do I need to use BGRABitmap on Windows?
Lazarus 3.0RC2, FPC 3.2.2 x86_64-win64-win32/win64

sash

  • Sr. Member
  • ****
  • Posts: 366
Re: Oval-Color button
« Reply #4 on: January 21, 2019, 10:38:31 pm »
I like to control the color and shape of buttons on my apps ... Comments welcomed.
1. My personal (although not that popular) opinion is that application should respect and maintain visual appearance that user chose and accepted in his OS/Widgetset.
2. Even if you have some reason to draw your own controls, I believe you should use TGraphicControl, not TWincontrol for buttons.
3. Did you try CustomDrawn controls, or maybe Qt, which (I think) should support theming?
« Last Edit: January 22, 2019, 12:00:08 pm by sash »
Lazarus 2.0.10 FPC 3.2.0 x86_64-linux-gtk2 @ Ubuntu 20.04 XFCE

HeavyUser

  • Sr. Member
  • ****
  • Posts: 397
Re: Oval-Color button
« Reply #5 on: January 21, 2019, 11:50:58 pm »
I like to control the color and shape of buttons on my apps ... Comments welcomed.
1. My personal (although not that popular) opinion is that application should respect and maintain visual appearance that user chose and accepted in his OS/Widgetset.
well microsoft office does not comply with wmicrosoft windows themes either, so respect is not the word I would use.
2. Even if you have some reason to draw your own controls, I believe you should use TGraphicControl, not TWincontrol for buttons.
no that would be  mistake mainly because TGraphicControl can not be focused and as a consequence can not accept keyboard actions (space or enter to press the button etc) or stop on it by the tab character.
3. Did you tried CustomDrawn controls, or maybe Qt, which (I think) should support theming?
not supported through lcl as far as I know.

sash

  • Sr. Member
  • ****
  • Posts: 366
Re: Oval-Color button
« Reply #6 on: January 22, 2019, 12:20:12 am »
so respect is not the word I would use.
Yes, this is how it started, and it was long before OfficeXP.

mainly because TGraphicControl can not be focused
If you need them to be focusable. Toolbuttons are TGraphicControl-s and thus are faster.
Lazarus 2.0.10 FPC 3.2.0 x86_64-linux-gtk2 @ Ubuntu 20.04 XFCE

Blaazen

  • Hero Member
  • *****
  • Posts: 3237
  • POKE 54296,15
    • Eye-Candy Controls
Re: Oval-Color button
« Reply #7 on: January 22, 2019, 12:26:29 am »
Even TGraphicControls can be pushed by keyboard, using acceleration key (Alt+C for Caption).
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

 

TinyPortal © 2005-2018