Optimize footprint/symbol library hover previews.
This commit is contained in:
parent
77e408a93d
commit
7589de6120
|
@ -254,7 +254,7 @@ LIB_TREE::~LIB_TREE()
|
||||||
m_details_ctrl->Unbind( wxEVT_HTML_LINK_CLICKED, &LIB_TREE::onDetailsLink, this );
|
m_details_ctrl->Unbind( wxEVT_HTML_LINK_CLICKED, &LIB_TREE::onDetailsLink, this );
|
||||||
|
|
||||||
m_hoverTimer.Stop();
|
m_hoverTimer.Stop();
|
||||||
hidePreview();
|
destroyPreview();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -643,16 +643,19 @@ void LIB_TREE::showPreview( wxDataViewItem aItem )
|
||||||
|
|
||||||
wxWindow* topLevelParent = wxGetTopLevelParent( m_parent );
|
wxWindow* topLevelParent = wxGetTopLevelParent( m_parent );
|
||||||
|
|
||||||
m_previewWindow = new wxPopupWindow( topLevelParent );
|
if( !m_previewWindow )
|
||||||
m_previewWindow->SetPosition( wxPoint( m_tree_ctrl->GetScreenRect().GetRight() - 10,
|
m_previewWindow = new wxPopupWindow( topLevelParent );
|
||||||
wxGetMousePosition().y - PREVIEW_SIZE.y / 2 ) );
|
|
||||||
|
bool wasShown = m_previewWindow->IsShown();
|
||||||
|
|
||||||
m_previewWindow->SetSize( PREVIEW_SIZE );
|
m_previewWindow->SetSize( PREVIEW_SIZE );
|
||||||
|
|
||||||
m_previewWindow->Freeze();
|
|
||||||
m_previewWindow->Show();
|
|
||||||
|
|
||||||
m_adapter->ShowPreview( m_previewWindow, aItem );
|
m_adapter->ShowPreview( m_previewWindow, aItem );
|
||||||
m_previewWindow->Thaw();
|
|
||||||
|
m_previewWindow->SetPosition( wxPoint( m_tree_ctrl->GetScreenRect().GetRight() - 10,
|
||||||
|
wxGetMousePosition().y - PREVIEW_SIZE.y / 2 ) );
|
||||||
|
|
||||||
|
m_previewWindow->Show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -664,6 +667,16 @@ void LIB_TREE::hidePreview()
|
||||||
if( m_previewWindow )
|
if( m_previewWindow )
|
||||||
{
|
{
|
||||||
m_previewWindow->Hide();
|
m_previewWindow->Hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LIB_TREE::destroyPreview()
|
||||||
|
{
|
||||||
|
hidePreview();
|
||||||
|
|
||||||
|
if( m_previewWindow )
|
||||||
|
{
|
||||||
m_previewWindow->Destroy();
|
m_previewWindow->Destroy();
|
||||||
m_previewWindow = nullptr;
|
m_previewWindow = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -687,9 +700,6 @@ void LIB_TREE::onIdle( wxIdleEvent& aEvent )
|
||||||
if( m_tree_ctrl->IsShownOnScreen() )
|
if( m_tree_ctrl->IsShownOnScreen() )
|
||||||
mouseOverWindow |= m_tree_ctrl->GetScreenRect().Contains( screenPos );
|
mouseOverWindow |= m_tree_ctrl->GetScreenRect().Contains( screenPos );
|
||||||
|
|
||||||
if( m_previewWindow && m_previewWindow->IsShownOnScreen() )
|
|
||||||
mouseOverWindow |= m_previewWindow->GetScreenRect().Contains( screenPos );
|
|
||||||
|
|
||||||
if( m_previewDisabled || topLevelFocus != topLevelParent || !mouseOverWindow )
|
if( m_previewDisabled || topLevelFocus != topLevelParent || !mouseOverWindow )
|
||||||
{
|
{
|
||||||
m_hoverTimer.Stop();
|
m_hoverTimer.Stop();
|
||||||
|
@ -718,10 +728,7 @@ void LIB_TREE::onIdle( wxIdleEvent& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
if( item != m_previewItem )
|
if( item != m_previewItem )
|
||||||
{
|
|
||||||
hidePreview();
|
|
||||||
showPreview( item );
|
showPreview( item );
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -378,29 +378,38 @@ bool SYMBOL_TREE_SYNCHRONIZING_ADAPTER::HasPreview( const wxDataViewItem& aItem
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SYMBOL_TREE_SYNCHRONIZING_ADAPTER::ShowPreview( wxWindow* aParent, const wxDataViewItem& aItem )
|
void SYMBOL_TREE_SYNCHRONIZING_ADAPTER::ShowPreview( wxWindow* aParent,
|
||||||
|
const wxDataViewItem& aItem )
|
||||||
{
|
{
|
||||||
|
static const wxString c_previewName = wxS( "symHoverPreview" );
|
||||||
|
|
||||||
LIB_TREE_NODE* node = ToNode( aItem );
|
LIB_TREE_NODE* node = ToNode( aItem );
|
||||||
wxCHECK( node, /* void */ );
|
wxCHECK( node, /* void */ );
|
||||||
|
|
||||||
wxBoxSizer* mainSizer = new wxBoxSizer( wxVERTICAL );
|
SYMBOL_PREVIEW_WIDGET* preview = dynamic_cast<SYMBOL_PREVIEW_WIDGET*>(
|
||||||
aParent->SetSizer( mainSizer );
|
wxWindow::FindWindowByName( c_previewName, aParent ) );
|
||||||
|
|
||||||
WX_PANEL* panel = new WX_PANEL( aParent );
|
if( !preview )
|
||||||
panel->SetBorders( true, true, true, true );
|
{
|
||||||
panel->SetBorderColor( KIGFX::COLOR4D::BLACK );
|
wxBoxSizer* mainSizer = new wxBoxSizer( wxVERTICAL );
|
||||||
|
aParent->SetSizer( mainSizer );
|
||||||
|
|
||||||
wxBoxSizer* panelSizer = new wxBoxSizer( wxVERTICAL );
|
WX_PANEL* panel = new WX_PANEL( aParent );
|
||||||
panel->SetSizer( panelSizer );
|
panel->SetBorders( true, true, true, true );
|
||||||
|
panel->SetBorderColor( KIGFX::COLOR4D::BLACK );
|
||||||
|
|
||||||
EDA_DRAW_PANEL_GAL::GAL_TYPE backend = m_frame->GetCanvas()->GetBackend();
|
wxBoxSizer* panelSizer = new wxBoxSizer( wxVERTICAL );
|
||||||
SYMBOL_PREVIEW_WIDGET* preview = new SYMBOL_PREVIEW_WIDGET( panel, &m_frame->Kiway(),
|
panel->SetSizer( panelSizer );
|
||||||
false, backend );
|
|
||||||
preview->SetLayoutDirection( wxLayout_LeftToRight );
|
|
||||||
|
|
||||||
panelSizer->Add( preview, 1, wxEXPAND|wxALL, 1 );
|
EDA_DRAW_PANEL_GAL::GAL_TYPE backend = m_frame->GetCanvas()->GetBackend();
|
||||||
mainSizer->Add( panel, 1, wxEXPAND, 0 );
|
preview = new SYMBOL_PREVIEW_WIDGET( panel, &m_frame->Kiway(), false, backend );
|
||||||
aParent->Layout();
|
preview->SetName( c_previewName );
|
||||||
|
preview->SetLayoutDirection( wxLayout_LeftToRight );
|
||||||
|
|
||||||
|
panelSizer->Add( preview, 1, wxEXPAND | wxALL, 1 );
|
||||||
|
mainSizer->Add( panel, 1, wxEXPAND, 0 );
|
||||||
|
aParent->Layout();
|
||||||
|
}
|
||||||
|
|
||||||
preview->DisplaySymbol( node->m_LibId, node->m_Unit );
|
preview->DisplaySymbol( node->m_LibId, node->m_Unit );
|
||||||
}
|
}
|
|
@ -208,6 +208,7 @@ protected:
|
||||||
|
|
||||||
void showPreview( wxDataViewItem aItem );
|
void showPreview( wxDataViewItem aItem );
|
||||||
void hidePreview();
|
void hidePreview();
|
||||||
|
void destroyPreview();
|
||||||
|
|
||||||
void onQueryText( wxCommandEvent& aEvent );
|
void onQueryText( wxCommandEvent& aEvent );
|
||||||
void onQueryCharHook( wxKeyEvent& aEvent );
|
void onQueryCharHook( wxKeyEvent& aEvent );
|
||||||
|
|
|
@ -332,18 +332,27 @@ bool FP_TREE_SYNCHRONIZING_ADAPTER::HasPreview( const wxDataViewItem& aItem )
|
||||||
|
|
||||||
void FP_TREE_SYNCHRONIZING_ADAPTER::ShowPreview( wxWindow* aParent, const wxDataViewItem& aItem )
|
void FP_TREE_SYNCHRONIZING_ADAPTER::ShowPreview( wxWindow* aParent, const wxDataViewItem& aItem )
|
||||||
{
|
{
|
||||||
|
static const wxString c_previewName = wxS( "fpHoverPreview" );
|
||||||
|
|
||||||
LIB_TREE_NODE* node = ToNode( aItem );
|
LIB_TREE_NODE* node = ToNode( aItem );
|
||||||
wxCHECK( node, /* void */ );
|
wxCHECK( node, /* void */ );
|
||||||
|
|
||||||
wxBoxSizer* mainSizer = new wxBoxSizer( wxVERTICAL );
|
FOOTPRINT_PREVIEW_PANEL* preview = dynamic_cast<FOOTPRINT_PREVIEW_PANEL*>(
|
||||||
aParent->SetSizer( mainSizer );
|
wxWindow::FindWindowByName( c_previewName, aParent ) );
|
||||||
|
|
||||||
FOOTPRINT_PREVIEW_PANEL* preview = FOOTPRINT_PREVIEW_PANEL::New( &m_frame->Kiway(), aParent,
|
if( !preview )
|
||||||
m_frame );
|
{
|
||||||
preview->GetGAL()->SetAxesEnabled( false );
|
wxBoxSizer* mainSizer = new wxBoxSizer( wxVERTICAL );
|
||||||
|
aParent->SetSizer( mainSizer );
|
||||||
|
|
||||||
mainSizer->Add( preview, 1, wxEXPAND|wxALL, 1 );
|
preview = FOOTPRINT_PREVIEW_PANEL::New( &m_frame->Kiway(), aParent, m_frame );
|
||||||
aParent->Layout();
|
|
||||||
|
preview->SetName( c_previewName );
|
||||||
|
preview->GetGAL()->SetAxesEnabled( false );
|
||||||
|
|
||||||
|
mainSizer->Add( preview, 1, wxEXPAND | wxALL, 1 );
|
||||||
|
aParent->Layout();
|
||||||
|
}
|
||||||
|
|
||||||
preview->DisplayFootprint( node->m_LibId );
|
preview->DisplayFootprint( node->m_LibId );
|
||||||
}
|
}
|
Loading…
Reference in New Issue