From a06e3bef33354a08f7f6334994abb19a5b4c8b6c Mon Sep 17 00:00:00 2001 From: Chris Pavlina Date: Sun, 7 Jan 2018 00:06:57 -0700 Subject: [PATCH] Layer Setup: DPI-independent default size Also, remove a wxPanel border as it makes device-independent sizing nearly impossible. For some reason wxPanel::GetClientSize() is returning garbage here and breaks centering text without fudge factors. I think it still looks good without the border, maybe better. --- pcbnew/dialogs/dialog_layers_setup.cpp | 17 +++++++++-------- pcbnew/dialogs/dialog_layers_setup_base.cpp | 6 +++--- pcbnew/dialogs/dialog_layers_setup_base.fbp | 6 +++--- pcbnew/dialogs/dialog_layers_setup_base.h | 2 +- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/pcbnew/dialogs/dialog_layers_setup.cpp b/pcbnew/dialogs/dialog_layers_setup.cpp index a40a74df6a..3d71e0ac35 100644 --- a/pcbnew/dialogs/dialog_layers_setup.cpp +++ b/pcbnew/dialogs/dialog_layers_setup.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2009 Isaac Marino Bavaresco, isaacbavaresco@yahoo.com.br * Copyright (C) 2009 SoftPLC Corporation, Dick Hollenbeck - * Copyright (C) 2009-2017 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2009-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 @@ -207,16 +207,19 @@ private: int offset = 0; wxSize txtz; + wxSize panel_sz = m_TitlePanel->GetSize(); + int voffset = panel_sz.y/2 - VertPixelsFromDU( 4 ); + txtz = m_nameStaticText->GetSize(); - m_nameStaticText->Move( offset + (widths[0] - txtz.x)/2, 5 ); + m_nameStaticText->Move( offset + (widths[0] - txtz.x)/2, voffset ); offset += widths[0]; txtz = m_enabledStaticText->GetSize(); - m_enabledStaticText->Move( offset + (widths[1] - txtz.x)/2, 5 ); + m_enabledStaticText->Move( offset + (widths[1] - txtz.x)/2, voffset ); offset += widths[1]; txtz = m_typeStaticText->GetSize(); - m_typeStaticText->Move( offset + (widths[2] - txtz.x)/2, 5 ); + m_typeStaticText->Move( offset + (widths[2] - txtz.x)/2, voffset ); } void OnSize( wxSizeEvent& event ) override; @@ -348,14 +351,12 @@ void DIALOG_LAYERS_SETUP::OnInitDialog( wxInitDialogEvent& aEvent ) { wxWindowBase::OnInitDialog( aEvent ); - // set the height of the title panel to be the size of any wxStaticText object - // plus 10 so we can have a border of 5 on both top and bottom. - m_TitlePanel->SetMinSize( wxSize( -1, m_AdhesFrontName->GetSize().y+10 ) ); + m_TitlePanel->SetMinSize( wxSize( -1, VertPixelsFromDU( 10 ) ) ); m_LayersListPanel->ShowScrollbars( wxSHOW_SB_ALWAYS, wxSHOW_SB_ALWAYS ); Layout(); - Fit(); + SetSizeInDU( 240, 240 ); Center(); m_sdbSizerOK->SetFocus(); diff --git a/pcbnew/dialogs/dialog_layers_setup_base.cpp b/pcbnew/dialogs/dialog_layers_setup_base.cpp index 2605d1ef22..f468aab5f9 100644 --- a/pcbnew/dialogs/dialog_layers_setup_base.cpp +++ b/pcbnew/dialogs/dialog_layers_setup_base.cpp @@ -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_LAYERS_SETUP_BASE::DIALOG_LAYERS_SETUP_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( -1,500 ), wxSize( -1,550 ) ); + this->SetSizeHints( wxSize( 200,200 ), wxSize( -1,-1 ) ); wxBoxSizer* bMainSizer; bMainSizer = new wxBoxSizer( wxVERTICAL ); @@ -98,7 +98,7 @@ DIALOG_LAYERS_SETUP_BASE::DIALOG_LAYERS_SETUP_BASE( wxWindow* parent, wxWindowID wxBoxSizer* bCaptionsSizer; bCaptionsSizer = new wxBoxSizer( wxHORIZONTAL ); - m_TitlePanel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxRAISED_BORDER|wxTAB_TRAVERSAL ); + m_TitlePanel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); m_TitlePanel->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_CAPTIONTEXT ) ); m_TitlePanel->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_ACTIVECAPTION ) ); m_TitlePanel->SetMinSize( wxSize( -1,15 ) ); diff --git a/pcbnew/dialogs/dialog_layers_setup_base.fbp b/pcbnew/dialogs/dialog_layers_setup_base.fbp index bcac33ce08..cba94a5a24 100644 --- a/pcbnew/dialogs/dialog_layers_setup_base.fbp +++ b/pcbnew/dialogs/dialog_layers_setup_base.fbp @@ -40,8 +40,8 @@ 0 wxID_ANY - -1,550 - -1,500 + -1,-1 + 200,200 DIALOG_LAYERS_SETUP_BASE -1,-1 @@ -909,7 +909,7 @@ - wxRAISED_BORDER|wxTAB_TRAVERSAL + wxTAB_TRAVERSAL diff --git a/pcbnew/dialogs/dialog_layers_setup_base.h b/pcbnew/dialogs/dialog_layers_setup_base.h index c1b4e98fc1..3da7b15dc0 100644 --- a/pcbnew/dialogs/dialog_layers_setup_base.h +++ b/pcbnew/dialogs/dialog_layers_setup_base.h @@ -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!