diff --git a/3d-viewer/3d_viewer/eda_3d_viewer.cpp b/3d-viewer/3d_viewer/eda_3d_viewer.cpp index 04b8c0c843..ef567da375 100644 --- a/3d-viewer/3d_viewer/eda_3d_viewer.cpp +++ b/3d-viewer/3d_viewer/eda_3d_viewer.cpp @@ -102,8 +102,6 @@ EDA_3D_VIEWER::EDA_3D_VIEWER( KIWAY *aKiway, PCB_BASE_FRAME *aParent, const wxSt icon.CopyFromBitmap( KiBitmap( icon_3d_xpm ) ); SetIcon( icon ); - SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); - // Create the status line static const int status_dims[5] = { -1, -1, 130, 130, 170 }; diff --git a/common/eda_base_frame.cpp b/common/eda_base_frame.cpp index ba66474d1e..e354bc0524 100644 --- a/common/eda_base_frame.cpp +++ b/common/eda_base_frame.cpp @@ -64,6 +64,7 @@ BEGIN_EVENT_TABLE( EDA_BASE_FRAME, wxFrame ) EVT_MENU_CLOSE( EDA_BASE_FRAME::OnMenuEvent ) EVT_MENU_HIGHLIGHT_ALL( EDA_BASE_FRAME::OnMenuEvent ) EVT_MOVE( EDA_BASE_FRAME::OnMove ) + EVT_MAXIMIZE( EDA_BASE_FRAME::OnMaximize ) END_EVENT_TABLE() EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* aParent, FRAME_T aFrameType, @@ -81,6 +82,7 @@ EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* aParent, FRAME_T aFrameType, m_mruPath = wxStandardPaths::Get().GetDocumentsDir(); m_toolManager = nullptr; m_settingsManager = nullptr; + m_FrameSize = wxSize( s_minsize_x, s_minsize_y ); // Set a reasonable minimal size for the frame SetSizeHints( s_minsize_x, s_minsize_y, -1, -1, -1, -1 ); @@ -434,6 +436,10 @@ void EDA_BASE_FRAME::LoadWindowSettings( WINDOW_SETTINGS* aCfg ) m_FramePos = GetPosition(); } + // Record the frame sizes in an un-maximized state + m_NormalFrameSize = m_FrameSize; + m_NormalFramePos = m_FramePos; + // Maximize if we were maximized before if( aCfg->maximized ) { @@ -460,13 +466,22 @@ void EDA_BASE_FRAME::SaveWindowSettings( WINDOW_SETTINGS* aCfg ) wxString baseCfgName = ConfigBaseName(); - m_FrameSize = GetSize(); - m_FramePos = GetPosition(); + // If the window is maximized, we use the saved window size from before it was maximized + if( IsMaximized() ) + { + m_FramePos = m_NormalFramePos; + m_FrameSize = m_NormalFrameSize; + } + else + { + m_FrameSize = GetSize(); + m_FramePos = GetPosition(); + } - aCfg->pos_x = m_FramePos.x; - aCfg->pos_y = m_FramePos.y; - aCfg->size_x = m_FrameSize.x; - aCfg->size_y = m_FrameSize.y; + aCfg->pos_x = m_FramePos.x; + aCfg->pos_y = m_FramePos.y; + aCfg->size_x = m_FrameSize.x; + aCfg->size_y = m_FrameSize.y; aCfg->maximized = IsMaximized(); wxLogTrace( traceDisplayLocation, "Saving window maximized: %s", IsMaximized() ? "true" : "false" ); @@ -741,6 +756,7 @@ bool EDA_BASE_FRAME::IsContentModified() return false; } + void EDA_BASE_FRAME::ChangeUserUnits( EDA_UNITS aUnits ) { SetUserUnits( aUnits ); @@ -749,3 +765,23 @@ void EDA_BASE_FRAME::ChangeUserUnits( EDA_UNITS aUnits ) wxCommandEvent e( UNITS_CHANGED ); ProcessEventLocally( e ); } + + +void EDA_BASE_FRAME::OnMaximize( wxMaximizeEvent& aEvent ) +{ + // When we maximize the window, we want to save the old information + // so that we can add it to the settings on next window load. + // Contrary to the documentation, this event seems to be generated + // when the window is also being unmaximized, so we only capture the + // size information when we maximize the window. + if( !IsMaximized() ) + { + m_NormalFrameSize = GetSize(); + m_NormalFramePos = GetPosition(); + wxLogTrace( traceDisplayLocation, "Maximizing window - Saving position (%d, %d) with size (%d, %d)", + m_NormalFramePos.x, m_NormalFramePos.y, m_NormalFrameSize.x, m_NormalFrameSize.y ); + } + + // Skip event to actually maximize the window + aEvent.Skip(); +} diff --git a/cvpcb/cvpcb_mainframe.cpp b/cvpcb/cvpcb_mainframe.cpp index eb0f76569e..f90f869887 100644 --- a/cvpcb/cvpcb_mainframe.cpp +++ b/cvpcb/cvpcb_mainframe.cpp @@ -49,9 +49,6 @@ #include #include -wxSize const FRAME_MIN_SIZE_DU( 400, 300 ); -wxSize const FRAME_DEFAULT_SIZE_DU( 500, 400 ); - #define CVPCB_MAINFRAME_NAME wxT( "CvpcbFrame" ) @@ -79,13 +76,6 @@ CVPCB_MAINFRAME::CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent ) : LoadSettings( config() ); - wxSize const frame_min( ConvertDialogToPixels( FRAME_MIN_SIZE_DU ) ); - - SetSizeHints( frame_min ); - - // Frame size and position - SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); - setupTools(); ReCreateMenuBar(); ReCreateHToolbar(); @@ -373,11 +363,6 @@ void CVPCB_MAINFRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) { EDA_BASE_FRAME::LoadSettings( aCfg ); - wxSize const frame_default( ConvertDialogToPixels( FRAME_DEFAULT_SIZE_DU ) ); - - if( m_FrameSize == wxDefaultSize ) - m_FrameSize = frame_default; - auto cfg = static_cast( aCfg ); m_filteringOptions = cfg->m_FilterFootprint; diff --git a/cvpcb/display_footprints_frame.cpp b/cvpcb/display_footprints_frame.cpp index 2e9a0cfa42..ae79a97e1c 100644 --- a/cvpcb/display_footprints_frame.cpp +++ b/cvpcb/display_footprints_frame.cpp @@ -69,6 +69,17 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( KIWAY* aKiway, wxWindow* aPa SetBoard( new BOARD() ); SetScreen( new PCB_SCREEN( GetPageSizeIU() ) ); + // Create GAL canvas before loading settings +#ifdef __WXMAC__ + // Cairo renderer doesn't handle Retina displays + EDA_DRAW_PANEL_GAL::GAL_TYPE backend = EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL; +#else + EDA_DRAW_PANEL_GAL::GAL_TYPE backend = EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO; +#endif + auto* gal_drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize, + GetGalDisplayOptions(), backend ); + SetCanvas( gal_drawPanel ); + // Don't show the default board solder mask clearance. Only the // footprint or pad clearance setting should be shown if it is not 0. GetBoard()->GetDesignSettings().m_SolderMaskMargin = 0; @@ -89,20 +100,6 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( KIWAY* aKiway, wxWindow* aPa displ_opts.m_ShowTrackClearanceMode = PCB_DISPLAY_OPTIONS::DO_NOT_SHOW_CLEARANCE; SetDisplayOptions( displ_opts ); - // Create GAL canvas -#ifdef __WXMAC__ - // Cairo renderer doesn't handle Retina displays - EDA_DRAW_PANEL_GAL::GAL_TYPE backend = EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL; -#else - EDA_DRAW_PANEL_GAL::GAL_TYPE backend = EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO; -#endif - auto* gal_drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize, - GetGalDisplayOptions(), backend ); - SetCanvas( gal_drawPanel ); - - // Now all panels are created, set the window size to the latest saved in config: - SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); - // Create the manager and dispatcher & route draw panel events to the dispatcher m_toolManager = new TOOL_MANAGER; m_toolManager->SetEnvironment( GetBoard(), gal_drawPanel->GetView(), diff --git a/eeschema/lib_view_frame.cpp b/eeschema/lib_view_frame.cpp index d7da7d4e4f..e62eb0b1b1 100644 --- a/eeschema/lib_view_frame.cpp +++ b/eeschema/lib_view_frame.cpp @@ -141,8 +141,6 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame GetRenderSettings()->m_ShowPinsElectricalType = GetShowElectricalType(); GetCanvas()->GetGAL()->SetGridVisibility( IsGridVisible() ); - SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); - setupTools(); ReCreateMenuBar(); ReCreateHToolbar(); diff --git a/eeschema/libedit/lib_edit_frame.cpp b/eeschema/libedit/lib_edit_frame.cpp index c430b5b44a..daa58e334a 100644 --- a/eeschema/libedit/lib_edit_frame.cpp +++ b/eeschema/libedit/lib_edit_frame.cpp @@ -101,7 +101,6 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_DrawSpecificUnit = false; m_SyncPinEdit = false; SetShowElectricalType( true ); - m_FrameSize = ConvertDialogToPixels( wxSize( 500, 350 ) ); // default in case of no prefs m_my_part = nullptr; m_treePane = nullptr; diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 57f2aba757..0ef8ea0866 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -221,7 +221,6 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ): m_printMonochrome = true; m_printSheetReference = true; m_hasAutoSave = true; - m_FrameSize = ConvertDialogToPixels( wxSize( 500, 350 ) ); // default in case of no prefs m_AboutTitle = "Eeschema"; m_findReplaceDialog = nullptr; diff --git a/include/eda_base_frame.h b/include/eda_base_frame.h index c081da9a88..35afc1e88c 100644 --- a/include/eda_base_frame.h +++ b/include/eda_base_frame.h @@ -124,6 +124,10 @@ protected: wxPoint m_FramePos; wxSize m_FrameSize; + // These contain the frame size and position for when it is not maximized + wxPoint m_NormalFramePos; + wxSize m_NormalFrameSize; + wxString m_AboutTitle; // Name of program displayed in About. wxAuiManager m_auimgr; @@ -245,6 +249,8 @@ public: aEvent.Skip(); } + void OnMaximize( wxMaximizeEvent& aEvent ); + void SetAutoSaveInterval( int aInterval ); int GetAutoSaveInterval() const { return m_autoSaveInterval; } diff --git a/pcbnew/footprint_edit_frame.cpp b/pcbnew/footprint_edit_frame.cpp index 367381cb69..d0586a009f 100644 --- a/pcbnew/footprint_edit_frame.cpp +++ b/pcbnew/footprint_edit_frame.cpp @@ -108,7 +108,6 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent, KICAD_DEFAULT_DRAWFRAME_STYLE, GetFootprintEditorFrameName() ) { m_showBorderAndTitleBlock = false; // true to show the frame references - m_FrameSize = ConvertDialogToPixels( wxSize( 500, 350 ) ); // default in case of no prefs m_canvasType = aBackend; m_AboutTitle = "ModEdit"; m_selLayerBox = nullptr; diff --git a/pcbnew/footprint_viewer_frame.cpp b/pcbnew/footprint_viewer_frame.cpp index 8c2dbcc89d..b01f9b72f4 100644 --- a/pcbnew/footprint_viewer_frame.cpp +++ b/pcbnew/footprint_viewer_frame.cpp @@ -189,8 +189,6 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent LoadSettings( config() ); GetGalDisplayOptions().m_axesEnabled = true; - SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); - GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); // Create GAL canvas diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index 0010ed1282..3bea606be9 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -177,7 +177,6 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_hasAutoSave = true; m_microWaveToolBar = NULL; m_Layers = nullptr; - m_FrameSize = ConvertDialogToPixels( wxSize( 500, 350 ) ); // default in case of no prefs // We don't know what state board was in when it was lasat saved, so we have to // assume dirty