Jerry-rig HTML-format alpha parsing
On wx3.0, the HTML format #RRGGBBAA cannot handle the alpha channel. Instead, we route this through a COLOR4D routine when we need to use these colors Fixes https://gitlab.com/kicad/code/kicad/issues/9963
This commit is contained in:
parent
348c2bc612
commit
78ff9a857a
|
@ -561,7 +561,10 @@ void BOARD_ADAPTER::InitSettings( REPORTER* aStatusReporter, REPORTER* aWarningR
|
|||
{
|
||||
if( aColorName.StartsWith( "#" ) )
|
||||
{
|
||||
return KIGFX::COLOR4D( wxColour( aColorName ) );
|
||||
/// Keep only the non-alpha channels of the color string,
|
||||
/// i.e. first 6 hex digits and the '#'
|
||||
|
||||
return KIGFX::COLOR4D( aColorName );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -110,6 +110,13 @@ COLOR4D::COLOR4D( EDA_COLOR_T aColor )
|
|||
|
||||
|
||||
#ifdef WX_COMPATIBILITY
|
||||
COLOR4D::COLOR4D( const wxString& aColorStr )
|
||||
{
|
||||
if( !SetFromHexString( aColorStr ) )
|
||||
SetFromWxString( aColorStr );
|
||||
}
|
||||
|
||||
|
||||
COLOR4D::COLOR4D( const wxColour& aColor )
|
||||
{
|
||||
r = aColor.Red() / 255.0;
|
||||
|
|
|
@ -146,6 +146,13 @@ public:
|
|||
COLOR4D& FromCSSRGBA( int aRed, int aGreen, int aBlue, double aAlpha = 1.0 );
|
||||
|
||||
#ifdef WX_COMPATIBILITY
|
||||
|
||||
/**
|
||||
* Defines a color from a CSS or HTML-type string
|
||||
* @param aColorStr input string
|
||||
*/
|
||||
COLOR4D( const wxString& aColorStr );
|
||||
|
||||
/**
|
||||
* @param aColor is the color type used by wxWidgets.
|
||||
*/
|
||||
|
|
|
@ -545,7 +545,7 @@ void PANEL_SETUP_BOARD_STACKUP::synchronizeWithBoard( bool aFullSync )
|
|||
|
||||
if( item->GetColor().StartsWith( "#" ) ) // User defined color
|
||||
{
|
||||
ui_row_item.m_UserColor = wxColour( item->GetColor() );
|
||||
ui_row_item.m_UserColor = COLOR4D( item->GetColor() ).ToColour();
|
||||
|
||||
if( bm_combo ) // Update user color shown in the wxBitmapComboBox
|
||||
{
|
||||
|
@ -799,7 +799,9 @@ BOARD_STACKUP_ROW_UI_ITEM PANEL_SETUP_BOARD_STACKUP::createRowData( int aRow,
|
|||
if( item->IsColorEditable() )
|
||||
{
|
||||
if( item->GetColor().StartsWith( "#" ) ) // User defined color
|
||||
ui_row_item.m_UserColor = wxColour( item->GetColor() );
|
||||
{
|
||||
ui_row_item.m_UserColor = COLOR4D( item->GetColor() ).ToColour();
|
||||
}
|
||||
else
|
||||
ui_row_item.m_UserColor = GetDefaultUserColor( item->GetType() );
|
||||
|
||||
|
@ -1478,7 +1480,7 @@ wxBitmapComboBox* PANEL_SETUP_BOARD_STACKUP::createColorBox( BOARD_STACKUP_ITEM*
|
|||
if( ii == GetColorUserDefinedListIdx()
|
||||
&& aStackupItem && aStackupItem->GetColor().StartsWith( "#" ) )
|
||||
{
|
||||
curr_color = wxColour( aStackupItem->GetColor() );
|
||||
curr_color = wxColour( COLOR4D( aStackupItem->GetColor() ).ToColour() );
|
||||
|
||||
// NB: wxWidgets 3.0's color.GetAsString( wxC2S_HTML_SYNTAX ) pukes on alpha
|
||||
label = getColourAsHexString( curr_color );
|
||||
|
|
|
@ -650,7 +650,7 @@ void GERBER_JOBFILE_WRITER::addJSONMaterialStackup()
|
|||
if( colorName.StartsWith( "#" ) ) // This is a user defined color.
|
||||
{
|
||||
// In job file a color can be given by its RGB values (0...255)
|
||||
wxColor color( colorName );
|
||||
wxColor color( COLOR4D( colorName ).ToColour() );
|
||||
colorName.Printf( "R%dG%dB%d", color.Red(), color.Green(), color.Blue() );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue