From 20e2dddc0b10fcfe81a4c404d2db07ab2f475fe9 Mon Sep 17 00:00:00 2001 From: Alex Shvartzkop Date: Mon, 27 May 2024 11:49:13 +0300 Subject: [PATCH] Make project manager text aligned with icons, also make it scrollable. --- kicad/dialogs/panel_kicad_launcher.cpp | 29 ++- kicad/dialogs/panel_kicad_launcher_base.cpp | 18 +- kicad/dialogs/panel_kicad_launcher_base.fbp | 185 +++++++++++++------- kicad/dialogs/panel_kicad_launcher_base.h | 13 +- 4 files changed, 145 insertions(+), 100 deletions(-) diff --git a/kicad/dialogs/panel_kicad_launcher.cpp b/kicad/dialogs/panel_kicad_launcher.cpp index 96a6d35f35..cab86228a0 100644 --- a/kicad/dialogs/panel_kicad_launcher.cpp +++ b/kicad/dialogs/panel_kicad_launcher.cpp @@ -46,7 +46,7 @@ void PANEL_KICAD_LAUNCHER::CreateLaunchers() { m_frame->SetPcmButton( nullptr ); - if( m_toolsSizer->GetRows() > 0 ) + if( m_toolsSizer->GetEffectiveRowsCount() > 0 ) { m_toolsSizer->Clear( true ); m_toolsSizer->SetRows( 0 ); @@ -64,10 +64,10 @@ void PANEL_KICAD_LAUNCHER::CreateLaunchers() auto addLauncher = [&]( const TOOL_ACTION& aAction, BITMAPS aBitmaps, const wxString& aHelpText, bool enabled = true ) { - BITMAP_BUTTON* btn = new BITMAP_BUTTON( this, wxID_ANY ); + BITMAP_BUTTON* btn = new BITMAP_BUTTON( m_scrolledWindow, wxID_ANY ); btn->SetBitmap( KiBitmapBundle( aBitmaps ) ); btn->SetDisabledBitmap( KiDisabledBitmapBundle( aBitmaps ) ); - btn->SetPadding( 5 ); + btn->SetPadding( FromDIP( 4 ) ); btn->SetToolTip( aAction.GetTooltip() ); auto handler = @@ -85,14 +85,15 @@ void PANEL_KICAD_LAUNCHER::CreateLaunchers() m_toolManager->ProcessEvent( *evt ); }; - wxStaticText* label = new wxStaticText( this, wxID_ANY, aAction.GetFriendlyName() ); - wxStaticText* help; + wxStaticText* label = new wxStaticText( m_scrolledWindow, wxID_ANY, wxEmptyString ); + wxStaticText* help = new wxStaticText( m_scrolledWindow, wxID_ANY, wxEmptyString ); label->SetToolTip( aAction.GetTooltip() ); label->SetFont( titleFont ); + label->SetLabel( aAction.GetFriendlyName() ); - help = new wxStaticText( this, wxID_ANY, aHelpText ); help->SetFont( helpFont ); + help->SetLabel( aHelpText ); btn->Bind( wxEVT_BUTTON, handler ); @@ -100,20 +101,14 @@ void PANEL_KICAD_LAUNCHER::CreateLaunchers() // any visual feedback that's a bit odd. Disabling for now. // label->Bind( wxEVT_LEFT_UP, handler ); - int row = m_toolsSizer->GetRows(); + m_toolsSizer->Add( btn, 1, wxALIGN_CENTER_VERTICAL ); - m_toolsSizer->Add( btn, wxGBPosition( row, 0 ), wxGBSpan( 2, 1 ), wxBOTTOM, 12 ); + wxBoxSizer* textSizer = new wxBoxSizer( wxVERTICAL ); - // Due to https://trac.wxwidgets.org/ticket/16088?cversion=0&cnum_hist=7 GTK fails to - // correctly set the BestSize of non-default-size or styled text so we need to make - // sure that the BestSize isn't needed by setting wxEXPAND. Unfortunately this makes - // wxALIGN_BOTTOM non-functional, so we have to jump through a bunch more hoops to - // try and align the title and help text in the middle of the icon. - m_toolsSizer->Add( label, wxGBPosition( row, 1 ), wxGBSpan( 1, 1 ), - wxTOP | wxEXPAND, 10 ); + textSizer->Add( label ); + textSizer->Add( help ); - m_toolsSizer->Add( help, wxGBPosition( row + 1, 1 ), wxGBSpan( 1, 1 ), - wxALIGN_TOP | wxTOP, 1 ); + m_toolsSizer->Add( textSizer, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL ); btn->Enable( enabled ); if( !enabled ) diff --git a/kicad/dialogs/panel_kicad_launcher_base.cpp b/kicad/dialogs/panel_kicad_launcher_base.cpp index 54a3deca06..9c9d4ac4be 100644 --- a/kicad/dialogs/panel_kicad_launcher_base.cpp +++ b/kicad/dialogs/panel_kicad_launcher_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 26 2018) +// C++ code generated with wxFormBuilder (version 4.1.0-0-g733bf3d) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -14,17 +14,17 @@ PANEL_KICAD_LAUNCHER_BASE::PANEL_KICAD_LAUNCHER_BASE( wxWindow* parent, wxWindow wxBoxSizer* bSizer2; bSizer2 = new wxBoxSizer( wxVERTICAL ); - m_mainSizer = new wxBoxSizer( wxVERTICAL ); - - m_toolsSizer = new wxGridBagSizer( 0, 10 ); + m_scrolledWindow = new wxScrolledWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL ); + m_scrolledWindow->SetScrollRate( 5, 5 ); + m_toolsSizer = new wxFlexGridSizer( 0, 2, 2, 10 ); m_toolsSizer->SetFlexibleDirection( wxBOTH ); - m_toolsSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_NONE ); + m_toolsSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - m_mainSizer->Add( m_toolsSizer, 0, wxALL|wxEXPAND, 5 ); - - - bSizer2->Add( m_mainSizer, 1, wxALL|wxEXPAND, 5 ); + m_scrolledWindow->SetSizer( m_toolsSizer ); + m_scrolledWindow->Layout(); + m_toolsSizer->Fit( m_scrolledWindow ); + bSizer2->Add( m_scrolledWindow, 1, wxEXPAND | wxALL, 5 ); this->SetSizer( bSizer2 ); diff --git a/kicad/dialogs/panel_kicad_launcher_base.fbp b/kicad/dialogs/panel_kicad_launcher_base.fbp index 9793911d93..1dbceb4f3d 100644 --- a/kicad/dialogs/panel_kicad_launcher_base.fbp +++ b/kicad/dialogs/panel_kicad_launcher_base.fbp @@ -1,88 +1,137 @@ - + - - - ; - C++ - 1 - source_name - 0 - 0 - res - UTF-8 - connect - panel_kicad_launcher_base - 1000 - none - - 1 - panel_kicad_launcher_base - - . - - 1 - 1 - 1 - 1 - UI - 0 - 0 - - 0 - wxAUI_MGR_DEFAULT + + + ; + C++ + 1 + source_name + 0 + 0 + res + UTF-8 + connect + panel_kicad_launcher_base + 1000 + none + + + 1 + panel_kicad_launcher_base + + . + + 1 + 1 + 1 + 1 + UI + 0 + 0 + 0 + + 0 + wxAUI_MGR_DEFAULT + + + 1 + 0 + 1 + impl_virtual + + + 0 + wxID_ANY + + + PANEL_KICAD_LAUNCHER_BASE + + -1,-1 + ; ; forward_declare + + 0 + + + wxTAB_TRAVERSAL + + + bSizer2 + wxVERTICAL + none + + 5 + wxEXPAND | wxALL + 1 + + 1 + 1 + 1 + 1 + + + + + + + 1 + 0 + 1 1 + 0 + Dock + 0 + Left + 0 1 - impl_virtual + 1 + 0 0 wxID_ANY + + 0 + + 0 - PANEL_KICAD_LAUNCHER_BASE + 1 + m_scrolledWindow + 1 + + + protected + 1 - -1,-1 + Resizable + 5 + 5 + 1 + ; ; forward_declare + 0 - wxTAB_TRAVERSAL - - - bSizer2 - wxVERTICAL - none - - 5 - wxALL|wxEXPAND - 1 - - - m_mainSizer - wxVERTICAL - protected - - 5 - wxALL|wxEXPAND - 0 - - - wxBOTH - - - 10 - -1,-1 - m_toolsSizer - wxFLEX_GROWMODE_NONE - protected - 0 - - - - + wxHSCROLL|wxVSCROLL + + 2 + wxBOTH + + + 10 + + m_toolsSizer + wxFLEX_GROWMODE_SPECIFIED + protected + 0 + 2 + + + diff --git a/kicad/dialogs/panel_kicad_launcher_base.h b/kicad/dialogs/panel_kicad_launcher_base.h index c7990b3529..b35c338bb9 100644 --- a/kicad/dialogs/panel_kicad_launcher_base.h +++ b/kicad/dialogs/panel_kicad_launcher_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 26 2018) +// C++ code generated with wxFormBuilder (version 4.1.0-0-g733bf3d) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -10,14 +10,14 @@ #include #include #include -#include -#include #include -#include +#include +#include #include #include #include #include +#include /////////////////////////////////////////////////////////////////////////// @@ -30,12 +30,13 @@ class PANEL_KICAD_LAUNCHER_BASE : public wxPanel private: protected: - wxBoxSizer* m_mainSizer; - wxGridBagSizer* m_toolsSizer; + wxScrolledWindow* m_scrolledWindow; + wxFlexGridSizer* m_toolsSizer; public: PANEL_KICAD_LAUNCHER_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); + ~PANEL_KICAD_LAUNCHER_BASE(); };