Eeschema: avoid using a incorrect background color the first time a SCH_DRAW_PANEL is displayed

When starting Eeschema, or a frame/dialog using a SCH_DRAW_PANEL, the bg color was initialized too late,
thus creating a flicker or an annoying draw artifact (in SYMBOL_PREVIEW_WIDGET for instance) if a Paint event
is fired before the right bg color is initialized.
Initializing the bg color earlier fix this issue.

Fixes: lp:1797203
https://bugs.launchpad.net/kicad/+bug/1797203
This commit is contained in:
jean-pierre charras 2019-01-25 20:18:22 +01:00
parent 4fbd5e8e0f
commit 4cd41e3941
3 changed files with 27 additions and 19 deletions

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014 Henner Zeller <h.zeller@acm.org>
* Copyright (C) 2016-2018 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2016-2019 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -142,19 +142,6 @@ DIALOG_CHOOSE_COMPONENT::DIALOG_CHOOSE_COMPONENT( SCH_BASE_FRAME* aParent, const
sizer->Add( buttonsSizer, 0, wxEXPAND | wxLEFT, 5 );
SetSizer( sizer );
Bind( wxEVT_INIT_DIALOG, &DIALOG_CHOOSE_COMPONENT::OnInitDialog, this );
Bind( wxEVT_TIMER, &DIALOG_CHOOSE_COMPONENT::OnCloseTimer, this, m_dbl_click_timer->GetId() );
Bind( COMPONENT_PRESELECTED, &DIALOG_CHOOSE_COMPONENT::OnComponentPreselected, this );
Bind( COMPONENT_SELECTED, &DIALOG_CHOOSE_COMPONENT::OnComponentSelected, this );
if( m_browser_button )
m_browser_button->Bind( wxEVT_COMMAND_BUTTON_CLICKED,
&DIALOG_CHOOSE_COMPONENT::OnUseBrowser, this );
if( m_fp_sel_ctrl )
m_fp_sel_ctrl->Bind( EVT_FOOTPRINT_SELECTED,
&DIALOG_CHOOSE_COMPONENT::OnFootprintSelected, this );
Layout();
// We specify the width of the right window (m_symbol_view_panel), because specify
@ -171,6 +158,19 @@ DIALOG_CHOOSE_COMPONENT::DIALOG_CHOOSE_COMPONENT( SCH_BASE_FRAME* aParent, const
SetInitialFocus( m_tree );
okButton->SetDefault();
Bind( wxEVT_INIT_DIALOG, &DIALOG_CHOOSE_COMPONENT::OnInitDialog, this );
Bind( wxEVT_TIMER, &DIALOG_CHOOSE_COMPONENT::OnCloseTimer, this, m_dbl_click_timer->GetId() );
Bind( COMPONENT_PRESELECTED, &DIALOG_CHOOSE_COMPONENT::OnComponentPreselected, this );
Bind( COMPONENT_SELECTED, &DIALOG_CHOOSE_COMPONENT::OnComponentSelected, this );
if( m_browser_button )
m_browser_button->Bind( wxEVT_COMMAND_BUTTON_CLICKED,
&DIALOG_CHOOSE_COMPONENT::OnUseBrowser, this );
if( m_fp_sel_ctrl )
m_fp_sel_ctrl->Bind( EVT_FOOTPRINT_SELECTED,
&DIALOG_CHOOSE_COMPONENT::OnFootprintSelected, this );
}

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014-2017 CERN
* Copyright (C) 2014-2019 CERN
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
* This program is free software; you can redistribute it and/or
@ -79,6 +79,11 @@ SCH_DRAW_PANEL::SCH_DRAW_PANEL( wxWindow* aParentWindow, wxWindowID aWindowId,
m_view->SetScaleLimits( 50.0, 0.05 ); // This fixes the zoom in and zoom out limits
m_view->SetMirror( false, false );
// Early initialization of the canvas background color,
// before any OnPaint event is fired for the canvas using a wrong bg color
auto settings = m_painter->GetSettings();
m_gal->SetClearColor( settings->GetBackgroundColor() );
setDefaultLayerOrder();
setDefaultLayerDeps();

View File

@ -35,10 +35,7 @@ SYMBOL_PREVIEW_WIDGET::SYMBOL_PREVIEW_WIDGET( wxWindow* aParent, KIWAY& aKiway,
EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType ) :
wxPanel( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ),
m_kiway( aKiway ),
m_preview( nullptr ),
m_status( nullptr ),
m_statusSizer( nullptr ),
m_previewItem( nullptr )
m_preview( nullptr ), m_status( nullptr ), m_statusSizer( nullptr ), m_previewItem( nullptr )
{
wxString eeschemaFrameKey( SCH_EDIT_FRAME_NAME );
auto eeschemaConfig = GetNewConfig( Pgm().App().GetAppName() );
@ -60,6 +57,12 @@ SYMBOL_PREVIEW_WIDGET::SYMBOL_PREVIEW_WIDGET( wxWindow* aParent, KIWAY& aKiway,
// strange artifacts on Windows when eeschema is run from Kicad manager (but not in stand alone...).
m_preview->GetGAL()->SetGridVisibility( false );
// Early initialization of the canvas background color,
// before any OnPaint event is fired for the canvas using a wrong bg color
KIGFX::VIEW* view = m_preview->GetView();
auto settings = static_cast<KIGFX::SCH_RENDER_SETTINGS*>( view->GetPainter()->GetSettings() );
m_preview->GetGAL()->SetClearColor( settings->GetBackgroundColor() );
SetBackgroundColour( *wxWHITE );
SetForegroundColour( *wxBLACK );