Recent

Author Topic: [CANCELLED] Disabled glyphs in TImageList  (Read 3884 times)

y.ivanov

  • Sr. Member
  • ****
  • Posts: 309
[CANCELLED] Disabled glyphs in TImageList
« on: November 25, 2021, 05:44:29 pm »
Is it possible to use images with multiple glyphs (i.e. double width: enabled, disabled) in TImageList and use them for TActionList and all associated visual controls?

I'm trying to put glyphs with black outline on a transparent background and the PerformEffect(gdeDisabled, ...) has no effect on them. The controls look the same way no matter if they're enabled or disabled.
« Last Edit: November 26, 2021, 07:05:35 pm by y.ivanov »

wp

  • Hero Member
  • *****
  • Posts: 9161
Re: Disabled glyphs in TImageList
« Reply #1 on: November 25, 2021, 07:45:44 pm »
To my knowledge this is a feature of the glyphs used by TBitBtn and TSpeedButton only. The normal TImageList contains only single images and generates the disabled images from them on demand. There is only TToolbar for which you can provide a separate image list for disabled and hot images - but the overall effect is that you need two (or three) image lists then.
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

y.ivanov

  • Sr. Member
  • ****
  • Posts: 309
Re: Disabled glyphs in TImageList
« Reply #2 on: November 25, 2021, 08:16:04 pm »
To my knowledge this is a feature of the glyphs used by TBitBtn and TSpeedButton only. The normal TImageList contains only single images and generates the disabled images from them on demand. There is only TToolbar for which you can provide a separate image list for disabled and hot images - but the overall effect is that you need two (or three) image lists then.
IOW, it is impossible to use images with black foreground and expect they'll look different when disabled? 
That seems to be even more true with TMainMenu - it gets the images directly from TImageList.

Is there a way to override the PerformEffect(gdeDisabled, ...) processing?

wp

  • Hero Member
  • *****
  • Posts: 9161
Re: Disabled glyphs in TImageList
« Reply #3 on: November 25, 2021, 10:02:12 pm »
Just a rough idea: PerformEffect is called in TCustomImagelist.GetBitmap, and this is a virtual method. So when you override this method in a descendant imagelist class you'd duplicate most of the code and replace the PerformEffect by whatever you want. But very probably there will be much more to be done to make this work.

Maybe it's easier to just owner-draw the menu? For example you could pack both normal and disabled images into the same imagelist, and when you need the disabled images you draw the image at index ImageIndex+1?
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

lainz

  • Hero Member
  • *****
  • Posts: 3884
Re: Disabled glyphs in TImageList
« Reply #4 on: November 25, 2021, 10:42:11 pm »
I tried to add SVG support to TImageList and it was impossible. Not discouraging you but things are not easy with that code.
In the end I made my own image list.

y.ivanov

  • Sr. Member
  • ****
  • Posts: 309
Re: Disabled glyphs in TImageList
« Reply #5 on: November 26, 2021, 07:02:29 pm »
Just a rough idea: PerformEffect is called in TCustomImagelist.GetBitmap, and this is a virtual method. So when you override this method in a descendant imagelist class you'd duplicate most of the code and replace the PerformEffect by whatever you want. But very probably there will be much more to be done to make this work.
*snip*
After some investigation, I found the problem is quite complicated: TCustomImagelist.GetBitmap() -> TCustomImageListResolution.GetBitmap() ->TRawImage.PerformEffect(). Not sure my intention is worth the effort and I've just replaced them with color.

@wp, @lainz
Anyway, thanks for the replies!


 

TinyPortal © 2005-2018