Display green badge for zero errors or zero warnings.

Fixes https://gitlab.com/kicad/code/kicad/issues/5735
This commit is contained in:
Jeff Young 2020-09-21 11:37:20 +01:00
parent c6fb799fcd
commit 6020b70596
4 changed files with 65 additions and 32 deletions

View File

@ -61,9 +61,24 @@ wxBitmap MakeBadge( SEVERITY aStyle, int aCount, wxWindow* aWindow, int aDepth )
badgeDC.SetBackground( brush ); badgeDC.SetBackground( brush );
badgeDC.Clear(); badgeDC.Clear();
if( aCount == 0 ) if( aCount < 0 )
{
return bitmap; return bitmap;
}
else if( aCount == 0 )
{
if( aStyle == RPT_SEVERITY_ERROR || aStyle == RPT_SEVERITY_WARNING )
{
badgeColour = *wxGREEN;
textColour = *wxWHITE;
}
else
{
return bitmap;
}
}
else
{
switch( aStyle ) switch( aStyle )
{ {
case RPT_SEVERITY_ERROR: case RPT_SEVERITY_ERROR:
@ -85,6 +100,7 @@ wxBitmap MakeBadge( SEVERITY aStyle, int aCount, wxWindow* aWindow, int aDepth )
textColour = *wxBLACK; textColour = *wxBLACK;
break; break;
} }
}
brush.SetStyle( wxBRUSHSTYLE_SOLID ); brush.SetStyle( wxBRUSHSTYLE_SOLID );
brush.SetColour( badgeColour ); brush.SetColour( badgeColour );

View File

@ -53,6 +53,7 @@
DIALOG_ERC::DIALOG_ERC( SCH_EDIT_FRAME* parent ) : DIALOG_ERC::DIALOG_ERC( SCH_EDIT_FRAME* parent ) :
DIALOG_ERC_BASE( parent, ID_DIALOG_ERC ), // parent looks for this ID explicitly DIALOG_ERC_BASE( parent, ID_DIALOG_ERC ), // parent looks for this ID explicitly
m_parent( parent ), m_parent( parent ),
m_ercRun( false ),
m_severities( RPT_SEVERITY_ERROR | RPT_SEVERITY_WARNING ) m_severities( RPT_SEVERITY_ERROR | RPT_SEVERITY_WARNING )
{ {
EESCHEMA_SETTINGS* settings = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() ); EESCHEMA_SETTINGS* settings = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
@ -113,6 +114,12 @@ void DIALOG_ERC::updateDisplayedCounts()
numExcluded += m_markerProvider->GetCount( RPT_SEVERITY_EXCLUSION ); numExcluded += m_markerProvider->GetCount( RPT_SEVERITY_EXCLUSION );
} }
if( !m_ercRun )
{
numErrors = -1;
numWarnings = -1;
}
m_errorsBadge->SetBitmap( MakeBadge( RPT_SEVERITY_ERROR, numErrors, m_errorsBadge ) ); m_errorsBadge->SetBitmap( MakeBadge( RPT_SEVERITY_ERROR, numErrors, m_errorsBadge ) );
m_warningsBadge->SetBitmap( MakeBadge( RPT_SEVERITY_WARNING, numWarnings, m_warningsBadge ) ); m_warningsBadge->SetBitmap( MakeBadge( RPT_SEVERITY_WARNING, numWarnings, m_warningsBadge ) );
m_exclusionsBadge->SetBitmap( MakeBadge( RPT_SEVERITY_EXCLUSION, numExcluded, m_exclusionsBadge ) ); m_exclusionsBadge->SetBitmap( MakeBadge( RPT_SEVERITY_EXCLUSION, numExcluded, m_exclusionsBadge ) );
@ -145,6 +152,7 @@ void DIALOG_ERC::OnEraseDrcMarkersClick( wxCommandEvent& event )
deleteAllMarkers( includeExclusions ); deleteAllMarkers( includeExclusions );
m_ercRun = false;
updateDisplayedCounts(); updateDisplayedCounts();
m_parent->GetCanvas()->Refresh(); m_parent->GetCanvas()->Refresh();
} }
@ -188,11 +196,14 @@ void DIALOG_ERC::OnRunERCClick( wxCommandEvent& event )
wxSafeYield(); // m_MarkersList must be redraw wxSafeYield(); // m_MarkersList must be redraw
WX_TEXT_CTRL_REPORTER reporter( m_MessagesList ); WX_TEXT_CTRL_REPORTER reporter( m_MessagesList );
TestErc( reporter ); testErc( reporter );
m_ercRun = true;
updateDisplayedCounts();
} }
void DIALOG_ERC::RedrawDrawPanel() void DIALOG_ERC::redrawDrawPanel()
{ {
WINDOW_THAWER thawer( m_parent ); WINDOW_THAWER thawer( m_parent );
@ -200,7 +211,7 @@ void DIALOG_ERC::RedrawDrawPanel()
} }
void DIALOG_ERC::TestErc( REPORTER& aReporter ) void DIALOG_ERC::testErc( REPORTER& aReporter )
{ {
wxFileName fn; wxFileName fn;
@ -291,9 +302,6 @@ void DIALOG_ERC::TestErc( REPORTER& aReporter )
// Display diags: // Display diags:
m_markerTreeModel->SetProvider( m_markerProvider ); m_markerTreeModel->SetProvider( m_markerProvider );
// Displays global results:
updateDisplayedCounts();
// Display new markers from the current screen: // Display new markers from the current screen:
KIGFX::VIEW* view = m_parent->GetCanvas()->GetView(); KIGFX::VIEW* view = m_parent->GetCanvas()->GetView();
@ -328,7 +336,7 @@ void DIALOG_ERC::OnERCItemSelected( wxDataViewEvent& aEvent )
} }
m_parent->FocusOnItem( item ); m_parent->FocusOnItem( item );
RedrawDrawPanel(); redrawDrawPanel();
} }
aEvent.Skip(); aEvent.Skip();

