From 4cd41e3941445fe32a61c54b60f2b979cff0a391 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 25 Jan 2019 20:18:22 +0100 Subject: [PATCH] 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 --- eeschema/dialogs/dialog_choose_component.cpp | 28 ++++++++++---------- eeschema/sch_draw_panel.cpp | 7 ++++- eeschema/widgets/symbol_preview_widget.cpp | 11 +++++--- 3 files changed, 27 insertions(+), 19 deletions(-) diff --git a/eeschema/dialogs/dialog_choose_component.cpp b/eeschema/dialogs/dialog_choose_component.cpp index 9f695fe882..ccb99ef8f7 100644 --- a/eeschema/dialogs/dialog_choose_component.cpp +++ b/eeschema/dialogs/dialog_choose_component.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2014 Henner Zeller - * 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 ); } diff --git a/eeschema/sch_draw_panel.cpp b/eeschema/sch_draw_panel.cpp index 19259c7c4d..e4fbfbe30f 100644 --- a/eeschema/sch_draw_panel.cpp +++ b/eeschema/sch_draw_panel.cpp @@ -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 * * 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(); diff --git a/eeschema/widgets/symbol_preview_widget.cpp b/eeschema/widgets/symbol_preview_widget.cpp index e3c50c3ba6..05715fb4cc 100644 --- a/eeschema/widgets/symbol_preview_widget.cpp +++ b/eeschema/widgets/symbol_preview_widget.cpp @@ -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( view->GetPainter()->GetSettings() ); + m_preview->GetGAL()->SetClearColor( settings->GetBackgroundColor() ); + SetBackgroundColour( *wxWHITE ); SetForegroundColour( *wxBLACK );