Recent

Author Topic: CustomDrawn: runtime look differs from designtime  (Read 898 times)

avra

  • Hero Member
  • *****
  • Posts: 1717
    • Additional info
CustomDrawn: runtime look differs from designtime
« on: May 28, 2019, 08:52:52 am »
I have TCDButton default rendering looking good in form designer, and I would like to see it looking the same in runtime. However runtime differs significantly, so I wonder what am I doing wrong?

Looks like big button keeps dsWindows7 DrawStyle, but small buttons bug and ignore dsDefault or dsCommon DrawStyles. How can I keep small buttons design time look in runtime?

I have tested on 32 bit Lazarus 2.0 fixes and FPC 3.2 fixes downloaded with fpcupdeluxe running on both WinXPx32 SP3 and current Win10x64 and problem is the same. Test project attached.
« Last Edit: May 28, 2019, 08:59:50 am by avra »
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

Peter H

  • Jr. Member
  • **
  • Posts: 57
Re: CustomDrawn: runtime look differs from designtime
« Reply #1 on: May 28, 2019, 11:59:05 am »
I quickly tried your project and I use an undocked IDE currently on Win7 32 bit.
Lazarus 2.02 FPC 3.0.4
In this environment buttons look the same at run time and at designtime.
I tried some different drawstyles.
But at designtime buttons dont look black as in your picture at designtime.

To get this flat 2D look, choose dsWinCE.
« Last Edit: May 28, 2019, 12:45:38 pm by Peter H »

avra

  • Hero Member
  • *****
  • Posts: 1717
    • Additional info
Re: CustomDrawn: runtime look differs from designtime
« Reply #2 on: May 28, 2019, 01:07:34 pm »
I quickly tried your project and I use an undocked IDE currently on Win7 32 bit.
Lazarus 2.02 FPC 3.0.4
Thanks!

In this environment buttons look the same at run time and at designtime.
I tried some different drawstyles.
But at designtime buttons dont look black as in your picture at designtime.
This made me test with Laz 2.0RC2 FPC 3.2 fixes and I can confirm that buttons don't look dark at design time, and I can not find any DesignStyle where that dark look shows. In my original example dark look showed not with one but with several styles (dsDefault, dsCommon, dsMacOSX...). Strange.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

avra

  • Hero Member
  • *****
  • Posts: 1717
    • Additional info
Re: CustomDrawn: runtime look differs from designtime
« Reply #3 on: May 28, 2019, 01:16:33 pm »
To get this flat 2D look, choose dsWinCE.

I have tried to use dsWinCE to mimic dark buttons from first picture, setting buttons color to gray and font color to white, but they do not look the same. First picture dark buttons have small 3D effect, while last picture dark buttons are complettely flat and have only black bounding box rendered.
« Last Edit: May 28, 2019, 01:18:40 pm by avra »
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

dogriz

  • Full Member
  • ***
  • Posts: 105
    • Tech blog - Delphi, Lazarus, Firebird, Windows, Linux, Android...
Re: CustomDrawn: runtime look differs from designtime
« Reply #4 on: May 28, 2019, 02:05:31 pm »
Tested on Debian Xfce + FPC 3.0.4/Lazarus 2.0.2 and it behaves the same as on your windows.
FPC 3.0.4
Lazarus 2.0.2
Debian x86_64, arm

avra

  • Hero Member
  • *****
  • Posts: 1717
    • Additional info
Re: CustomDrawn: runtime look differs from designtime
« Reply #5 on: May 28, 2019, 02:58:56 pm »
Tested on Debian Xfce + FPC 3.0.4/Lazarus 2.0.2 and it behaves the same as on your windows.
Thanks for testing. Are you saying that in design mode you see dark buttons but in runtime they are not dark?
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

dogriz

  • Full Member
  • ***
  • Posts: 105
    • Tech blog - Delphi, Lazarus, Firebird, Windows, Linux, Android...
Re: CustomDrawn: runtime look differs from designtime
« Reply #6 on: May 29, 2019, 08:19:39 am »
Thanks for testing. Are you saying that in design mode you see dark buttons but in runtime they are not dark?
Yes, exactly the same.
FPC 3.0.4
Lazarus 2.0.2
Debian x86_64, arm

wp

  • Hero Member
  • *****
  • Posts: 6351
Re: CustomDrawn: runtime look differs from designtime
« Reply #7 on: May 29, 2019, 11:20:22 am »
First that I am testing these components. It looks that the units of the drawers needed have to be added to the uses clause. In the Lazarus LCL folder I see only CustomDrawn_Common, CustomDrawn_Mac, CustomDrawn_WinXP, CustomDrawn_Android, no Win2000, no Win7, no KDEPastique, no GNOME. And the existing ones are far from being complete, they usually implement only drawing of the buttons. What am I missing? Is there a demo project somewhere?
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

lainz

  • Hero Member
  • *****
  • Posts: 3284
    • Lainz
Re: CustomDrawn: runtime look differs from designtime
« Reply #8 on: May 31, 2019, 08:48:26 pm »
The dark ones I think comes from an old installation of BGRAControls, where I override the default theme to make a dark theme.

You need to add the unit bgracustomdrawn in order to apply that dark theme.

lainz

  • Hero Member
  • *****
  • Posts: 3284
    • Lainz
Re: CustomDrawn: runtime look differs from designtime
« Reply #9 on: May 31, 2019, 08:54:00 pm »
First that I am testing these components. It looks that the units of the drawers needed have to be added to the uses clause. In the Lazarus LCL folder I see only CustomDrawn_Common, CustomDrawn_Mac, CustomDrawn_WinXP, CustomDrawn_Android, no Win2000, no Win7, no KDEPastique, no GNOME. And the existing ones are far from being complete, they usually implement only drawing of the buttons. What am I missing? Is there a demo project somewhere?

BGRAControls comes with Windows theming unit for custom drawn.

dogriz

  • Full Member
  • ***
  • Posts: 105
    • Tech blog - Delphi, Lazarus, Firebird, Windows, Linux, Android...
Re: CustomDrawn: runtime look differs from designtime
« Reply #10 on: June 03, 2019, 08:19:24 am »
When I add bgracustomdrawn unit, buttons are dark at runtime, but code:
Code: [Select]
CDButton3.Color := clRed; doesn't work any more. Why?
FPC 3.0.4
Lazarus 2.0.2
Debian x86_64, arm

lainz

  • Hero Member
  • *****
  • Posts: 3284
    • Lainz
Re: CustomDrawn: runtime look differs from designtime
« Reply #11 on: June 04, 2019, 12:50:15 am »
When I add bgracustomdrawn unit, buttons are dark at runtime, but code:
Code: [Select]
CDButton3.Color := clRed; doesn't work any more. Why?

You're using a custom theme, that in this case doesn't support color variables, all is hardcoded in theme. If you want to support color, edit the bgratheme and read the color variables inside the drawing routines.