Fix some issue in the pin conflicts map with button alignment on Mac.
Fixes https://gitlab.com/kicad/code/kicad/issues/13333
This commit is contained in:
parent
77ee82459e
commit
13d196c509
|
@ -35,6 +35,7 @@
|
|||
#include <wx/bmpbuttn.h>
|
||||
#include <wx/statline.h>
|
||||
#include <wx/stattext.h>
|
||||
#include <widgets/bitmap_button.h>
|
||||
|
||||
|
||||
// Control identifiers for events
|
||||
|
@ -71,16 +72,16 @@ void PANEL_SETUP_PINMAP::reBuildMatrixPanel()
|
|||
{
|
||||
// Try to know the size of bitmap button used in drc matrix
|
||||
wxBitmapButton* dummy = new wxBitmapButton( m_matrixPanel, wxID_ANY, KiBitmap( BITMAPS::ercerr ) );
|
||||
wxSize bmapSize = dummy->GetSize();
|
||||
wxSize bitmapSize = dummy->GetSize();
|
||||
delete dummy;
|
||||
|
||||
wxSize charSize = KIUI::GetTextSize( "X", m_matrixPanel );
|
||||
wxPoint pos( 0, charSize.y * 2 );
|
||||
wxStaticText* text;
|
||||
wxPoint offset( 2, 3 );
|
||||
|
||||
#ifdef __WXMAC__
|
||||
bmapSize.y += 2;
|
||||
charSize.y += 2;
|
||||
bitmapSize += { 4, 2 };
|
||||
#endif
|
||||
|
||||
if( !m_initialized )
|
||||
|
@ -90,9 +91,9 @@ void PANEL_SETUP_PINMAP::reBuildMatrixPanel()
|
|||
// Print row labels
|
||||
for( int ii = 0; ii < ELECTRICAL_PINTYPES_TOTAL; ii++ )
|
||||
{
|
||||
int y = pos.y + (ii * bmapSize.y);
|
||||
int y = pos.y + (ii * bitmapSize.y);
|
||||
text = new wxStaticText( m_matrixPanel, -1, CommentERC_H[ii],
|
||||
wxPoint( 5, y + ( bmapSize.y / 2 ) - ( 12 / 2 ) ) );
|
||||
wxPoint( 5, y + ( bitmapSize.y / 2 ) - charSize.y / 2 ) );
|
||||
labels.push_back( text );
|
||||
|
||||
int x = text->GetRect().GetRight();
|
||||
|
@ -114,34 +115,38 @@ void PANEL_SETUP_PINMAP::reBuildMatrixPanel()
|
|||
pos = m_buttonList[0][0]->GetPosition();
|
||||
}
|
||||
|
||||
#ifdef __WXMAC__
|
||||
charSize += { 0, 2 };
|
||||
#endif
|
||||
|
||||
for( int ii = 0; ii < ELECTRICAL_PINTYPES_TOTAL; ii++ )
|
||||
{
|
||||
int y = pos.y + (ii * bmapSize.y);
|
||||
int y = pos.y + (ii * bitmapSize.y);
|
||||
|
||||
for( int jj = 0; jj <= ii; jj++ )
|
||||
{
|
||||
// Add column labels (only once)
|
||||
PIN_ERROR diag = m_schematic->ErcSettings().GetPinMapValue( ii, jj );
|
||||
|
||||
int x = pos.x + ( jj * ( bmapSize.x + 2 ) );
|
||||
int x = pos.x + ( jj * ( bitmapSize.x - 2 ) );
|
||||
|
||||
if( ( ii == jj ) && !m_initialized )
|
||||
{
|
||||
wxPoint textPos( x + KiROUND( bmapSize.x / 2 ) - KiROUND( charSize.x ),
|
||||
wxPoint textPos( x + KiROUND( bitmapSize.x / 2 ) - KiROUND( charSize.x ),
|
||||
y - charSize.y * 2 );
|
||||
new wxStaticText( m_matrixPanel, wxID_ANY, CommentERC_V[ii], textPos );
|
||||
new wxStaticText( m_matrixPanel, wxID_ANY, CommentERC_V[ii], textPos + offset );
|
||||
|
||||
wxPoint calloutPos( x + KiROUND( bmapSize.x / 2 ) - KiROUND( charSize.x / 2 ),
|
||||
y - charSize.y );
|
||||
new wxStaticText( m_matrixPanel, wxID_ANY, "|", calloutPos );
|
||||
wxPoint calloutPos( x + KiROUND( bitmapSize.x / 2 ) - KiROUND( charSize.x / 2 ),
|
||||
y - charSize.y - 2 );
|
||||
new wxStaticText( m_matrixPanel, wxID_ANY, "|", calloutPos + offset );
|
||||
}
|
||||
|
||||
int event_id = ID_MATRIX_0 + ii + ( jj * ELECTRICAL_PINTYPES_TOTAL );
|
||||
int id = ID_MATRIX_0 + ii + ( jj * ELECTRICAL_PINTYPES_TOTAL );
|
||||
BITMAPS bitmap_butt = BITMAPS::erc_green;
|
||||
|
||||
delete m_buttonList[ii][jj];
|
||||
wxBitmapButton* btn = new wxBitmapButton( m_matrixPanel, event_id,
|
||||
KiBitmap( bitmap_butt ), wxPoint( x, y ) );
|
||||
BITMAP_BUTTON* btn = new BITMAP_BUTTON( m_matrixPanel, id, KiBitmap( bitmap_butt ),
|
||||
wxPoint( x, y ), bitmapSize );
|
||||
|
||||
#ifdef __WXMAC__
|
||||
btn->SetSize( btn->GetSize().x - 1, btn->GetSize().y );
|
||||
|
@ -157,7 +162,7 @@ void PANEL_SETUP_PINMAP::reBuildMatrixPanel()
|
|||
}
|
||||
|
||||
|
||||
void PANEL_SETUP_PINMAP::setDRCMatrixButtonState( wxBitmapButton *aButton, PIN_ERROR aState )
|
||||
void PANEL_SETUP_PINMAP::setDRCMatrixButtonState( BITMAP_BUTTON *aButton, PIN_ERROR aState )
|
||||
{
|
||||
BITMAPS bitmap_butt = BITMAPS::INVALID_BITMAP;
|
||||
wxString tooltip;
|
||||
|
@ -197,7 +202,7 @@ void PANEL_SETUP_PINMAP::changeErrorLevel( wxCommandEvent& event )
|
|||
int ii = id - ID_MATRIX_0;
|
||||
int x = ii / ELECTRICAL_PINTYPES_TOTAL;
|
||||
int y = ii % ELECTRICAL_PINTYPES_TOTAL;
|
||||
wxBitmapButton* butt = (wxBitmapButton*) event.GetEventObject();
|
||||
BITMAP_BUTTON* butt = (BITMAP_BUTTON*) event.GetEventObject();
|
||||
|
||||
int level = static_cast<int>( m_schematic->ErcSettings().GetPinMapValue( y, x ) );
|
||||
level = ( level + 1 ) % 3;
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
class SCH_EDIT_FRAME;
|
||||
class SCHEMATIC;
|
||||
class wxBitmapButton;
|
||||
class BITMAP_BUTTON;
|
||||
|
||||
|
||||
class PANEL_SETUP_PINMAP : public PANEL_SETUP_PINMAP_BASE
|
||||
|
@ -48,13 +48,13 @@ public:
|
|||
private:
|
||||
void changeErrorLevel( wxCommandEvent& event );
|
||||
void reBuildMatrixPanel();
|
||||
void setDRCMatrixButtonState( wxBitmapButton *aButton, PIN_ERROR aState );
|
||||
void setDRCMatrixButtonState( BITMAP_BUTTON *aButton, PIN_ERROR aState );
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
SCH_EDIT_FRAME* m_parent;
|
||||
SCHEMATIC* m_schematic;
|
||||
wxBitmapButton* m_buttonList[ELECTRICAL_PINTYPES_TOTAL][ELECTRICAL_PINTYPES_TOTAL];
|
||||
BITMAP_BUTTON* m_buttonList[ELECTRICAL_PINTYPES_TOTAL][ELECTRICAL_PINTYPES_TOTAL];
|
||||
bool m_initialized;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue