Convert Rescue Symbols dialog previews to GAL.
This commit is contained in:
parent
893f7641ce
commit
6eafb9a2fd
|
@ -32,6 +32,7 @@
|
|||
#include <vector>
|
||||
#include <project_rescue.h>
|
||||
#include <eeschema_config.h>
|
||||
#include <symbol_preview_widget.h>
|
||||
|
||||
class DIALOG_RESCUE_EACH: public DIALOG_RESCUE_EACH_BASE
|
||||
{
|
||||
|
@ -59,12 +60,9 @@ private:
|
|||
bool TransferDataFromWindow() override;
|
||||
void PopulateConflictList();
|
||||
void PopulateInstanceList();
|
||||
void OnConflictSelect( wxDataViewEvent& event ) override;
|
||||
void OnNeverShowClick( wxCommandEvent& event ) override;
|
||||
void OnCancelClick( wxCommandEvent& event ) override;
|
||||
void OnHandleCachePreviewRepaint( wxPaintEvent& aRepaintEvent ) override;
|
||||
void OnHandleLibraryPreviewRepaint( wxPaintEvent& aRepaintEvent ) override;
|
||||
void renderPreview( LIB_PART* aComponent, int aUnit, wxPanel* panel );
|
||||
void OnConflictSelect( wxDataViewEvent& aEvent ) override;
|
||||
void OnNeverShowClick( wxCommandEvent& aEvent ) override;
|
||||
void OnCancelClick( wxCommandEvent& aEvent ) override;
|
||||
};
|
||||
|
||||
|
||||
|
@ -117,11 +115,11 @@ DIALOG_RESCUE_EACH::DIALOG_RESCUE_EACH( SCH_EDIT_FRAME* aParent, RESCUER& aRescu
|
|||
width = dc.GetTextExtent( header ).GetWidth() * 10;
|
||||
m_ListOfInstances->AppendTextColumn( header, wxDATAVIEW_CELL_INERT, width );
|
||||
|
||||
m_componentViewOld->SetLayoutDirection( wxLayout_LeftToRight );
|
||||
m_componentViewNew->SetLayoutDirection( wxLayout_LeftToRight );
|
||||
m_previewOldWidget->SetLayoutDirection( wxLayout_LeftToRight );
|
||||
m_previewNewWidget->SetLayoutDirection( wxLayout_LeftToRight );
|
||||
|
||||
Layout();
|
||||
SetSizeInDU( 480, 240 );
|
||||
SetSizeInDU( 480, 360 );
|
||||
|
||||
// Make sure the HTML window is large enough. Some fun size juggling and
|
||||
// fudge factors here but it does seem to work pretty reliably.
|
||||
|
@ -132,7 +130,7 @@ DIALOG_RESCUE_EACH::DIALOG_RESCUE_EACH( SCH_EDIT_FRAME* aParent, RESCUER& aRescu
|
|||
m_htmlPrompt->SetSizeHints( 2 * prompt_size.x / 3, approx_info_height );
|
||||
Layout();
|
||||
GetSizer()->SetSizeHints( this );
|
||||
SetSizeInDU( 480, 240 );
|
||||
SetSizeInDU( 480, 360 );
|
||||
Center();
|
||||
}
|
||||
|
||||
|
@ -206,77 +204,8 @@ void DIALOG_RESCUE_EACH::PopulateInstanceList()
|
|||
count++;
|
||||
}
|
||||
|
||||
m_titleInstances->SetLabelText( wxString::Format(
|
||||
_( "Instances of this symbol (%d items):" ), count ) );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_RESCUE_EACH::OnHandleCachePreviewRepaint( wxPaintEvent& aRepaintEvent )
|
||||
{
|
||||
int row = m_ListOfConflicts->GetSelectedRow();
|
||||
|
||||
if( row == wxNOT_FOUND )
|
||||
row = 0;
|
||||
|
||||
RESCUE_CANDIDATE& selected_part = m_Rescuer->m_all_candidates[row];
|
||||
|
||||
if( selected_part.GetCacheCandidate() )
|
||||
renderPreview( selected_part.GetCacheCandidate(), 0, m_componentViewOld );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_RESCUE_EACH::OnHandleLibraryPreviewRepaint( wxPaintEvent& aRepaintEvent )
|
||||
{
|
||||
int row = m_ListOfConflicts->GetSelectedRow();
|
||||
|
||||
if( row == wxNOT_FOUND )
|
||||
row = 0;
|
||||
|
||||
RESCUE_CANDIDATE& selected_part = m_Rescuer->m_all_candidates[row];
|
||||
|
||||
if( selected_part.GetLibCandidate() )
|
||||
renderPreview( selected_part.GetLibCandidate(), 0, m_componentViewNew );
|
||||
}
|
||||
|
||||
|
||||
// Render the preview in our m_componentView. If this gets more complicated, we should
|
||||
// probably have a derived class from wxPanel; but this keeps things local.
|
||||
// Call it only from a Paint Event, because we are using a wxPaintDC to draw the component
|
||||
void DIALOG_RESCUE_EACH::renderPreview( LIB_PART* aComponent, int aUnit, wxPanel* aPanel )
|
||||
{
|
||||
wxPaintDC dc( aPanel );
|
||||
wxColour bgColor = m_Parent->GetDrawBgColor().ToColour();
|
||||
|
||||
dc.SetBackground( wxBrush( bgColor ) );
|
||||
dc.Clear();
|
||||
|
||||
if( aComponent == NULL )
|
||||
return;
|
||||
|
||||
if( aUnit <= 0 )
|
||||
aUnit = 1;
|
||||
|
||||
const wxSize dc_size = dc.GetSize();
|
||||
dc.SetDeviceOrigin( dc_size.x / 2, dc_size.y / 2 );
|
||||
|
||||
// Find joint bounding box for everything we are about to draw.
|
||||
EDA_RECT bBox = aComponent->GetUnitBoundingBox( aUnit, /* deMorganConvert */ 1 );
|
||||
const double xscale = (double) dc_size.x / bBox.GetWidth();
|
||||
const double yscale = (double) dc_size.y / bBox.GetHeight();
|
||||
const double scale = std::min( xscale, yscale ) * 0.85;
|
||||
|
||||
dc.SetUserScale( scale, scale );
|
||||
|
||||
wxPoint offset = - bBox.Centre();
|
||||
|
||||
// Avoid rendering when either dimension is zero
|
||||
int width, height;
|
||||
|
||||
dc.GetSize( &width, &height );
|
||||
if( !width || !height )
|
||||
return;
|
||||
|
||||
aComponent->Draw( NULL, &dc, offset, aUnit, 1, PART_DRAW_OPTIONS::Default() );
|
||||
wxString msg = wxString::Format( _( "Instances of this symbol (%d items):" ), count );
|
||||
m_titleInstances->SetLabelText( msg );
|
||||
}
|
||||
|
||||
|
||||
|
@ -290,8 +219,19 @@ void DIALOG_RESCUE_EACH::OnConflictSelect( wxDataViewEvent& aEvent )
|
|||
|
||||
PopulateInstanceList();
|
||||
|
||||
m_componentViewOld->Refresh();
|
||||
m_componentViewNew->Refresh();
|
||||
int row = m_ListOfConflicts->GetSelectedRow();
|
||||
|
||||
if( row < 0 )
|
||||
{
|
||||
m_previewOldWidget->DisplayPart( nullptr, 0 );
|
||||
m_previewNewWidget->DisplayPart( nullptr, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
RESCUE_CANDIDATE& selected_part = m_Rescuer->m_all_candidates[row];
|
||||
m_previewOldWidget->DisplayPart( selected_part.GetCacheCandidate(), 0 );
|
||||
m_previewNewWidget->DisplayPart( selected_part.GetLibCandidate(), 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Aug 2 2018)
|
||||
// C++ code generated with wxFormBuilder (version Dec 30 2017)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
|
@ -17,71 +17,90 @@ DIALOG_RESCUE_EACH_BASE::DIALOG_RESCUE_EACH_BASE( wxWindow* parent, wxWindowID i
|
|||
bSizerMain = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_htmlPrompt = new wxHtmlWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO );
|
||||
bSizerMain->Add( m_htmlPrompt, 1, wxALL|wxEXPAND, 5 );
|
||||
m_htmlPrompt->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) );
|
||||
m_htmlPrompt->SetMinSize( wxSize( -1,50 ) );
|
||||
|
||||
bSizerMain->Add( m_htmlPrompt, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 );
|
||||
|
||||
m_titleSymbols = new wxStaticText( this, wxID_ANY, _("Symbols to update:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_titleSymbols->Wrap( -1 );
|
||||
m_titleSymbols->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxEmptyString ) );
|
||||
|
||||
bSizerMain->Add( m_titleSymbols, 0, wxLEFT|wxRIGHT, 5 );
|
||||
bSizerMain->Add( m_titleSymbols, 0, wxLEFT|wxRIGHT, 10 );
|
||||
|
||||
m_ListOfConflicts = new wxDataViewListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bSizerMain->Add( m_ListOfConflicts, 2, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
|
||||
bSizerMain->Add( m_ListOfConflicts, 3, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 10 );
|
||||
|
||||
m_titleInstances = new wxStaticText( this, wxID_ANY, _("Instances of this symbol:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_titleInstances->Wrap( -1 );
|
||||
m_titleInstances->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxEmptyString ) );
|
||||
|
||||
bSizerMain->Add( m_titleInstances, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
|
||||
bSizerMain->Add( m_titleInstances, 0, wxRIGHT|wxLEFT, 10 );
|
||||
|
||||
m_ListOfInstances = new wxDataViewListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bSizerMain->Add( m_ListOfInstances, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
|
||||
bSizerMain->Add( m_ListOfInstances, 2, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 10 );
|
||||
|
||||
wxBoxSizer* bSizerView;
|
||||
bSizerView = new wxBoxSizer( wxHORIZONTAL );
|
||||
wxBoxSizer* bSizerPreviews;
|
||||
bSizerPreviews = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
wxBoxSizer* bSizer6;
|
||||
bSizer6 = new wxBoxSizer( wxVERTICAL );
|
||||
wxBoxSizer* bSizerLeftPreview;
|
||||
bSizerLeftPreview = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_staticText2 = new wxStaticText( this, wxID_ANY, _("Cached Symbol:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticText2->Wrap( -1 );
|
||||
m_staticText2->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxEmptyString ) );
|
||||
m_previewOldLabel = new wxStaticText( this, wxID_ANY, _("Cached Symbol:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_previewOldLabel->Wrap( -1 );
|
||||
m_previewOldLabel->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxEmptyString ) );
|
||||
|
||||
bSizer6->Add( m_staticText2, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
|
||||
bSizerLeftPreview->Add( m_previewOldLabel, 0, 0, 5 );
|
||||
|
||||
m_componentViewOld = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE );
|
||||
m_componentViewOld->SetMinSize( wxSize( 150,150 ) );
|
||||
m_previewOldPanel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
|
||||
wxBoxSizer* bSizerOldPanel;
|
||||
bSizerOldPanel = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
bSizer6->Add( m_componentViewOld, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
|
||||
m_previewOldWidget = new SYMBOL_PREVIEW_WIDGET( m_previewOldPanel, Kiway() );
|
||||
bSizerOldPanel->Add( m_previewOldWidget, 1, wxEXPAND, 5 );
|
||||
|
||||
|
||||
bSizerView->Add( bSizer6, 1, wxEXPAND, 5 );
|
||||
|
||||
wxBoxSizer* bSizer7;
|
||||
bSizer7 = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_staticText3 = new wxStaticText( this, wxID_ANY, _("Library Symbol:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticText3->Wrap( -1 );
|
||||
m_staticText3->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxEmptyString ) );
|
||||
|
||||
bSizer7->Add( m_staticText3, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
m_componentViewNew = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE );
|
||||
m_componentViewNew->SetMinSize( wxSize( 150,150 ) );
|
||||
|
||||
bSizer7->Add( m_componentViewNew, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
|
||||
m_previewOldPanel->SetSizer( bSizerOldPanel );
|
||||
m_previewOldPanel->Layout();
|
||||
bSizerOldPanel->Fit( m_previewOldPanel );
|
||||
bSizerLeftPreview->Add( m_previewOldPanel, 1, wxEXPAND | wxALL, 5 );
|
||||
|
||||
|
||||
bSizerView->Add( bSizer7, 1, wxEXPAND, 5 );
|
||||
bSizerPreviews->Add( bSizerLeftPreview, 1, wxEXPAND, 5 );
|
||||
|
||||
wxBoxSizer* bSizerRightPreview;
|
||||
bSizerRightPreview = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_previewNewLabel = new wxStaticText( this, wxID_ANY, _("Library Symbol:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_previewNewLabel->Wrap( -1 );
|
||||
m_previewNewLabel->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxEmptyString ) );
|
||||
|
||||
bSizerRightPreview->Add( m_previewNewLabel, 0, 0, 5 );
|
||||
|
||||
m_previewNewPanel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
|
||||
wxBoxSizer* bSizerNewPanel;
|
||||
bSizerNewPanel = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_previewNewWidget = new SYMBOL_PREVIEW_WIDGET( m_previewNewPanel, Kiway() );
|
||||
bSizerNewPanel->Add( m_previewNewWidget, 1, wxEXPAND, 5 );
|
||||
|
||||
|
||||
bSizerMain->Add( bSizerView, 2, wxEXPAND, 5 );
|
||||
m_previewNewPanel->SetSizer( bSizerNewPanel );
|
||||
m_previewNewPanel->Layout();
|
||||
bSizerNewPanel->Fit( m_previewNewPanel );
|
||||
bSizerRightPreview->Add( m_previewNewPanel, 1, wxEXPAND | wxALL, 5 );
|
||||
|
||||
|
||||
bSizerPreviews->Add( bSizerRightPreview, 1, wxEXPAND, 5 );
|
||||
|
||||
|
||||
bSizerMain->Add( bSizerPreviews, 3, wxEXPAND|wxRIGHT|wxLEFT, 10 );
|
||||
|
||||
wxBoxSizer* bSizer5;
|
||||
bSizer5 = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
m_btnNeverShowAgain = new wxButton( this, wxID_ANY, _("Never Show Again"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bSizer5->Add( m_btnNeverShowAgain, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
||||
bSizer5->Add( m_btnNeverShowAgain, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 10 );
|
||||
|
||||
|
||||
bSizer5->Add( 0, 0, 1, wxEXPAND, 5 );
|
||||
|
@ -108,8 +127,6 @@ DIALOG_RESCUE_EACH_BASE::DIALOG_RESCUE_EACH_BASE( wxWindow* parent, wxWindowID i
|
|||
// Connect Events
|
||||
this->Connect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_RESCUE_EACH_BASE::OnDialogResize ) );
|
||||
m_ListOfConflicts->Connect( wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, wxDataViewEventHandler( DIALOG_RESCUE_EACH_BASE::OnConflictSelect ), NULL, this );
|
||||
m_componentViewOld->Connect( wxEVT_PAINT, wxPaintEventHandler( DIALOG_RESCUE_EACH_BASE::OnHandleCachePreviewRepaint ), NULL, this );
|
||||
m_componentViewNew->Connect( wxEVT_PAINT, wxPaintEventHandler( DIALOG_RESCUE_EACH_BASE::OnHandleLibraryPreviewRepaint ), NULL, this );
|
||||
m_btnNeverShowAgain->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_RESCUE_EACH_BASE::OnNeverShowClick ), NULL, this );
|
||||
m_stdButtonsCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_RESCUE_EACH_BASE::OnCancelClick ), NULL, this );
|
||||
}
|
||||
|
@ -119,8 +136,6 @@ DIALOG_RESCUE_EACH_BASE::~DIALOG_RESCUE_EACH_BASE()
|
|||
// Disconnect Events
|
||||
this->Disconnect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_RESCUE_EACH_BASE::OnDialogResize ) );
|
||||
m_ListOfConflicts->Disconnect( wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, wxDataViewEventHandler( DIALOG_RESCUE_EACH_BASE::OnConflictSelect ), NULL, this );
|
||||
m_componentViewOld->Disconnect( wxEVT_PAINT, wxPaintEventHandler( DIALOG_RESCUE_EACH_BASE::OnHandleCachePreviewRepaint ), NULL, this );
|
||||
m_componentViewNew->Disconnect( wxEVT_PAINT, wxPaintEventHandler( DIALOG_RESCUE_EACH_BASE::OnHandleLibraryPreviewRepaint ), NULL, this );
|
||||
m_btnNeverShowAgain->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_RESCUE_EACH_BASE::OnNeverShowClick ), NULL, this );
|
||||
m_stdButtonsCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_RESCUE_EACH_BASE::OnCancelClick ), NULL, this );
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Aug 2 2018)
|
||||
// C++ code generated with wxFormBuilder (version Dec 30 2017)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
|
@ -20,11 +20,9 @@
|
|||
#include <wx/string.h>
|
||||
#include <wx/stattext.h>
|
||||
#include <wx/dataview.h>
|
||||
#include <wx/panel.h>
|
||||
#include <symbol_preview_widget.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/bitmap.h>
|
||||
#include <wx/image.h>
|
||||
#include <wx/icon.h>
|
||||
#include <wx/panel.h>
|
||||
#include <wx/button.h>
|
||||
#include <wx/dialog.h>
|
||||
|
||||
|
@ -44,10 +42,12 @@ class DIALOG_RESCUE_EACH_BASE : public DIALOG_SHIM
|
|||
wxDataViewListCtrl* m_ListOfConflicts;
|
||||
wxStaticText* m_titleInstances;
|
||||
wxDataViewListCtrl* m_ListOfInstances;
|
||||
wxStaticText* m_staticText2;
|
||||
wxPanel* m_componentViewOld;
|
||||
wxStaticText* m_staticText3;
|
||||
wxPanel* m_componentViewNew;
|
||||
wxStaticText* m_previewOldLabel;
|
||||
wxPanel* m_previewOldPanel;
|
||||
SYMBOL_PREVIEW_WIDGET* m_previewOldWidget;
|
||||
wxStaticText* m_previewNewLabel;
|
||||
wxPanel* m_previewNewPanel;
|
||||
SYMBOL_PREVIEW_WIDGET* m_previewNewWidget;
|
||||
wxButton* m_btnNeverShowAgain;
|
||||
wxStdDialogButtonSizer* m_stdButtons;
|
||||
wxButton* m_stdButtonsOK;
|
||||
|
@ -56,8 +56,6 @@ class DIALOG_RESCUE_EACH_BASE : public DIALOG_SHIM
|
|||
// Virtual event handlers, overide them in your derived class
|
||||
virtual void OnDialogResize( wxSizeEvent& event ) { event.Skip(); }
|
||||
virtual void OnConflictSelect( wxDataViewEvent& event ) { event.Skip(); }
|
||||
virtual void OnHandleCachePreviewRepaint( wxPaintEvent& event ) { event.Skip(); }
|
||||
virtual void OnHandleLibraryPreviewRepaint( wxPaintEvent& event ) { event.Skip(); }
|
||||
virtual void OnNeverShowClick( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); }
|
||||
|
||||
|
|
|
@ -29,12 +29,11 @@
|
|||
#include <pgm_base.h>
|
||||
|
||||
SYMBOL_PREVIEW_WIDGET::SYMBOL_PREVIEW_WIDGET( wxWindow* aParent, KIWAY& aKiway ) :
|
||||
wxPanel( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize,
|
||||
wxFULL_REPAINT_ON_RESIZE | wxTAB_TRAVERSAL ),
|
||||
wxPanel( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ),
|
||||
m_kiway( aKiway ),
|
||||
m_preview( nullptr ),
|
||||
m_status( nullptr ),
|
||||
m_sizer( nullptr ),
|
||||
m_statusSizer( nullptr ),
|
||||
m_previewItem( nullptr )
|
||||
{
|
||||
m_galDisplayOptions.ReadConfig( Pgm().CommonSettings(), GAL_DISPLAY_OPTIONS_KEY );
|
||||
|
@ -47,16 +46,16 @@ SYMBOL_PREVIEW_WIDGET::SYMBOL_PREVIEW_WIDGET( wxWindow* aParent, KIWAY& aKiway )
|
|||
SetForegroundColour( *wxBLACK );
|
||||
|
||||
m_status = new wxStaticText( this, -1, wxEmptyString );
|
||||
m_sizer = new wxBoxSizer( wxVERTICAL );
|
||||
m_sizer->Add( 0, 0, 1 );
|
||||
m_sizer->Add( m_status, 0, wxALL | wxALIGN_CENTER, 0 );
|
||||
m_sizer->Add( 0, 0, 1 );
|
||||
m_statusSizer = new wxBoxSizer( wxVERTICAL );
|
||||
m_statusSizer->Add( 0, 0, 1 );
|
||||
m_statusSizer->Add( m_status, 0, wxALL | wxALIGN_CENTER, 0 );
|
||||
m_statusSizer->Add( 0, 0, 1 );
|
||||
|
||||
auto outer_sizer = new wxBoxSizer( wxVERTICAL );
|
||||
outer_sizer->Add( m_preview, 1, wxALL | wxEXPAND, 0 );
|
||||
outer_sizer->Add( m_sizer, 1, wxALL | wxALIGN_CENTER, 0 );
|
||||
outer_sizer->Add( m_statusSizer, 1, wxALL | wxALIGN_CENTER, 0 );
|
||||
|
||||
m_sizer->ShowItems( false );
|
||||
m_statusSizer->ShowItems( false );
|
||||
|
||||
SetSizer( outer_sizer );
|
||||
}
|
||||
|
@ -72,7 +71,7 @@ SYMBOL_PREVIEW_WIDGET::~SYMBOL_PREVIEW_WIDGET()
|
|||
void SYMBOL_PREVIEW_WIDGET::SetStatusText( wxString const& aText )
|
||||
{
|
||||
m_status->SetLabel( aText );
|
||||
m_sizer->ShowItems( true );
|
||||
m_statusSizer->ShowItems( true );
|
||||
m_preview->Hide();
|
||||
Layout();
|
||||
}
|
||||
|
@ -131,8 +130,47 @@ void SYMBOL_PREVIEW_WIDGET::DisplaySymbol( const LIB_ID& aSymbolID, int aUnit )
|
|||
m_preview->ForceRefresh();
|
||||
|
||||
m_preview->Show();
|
||||
m_sizer->ShowItems( false );
|
||||
Layout();
|
||||
m_statusSizer->ShowItems( false );
|
||||
}
|
||||
|
||||
|
||||
void SYMBOL_PREVIEW_WIDGET::DisplayPart( LIB_PART* aPart, int aUnit )
|
||||
{
|
||||
KIGFX::VIEW* view = m_preview->GetView();
|
||||
|
||||
if( m_previewItem )
|
||||
{
|
||||
view->Remove( m_previewItem );
|
||||
m_previewItem = nullptr;
|
||||
}
|
||||
|
||||
if( aPart )
|
||||
{
|
||||
// If unit isn't specified for a multi-unit part, pick the first. (Otherwise we'll
|
||||
// draw all of them.)
|
||||
if( aPart->IsMulti() && aUnit == 0 )
|
||||
aUnit = 1;
|
||||
|
||||
view->Add( aPart );
|
||||
m_previewItem = aPart;
|
||||
|
||||
// Zoom to fit
|
||||
BOX2I bBox = aPart->GetUnitBoundingBox( aUnit, 0 );
|
||||
VECTOR2D clientSize = m_preview->GetClientSize();
|
||||
double scale = std::min( fabs( clientSize.x / bBox.GetWidth() ),
|
||||
fabs( clientSize.y / bBox.GetHeight() ) );
|
||||
|
||||
// Above calculation will yield an exact fit; add a bit of whitespace around symbol
|
||||
scale /= 1.2;
|
||||
|
||||
view->SetScale( scale );
|
||||
view->SetCenter( bBox.Centre() );
|
||||
}
|
||||
|
||||
m_preview->ForceRefresh();
|
||||
|
||||
m_preview->Show();
|
||||
m_statusSizer->ShowItems( false );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -25,8 +25,10 @@
|
|||
#include <gal/gal_display_options.h>
|
||||
|
||||
|
||||
class EDA_ITEM;
|
||||
class LIB_ID;
|
||||
class LIB_ALIAS;
|
||||
class LIB_PART;
|
||||
class EDA_DRAW_PANEL_GAL;
|
||||
class wxStaticText;
|
||||
class wxSizer;
|
||||
|
@ -56,6 +58,8 @@ public:
|
|||
*/
|
||||
void DisplaySymbol( const LIB_ID& aSymbolID, int aUnit );
|
||||
|
||||
void DisplayPart( LIB_PART* aPart, int aUnit );
|
||||
|
||||
private:
|
||||
KIWAY& m_kiway;
|
||||
|
||||
|
@ -63,9 +67,9 @@ private:
|
|||
EDA_DRAW_PANEL_GAL* m_preview;
|
||||
|
||||
wxStaticText* m_status;
|
||||
wxSizer* m_sizer;
|
||||
wxSizer* m_statusSizer;
|
||||
|
||||
LIB_ALIAS* m_previewItem;
|
||||
EDA_ITEM* m_previewItem;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue