From d07738a06c313896bf105e6ecd3337f38340526a Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Tue, 21 Feb 2023 20:06:54 +0100 Subject: [PATCH] gr_basic.cpp: ensure a pen with width = 0 is transparent. Setting its color to COLOR4D::UNSPECIFIED (i.e. opacity = 0) is not enough for all platforms (i.e. Windows) --- common/gr_basic.cpp | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/common/gr_basic.cpp b/common/gr_basic.cpp index 00898d7372..047805d10e 100644 --- a/common/gr_basic.cpp +++ b/common/gr_basic.cpp @@ -102,18 +102,24 @@ void GRSetColorPen( wxDC* DC, const COLOR4D& Color, int width, wxPenStyle style if( !curr_pen.IsOk() || curr_pen.GetColour() != color.ToColour() || curr_pen.GetWidth() != width || curr_pen.GetStyle() != style ) { - wxPen pen; - pen.SetColour( color.ToColour() ); - - if( style == wxPENSTYLE_DOT ) + if( width == 0 ) + // COLOR4D::UNSPECIFIED (i.e. opacity = 0) does not work on all platforms + // So ensure the pen is transparent + DC->SetPen( *wxTRANSPARENT_PEN ); + else { - style = wxPENSTYLE_USER_DASH; - pen.SetDashes( 2, dots ); - } + wxPen pen; + pen.SetColour( color.ToColour() ); - pen.SetWidth( width ); - pen.SetStyle( style ); - DC->SetPen( pen ); + if( style == wxPENSTYLE_DOT ) + { + style = wxPENSTYLE_USER_DASH; + pen.SetDashes( 2, dots ); + } + + pen.SetWidth( width ); + pen.SetStyle( style ); + } } else {