From ad59254be887b5cb9278027f08ee9b70568ba87d Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 10 Sep 2021 18:35:45 +0100 Subject: [PATCH] Another round of font sizing tweaks. It appears that both strategies in the last commit worked, leaving us with squared scaling. The dialog pixel architecture seems safer than our icon scaling stuff, so this version attempts to use only it. Also works around a bug where wxELLIPSIZE_MIDDLE doesn't work on Mac. Fixes https://gitlab.com/kicad/code/kicad/issues/8608 Fixes https://gitlab.com/kicad/code/kicad/issues/8375 --- common/tool/action_menu.cpp | 2 +- common/widgets/ui_common.cpp | 21 +++++---------- common/widgets/wx_grid.cpp | 10 ++++--- kicad/dialogs/panel_kicad_launcher.cpp | 18 ++++++------- kicad/kicad_manager_frame.cpp | 26 ++++++++++++++----- kicad/project_tree.cpp | 2 +- .../dialogs/dialog_footprint_properties.cpp | 5 ++-- .../dialog_footprint_properties_fp_editor.cpp | 5 ++-- 8 files changed, 46 insertions(+), 43 deletions(-) diff --git a/common/tool/action_menu.cpp b/common/tool/action_menu.cpp index b788f30887..45afd6cc11 100644 --- a/common/tool/action_menu.cpp +++ b/common/tool/action_menu.cpp @@ -338,7 +338,7 @@ void ACTION_MENU::updateHotKeys() const TOOL_ACTION& action = *ii.second; int key = toolMgr->GetHotKey( action ) & ~MD_MODIFIER_MASK; - if( key >= 0 ) + if( key > 0 ) { int mod = toolMgr->GetHotKey( action ) & MD_MODIFIER_MASK; int flags = 0; diff --git a/common/widgets/ui_common.cpp b/common/widgets/ui_common.cpp index b911ea5ce5..c407357e34 100644 --- a/common/widgets/ui_common.cpp +++ b/common/widgets/ui_common.cpp @@ -98,21 +98,12 @@ wxFont makeGUIFont( wxWindow* aWindow, int aDialogSize ) { wxFont font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ); - // Using wxFont::SetSymbolicSize() fails on (at least) GTK with HiDPI screens, so we have - // to build our own version based off our icon scaling architecture. + // Using wxFont::SetSymbolicSize() fails on (at least) GTK with HiDPI screens, but the + // dialog pixel conversion stuff seems to work.... int vert_size = aWindow->ConvertDialogToPixels( wxSize( 0, aDialogSize ) ).y; - if( Pgm().GetCommonSettings()->m_Appearance.icon_scale > 0 ) - vert_size *= Pgm().GetCommonSettings()->m_Appearance.icon_scale / 4; - - if( vert_size < 7 ) - vert_size = 7; - - if( vert_size < 10 ) - vert_size += 1; - - font.SetPointSize( vert_size ); + font.SetPointSize( vert_size / 2 ); #ifdef __WXMAC__ // https://trac.wxwidgets.org/ticket/19210 @@ -126,19 +117,19 @@ wxFont makeGUIFont( wxWindow* aWindow, int aDialogSize ) wxFont KIUI::GetControlFont( wxWindow* aWindow ) { - return makeGUIFont( aWindow, 7 ); + return makeGUIFont( aWindow, 14 ); } wxFont KIUI::GetInfoFont( wxWindow* aWindow ) { - return makeGUIFont( aWindow, 6 ); + return makeGUIFont( aWindow, 13 ); } wxFont KIUI::GetStatusFont( wxWindow* aWindow ) { - return makeGUIFont( aWindow, 5 ); + return makeGUIFont( aWindow, 11 ); } diff --git a/common/widgets/wx_grid.cpp b/common/widgets/wx_grid.cpp index d7decce4a9..64a941be99 100644 --- a/common/widgets/wx_grid.cpp +++ b/common/widgets/wx_grid.cpp @@ -41,7 +41,6 @@ WX_GRID::WX_GRID( wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxS // Make sure the GUI font scales properly on GTK SetDefaultCellFont( KIUI::GetControlFont( this ) ); - } @@ -60,10 +59,13 @@ void WX_GRID::SetColLabelSize( int aHeight ) return; } - // correct wxFormBuilder height for large fonts - wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ); - int minHeight = guiFont.GetPixelSize().y + 2 * MIN_GRIDCELL_MARGIN; + // Make sure the GUI font scales properly on GTK + wxFont headingFont = KIUI::GetInfoFont( this ); + headingFont.MakeBold(); + SetLabelFont( headingFont ); + // Correct wxFormBuilder height for large fonts + int minHeight = headingFont.GetPixelSize().y + 2 * MIN_GRIDCELL_MARGIN; wxGrid::SetColLabelSize( std::max( aHeight, minHeight ) ); } diff --git a/kicad/dialogs/panel_kicad_launcher.cpp b/kicad/dialogs/panel_kicad_launcher.cpp index 0b35e33fee..6d3c970481 100644 --- a/kicad/dialogs/panel_kicad_launcher.cpp +++ b/kicad/dialogs/panel_kicad_launcher.cpp @@ -104,41 +104,41 @@ void PANEL_KICAD_LAUNCHER::CreateLaunchers() }; addLauncher( KICAD_MANAGER_ACTIONS::editSchematic, - KiBitmap( BITMAPS::icon_eeschema, 48 ), + KiScaledBitmap( BITMAPS::icon_eeschema, this, 48 ), _( "Edit the project schematic" ) ); addLauncher( KICAD_MANAGER_ACTIONS::editSymbols, - KiBitmap( BITMAPS::icon_libedit, 48 ), + KiScaledBitmap( BITMAPS::icon_libedit, this, 48 ), _( "Edit global and/or project schematic symbol libraries" ) ); addLauncher( KICAD_MANAGER_ACTIONS::editPCB, - KiBitmap( BITMAPS::icon_pcbnew, 48 ), + KiScaledBitmap( BITMAPS::icon_pcbnew, this, 48 ), _( "Edit the project PCB design" ) ); addLauncher( KICAD_MANAGER_ACTIONS::editFootprints, - KiBitmap( BITMAPS::icon_modedit, 48 ), + KiScaledBitmap( BITMAPS::icon_modedit, this, 48 ), _( "Edit global and/or project PCB footprint libraries" ) ); addLauncher( KICAD_MANAGER_ACTIONS::viewGerbers, - KiBitmap( BITMAPS::icon_gerbview, 48 ), + KiScaledBitmap( BITMAPS::icon_gerbview, this, 48 ), _( "Preview Gerber files" ) ); addLauncher( KICAD_MANAGER_ACTIONS::convertImage, - KiBitmap( BITMAPS::icon_bitmap2component, 48 ), + KiScaledBitmap( BITMAPS::icon_bitmap2component, this, 48 ), _( "Convert bitmap images to schematic symbols or PCB footprints" ) ); addLauncher( KICAD_MANAGER_ACTIONS::showCalculator, - KiBitmap( BITMAPS::icon_pcbcalculator, 48 ), + KiScaledBitmap( BITMAPS::icon_pcbcalculator, this, 48 ), _( "Show tools for calculating resistance, current capacity, etc." ) ); addLauncher( KICAD_MANAGER_ACTIONS::editDrawingSheet, - KiBitmap( BITMAPS::icon_pagelayout_editor, 48 ), + KiScaledBitmap( BITMAPS::icon_pagelayout_editor, this, 48 ), _( "Edit drawing sheet borders and title blocks for use in schematics and PCB " "designs" ) ); #ifdef PCM addLauncher( KICAD_MANAGER_ACTIONS::showPluginManager, - KiBitmap( BITMAPS::icon_pcm, 48 ), + KiScaledBitmap( BITMAPS::icon_pcm, this, 48 ), _( "Manage downloadable packages from KiCad and 3rd party repositories" ) ); #endif diff --git a/kicad/kicad_manager_frame.cpp b/kicad/kicad_manager_frame.cpp index 3425b57b59..d0088b143a 100644 --- a/kicad/kicad_manager_frame.cpp +++ b/kicad/kicad_manager_frame.cpp @@ -52,6 +52,7 @@ #include #include #include +#include #include @@ -122,12 +123,10 @@ KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& titl wxXmlDocument dummy; #endif - // Create the status line (bottom of the frame) - static const int dims[2] = { -1, -1 }; - - CreateStatusBar( 2, wxSTB_SIZEGRIP | wxSTB_SHOW_TIPS | wxSTB_ELLIPSIZE_MIDDLE | - wxFULL_REPAINT_ON_RESIZE ); - SetStatusWidths( 2, dims ); + // Create the status line (bottom of the frame). Left half is for project name; right half + // is for Reporter (currently used by archiver/unarchiver). + CreateStatusBar( 2 ); + GetStatusBar()->SetFont( KIUI::GetStatusFont( this ) ); // Give an icon wxIcon icon; @@ -346,6 +345,8 @@ void KICAD_MANAGER_FRAME::OnSize( wxSizeEvent& event ) if( m_auimgr.GetManagedWindow() ) m_auimgr.Update(); + PrintPrjInfo(); + event.Skip(); } @@ -681,8 +682,19 @@ void KICAD_MANAGER_FRAME::InstallPreferences( PAGED_DIALOG* aParent, void KICAD_MANAGER_FRAME::PrintPrjInfo() { - SetStatusText( wxString::Format( _( "Project: %s" ), Prj().GetProjectFullName() ) ); + // wxStatusBar's wxELLIPSIZE_MIDDLE flag doesn't work (at least on Mac). + wxString status = wxString::Format( _( "Project: %s" ), Prj().GetProjectFullName() ); + wxStatusBar* statusBar = GetStatusBar(); + int width = statusBar->GetSize().GetWidth() / 2; + + if( width > 20 ) + { + wxClientDC dc( this ); + status = wxControl::Ellipsize( status, dc, wxELLIPSIZE_MIDDLE, width ); + } + + SetStatusText( status ); } diff --git a/kicad/project_tree.cpp b/kicad/project_tree.cpp index 4348e7c866..26198fab1d 100644 --- a/kicad/project_tree.cpp +++ b/kicad/project_tree.cpp @@ -49,7 +49,7 @@ PROJECT_TREE::PROJECT_TREE( PROJECT_TREE_PANE* parent ) : m_projectTreePane = parent; // Make sure the GUI font scales properly on GTK - SetFont( KIUI::GetControlFont( this ) ); + SetFont( KIUI::GetInfoFont( this ) ); // icons size is not know (depending on they are built) // so get it: diff --git a/pcbnew/dialogs/dialog_footprint_properties.cpp b/pcbnew/dialogs/dialog_footprint_properties.cpp index 271d8f7f2f..e0554dd3bd 100644 --- a/pcbnew/dialogs/dialog_footprint_properties.cpp +++ b/pcbnew/dialogs/dialog_footprint_properties.cpp @@ -114,15 +114,14 @@ DIALOG_FOOTPRINT_PROPERTIES::DIALOG_FOOTPRINT_PROPERTIES( PCB_EDIT_FRAME* aParen m_allow90Label->SetFont( infoFont ); m_allow180Label->SetFont( infoFont ); #endif - m_staticTextInfoCopper->SetFont( infoFont ); - m_staticTextInfoPaste->SetFont( infoFont ); - m_libraryIDLabel->SetFont( infoFont ); m_tcLibraryID->SetFont( infoFont ); infoFont.SetStyle( wxFONTSTYLE_ITALIC ); m_staticTextInfoValNeg->SetFont( infoFont ); m_staticTextInfoValPos->SetFont( infoFont ); + m_staticTextInfoCopper->SetFont( infoFont ); + m_staticTextInfoPaste->SetFont( infoFont ); m_NoteBook->SetSelection( m_page ); diff --git a/pcbnew/dialogs/dialog_footprint_properties_fp_editor.cpp b/pcbnew/dialogs/dialog_footprint_properties_fp_editor.cpp index 49d374b18b..f50b350a64 100644 --- a/pcbnew/dialogs/dialog_footprint_properties_fp_editor.cpp +++ b/pcbnew/dialogs/dialog_footprint_properties_fp_editor.cpp @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include @@ -106,12 +105,12 @@ DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR( m_allow90Label->SetFont( infoFont ); m_allow180Label->SetFont( infoFont ); #endif - m_staticTextInfoCopper->SetFont( infoFont ); - m_staticTextInfoPaste->SetFont( infoFont ); infoFont.SetStyle( wxFONTSTYLE_ITALIC ); m_staticTextInfoValNeg->SetFont( infoFont ); m_staticTextInfoValPos->SetFont( infoFont ); + m_staticTextInfoCopper->SetFont( infoFont ); + m_staticTextInfoPaste->SetFont( infoFont ); if( static_cast( m_page ) >= 0 ) m_NoteBook->SetSelection( (unsigned) m_page );