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_hoverTimer.Stop();
|
||||
hidePreview();
|
||||
destroyPreview();
|
||||
}
|
||||
|
||||
|
||||
|
@ -643,16 +643,19 @@ void LIB_TREE::showPreview( wxDataViewItem aItem )
|
|||
|
||||
wxWindow* topLevelParent = wxGetTopLevelParent( m_parent );
|
||||
|
||||
m_previewWindow = new wxPopupWindow( topLevelParent );
|
||||
m_previewWindow->SetPosition( wxPoint( m_tree_ctrl->GetScreenRect().GetRight() - 10,
|
||||
wxGetMousePosition().y - PREVIEW_SIZE.y / 2 ) );
|
||||
if( !m_previewWindow )
|
||||
m_previewWindow = new wxPopupWindow( topLevelParent );
|
||||
|
||||
bool wasShown = m_previewWindow->IsShown();
|
||||
|
||||
m_previewWindow->SetSize( PREVIEW_SIZE );
|
||||
|
||||
m_previewWindow->Freeze();
|
||||
m_previewWindow->Show();
|
||||
|
||||
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 )
|
||||
{
|
||||
m_previewWindow->Hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LIB_TREE::destroyPreview()
|
||||
{
|
||||
hidePreview();
|
||||
|
||||
if( m_previewWindow )
|
||||
{
|
||||
m_previewWindow->Destroy();
|
||||
m_previewWindow = nullptr;
|
||||
}
|
||||
|
@ -687,9 +700,6 @@ void LIB_TREE::onIdle( wxIdleEvent& aEvent )
|
|||
if( m_tree_ctrl->IsShownOnScreen() )
|
||||
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 )
|
||||
{
|
||||
m_hoverTimer.Stop();
|
||||
|
@ -718,10 +728,7 @@ void LIB_TREE::onIdle( wxIdleEvent& aEvent )
|
|||
}
|
||||
|
||||
if( item != m_previewItem )
|
||||
{
|
||||
hidePreview();
|
||||
showPreview( item );
|
||||
}
|
||||
|
||||
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 );
|
||||
wxCHECK( node, /* void */ );
|
||||
|
||||
wxBoxSizer* mainSizer = new wxBoxSizer( wxVERTICAL );
|
||||
aParent->SetSizer( mainSizer );
|
||||
SYMBOL_PREVIEW_WIDGET* preview = dynamic_cast<SYMBOL_PREVIEW_WIDGET*>(
|
||||
wxWindow::FindWindowByName( c_previewName, aParent ) );
|
||||
|
||||
WX_PANEL* panel = new WX_PANEL( aParent );
|
||||
panel->SetBorders( true, true, true, true );
|
||||
panel->SetBorderColor( KIGFX::COLOR4D::BLACK );
|
||||
if( !preview )
|
||||
{
|
||||
wxBoxSizer* mainSizer = new wxBoxSizer( wxVERTICAL );
|
||||
aParent->SetSizer( mainSizer );
|
||||
|
||||
wxBoxSizer* panelSizer = new wxBoxSizer( wxVERTICAL );
|
||||
panel->SetSizer( panelSizer );
|
||||
WX_PANEL* panel = new WX_PANEL( aParent );
|
||||
panel->SetBorders( true, true, true, true );
|
||||
panel->SetBorderColor( KIGFX::COLOR4D::BLACK );
|
||||
|
||||
EDA_DRAW_PANEL_GAL::GAL_TYPE backend = m_frame->GetCanvas()->GetBackend();
|
||||
SYMBOL_PREVIEW_WIDGET* preview = new SYMBOL_PREVIEW_WIDGET( panel, &m_frame->Kiway(),
|
||||
false, backend );
|
||||
preview->SetLayoutDirection( wxLayout_LeftToRight );
|
||||
wxBoxSizer* panelSizer = new wxBoxSizer( wxVERTICAL );
|
||||
panel->SetSizer( panelSizer );
|
||||
|
||||
panelSizer->Add( preview, 1, wxEXPAND|wxALL, 1 );
|
||||
mainSizer->Add( panel, 1, wxEXPAND, 0 );
|
||||
aParent->Layout();
|
||||
EDA_DRAW_PANEL_GAL::GAL_TYPE backend = m_frame->GetCanvas()->GetBackend();
|
||||
preview = new SYMBOL_PREVIEW_WIDGET( panel, &m_frame->Kiway(), false, backend );
|
||||
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 );
|
||||
}
|
|
@ -208,6 +208,7 @@ protected:
|
|||
|
||||
void showPreview( wxDataViewItem aItem );
|
||||
void hidePreview();
|
||||
void destroyPreview();
|
||||
|
||||
void onQueryText( wxCommandEvent& 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 )
|
||||
{
|
||||
static const wxString c_previewName = wxS( "fpHoverPreview" );
|
||||
|
||||
LIB_TREE_NODE* node = ToNode( aItem );
|
||||
wxCHECK( node, /* void */ );
|
||||
|
||||
wxBoxSizer* mainSizer = new wxBoxSizer( wxVERTICAL );
|
||||
aParent->SetSizer( mainSizer );
|
||||
FOOTPRINT_PREVIEW_PANEL* preview = dynamic_cast<FOOTPRINT_PREVIEW_PANEL*>(
|
||||
wxWindow::FindWindowByName( c_previewName, aParent ) );
|
||||
|
||||
FOOTPRINT_PREVIEW_PANEL* preview = FOOTPRINT_PREVIEW_PANEL::New( &m_frame->Kiway(), aParent,
|
||||
m_frame );
|
||||
preview->GetGAL()->SetAxesEnabled( false );
|
||||
if( !preview )
|
||||
{
|
||||
wxBoxSizer* mainSizer = new wxBoxSizer( wxVERTICAL );
|
||||
aParent->SetSizer( mainSizer );
|
||||
|
||||
mainSizer->Add( preview, 1, wxEXPAND|wxALL, 1 );
|
||||
aParent->Layout();
|
||||
preview = FOOTPRINT_PREVIEW_PANEL::New( &m_frame->Kiway(), aParent, m_frame );
|
||||
|
||||
preview->SetName( c_previewName );
|
||||
preview->GetGAL()->SetAxesEnabled( false );
|
||||
|
||||
mainSizer->Add( preview, 1, wxEXPAND | wxALL, 1 );
|
||||
aParent->Layout();
|
||||
}
|
||||
|
||||
preview->DisplayFootprint( node->m_LibId );
|
||||
}
|
Loading…
Reference in New Issue