checkdigits / delphidarkmode

Detecting and acting on Windows' Dark Mode theme setting using Delphi
GNU General Public License v3.0
44 stars 10 forks source link

Add FMX version #1

Open birbilis opened 2 years ago

birbilis commented 2 years ago

Could use some conditional defines I think to check if the project is FMX or VCL one and use the appropriate Style management unit. The more or less the rest of the code should be the same

birbilis commented 2 years ago

Eventually one could contribute an implementation of IFMXSystemApperanceService for Windows, as mentioned at https://quality.embarcadero.com/browse/RSP-37290 and in comments at https://stackoverflow.com/a/67457500/903783

checkdigits commented 2 years ago

Hmm. There is an intention to refactor this as a class helper for forms. This is how I've seen things like rounded corners done and so on and I've seen Marco Cantu using this method as well.

With it refactored as a class helper it would be a little more than conditional defines but still doable. 👍

I think I'll definitely add FMX support and likely combine in the rounded corners control too just for good measure.

birbilis commented 2 years ago

what I was meaning is that FMX has a service to get dark mode info (but not notification for it switching I think) for OS-X, iOS, Android but not for Windows. Such platform services are defined as interfaces and then concrete implementations per platform are provided. The client just asks FMX for an FMX service interface implementation for the current platform and it checks if one has been registered for the current platform/architecture and returns it. So the missing Windows bits could be taken from your implementation and have a full FMX implementation for all platforms (ok, apart from Linux), with the missing part though being registering for notifications (the FMX service definition lacks that I think as a concept)

checkdigits commented 2 years ago

Yes, but the FMX service as it stands would limit the minimum version of Delphi/C++ builder it would work with. That said it's not a bad idea to add in the missing Windows capabilities.

The trapping of the change event is relatively simple on Windows (until Microsoft change how it works!) but for other platforms it's not quite as universally supported which may be why it was avoided in the first place.

Thanks for the inspiration. I just need to invent a few extra weekdays now, so I get the time to do it all. 🤪

birbilis commented 2 years ago

actually, I'd expect Embarcadero to port those interfaces back into VCL so that one could evolve their VCL app gradually with such features and eventually either port it or maintain both VCL and FMX versions of their app with a large common codebase

checkdigits commented 2 years ago

I would be very surprised if there is not something along these lines planned. Marco Cantú did a similar thing with a class helper for TForm in a recent blog post of his - that would be my suggested method since it's a more clean implementation.