Show a tooltip if dialog_choose_component has no symbol selected.

This commit is contained in:
jean-pierre charras 2017-11-23 13:24:02 +01:00
parent 1aff677562
commit d52fd5769d
2 changed files with 21 additions and 3 deletions

View File

@ -297,7 +297,11 @@ void DIALOG_CHOOSE_COMPONENT::OnSchViewPaint( wxPaintEvent& aEvent )
LIB_ID id = m_tree->GetSelectedLibId( &unit ); LIB_ID id = m_tree->GetSelectedLibId( &unit );
if( !id.IsValid() ) if( !id.IsValid() )
{
// No symbol to show, display a tooltip
RenderPreview( nullptr, unit );
return; return;
}
LIB_ALIAS* alias = nullptr; LIB_ALIAS* alias = nullptr;
@ -319,10 +323,13 @@ void DIALOG_CHOOSE_COMPONENT::OnSchViewPaint( wxPaintEvent& aEvent )
LIB_PART* part = alias ? alias->GetPart() : nullptr; LIB_PART* part = alias ? alias->GetPart() : nullptr;
// Don't draw anything (not even the background) if we don't have // Don't draw if we don't have a part to show
// a part to show // just display a tooltip
if( !part ) if( !part )
{
RenderPreview( nullptr, unit );
return; return;
}
if( alias->IsRoot() ) if( alias->IsRoot() )
{ {
@ -411,6 +418,16 @@ void DIALOG_CHOOSE_COMPONENT::RenderPreview( LIB_PART* aComponent, int aUnit )
if( dc_size.x == 0 || dc_size.y == 0 ) if( dc_size.x == 0 || dc_size.y == 0 )
return; return;
if( !aComponent ) // display a tooltip
{
wxString tooltip = _( "Double click here to select a symbol\nfrom the library browser" );
wxSize tsize = dc.GetTextExtent( tooltip.BeforeLast( '\n' ) );
dc.DrawText( tooltip.BeforeLast( '\n' ), ( dc_size.x - tsize.x )/2, ( dc_size.y - tsize.y )/2 );
tsize = dc.GetTextExtent( tooltip.AfterLast( '\n' ) );
dc.DrawText( tooltip.AfterLast( '\n' ), ( dc_size.x - tsize.x )/2, ( dc_size.y + tsize.y )/2 );
return;
}
GRResetPenAndBrush( &dc ); GRResetPenAndBrush( &dc );
COLOR4D bgColor = m_parent->GetDrawBgColor(); COLOR4D bgColor = m_parent->GetDrawBgColor();

View File

@ -180,7 +180,8 @@ protected:
void PopulateFootprintSelector( LIB_ID const& aLibId ); void PopulateFootprintSelector( LIB_ID const& aLibId );
/** /**
* Display a given component into the schematic symbol preview. * Display a given symbol into the schematic symbol preview.
* when no symbol selected, display a tooltip
*/ */
void RenderPreview( LIB_PART* aComponent, int aUnit ); void RenderPreview( LIB_PART* aComponent, int aUnit );