More window sizing fixes
* Push all sizing operations into EDA_BASE_FRAME * Save the unmaximized window size when maximizing so that we can then save it in the config if the window is maximized. Otherwise the config ends up with the maximized size saved, and weird behavior occurs when unmaximizing on the next opening.
This commit is contained in:
parent
127df701da
commit
d006acecf4
|
@ -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 };
|
||||
|
||||
|
|
|
@ -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,8 +466,17 @@ void EDA_BASE_FRAME::SaveWindowSettings( WINDOW_SETTINGS* aCfg )
|
|||
|
||||
wxString baseCfgName = ConfigBaseName();
|
||||
|
||||
// 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;
|
||||
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -49,9 +49,6 @@
|
|||
#include <tools/cvpcb_association_tool.h>
|
||||
#include <tools/cvpcb_control.h>
|
||||
|
||||
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<CVPCB_SETTINGS*>( aCfg );
|
||||
|
||||
m_filteringOptions = cfg->m_FilterFootprint;
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue