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,29 +61,45 @@ wxBitmap MakeBadge( SEVERITY aStyle, int aCount, wxWindow* aWindow, int aDepth )
badgeDC.SetBackground( brush );
badgeDC.Clear();
if( aCount == 0 )
return bitmap;
switch( aStyle )
if( aCount < 0 )
{
case RPT_SEVERITY_ERROR:
badgeColour = *wxRED;
textColour = *wxWHITE;
break;
case RPT_SEVERITY_WARNING:
badgeColour = *wxYELLOW;
textColour = *wxBLACK;
break;
case RPT_SEVERITY_ACTION:
badgeColour = *wxGREEN;
textColour = *wxWHITE;
break;
case RPT_SEVERITY_EXCLUSION:
case RPT_SEVERITY_INFO:
default:
badgeColour = *wxLIGHT_GREY;
textColour = *wxBLACK;
break;
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 )
{
case RPT_SEVERITY_ERROR:
badgeColour = *wxRED;
textColour = *wxWHITE;
break;
case RPT_SEVERITY_WARNING:
badgeColour = *wxYELLOW;
textColour = *wxBLACK;
break;
case RPT_SEVERITY_ACTION:
badgeColour = *wxGREEN;
textColour = *wxWHITE;
break;
case RPT_SEVERITY_EXCLUSION:
case RPT_SEVERITY_INFO:
default:
badgeColour = *wxLIGHT_GREY;
textColour = *wxBLACK;
break;
}
}
brush.SetStyle( wxBRUSHSTYLE_SOLID );

View File

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

View File

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

View File

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