Don't shrink progress reporter when message changes; only grow.
This commit is contained in:
parent
d1b8b68c68
commit
8e26946567
|
@ -30,7 +30,6 @@
|
||||||
|
|
||||||
PROGRESS_REPORTER_BASE::PROGRESS_REPORTER_BASE( int aNumPhases ) :
|
PROGRESS_REPORTER_BASE::PROGRESS_REPORTER_BASE( int aNumPhases ) :
|
||||||
PROGRESS_REPORTER(),
|
PROGRESS_REPORTER(),
|
||||||
m_msgChanged( false ),
|
|
||||||
m_phase( 0 ),
|
m_phase( 0 ),
|
||||||
m_numPhases( aNumPhases ),
|
m_numPhases( aNumPhases ),
|
||||||
m_progress( 0 ),
|
m_progress( 0 ),
|
||||||
|
@ -65,7 +64,6 @@ void PROGRESS_REPORTER_BASE::Report( const wxString& aMessage )
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> guard( m_mutex );
|
std::lock_guard<std::mutex> guard( m_mutex );
|
||||||
m_rptMessage = aMessage;
|
m_rptMessage = aMessage;
|
||||||
m_msgChanged = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -34,17 +34,16 @@ WX_PROGRESS_REPORTER::WX_PROGRESS_REPORTER( wxWindow* aParent, const wxString& a
|
||||||
bool aReserveSpaceForMessage ) :
|
bool aReserveSpaceForMessage ) :
|
||||||
PROGRESS_REPORTER_BASE( aNumPhases ),
|
PROGRESS_REPORTER_BASE( aNumPhases ),
|
||||||
wxProgressDialog( aTitle, ( aReserveSpaceForMessage ? wxT( " " ) : wxT( "" ) ), 1, aParent,
|
wxProgressDialog( aTitle, ( aReserveSpaceForMessage ? wxT( " " ) : wxT( "" ) ), 1, aParent,
|
||||||
// wxPD_APP_MODAL | // Don't use; messes up OSX when called from
|
// wxPD_APP_MODAL | // Don't use; messes up OSX when called from
|
||||||
// quasi-modal dialog
|
// quasi-modal dialog
|
||||||
wxPD_AUTO_HIDE | // *MUST* use; otherwise wxWidgets will spin
|
wxPD_AUTO_HIDE | // *MUST* use; otherwise wxWidgets will spin
|
||||||
// up another event loop on completion which
|
// up another event loop on completion which
|
||||||
// causes all sorts of grief
|
// causes all sorts of grief
|
||||||
( aCanAbort ? wxPD_CAN_ABORT : 0 ) |
|
( aCanAbort ? wxPD_CAN_ABORT : 0 ) | wxPD_ELAPSED_TIME ),
|
||||||
wxPD_ELAPSED_TIME )
|
|
||||||
#if wxCHECK_VERSION( 3, 1, 0 )
|
#if wxCHECK_VERSION( 3, 1, 0 )
|
||||||
,
|
m_appProgressIndicator( aParent ),
|
||||||
m_appProgressIndicator( aParent )
|
|
||||||
#endif
|
#endif
|
||||||
|
m_messageWidth( 0 )
|
||||||
{
|
{
|
||||||
#if wxCHECK_VERSION( 3, 1, 0 )
|
#if wxCHECK_VERSION( 3, 1, 0 )
|
||||||
// wxAppProgressIndicator doesn't like value > max, ever. However there are some risks
|
// wxAppProgressIndicator doesn't like value > max, ever. However there are some risks
|
||||||
|
@ -67,21 +66,27 @@ bool WX_PROGRESS_REPORTER::updateUI()
|
||||||
if( cur < 0 || cur > 1000 )
|
if( cur < 0 || cur > 1000 )
|
||||||
cur = 0;
|
cur = 0;
|
||||||
|
|
||||||
bool msgChanged = false;
|
SetRange( 1000 );
|
||||||
|
|
||||||
wxString message;
|
wxString message;
|
||||||
|
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> guard( m_mutex );
|
std::lock_guard<std::mutex> guard( m_mutex );
|
||||||
message = m_rptMessage;
|
message = m_rptMessage;
|
||||||
msgChanged = m_msgChanged;
|
|
||||||
m_msgChanged = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SetRange( 1000 );
|
int newWidth = GetTextExtent( m_rptMessage ).x;
|
||||||
bool diag = wxProgressDialog::Update( cur, message );
|
|
||||||
|
|
||||||
if( msgChanged )
|
if( newWidth > m_messageWidth )
|
||||||
|
{
|
||||||
|
m_messageWidth = newWidth;
|
||||||
Fit();
|
Fit();
|
||||||
|
}
|
||||||
|
|
||||||
|
Raise();
|
||||||
|
SetFocus();
|
||||||
|
|
||||||
|
bool diag = wxProgressDialog::Update( cur, message );
|
||||||
|
|
||||||
return diag;
|
return diag;
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,7 +113,6 @@ protected:
|
||||||
virtual bool updateUI() = 0;
|
virtual bool updateUI() = 0;
|
||||||
|
|
||||||
wxString m_rptMessage;
|
wxString m_rptMessage;
|
||||||
bool m_msgChanged; // true after change in m_rptMessage
|
|
||||||
|
|
||||||
mutable std::mutex m_mutex;
|
mutable std::mutex m_mutex;
|
||||||
std::atomic_int m_phase;
|
std::atomic_int m_phase;
|
||||||
|
|
|
@ -71,12 +71,15 @@ public:
|
||||||
wxProgressDialog::SetTitle( aTitle );
|
wxProgressDialog::SetTitle( aTitle );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool updateUI() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#if wxCHECK_VERSION( 3, 1, 0 )
|
#if wxCHECK_VERSION( 3, 1, 0 )
|
||||||
wxAppProgressIndicator m_appProgressIndicator;
|
wxAppProgressIndicator m_appProgressIndicator;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool updateUI() override;
|
int m_messageWidth;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,10 @@ void CONNECTIVITY_DATA::Build( BOARD* aBoard, PROGRESS_REPORTER* aReporter )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( aReporter )
|
if( aReporter )
|
||||||
|
{
|
||||||
aReporter->Report( _( "Updating nets..." ) );
|
aReporter->Report( _( "Updating nets..." ) );
|
||||||
|
aReporter->KeepRefreshing( false );
|
||||||
|
}
|
||||||
|
|
||||||
m_connAlgo.reset( new CN_CONNECTIVITY_ALGO );
|
m_connAlgo.reset( new CN_CONNECTIVITY_ALGO );
|
||||||
m_connAlgo->Build( aBoard, aReporter );
|
m_connAlgo->Build( aBoard, aReporter );
|
||||||
|
|
|
@ -182,7 +182,7 @@ void PCB_DRAW_PANEL_GAL::DisplayBoard( BOARD* aBoard, PROGRESS_REPORTER* aReport
|
||||||
{
|
{
|
||||||
m_view->Clear();
|
m_view->Clear();
|
||||||
|
|
||||||
aBoard->CacheTriangulation();
|
aBoard->CacheTriangulation( aReporter );
|
||||||
|
|
||||||
if( m_drawingSheet )
|
if( m_drawingSheet )
|
||||||
m_drawingSheet->SetFileName( TO_UTF8( aBoard->GetFileName() ) );
|
m_drawingSheet->SetFileName( TO_UTF8( aBoard->GetFileName() ) );
|
||||||
|
|
Loading…
Reference in New Issue