From 66d9e7073fbf5a3662bfd760ae466a697cfc9e9d Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 14 Nov 2021 15:01:00 +0000 Subject: [PATCH] More discrete borders for Kicad mgr, PCM and appearances panels. Fixes https://gitlab.com/kicad/code/kicad/issues/9616 --- common/CMakeLists.txt | 1 + common/widgets/wx_panel.cpp | 67 +++++++++++++++++++ include/widgets/wx_panel.h | 57 ++++++++++++++++ kicad/kicad_manager_frame.cpp | 2 +- kicad/pcm/dialogs/panel_package.cpp | 26 ------- kicad/pcm/dialogs/panel_package.h | 14 ---- kicad/pcm/dialogs/panel_packages_view.cpp | 2 + kicad/pcm/dialogs/panel_packages_view.h | 2 - .../pcm/dialogs/panel_packages_view_base.cpp | 4 +- .../pcm/dialogs/panel_packages_view_base.fbp | 2 +- kicad/pcm/dialogs/panel_packages_view_base.h | 4 +- kicad/project_tree_pane.cpp | 16 +++++ kicad/project_tree_pane.h | 7 +- pcbnew/widgets/appearance_controls.cpp | 1 + pcbnew/widgets/appearance_controls_base.cpp | 2 +- pcbnew/widgets/appearance_controls_base.fbp | 2 +- pcbnew/widgets/appearance_controls_base.h | 3 +- pcbnew/widgets/panel_selection_filter.cpp | 2 + .../widgets/panel_selection_filter_base.cpp | 2 +- .../widgets/panel_selection_filter_base.fbp | 2 +- pcbnew/widgets/panel_selection_filter_base.h | 3 +- 21 files changed, 166 insertions(+), 55 deletions(-) create mode 100644 common/widgets/wx_panel.cpp create mode 100644 include/widgets/wx_panel.h diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index e3c1d9302e..966a0d8e97 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -242,6 +242,7 @@ set( COMMON_WIDGET_SRCS widgets/wx_busy_indicator.cpp widgets/wx_ellipsized_static_text.cpp widgets/wx_grid.cpp + widgets/wx_panel.cpp widgets/wx_progress_reporters.cpp widgets/wx_splitter_window.cpp ) diff --git a/common/widgets/wx_panel.cpp b/common/widgets/wx_panel.cpp new file mode 100644 index 0000000000..2995068cf3 --- /dev/null +++ b/common/widgets/wx_panel.cpp @@ -0,0 +1,67 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2018-2021 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 Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include +#include +#include + +WX_PANEL::WX_PANEL( wxWindow* parent, wxWindowID id, const wxPoint& pos, + const wxSize& size, long style, const wxString& name ) : + wxPanel( parent, id, pos, size, style, name ), + m_leftBorder( false ), + m_rightBorder( false ), + m_topBorder( false ), + m_bottomBorder( false ) +{ + this->Connect( wxEVT_PAINT, wxPaintEventHandler( WX_PANEL::OnPaint ) ); +} + + +WX_PANEL::~WX_PANEL() +{ + this->Disconnect( wxEVT_PAINT, wxPaintEventHandler( WX_PANEL::OnPaint ) ); +} + + +void WX_PANEL::OnPaint( wxPaintEvent& event ) +{ + wxRect rect( wxPoint( 0, 0 ), GetClientSize() ); + wxPaintDC dc( this ); + + dc.SetBrush( wxSystemSettings::GetColour( wxSYS_COLOUR_FRAMEBK ) ); + dc.SetPen( wxPen( wxSystemSettings::GetColour( wxSYS_COLOUR_ACTIVEBORDER ), 1 ) ); + + if( m_leftBorder ) + dc.DrawLine( rect.GetLeft(), rect.GetTop(), rect.GetLeft(), rect.GetBottom() ); + + if( m_rightBorder ) + dc.DrawLine( rect.GetRight(), rect.GetTop(), rect.GetRight(), rect.GetBottom() ); + + if( m_topBorder ) + dc.DrawLine( rect.GetLeft(), rect.GetTop(), rect.GetRight(), rect.GetTop() ); + + if( m_bottomBorder ) + dc.DrawLine( rect.GetLeft(), rect.GetBottom(), rect.GetRight(), rect.GetBottom() ); +} + + diff --git a/include/widgets/wx_panel.h b/include/widgets/wx_panel.h new file mode 100644 index 0000000000..e429c07042 --- /dev/null +++ b/include/widgets/wx_panel.h @@ -0,0 +1,57 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2018, 2021 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 Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef WX_PANEL_H +#define WX_PANEL_H + +#include + +class WX_PANEL : public wxPanel +{ +public: + WX_PANEL( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, + const wxString& name = wxEmptyString ); + + ~WX_PANEL(); + + void SetBorders( bool aLeft, bool aRight, bool aTop, bool aBottom ) + { + m_leftBorder = aLeft; + m_rightBorder = aRight; + m_topBorder = aTop; + m_bottomBorder = aBottom; + } + +private: + void OnPaint( wxPaintEvent& event ); + +private: + bool m_leftBorder; + bool m_rightBorder; + bool m_topBorder; + bool m_bottomBorder; +}; + + +#endif //WX_PANEL_H diff --git a/kicad/kicad_manager_frame.cpp b/kicad/kicad_manager_frame.cpp index 6bec1d12ad..7ca215f93c 100644 --- a/kicad/kicad_manager_frame.cpp +++ b/kicad/kicad_manager_frame.cpp @@ -167,7 +167,7 @@ KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& titl // A trick is to use MinSize() to set the required pane width, // and after give a reasonable MinSize value m_auimgr.AddPane( m_leftWin, EDA_PANE().Palette().Name( "ProjectTree" ).Left().Layer( 1 ) - .Caption( _( "Project Files" ) ).PaneBorder( true ) + .Caption( _( "Project Files" ) ).PaneBorder( false ) .MinSize( m_leftWinWidth, -1 ).BestSize( m_leftWinWidth, -1 ) ); m_auimgr.AddPane( m_launcher, EDA_PANE().Canvas().Name( "Launcher" ).Center() diff --git a/kicad/pcm/dialogs/panel_package.cpp b/kicad/pcm/dialogs/panel_package.cpp index c8c13d636d..9cdf315ece 100644 --- a/kicad/pcm/dialogs/panel_package.cpp +++ b/kicad/pcm/dialogs/panel_package.cpp @@ -191,29 +191,3 @@ wxString PANEL_PACKAGE::GetPreferredVersion() const } -RIGHT_BORDERED_PANEL::RIGHT_BORDERED_PANEL( wxWindow* parent, wxWindowID id, const wxPoint& pos, - const wxSize& size, long style, const wxString& name ) : - wxPanel( parent, id, pos, size, style, name ) -{ - this->Connect( wxEVT_PAINT, wxPaintEventHandler( RIGHT_BORDERED_PANEL::OnPaint ) ); -} - - -RIGHT_BORDERED_PANEL::~RIGHT_BORDERED_PANEL() -{ - this->Disconnect( wxEVT_PAINT, wxPaintEventHandler( RIGHT_BORDERED_PANEL::OnPaint ) ); -} - - -void RIGHT_BORDERED_PANEL::OnPaint( wxPaintEvent& event ) -{ - wxRect rect( wxPoint( 0, 0 ), GetClientSize() ); - wxPaintDC dc( this ); - - dc.SetBrush( wxSystemSettings::GetColour( wxSYS_COLOUR_FRAMEBK ) ); - dc.SetPen( wxPen( wxSystemSettings::GetColour( wxSYS_COLOUR_ACTIVEBORDER ), 1 ) ); - - dc.DrawLine( rect.GetRight(), rect.GetTop(), rect.GetRight(), rect.GetBottom() ); -} - - diff --git a/kicad/pcm/dialogs/panel_package.h b/kicad/pcm/dialogs/panel_package.h index a3bc0d8e8a..243c944c8f 100644 --- a/kicad/pcm/dialogs/panel_package.h +++ b/kicad/pcm/dialogs/panel_package.h @@ -92,18 +92,4 @@ private: }; -class RIGHT_BORDERED_PANEL : public wxPanel -{ -public: - RIGHT_BORDERED_PANEL( wxWindow* parent, wxWindowID id = wxID_ANY, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, - const wxString& name = wxEmptyString ); - - ~RIGHT_BORDERED_PANEL(); - -private: - void OnPaint( wxPaintEvent& event ); -}; - #endif // PANEL_PACKAGE_H_ diff --git a/kicad/pcm/dialogs/panel_packages_view.cpp b/kicad/pcm/dialogs/panel_packages_view.cpp index dceb873fd7..34ff7d746c 100644 --- a/kicad/pcm/dialogs/panel_packages_view.cpp +++ b/kicad/pcm/dialogs/panel_packages_view.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -70,6 +71,7 @@ PANEL_PACKAGES_VIEW::PANEL_PACKAGES_VIEW( wxWindow* m_searchCtrl->Bind( wxEVT_TEXT, &PANEL_PACKAGES_VIEW::OnSearchTextChanged, this ); m_searchCtrl->SetDescriptiveText( _( "Filter" ) ); + m_panelList->SetBorders( false, true, false, false ); m_gridVersions->PushEventHandler( new GRID_TRICKS( m_gridVersions ) ); diff --git a/kicad/pcm/dialogs/panel_packages_view.h b/kicad/pcm/dialogs/panel_packages_view.h index fc26dbd3d1..caec8b1810 100644 --- a/kicad/pcm/dialogs/panel_packages_view.h +++ b/kicad/pcm/dialogs/panel_packages_view.h @@ -112,8 +112,6 @@ private: PANEL_PACKAGE* m_currentSelected; std::shared_ptr m_pcm; - int m_initSashPos; - enum PACKAGE_VERSIONS_GRID_COLUMNS { COL_VERSION = 0, diff --git a/kicad/pcm/dialogs/panel_packages_view_base.cpp b/kicad/pcm/dialogs/panel_packages_view_base.cpp index 178713dced..02262e1cb3 100644 --- a/kicad/pcm/dialogs/panel_packages_view_base.cpp +++ b/kicad/pcm/dialogs/panel_packages_view_base.cpp @@ -6,7 +6,7 @@ /////////////////////////////////////////////////////////////////////////// #include "html_window.h" -#include "panel_package.h" +#include "widgets/wx_panel.h" #include "panel_packages_view_base.h" @@ -21,7 +21,7 @@ PANEL_PACKAGES_VIEW_BASE::PANEL_PACKAGES_VIEW_BASE( wxWindow* parent, wxWindowID m_splitter1->SetSashGravity( 0.25 ); m_splitter1->Connect( wxEVT_IDLE, wxIdleEventHandler( PANEL_PACKAGES_VIEW_BASE::m_splitter1OnIdle ), NULL, this ); - m_panelList = new RIGHT_BORDERED_PANEL( m_splitter1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE|wxTAB_TRAVERSAL ); + m_panelList = new WX_PANEL( m_splitter1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE|wxTAB_TRAVERSAL ); wxBoxSizer* bPanelListSizer; bPanelListSizer = new wxBoxSizer( wxVERTICAL ); diff --git a/kicad/pcm/dialogs/panel_packages_view_base.fbp b/kicad/pcm/dialogs/panel_packages_view_base.fbp index 018855c68f..1c5c2e7eda 100644 --- a/kicad/pcm/dialogs/panel_packages_view_base.fbp +++ b/kicad/pcm/dialogs/panel_packages_view_base.fbp @@ -161,7 +161,7 @@ Resizable 1 - RIGHT_BORDERED_PANEL; panel_package.h; forward_declare + WX_PANEL; widgets/wx_panel.h; forward_declare 0 diff --git a/kicad/pcm/dialogs/panel_packages_view_base.h b/kicad/pcm/dialogs/panel_packages_view_base.h index 4e96b82cf2..d4a8015001 100644 --- a/kicad/pcm/dialogs/panel_packages_view_base.h +++ b/kicad/pcm/dialogs/panel_packages_view_base.h @@ -11,7 +11,7 @@ #include #include class HTML_WINDOW; -class RIGHT_BORDERED_PANEL; +class WX_PANEL; #include "widgets/wx_grid.h" #include "widgets/wx_splitter_window.h" @@ -45,7 +45,7 @@ class PANEL_PACKAGES_VIEW_BASE : public wxPanel protected: WX_SPLITTER_WINDOW* m_splitter1; - RIGHT_BORDERED_PANEL* m_panelList; + WX_PANEL* m_panelList; wxSearchCtrl* m_searchCtrl; wxScrolledWindow* m_packageListWindow; wxPanel* m_panelDetails; diff --git a/kicad/project_tree_pane.cpp b/kicad/project_tree_pane.cpp index abd42d588f..d2004d7d10 100644 --- a/kicad/project_tree_pane.cpp +++ b/kicad/project_tree_pane.cpp @@ -42,6 +42,8 @@ #include #include #include +#include +#include #include "project_tree_item.h" #include "project_tree.h" @@ -130,6 +132,7 @@ BEGIN_EVENT_TABLE( PROJECT_TREE_PANE, wxSashLayoutWindow ) EVT_MENU( ID_PROJECT_DELETE, PROJECT_TREE_PANE::onDeleteFile ) EVT_MENU( ID_PROJECT_RENAME, PROJECT_TREE_PANE::onRenameFile ) EVT_IDLE( PROJECT_TREE_PANE::onIdle ) + EVT_PAINT( PROJECT_TREE_PANE::onPaint ) END_EVENT_TABLE() @@ -1265,6 +1268,19 @@ void PROJECT_TREE_PANE::onThemeChanged( wxSysColourChangedEvent &aEvent ) } +void PROJECT_TREE_PANE::onPaint( wxPaintEvent& event ) +{ + wxRect rect( wxPoint( 0, 0 ), GetClientSize() ); + wxPaintDC dc( this ); + + dc.SetBrush( wxSystemSettings::GetColour( wxSYS_COLOUR_FRAMEBK ) ); + dc.SetPen( wxPen( wxSystemSettings::GetColour( wxSYS_COLOUR_ACTIVEBORDER ), 1 ) ); + + dc.DrawLine( rect.GetLeft(), rect.GetTop(), rect.GetLeft(), rect.GetBottom() ); + dc.DrawLine( rect.GetRight(), rect.GetTop(), rect.GetRight(), rect.GetBottom() ); +} + + void KICAD_MANAGER_FRAME::OnChangeWatchedPaths( wxCommandEvent& aEvent ) { m_leftWin->FileWatcherReset(); diff --git a/kicad/project_tree_pane.h b/kicad/project_tree_pane.h index fddc8e8c57..0c7b31b22b 100644 --- a/kicad/project_tree_pane.h +++ b/kicad/project_tree_pane.h @@ -147,7 +147,12 @@ private: * Idle event handler, used process the selected items at a point in time * when all other events have been consumed */ - void onIdle( wxIdleEvent &aEvent ); + void onIdle( wxIdleEvent& aEvent ); + + /** + * We don't have uniform borders so we have to draw them ourselves. + */ + void onPaint( wxPaintEvent& aEvent ); /** * Shutdown the file watcher. Used when closing to prevent post-free access into the project diff --git a/pcbnew/widgets/appearance_controls.cpp b/pcbnew/widgets/appearance_controls.cpp index 21b4a98a6e..bf82600f57 100644 --- a/pcbnew/widgets/appearance_controls.cpp +++ b/pcbnew/widgets/appearance_controls.cpp @@ -413,6 +413,7 @@ APPEARANCE_CONTROLS::APPEARANCE_CONTROLS( PCB_BASE_FRAME* aParent, wxWindow* aFo int screenHeight = wxSystemSettings::GetMetric( wxSYS_SCREEN_Y ); m_layerPanelColour = m_panelLayers->GetBackgroundColour().ChangeLightness( 110 ); + SetBorders( true, false, false, false ); m_layersOuterSizer = new wxBoxSizer( wxVERTICAL ); m_windowLayers->SetSizer( m_layersOuterSizer ); diff --git a/pcbnew/widgets/appearance_controls_base.cpp b/pcbnew/widgets/appearance_controls_base.cpp index 73011b1f34..605641b3fa 100644 --- a/pcbnew/widgets/appearance_controls_base.cpp +++ b/pcbnew/widgets/appearance_controls_base.cpp @@ -12,7 +12,7 @@ /////////////////////////////////////////////////////////////////////////// -APPEARANCE_CONTROLS_BASE::APPEARANCE_CONTROLS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name ) +APPEARANCE_CONTROLS_BASE::APPEARANCE_CONTROLS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : WX_PANEL( parent, id, pos, size, style, name ) { this->SetMinSize( wxSize( 200,360 ) ); diff --git a/pcbnew/widgets/appearance_controls_base.fbp b/pcbnew/widgets/appearance_controls_base.fbp index a434d9f8b9..3deb4897cc 100644 --- a/pcbnew/widgets/appearance_controls_base.fbp +++ b/pcbnew/widgets/appearance_controls_base.fbp @@ -44,7 +44,7 @@ APPEARANCE_CONTROLS_BASE 215,400 - ; ; forward_declare + WX_PANEL; widgets/wx_panel.h; forward_declare diff --git a/pcbnew/widgets/appearance_controls_base.h b/pcbnew/widgets/appearance_controls_base.h index 686f5f6234..a5b2ff8c3b 100644 --- a/pcbnew/widgets/appearance_controls_base.h +++ b/pcbnew/widgets/appearance_controls_base.h @@ -13,6 +13,7 @@ class BITMAP_BUTTON; class WX_GRID; +#include "widgets/wx_panel.h" #include #include #include @@ -37,7 +38,7 @@ class WX_GRID; /////////////////////////////////////////////////////////////////////////////// /// Class APPEARANCE_CONTROLS_BASE /////////////////////////////////////////////////////////////////////////////// -class APPEARANCE_CONTROLS_BASE : public wxPanel +class APPEARANCE_CONTROLS_BASE : public WX_PANEL { private: diff --git a/pcbnew/widgets/panel_selection_filter.cpp b/pcbnew/widgets/panel_selection_filter.cpp index ddc3d1330a..bb69820e2c 100644 --- a/pcbnew/widgets/panel_selection_filter.cpp +++ b/pcbnew/widgets/panel_selection_filter.cpp @@ -43,6 +43,8 @@ PANEL_SELECTION_FILTER::PANEL_SELECTION_FILTER( wxWindow* aParent ) : m_cbOtherItems->SetFont( font ); m_cbAllItems->SetFont( font ); + SetBorders( true, false, false, false ); + wxASSERT( m_frame ); m_tool = m_frame->GetToolManager()->GetTool(); wxASSERT( m_tool ); diff --git a/pcbnew/widgets/panel_selection_filter_base.cpp b/pcbnew/widgets/panel_selection_filter_base.cpp index 12b88b9c37..e5893dc027 100644 --- a/pcbnew/widgets/panel_selection_filter_base.cpp +++ b/pcbnew/widgets/panel_selection_filter_base.cpp @@ -9,7 +9,7 @@ /////////////////////////////////////////////////////////////////////////// -PANEL_SELECTION_FILTER_BASE::PANEL_SELECTION_FILTER_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name ) +PANEL_SELECTION_FILTER_BASE::PANEL_SELECTION_FILTER_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : WX_PANEL( parent, id, pos, size, style, name ) { wxGridBagSizer* gbSizer1; gbSizer1 = new wxGridBagSizer( 0, 0 ); diff --git a/pcbnew/widgets/panel_selection_filter_base.fbp b/pcbnew/widgets/panel_selection_filter_base.fbp index ef60def31d..f358b00ab3 100644 --- a/pcbnew/widgets/panel_selection_filter_base.fbp +++ b/pcbnew/widgets/panel_selection_filter_base.fbp @@ -44,7 +44,7 @@ PANEL_SELECTION_FILTER_BASE 249,146 - ; ; forward_declare + WX_PANEL; widgets/wx_panel.h; forward_declare diff --git a/pcbnew/widgets/panel_selection_filter_base.h b/pcbnew/widgets/panel_selection_filter_base.h index e2f4f580c1..8ff997746c 100644 --- a/pcbnew/widgets/panel_selection_filter_base.h +++ b/pcbnew/widgets/panel_selection_filter_base.h @@ -10,6 +10,7 @@ #include #include #include +#include "widgets/wx_panel.h" #include #include #include @@ -25,7 +26,7 @@ /////////////////////////////////////////////////////////////////////////////// /// Class PANEL_SELECTION_FILTER_BASE /////////////////////////////////////////////////////////////////////////////// -class PANEL_SELECTION_FILTER_BASE : public wxPanel +class PANEL_SELECTION_FILTER_BASE : public WX_PANEL { private: