Recent

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

alpine

  • Hero Member
  • *****
  • Posts: 1032
[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 »
"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

wp

  • Hero Member
  • *****
  • Posts: 11830
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.

alpine

  • Hero Member
  • *****
  • Posts: 1032
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?
"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

wp

  • Hero Member
  • *****
  • Posts: 11830
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?

lainz

  • Hero Member
  • *****
  • Posts: 4449
    • https://lainz.github.io/
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.

alpine

  • Hero Member
  • *****
  • Posts: 1032
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!

"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

 

TinyPortal © 2005-2018