Fix several dialogs with bad default sizing
- Add helper methods for DPI-independent sizes - Make splitter sashes visible on macOS - Remove SetSizeInChars() - wx has a built-in way that I missed - DIALOG_CHOOSE_COMPONENT: DPI-indep splitter sizes - DIALOG_RESCUE_EACH: DPI-indep default size and sensible HTML window size - COMPONENT_TREE: DPI-indep sizing - DIALOG_FP_LIB_TABLE, DIALOG_SYMBOL_LIB_TABLE
This commit is contained in:
parent
53ae5c36f4
commit
13bc706518
|
@ -115,10 +115,26 @@ void DIALOG_SHIM::FinishDialogSettings()
|
|||
}
|
||||
|
||||
|
||||
void DIALOG_SHIM::SetSizeInChars( int x, int y )
|
||||
void DIALOG_SHIM::SetSizeInDU( int x, int y )
|
||||
{
|
||||
auto text_sz = GetTextExtent( "X" );
|
||||
SetSize( x * text_sz.x, y * text_sz.y );
|
||||
wxPoint sz( x, y );
|
||||
auto pixels_as_point = ConvertDialogToPixels( sz );
|
||||
wxSize pixels_as_size( pixels_as_point.x, pixels_as_point.y );
|
||||
SetSize( pixels_as_size );
|
||||
}
|
||||
|
||||
|
||||
int DIALOG_SHIM::HorizPixelsFromDU( int x )
|
||||
{
|
||||
wxPoint sz( x, 0 );
|
||||
return ConvertDialogToPixels( sz ).x;
|
||||
}
|
||||
|
||||
|
||||
int DIALOG_SHIM::VertPixelsFromDU( int y )
|
||||
{
|
||||
wxPoint sz( 0, y );
|
||||
return ConvertDialogToPixels( sz ).y;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -70,11 +70,11 @@ DIALOG_CHOOSE_COMPONENT::DIALOG_CHOOSE_COMPONENT( SCH_BASE_FRAME* aParent, const
|
|||
// Use a slightly different layout, with a details pane spanning the entire window,
|
||||
// if we're not showing footprints.
|
||||
auto vsplitter = aShowFootprints ? nullptr : new wxSplitterWindow(
|
||||
this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_LIVE_UPDATE );
|
||||
this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_LIVE_UPDATE | wxSP_3DSASH );
|
||||
|
||||
auto splitter = new wxSplitterWindow(
|
||||
vsplitter ? static_cast<wxWindow *>( vsplitter ) : static_cast<wxWindow *>( this ),
|
||||
wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_LIVE_UPDATE );
|
||||
wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_LIVE_UPDATE | wxSP_3DSASH );
|
||||
|
||||
auto details = aShowFootprints ? nullptr : new wxHtmlWindow(
|
||||
vsplitter, wxID_ANY, wxDefaultPosition, wxDefaultSize,
|
||||
|
@ -86,21 +86,10 @@ DIALOG_CHOOSE_COMPONENT::DIALOG_CHOOSE_COMPONENT( SCH_BASE_FRAME* aParent, const
|
|||
auto buttons = new wxStdDialogButtonSizer();
|
||||
m_dbl_click_timer = new wxTimer( this );
|
||||
|
||||
splitter->SetSashGravity( 0.9 );
|
||||
splitter->SetMinimumPaneSize( 1 );
|
||||
splitter->SplitVertically( m_tree, right_panel, -300 );
|
||||
|
||||
if( vsplitter )
|
||||
{
|
||||
vsplitter->SetSashGravity( 0.5 );
|
||||
vsplitter->SetMinimumPaneSize( 1 );
|
||||
vsplitter->SplitHorizontally( splitter, details, -200 );
|
||||
sizer->Add( vsplitter, 1, wxEXPAND | wxALL, 5 );
|
||||
}
|
||||
else
|
||||
{
|
||||
sizer->Add( splitter, 1, wxEXPAND | wxALL, 5 );
|
||||
}
|
||||
|
||||
buttons->AddButton( new wxButton( this, wxID_OK ) );
|
||||
buttons->AddButton( new wxButton( this, wxID_CANCEL ) );
|
||||
|
@ -124,16 +113,19 @@ DIALOG_CHOOSE_COMPONENT::DIALOG_CHOOSE_COMPONENT( SCH_BASE_FRAME* aParent, const
|
|||
Layout();
|
||||
|
||||
if( m_default_size == wxSize( -1, -1 ) )
|
||||
{
|
||||
#ifdef __WXMAC__
|
||||
SetSizeInChars( 60, 32 );
|
||||
#else
|
||||
SetSizeInChars( 80, 32 );
|
||||
#endif
|
||||
}
|
||||
SetSizeInDU( 320, 256 );
|
||||
else
|
||||
{
|
||||
SetSize( m_default_size );
|
||||
|
||||
splitter->SetSashGravity( 0.9 );
|
||||
splitter->SetMinimumPaneSize( 1 );
|
||||
splitter->SplitVertically( m_tree, right_panel, HorizPixelsFromDU( -100 ) );
|
||||
|
||||
if( vsplitter )
|
||||
{
|
||||
vsplitter->SetSashGravity( 0.5 );
|
||||
vsplitter->SetMinimumPaneSize( 1 );
|
||||
vsplitter->SplitHorizontally( splitter, details, VertPixelsFromDU( -80 ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Chris Pavlina <pavlina.chris@gmail.com>
|
||||
* Copyright (C) 2015-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2015-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -65,7 +64,6 @@ private:
|
|||
void OnCancelClick( wxCommandEvent& event ) override;
|
||||
void OnHandleCachePreviewRepaint( wxPaintEvent& aRepaintEvent ) override;
|
||||
void OnHandleLibraryPreviewRepaint( wxPaintEvent& aRepaintEvent ) override;
|
||||
void OnDialogResize( wxSizeEvent& aSizeEvent ) override;
|
||||
void renderPreview( LIB_PART* aComponent, int aUnit, wxPanel* panel );
|
||||
};
|
||||
|
||||
|
@ -122,6 +120,21 @@ DIALOG_RESCUE_EACH::DIALOG_RESCUE_EACH( SCH_EDIT_FRAME* aParent, RESCUER& aRescu
|
|||
|
||||
m_componentViewOld->SetLayoutDirection( wxLayout_LeftToRight );
|
||||
m_componentViewNew->SetLayoutDirection( wxLayout_LeftToRight );
|
||||
|
||||
Layout();
|
||||
SetSizeInDU( 280, 240 );
|
||||
|
||||
// Make sure the HTML window is large enough. Some fun size juggling and
|
||||
// fudge factors here but it does seem to work pretty reliably.
|
||||
auto info_size = m_htmlPrompt->GetTextExtent( info );
|
||||
auto prompt_size = m_htmlPrompt->GetSize();
|
||||
auto font_size = m_htmlPrompt->GetTextExtent( "X" );
|
||||
auto approx_info_height = ( 2 * info_size.x / prompt_size.x ) * font_size.y;
|
||||
m_htmlPrompt->SetSizeHints( 2 * prompt_size.x / 3, approx_info_height );
|
||||
Layout();
|
||||
GetSizer()->SetSizeHints( this );
|
||||
SetSizeInDU( 280, 240 );
|
||||
Center();
|
||||
}
|
||||
|
||||
|
||||
|
@ -141,11 +154,6 @@ bool DIALOG_RESCUE_EACH::TransferDataToWindow()
|
|||
if( !m_AskShowAgain )
|
||||
m_btnNeverShowAgain->Hide();
|
||||
|
||||
GetSizer()->Layout();
|
||||
GetSizer()->Fit( this );
|
||||
GetSizer()->SetSizeHints( this );
|
||||
Centre();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -232,13 +240,6 @@ void DIALOG_RESCUE_EACH::OnHandleLibraryPreviewRepaint( wxPaintEvent& aRepaintEv
|
|||
}
|
||||
|
||||
|
||||
void DIALOG_RESCUE_EACH::OnDialogResize( wxSizeEvent& aSizeEvent )
|
||||
{
|
||||
// Placeholder - I was previously doing some extra reflow here.
|
||||
DIALOG_RESCUE_EACH_BASE::OnDialogResize( aSizeEvent );
|
||||
}
|
||||
|
||||
|
||||
// Render the preview in our m_componentView. If this gets more complicated, we should
|
||||
// probably have a derived class from wxPanel; but this keeps things local.
|
||||
// Call it only from a Paint Event, because we are using a wxPaintDC to draw the component
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Nov 22 2017)
|
||||
// C++ code generated with wxFormBuilder (version Jan 2 2018)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
|
@ -11,7 +11,7 @@
|
|||
|
||||
DIALOG_RESCUE_EACH_BASE::DIALOG_RESCUE_EACH_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
|
||||
{
|
||||
this->SetSizeHints( wxSize( 500,-1 ), wxDefaultSize );
|
||||
this->SetSizeHints( wxSize( 400,-1 ), wxDefaultSize );
|
||||
|
||||
wxBoxSizer* bSizerMain;
|
||||
bSizerMain = new wxBoxSizer( wxVERTICAL );
|
||||
|
@ -101,6 +101,7 @@ DIALOG_RESCUE_EACH_BASE::DIALOG_RESCUE_EACH_BASE( wxWindow* parent, wxWindowID i
|
|||
|
||||
this->SetSizer( bSizerMain );
|
||||
this->Layout();
|
||||
bSizerMain->Fit( this );
|
||||
|
||||
this->Centre( wxBOTH );
|
||||
|
||||
|
|
|
@ -41,10 +41,10 @@
|
|||
<property name="hidden">0</property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="maximum_size"></property>
|
||||
<property name="minimum_size">500,-1</property>
|
||||
<property name="minimum_size">400,-1</property>
|
||||
<property name="name">DIALOG_RESCUE_EACH_BASE</property>
|
||||
<property name="pos"></property>
|
||||
<property name="size">500,-1</property>
|
||||
<property name="size">-1,-1</property>
|
||||
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
|
||||
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
|
||||
<property name="title">Project Rescue Helper</property>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Nov 22 2017)
|
||||
// C++ code generated with wxFormBuilder (version Jan 2 2018)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
|
@ -61,7 +61,7 @@ class DIALOG_RESCUE_EACH_BASE : public DIALOG_SHIM
|
|||
|
||||
public:
|
||||
|
||||
DIALOG_RESCUE_EACH_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Project Rescue Helper"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 500,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
|
||||
DIALOG_RESCUE_EACH_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Project Rescue Helper"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
|
||||
~DIALOG_RESCUE_EACH_BASE();
|
||||
|
||||
};
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2017 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2017-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
|
@ -217,6 +217,8 @@ DIALOG_SYMBOL_LIB_TABLE::DIALOG_SYMBOL_LIB_TABLE( wxTopLevelWindow* aParent,
|
|||
m_cur_grid = m_project_grid;
|
||||
}
|
||||
|
||||
SetSizeInDU( 360, 240 );
|
||||
|
||||
// On some window managers (Unity, XFCE), this dialog is
|
||||
// not always raised, depending on this dialog is run.
|
||||
// Force it to be raised
|
||||
|
|
|
@ -83,8 +83,10 @@ COMPONENT_TREE::COMPONENT_TREE( wxWindow* aParent, SYMBOL_LIB_TABLE* aSymLibTabl
|
|||
{
|
||||
if( !aDetails )
|
||||
{
|
||||
m_details_ctrl = new wxHtmlWindow( this, wxID_ANY, wxDefaultPosition, wxSize( 320, 240 ),
|
||||
wxHW_SCROLLBAR_AUTO | wxSUNKEN_BORDER );
|
||||
auto html_sz = ConvertDialogToPixels( wxPoint( 80, 80 ) );
|
||||
m_details_ctrl = new wxHtmlWindow(
|
||||
this, wxID_ANY, wxDefaultPosition, wxSize( html_sz.x, html_sz.y ),
|
||||
wxHW_SCROLLBAR_AUTO | wxSUNKEN_BORDER );
|
||||
|
||||
sizer->Add( m_details_ctrl, 1, wxALL | wxEXPAND, 5 );
|
||||
}
|
||||
|
|
|
@ -128,13 +128,23 @@ protected:
|
|||
void FinishDialogSettings();
|
||||
|
||||
/**
|
||||
* Set the dialog to given dimensions in character widths and heights.
|
||||
* This is useful for dialogs with highly flexible sizes, like the symbol chooser,
|
||||
* where standard methods of computing default dialog sizes are a bit useless.
|
||||
*
|
||||
* This should be called at the end of the constructor.
|
||||
* Set the dialog to the given dimensions in "dialog units". These are units equivalent
|
||||
* to 4* the average character width and 8* the average character height, allowing a dialog
|
||||
* to be sized in a way that scales it with the system font.
|
||||
*/
|
||||
void SetSizeInChars( int x, int y );
|
||||
void SetSizeInDU( int x, int y );
|
||||
|
||||
/**
|
||||
* Convert an integer number of dialog units to pixels, horizontally. See SetSizeInDU or
|
||||
* wxDialog documentation for more information.
|
||||
*/
|
||||
int HorizPixelsFromDU( int x );
|
||||
|
||||
/**
|
||||
* Convert an integer number of dialog units to pixels, vertically. See SetSizeInDU or
|
||||
* wxDialog documentation for more information.
|
||||
*/
|
||||
int VertPixelsFromDU( int y );
|
||||
|
||||
bool m_fixupsRun;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 2013 CERN
|
||||
* Copyright (C) 2012-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2012-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -243,6 +243,8 @@ public:
|
|||
// for ALT+A handling, we want the initial focus to be on the first selected grid.
|
||||
m_cur_grid->SetFocus();
|
||||
|
||||
SetSizeInDU( 360, 240 );
|
||||
|
||||
// On some windows manager (Unity, XFCE), this dialog is
|
||||
// not always raised, depending on this dialog is run.
|
||||
// Force it to be raised
|
||||
|
|
Loading…
Reference in New Issue