pleditor: Ensure toolbars are redrawn when icon size changes

This ensures the icon scaling factor is applied to the toolbars,
and also fixes a drawing artifact where the old dropdown boxes
would still be visible on top of the scaled icons (with the new
ones in their proper place.
This commit is contained in:
Ian McInerney 2020-10-01 19:50:09 +01:00
parent 481026e901
commit f736cc15b6
2 changed files with 25 additions and 8 deletions

View File

@ -79,18 +79,20 @@ END_EVENT_TABLE()
PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
EDA_DRAW_FRAME( aKiway, aParent, FRAME_PL_EDITOR, wxT( "PlEditorFrame" ),
wxDefaultPosition, wxDefaultSize,
KICAD_DEFAULT_DRAWFRAME_STYLE, PL_EDITOR_FRAME_NAME )
KICAD_DEFAULT_DRAWFRAME_STYLE, PL_EDITOR_FRAME_NAME ),
m_propertiesFrameWidth( 200 ),
m_originSelectBox( nullptr ),
m_originSelectChoice( 0 ),
m_pageSelectBox( nullptr ),
m_propertiesPagelayout( nullptr )
{
m_userUnits = EDA_UNITS::MILLIMETRES;
m_showBorderAndTitleBlock = true; // true for reference drawings.
m_originSelectChoice = 0;
WS_DATA_MODEL::GetTheInstance().m_EditMode = true;
SetShowPageLimits( true );
m_AboutTitle = "PlEditor";
m_propertiesFrameWidth = 200;
// Give an icon
wxIcon icon;
icon.CopyFromBitmap( KiBitmap( icon_pagelayout_editor_xpm ) );
@ -597,6 +599,10 @@ void PL_EDITOR_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVar
GetCanvas()->GetView()->UpdateAllItems( KIGFX::COLOR );
GetCanvas()->Refresh();
RecreateToolbars();
Layout();
SendSizeEvent();
}

View File

@ -80,17 +80,24 @@ void PL_EDITOR_FRAME::ReCreateHToolbar()
_("Left Top page corner")
};
m_originSelectBox = new wxChoice( m_mainToolBar, ID_SELECT_COORDINATE_ORIGIN,
wxDefaultPosition, wxDefaultSize, 5, choiceList );
if( !m_originSelectBox )
{
m_originSelectBox = new wxChoice( m_mainToolBar, ID_SELECT_COORDINATE_ORIGIN,
wxDefaultPosition, wxDefaultSize, 5, choiceList );
}
m_mainToolBar->AddControl( m_originSelectBox );
m_originSelectBox->SetToolTip( _("Origin of coordinates displayed to the status bar") );
int minwidth = 0;
for( int ii = 0; ii < 5; ii++ )
{
int width = GetTextSize( choiceList[ii], m_originSelectBox ).x;
minwidth = std::max( minwidth, width );
}
m_originSelectBox->SetMinSize( wxSize( minwidth, -1 ) );
m_originSelectBox->SetSelection( m_originSelectChoice );
@ -100,8 +107,12 @@ void PL_EDITOR_FRAME::ReCreateHToolbar()
_("Other pages")
};
m_pageSelectBox = new wxChoice( m_mainToolBar, ID_SELECT_PAGE_NUMBER,
wxDefaultPosition, wxDefaultSize, 2, pageList );
if( !m_pageSelectBox )
{
m_pageSelectBox = new wxChoice( m_mainToolBar, ID_SELECT_PAGE_NUMBER,
wxDefaultPosition, wxDefaultSize, 2, pageList );
}
m_mainToolBar->AddControl( m_pageSelectBox );
m_pageSelectBox->SetToolTip( _("Simulate page 1 or other pages to show how items\n"\
"which are not on all page are displayed") );