View File

@ -42,6 +42,8 @@ private:
RC_ITEMS_PROVIDER* m_markerProvider; RC_ITEMS_PROVIDER* m_markerProvider;
RC_TREE_MODEL* m_markerTreeModel; RC_TREE_MODEL* m_markerTreeModel;
bool m_ercRun;
int m_severities; int m_severities;
public: public:
@ -61,9 +63,9 @@ private:
void OnSaveReport( wxCommandEvent& aEvent ) override; void OnSaveReport( wxCommandEvent& aEvent ) override;
void OnButtonCloseClick( wxCommandEvent& event ) override; void OnButtonCloseClick( wxCommandEvent& event ) override;
void RedrawDrawPanel(); void redrawDrawPanel();
void TestErc( REPORTER& aReporter ); void testErc( REPORTER& aReporter );
bool writeReport( const wxString& aFullFileName ); bool writeReport( const wxString& aFullFileName );

View File

@ -752,6 +752,7 @@ void DIALOG_DRC::OnDeleteAllClick( wxCommandEvent& aEvent )
deleteAllMarkers( s_includeExclusions ); deleteAllMarkers( s_includeExclusions );
m_drcRun = false;
refreshBoardEditor(); refreshBoardEditor();
updateDisplayedCounts(); updateDisplayedCounts();
} }
@ -817,13 +818,19 @@ void DIALOG_DRC::updateDisplayedCounts()
numExcluded += m_unconnectedItemsProvider->GetCount( RPT_SEVERITY_EXCLUSION ); numExcluded += m_unconnectedItemsProvider->GetCount( RPT_SEVERITY_EXCLUSION );
} }
if( m_footprintWarningsProvider ) if( m_footprintTestsRun && m_footprintWarningsProvider )
{ {
numErrors += m_footprintWarningsProvider->GetCount( RPT_SEVERITY_ERROR ); numErrors += m_footprintWarningsProvider->GetCount( RPT_SEVERITY_ERROR );
numWarnings += m_footprintWarningsProvider->GetCount( RPT_SEVERITY_WARNING ); numWarnings += m_footprintWarningsProvider->GetCount( RPT_SEVERITY_WARNING );
numExcluded += m_footprintWarningsProvider->GetCount( RPT_SEVERITY_EXCLUSION ); numExcluded += m_footprintWarningsProvider->GetCount( RPT_SEVERITY_EXCLUSION );
} }
if( !m_drcRun )
{
numErrors = -1;
numWarnings = -1;
}
m_errorsBadge->SetBitmap( MakeBadge( RPT_SEVERITY_ERROR, numErrors, m_errorsBadge ) ); m_errorsBadge->SetBitmap( MakeBadge( RPT_SEVERITY_ERROR, numErrors, m_errorsBadge ) );
m_warningsBadge->SetBitmap( MakeBadge( RPT_SEVERITY_WARNING, numWarnings, m_warningsBadge ) ); m_warningsBadge->SetBitmap( MakeBadge( RPT_SEVERITY_WARNING, numWarnings, m_warningsBadge ) );
m_exclusionsBadge->SetBitmap( MakeBadge( RPT_SEVERITY_EXCLUSION, numExcluded, m_exclusionsBadge ) ); m_exclusionsBadge->SetBitmap( MakeBadge( RPT_SEVERITY_EXCLUSION, numExcluded, m_exclusionsBadge ) );