diff --git a/eeschema/dialogs/dialog_choose_component.cpp b/eeschema/dialogs/dialog_choose_component.cpp index 01886e9c40..89006b6b90 100644 --- a/eeschema/dialogs/dialog_choose_component.cpp +++ b/eeschema/dialogs/dialog_choose_component.cpp @@ -297,7 +297,11 @@ void DIALOG_CHOOSE_COMPONENT::OnSchViewPaint( wxPaintEvent& aEvent ) LIB_ID id = m_tree->GetSelectedLibId( &unit ); if( !id.IsValid() ) + { + // No symbol to show, display a tooltip + RenderPreview( nullptr, unit ); return; + } LIB_ALIAS* alias = nullptr; @@ -319,10 +323,13 @@ void DIALOG_CHOOSE_COMPONENT::OnSchViewPaint( wxPaintEvent& aEvent ) LIB_PART* part = alias ? alias->GetPart() : nullptr; - // Don't draw anything (not even the background) if we don't have - // a part to show + // Don't draw if we don't have a part to show + // just display a tooltip if( !part ) + { + RenderPreview( nullptr, unit ); return; + } 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 ) 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 ); COLOR4D bgColor = m_parent->GetDrawBgColor(); diff --git a/eeschema/dialogs/dialog_choose_component.h b/eeschema/dialogs/dialog_choose_component.h index 4666aaa5f9..94bb15f9af 100644 --- a/eeschema/dialogs/dialog_choose_component.h +++ b/eeschema/dialogs/dialog_choose_component.h @@ -180,7 +180,8 @@ protected: 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 );