Added per-pixel alpha blending capability to wxOverlay under wxMSW

By default, wxMSW overlay uses a constant alpha for the window's opacity which
can be changed by the added wxOverlay::SetOpacity() function. For some applications,
that's all they need. But for others, per-pixel alpha blending is a requirement.
This capability can be enabled by calling SetOpacity(-1) before initializing the
overlay. But the drawing must be done via a graphics context because the standard DC
under MSW does not support alpha drawing.

Also request that the overlay window be positioned below any floating windows
on the target (if any).
This commit is contained in:
AliKet 2024-02-09 21:45:48 +01:00
parent e79466f02b
commit 7b75d0a256
5 changed files with 142 additions and 10 deletions

View file

@ -27,6 +27,25 @@ public:
example, when the window content has been changed and repainted.
*/
void Reset();
/**
Sets or unsets constant opacity of the overlay window.
If @a alpha is `-1`, use per-pixel alpha blending, otherwise use the
given alpha value for all pixels.
@note Drawing on the overlay window is opaque by default under wxMSW.
You have to call SetOpacity(-1) before initializing the overlay and use
a graphics context to do the actual drawing if you want per-pixel alpha
blending. Or, assuming that SetOpacity(-1) wasn't called, explicitly set
the alpha value (at any time) to change the overlay window's opacity.
@note This is currently only implemented for wxMSW and does nothing in
the other ports.
@since 3.3.0
*/
void SetOpacity(int alpha);
};