Don't reset alpha when specified in hex value.

Also fixes a bug with colour picker cursor drawing on Mac.

Fixes https://gitlab.com/kicad/code/kicad/issues/14646
This commit is contained in:
Jeff Young 2023-04-29 17:50:29 +01:00
parent f4b43617e7
commit a817b4c1ff
2 changed files with 13 additions and 11 deletions

View File

@ -396,12 +396,12 @@ void DIALOG_COLOR_PICKER::drawRGBPalette()
// Use Y axis from bottom to top and origin to center // Use Y axis from bottom to top and origin to center
bitmapDC.SetAxisOrientation( true, true ); bitmapDC.SetAxisOrientation( true, true );
#if wxCHECK_VERSION( 3, 1, 7 ) #if wxCHECK_VERSION( 3, 1, 7 ) && !defined( __WXMAC__)
// For some reason, SetDeviceOrigin has changed in wxWidgets 3.1.6 or 3.1.7 // For some reason, SetDeviceOrigin has changed in wxWidgets 3.1.6 or 3.1.7
bitmapDC.SetDeviceOrigin( half_size, -half_size ); bitmapDC.SetDeviceOrigin( half_size, -half_size );
#else #else
bitmapDC.SetDeviceOrigin( half_size, half_size ); bitmapDC.SetDeviceOrigin( half_size, half_size );
#endif #endif
// Reserve room to draw cursors inside the bitmap // Reserve room to draw cursors inside the bitmap
half_size -= m_cursorsSize/2; half_size -= m_cursorsSize/2;
@ -466,12 +466,12 @@ void DIALOG_COLOR_PICKER::drawHSVPalette()
// Use Y axis from bottom to top and origin to center // Use Y axis from bottom to top and origin to center
bitmapDC.SetAxisOrientation( true, true ); bitmapDC.SetAxisOrientation( true, true );
#if wxCHECK_VERSION( 3, 1, 7 ) #if wxCHECK_VERSION( 3, 1, 7 ) && !defined( __WXMAC__)
// For some reason, SetDeviceOrigin has changed in wxWidgets 3.1.6 or 3.1.7 // For some reason, SetDeviceOrigin has changed in wxWidgets 3.1.6 or 3.1.7
bitmapDC.SetDeviceOrigin( half_size, -half_size ); bitmapDC.SetDeviceOrigin( half_size, -half_size );
#else #else
bitmapDC.SetDeviceOrigin( half_size, half_size ); bitmapDC.SetDeviceOrigin( half_size, half_size );
#endif #endif
// Reserve room to draw cursors inside the bitmap // Reserve room to draw cursors inside the bitmap
half_size -= m_cursorsSize / 2; half_size -= m_cursorsSize / 2;
@ -701,11 +701,13 @@ void DIALOG_COLOR_PICKER::onHSVMouseDrag( wxMouseEvent& event )
void DIALOG_COLOR_PICKER::OnColorValueText( wxCommandEvent& event ) void DIALOG_COLOR_PICKER::OnColorValueText( wxCommandEvent& event )
{ {
m_newColor4D.SetFromHexString( m_colorValue->GetValue() ); if( m_newColor4D.SetFromHexString( m_colorValue->GetValue() ) )
m_newColor4D.ToHSV( m_hue, m_sat, m_val, true ); {
m_newColor4D.ToHSV( m_hue, m_sat, m_val, true );
SetEditVals( HEX_CHANGED, true ); SetEditVals( HEX_CHANGED, false );
drawAll(); drawAll();
}
} }

View File

@ -179,7 +179,7 @@ bool COLOR4D::SetFromHexString( const wxString& aColorString )
str.Trim( true ); str.Trim( true );
str.Trim( false ); str.Trim( false );
if( str.length() < 7 || str.GetChar( 0 ) != '#' ) if( str.length() < 7 || !str.StartsWith( '#' ) )
return false; return false;
unsigned long tmp; unsigned long tmp;