PcbNew: Fix layer alpha overrides being overwritten by color changes

Fixes: lp:1827518
* https://bugs.launchpad.net/kicad/+bug/1827518
This commit is contained in:
Jon Evans 2019-05-26 20:20:18 -04:00
parent 720b26d11e
commit cb3edf2607
1 changed files with 14 additions and 10 deletions

View File

@ -488,17 +488,19 @@ int PCBNEW_CONTROL::LayerToggle( const TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::LayerAlphaInc( const TOOL_EVENT& aEvent ) int PCBNEW_CONTROL::LayerAlphaInc( const TOOL_EVENT& aEvent )
{ {
auto painter = static_cast<KIGFX::PCB_PAINTER*>( getView()->GetPainter() ); auto& settings = m_frame->Settings().Colors();
auto settings = painter->GetSettings();
LAYER_NUM currentLayer = m_frame->GetActiveLayer(); LAYER_NUM currentLayer = m_frame->GetActiveLayer();
KIGFX::COLOR4D currentColor = settings->GetLayerColor( currentLayer ); KIGFX::COLOR4D currentColor = settings.GetLayerColor( currentLayer );
if( currentColor.a <= ALPHA_MAX - ALPHA_STEP ) if( currentColor.a <= ALPHA_MAX - ALPHA_STEP )
{ {
currentColor.a += ALPHA_STEP; currentColor.a += ALPHA_STEP;
settings->SetLayerColor( currentLayer, currentColor ); settings.SetLayerColor( currentLayer, currentColor );
m_frame->GetGalCanvas()->GetView()->UpdateLayerColor( currentLayer );
KIGFX::VIEW* view = m_frame->GetGalCanvas()->GetView();
view->GetPainter()->GetSettings()->ImportLegacyColors( &settings );
view->UpdateLayerColor( currentLayer );
wxUpdateUIEvent dummy; wxUpdateUIEvent dummy;
static_cast<PCB_EDIT_FRAME*>( m_frame )->OnUpdateLayerAlpha( dummy ); static_cast<PCB_EDIT_FRAME*>( m_frame )->OnUpdateLayerAlpha( dummy );
@ -512,17 +514,19 @@ int PCBNEW_CONTROL::LayerAlphaInc( const TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::LayerAlphaDec( const TOOL_EVENT& aEvent ) int PCBNEW_CONTROL::LayerAlphaDec( const TOOL_EVENT& aEvent )
{ {
auto painter = static_cast<KIGFX::PCB_PAINTER*>( getView()->GetPainter() ); auto& settings = m_frame->Settings().Colors();
auto settings = painter->GetSettings();
LAYER_NUM currentLayer = m_frame->GetActiveLayer(); LAYER_NUM currentLayer = m_frame->GetActiveLayer();
KIGFX::COLOR4D currentColor = settings->GetLayerColor( currentLayer ); KIGFX::COLOR4D currentColor = settings.GetLayerColor( currentLayer );
if( currentColor.a >= ALPHA_MIN + ALPHA_STEP ) if( currentColor.a >= ALPHA_MIN + ALPHA_STEP )
{ {
currentColor.a -= ALPHA_STEP; currentColor.a -= ALPHA_STEP;
settings->SetLayerColor( currentLayer, currentColor ); settings.SetLayerColor( currentLayer, currentColor );
m_frame->GetGalCanvas()->GetView()->UpdateLayerColor( currentLayer );
KIGFX::VIEW* view = m_frame->GetGalCanvas()->GetView();
view->GetPainter()->GetSettings()->ImportLegacyColors( &settings );
view->UpdateLayerColor( currentLayer );
wxUpdateUIEvent dummy; wxUpdateUIEvent dummy;
static_cast<PCB_BASE_FRAME*>( m_frame )->OnUpdateLayerAlpha( dummy ); static_cast<PCB_BASE_FRAME*>( m_frame )->OnUpdateLayerAlpha( dummy );