Add MRU to image placement tools

(cherry picked from commit faa3829ad4)
This commit is contained in:
Seth Hillbrand 2022-02-25 13:18:43 -08:00
parent 69bd4218f7
commit 23351b2046
4 changed files with 9 additions and 3 deletions

View File

@ -62,6 +62,7 @@ SCH_DRAWING_TOOLS::SCH_DRAWING_TOOLS() :
m_lastTextOrientation( LABEL_SPIN_STYLE::RIGHT ),
m_lastTextBold( false ),
m_lastTextItalic( false ),
m_mruPath( wxEmptyString ),
m_inPlaceSymbol( false ),
m_inPlaceImage( false ),
m_inSingleClickPlace( false ),
@ -489,7 +490,7 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
// having an auto-pan
EDA_RECT canvas_area = GetCanvasFreeAreaPixels();
wxFileDialog dlg( m_frame, _( "Choose Image" ), wxEmptyString, wxEmptyString,
wxFileDialog dlg( m_frame, _( "Choose Image" ), m_mruPath, wxEmptyString,
_( "Image Files" ) + wxS( " " ) + wxImage::GetImageExtWildcard(),
wxFD_OPEN );
@ -510,6 +511,7 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
cursorPos = controls->GetMousePosition( true );
wxString fullFilename = dlg.GetPath();
m_mruPath = wxPathOnly( fullFilename );
if( wxFileExists( fullFilename ) )
image = new SCH_BITMAP( (wxPoint)cursorPos );

View File

@ -88,6 +88,7 @@ private:
LABEL_SPIN_STYLE m_lastTextOrientation;
bool m_lastTextBold;
bool m_lastTextItalic;
wxString m_mruPath;
///< Re-entrancy guards
bool m_inPlaceSymbol;

View File

@ -89,7 +89,8 @@ PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
m_propertiesFrameWidth( 200 ),
m_originSelectBox( nullptr ),
m_originSelectChoice( 0 ),
m_pageSelectBox( nullptr )
m_pageSelectBox( nullptr ),
m_mruImagePath( wxEmptyString )
{
m_maximizeByDefault = true;
m_userUnits = EDA_UNITS::MILLIMETRES;
@ -849,7 +850,7 @@ DS_DATA_ITEM* PL_EDITOR_FRAME::AddDrawingSheetItem( int aType )
case DS_DATA_ITEM::DS_BITMAP:
{
wxFileDialog fileDlg( this, _( "Choose Image" ), wxEmptyString, wxEmptyString,
wxFileDialog fileDlg( this, _( "Choose Image" ), m_mruImagePath, wxEmptyString,
_( "Image Files" ) + wxS( " " ) + wxImage::GetImageExtWildcard(),
wxFD_OPEN );
@ -857,6 +858,7 @@ DS_DATA_ITEM* PL_EDITOR_FRAME::AddDrawingSheetItem( int aType )
return nullptr;
wxString fullFilename = fileDlg.GetPath();
m_mruImagePath = wxPathOnly( fullFilename );
if( !wxFileExists( fullFilename ) )
{

View File

@ -285,6 +285,7 @@ private:
int m_originSelectChoice; // the last choice for m_originSelectBox
wxChoice* m_pageSelectBox; // The page number sel'ector (page 1 or other pages
// useful when there are some items which are
wxString m_mruImagePath; // Most recently used path for placing a new image
// only on page 1, not on page 1
wxPoint m_grid_origin;
};