More discrete borders for Kicad mgr, PCM and appearances panels.

Fixes https://gitlab.com/kicad/code/kicad/issues/9616
This commit is contained in:
Jeff Young 2021-11-14 15:01:00 +00:00
parent 591fbf6383
commit 66d9e7073f
21 changed files with 166 additions and 55 deletions

View File

@ -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
)

View File

@ -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 <widgets/wx_panel.h>
#include <wx/dcclient.h>
#include <wx/settings.h>
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() );
}

View File

@ -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 <wx/panel.h>
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

View File

@ -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()

View File

@ -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() );
}

View File

@ -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_

View File

@ -25,6 +25,7 @@
#include <settings/settings_manager.h>
#include <settings/common_settings.h>
#include <widgets/wx_splitter_window.h>
#include <widgets/wx_panel.h>
#include <string_utils.h>
#include <html_window.h>
@ -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 ) );

View File

@ -112,8 +112,6 @@ private:
PANEL_PACKAGE* m_currentSelected;
std::shared_ptr<PLUGIN_CONTENT_MANAGER> m_pcm;
int m_initSashPos;
enum PACKAGE_VERSIONS_GRID_COLUMNS
{
COL_VERSION = 0,

View File

@ -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 );

View File

@ -161,7 +161,7 @@
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="subclass">RIGHT_BORDERED_PANEL; panel_package.h; forward_declare</property>
<property name="subclass">WX_PANEL; widgets/wx_panel.h; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>

View File

@ -11,7 +11,7 @@
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
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;

View File

@ -42,6 +42,8 @@
#include <core/kicad_algo.h>
#include <paths.h>
#include <launch_ext.h>
#include <wx/dcclient.h>
#include <wx/settings.h>
#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();

View File

@ -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

View File

@ -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 );

View File

@ -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 ) );

View File

@ -44,7 +44,7 @@
<property name="name">APPEARANCE_CONTROLS_BASE</property>
<property name="pos"></property>
<property name="size">215,400</property>
<property name="subclass">; ; forward_declare</property>
<property name="subclass">WX_PANEL; widgets/wx_panel.h; forward_declare</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>

View File

@ -13,6 +13,7 @@
class BITMAP_BUTTON;
class WX_GRID;
#include "widgets/wx_panel.h"
#include <wx/scrolwin.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
@ -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:

View File

@ -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<PCB_SELECTION_TOOL>();
wxASSERT( m_tool );

View File

@ -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 );

View File

@ -44,7 +44,7 @@
<property name="name">PANEL_SELECTION_FILTER_BASE</property>
<property name="pos"></property>
<property name="size">249,146</property>
<property name="subclass">; ; forward_declare</property>
<property name="subclass">WX_PANEL; widgets/wx_panel.h; forward_declare</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>

View File

@ -10,6 +10,7 @@
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
#include "widgets/wx_panel.h"
#include <wx/string.h>
#include <wx/checkbox.h>
#include <wx/gdicmn.h>
@ -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: