mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-20 00:21:31 +00:00
Splitter bar for netclass setup.
Fixes https://gitlab.com/kicad/code/kicad/issues/7668
This commit is contained in:
parent
e251cf067a
commit
efae25e24e
@ -23,6 +23,9 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <pgm_base.h>
|
||||
#include <base_units.h>
|
||||
#include <bitmaps.h>
|
||||
#include <netclass.h>
|
||||
@ -36,8 +39,6 @@
|
||||
#include <widgets/grid_icon_text_helpers.h>
|
||||
#include <widgets/grid_text_helpers.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
// PCBNEW columns of netclasses grid
|
||||
enum {
|
||||
GRID_NAME = 0,
|
||||
@ -90,14 +91,6 @@ PANEL_SETUP_NETCLASSES::PANEL_SETUP_NETCLASSES( PAGED_DIALOG* aParent, NETCLASSE
|
||||
|
||||
m_netclassesDirty = true;
|
||||
|
||||
// Figure out the smallest the netclass membership pane can ever be so that nothing is cutoff
|
||||
// and force it to be that size.
|
||||
m_membershipSize = GetSize();
|
||||
m_membershipSize.y -= m_netclassesPane->GetSize().y;
|
||||
m_membershipSize.x = -1;
|
||||
m_membershipPane->SetMinSize( m_membershipSize );
|
||||
m_membershipPane->SetMaxSize( m_membershipSize );
|
||||
|
||||
// Prevent Size events from firing before we are ready
|
||||
Freeze();
|
||||
m_netclassGrid->BeginBatch();
|
||||
@ -170,6 +163,9 @@ PANEL_SETUP_NETCLASSES::PANEL_SETUP_NETCLASSES( PAGED_DIALOG* aParent, NETCLASSE
|
||||
attr->SetRenderer( new GRID_CELL_ESCAPED_TEXT_RENDERER );
|
||||
m_membershipGrid->SetColAttr( 0, attr );
|
||||
|
||||
COMMON_SETTINGS* cfg = Pgm().GetCommonSettings();
|
||||
m_splitter->SetSashPosition( cfg->m_NetclassPanel.sash_pos );
|
||||
|
||||
m_addButton->SetBitmap( KiBitmap( small_plus_xpm ) );
|
||||
m_removeButton->SetBitmap( KiBitmap( small_trash_xpm ) );
|
||||
|
||||
@ -191,6 +187,9 @@ PANEL_SETUP_NETCLASSES::PANEL_SETUP_NETCLASSES( PAGED_DIALOG* aParent, NETCLASSE
|
||||
|
||||
PANEL_SETUP_NETCLASSES::~PANEL_SETUP_NETCLASSES()
|
||||
{
|
||||
COMMON_SETTINGS* cfg = Pgm().GetCommonSettings();
|
||||
cfg->m_NetclassPanel.sash_pos = m_splitter->GetSashPosition();
|
||||
|
||||
delete [] m_originalColWidths;
|
||||
|
||||
// Delete the GRID_TRICKS.
|
||||
@ -676,23 +675,6 @@ void PANEL_SETUP_NETCLASSES::OnUpdateUI( wxUpdateUIEvent& event )
|
||||
rebuildNetclassDropdowns();
|
||||
m_netclassesDirty = false;
|
||||
}
|
||||
|
||||
// Recompute the desired size for the two content panes. We cannot leave this sizing to
|
||||
// wxWidgets because it wants to shrink the membership panel to an unusable size when the
|
||||
// netlist panel grows, and also it introduces undesired artifacts when the window is resized
|
||||
// and the panes can grow/shrink.
|
||||
wxSize netclassSize = GetClientSize();
|
||||
netclassSize.y -= m_membershipSize.y;
|
||||
|
||||
// Modify m_netclassesPane size only if needed, because calling Layout() has the annoying
|
||||
// effect of closing any open wxChoice dropdowns. So it cannot blindly called inside each
|
||||
// wxUpdateUIEvent event, at least on Windows + wxWidgets 3.0 (not an issue with 3.1.1).
|
||||
if( netclassSize.y != m_netclassesPane->GetSize().y )
|
||||
{
|
||||
m_netclassesPane->SetMinSize( netclassSize );
|
||||
m_netclassesPane->SetMaxSize( netclassSize );
|
||||
Layout();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -19,11 +19,13 @@ PANEL_SETUP_NETCLASSES_BASE::PANEL_SETUP_NETCLASSES_BASE( wxWindow* parent, wxWi
|
||||
wxBoxSizer* bMargins;
|
||||
bMargins = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_netclassesPane = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
|
||||
wxStaticBoxSizer* sbSizerUpper;
|
||||
sbSizerUpper = new wxStaticBoxSizer( new wxStaticBox( m_netclassesPane, wxID_ANY, _("Net Classes") ), wxVERTICAL );
|
||||
m_splitter = new wxSplitterWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3DSASH|wxSP_LIVE_UPDATE|wxSP_NO_XP_THEME );
|
||||
m_splitter->SetMinimumPaneSize( 80 );
|
||||
|
||||
m_netclassesPane = new wxPanel( m_splitter, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
|
||||
wxBoxSizer* bUpperSizer;
|
||||
bUpperSizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
sbSizerUpper->SetMinSize( wxSize( -1,140 ) );
|
||||
m_netclassGrid = new WX_GRID( m_netclassesPane, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_DEFAULT|wxHSCROLL|wxTAB_TRAVERSAL|wxVSCROLL );
|
||||
|
||||
// Grid
|
||||
@ -37,7 +39,7 @@ PANEL_SETUP_NETCLASSES_BASE::PANEL_SETUP_NETCLASSES_BASE( wxWindow* parent, wxWi
|
||||
m_netclassGrid->EnableDragColMove( false );
|
||||
m_netclassGrid->EnableDragColSize( true );
|
||||
m_netclassGrid->SetColLabelSize( 24 );
|
||||
m_netclassGrid->SetColLabelValue( 0, _("Name") );
|
||||
m_netclassGrid->SetColLabelValue( 0, _("Net Class") );
|
||||
m_netclassGrid->SetColLabelValue( 1, _("Clearance") );
|
||||
m_netclassGrid->SetColLabelValue( 2, _("Track Width") );
|
||||
m_netclassGrid->SetColLabelValue( 3, _("Via Size") );
|
||||
@ -62,32 +64,30 @@ PANEL_SETUP_NETCLASSES_BASE::PANEL_SETUP_NETCLASSES_BASE( wxWindow* parent, wxWi
|
||||
|
||||
// Cell Defaults
|
||||
m_netclassGrid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP );
|
||||
sbSizerUpper->Add( m_netclassGrid, 1, wxEXPAND, 5 );
|
||||
bUpperSizer->Add( m_netclassGrid, 1, wxEXPAND|wxLEFT, 2 );
|
||||
|
||||
wxBoxSizer* buttonBoxSizer;
|
||||
buttonBoxSizer = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
m_addButton = new wxBitmapButton( m_netclassesPane, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( -1,-1 ), wxBU_AUTODRAW|0 );
|
||||
buttonBoxSizer->Add( m_addButton, 0, wxRIGHT, 5 );
|
||||
buttonBoxSizer->Add( m_addButton, 0, wxLEFT, 2 );
|
||||
|
||||
|
||||
buttonBoxSizer->Add( 0, 0, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 );
|
||||
buttonBoxSizer->Add( 5, 0, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
m_removeButton = new wxBitmapButton( m_netclassesPane, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( -1,-1 ), wxBU_AUTODRAW|0 );
|
||||
buttonBoxSizer->Add( m_removeButton, 0, wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
|
||||
sbSizerUpper->Add( buttonBoxSizer, 0, wxTOP|wxEXPAND, 2 );
|
||||
bUpperSizer->Add( buttonBoxSizer, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 );
|
||||
|
||||
|
||||
m_netclassesPane->SetSizer( sbSizerUpper );
|
||||
m_netclassesPane->SetSizer( bUpperSizer );
|
||||
m_netclassesPane->Layout();
|
||||
sbSizerUpper->Fit( m_netclassesPane );
|
||||
bMargins->Add( m_netclassesPane, 2, wxALL|wxEXPAND, 5 );
|
||||
|
||||
m_membershipPane = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
|
||||
wxStaticBoxSizer* sbMembership;
|
||||
sbMembership = new wxStaticBoxSizer( new wxStaticBox( m_membershipPane, wxID_ANY, _("Net Class Memberships") ), wxHORIZONTAL );
|
||||
bUpperSizer->Fit( m_netclassesPane );
|
||||
m_membershipPane = new wxPanel( m_splitter, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
|
||||
wxBoxSizer* bLowerSizer;
|
||||
bLowerSizer = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
wxBoxSizer* bLeft;
|
||||
bLeft = new wxBoxSizer( wxVERTICAL );
|
||||
@ -112,35 +112,35 @@ PANEL_SETUP_NETCLASSES_BASE::PANEL_SETUP_NETCLASSES_BASE( wxWindow* parent, wxWi
|
||||
|
||||
sbFilters->Add( bSizer9, 0, wxEXPAND, 5 );
|
||||
|
||||
wxBoxSizer* bSizer10;
|
||||
bSizer10 = new wxBoxSizer( wxHORIZONTAL );
|
||||
wxBoxSizer* bSizer101;
|
||||
bSizer101 = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
m_filterLabel = new wxStaticText( sbFilters->GetStaticBox(), wxID_ANY, _("Net name filter:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_filterLabel->Wrap( -1 );
|
||||
m_filterLabel->SetMinSize( wxSize( 120,-1 ) );
|
||||
|
||||
bSizer10->Add( m_filterLabel, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
||||
bSizer101->Add( m_filterLabel, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
||||
|
||||
m_netNameFilter = new wxTextCtrl( sbFilters->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
|
||||
bSizer10->Add( m_netNameFilter, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
||||
bSizer101->Add( m_netNameFilter, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
||||
|
||||
|
||||
sbFilters->Add( bSizer10, 0, wxEXPAND, 5 );
|
||||
sbFilters->Add( bSizer101, 0, wxEXPAND, 5 );
|
||||
|
||||
wxBoxSizer* bSizer13;
|
||||
bSizer13 = new wxBoxSizer( wxHORIZONTAL );
|
||||
wxBoxSizer* bSizer131;
|
||||
bSizer131 = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
m_showAllButton = new wxButton( sbFilters->GetStaticBox(), wxID_ANY, _("Show All Nets"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bSizer13->Add( m_showAllButton, 1, wxALL, 5 );
|
||||
bSizer131->Add( m_showAllButton, 1, wxALL, 5 );
|
||||
|
||||
|
||||
bSizer13->Add( 0, 0, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 );
|
||||
bSizer131->Add( 0, 0, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
m_filterNetsButton = new wxButton( sbFilters->GetStaticBox(), wxID_ANY, _("Apply Filters"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bSizer13->Add( m_filterNetsButton, 1, wxALL, 5 );
|
||||
bSizer131->Add( m_filterNetsButton, 1, wxALL, 5 );
|
||||
|
||||
|
||||
sbFilters->Add( bSizer13, 1, wxEXPAND|wxTOP|wxBOTTOM, 6 );
|
||||
sbFilters->Add( bSizer131, 1, wxEXPAND|wxTOP|wxBOTTOM, 6 );
|
||||
|
||||
|
||||
bLeft->Add( sbFilters, 0, wxEXPAND|wxBOTTOM, 5 );
|
||||
@ -184,7 +184,7 @@ PANEL_SETUP_NETCLASSES_BASE::PANEL_SETUP_NETCLASSES_BASE( wxWindow* parent, wxWi
|
||||
bLeft->Add( sbEdit, 1, wxEXPAND|wxTOP, 8 );
|
||||
|
||||
|
||||
sbMembership->Add( bLeft, 1, wxEXPAND|wxRIGHT, 5 );
|
||||
bLowerSizer->Add( bLeft, 1, wxEXPAND|wxTOP|wxRIGHT, 5 );
|
||||
|
||||
wxBoxSizer* bRight;
|
||||
bRight = new wxBoxSizer( wxVERTICAL );
|
||||
@ -218,16 +218,17 @@ PANEL_SETUP_NETCLASSES_BASE::PANEL_SETUP_NETCLASSES_BASE( wxWindow* parent, wxWi
|
||||
bRight->Add( m_membershipGrid, 1, wxEXPAND|wxBOTTOM|wxLEFT, 5 );
|
||||
|
||||
|
||||
sbMembership->Add( bRight, 1, wxEXPAND|wxLEFT, 5 );
|
||||
bLowerSizer->Add( bRight, 1, wxEXPAND|wxTOP|wxLEFT, 5 );
|
||||
|
||||
|
||||
m_membershipPane->SetSizer( sbMembership );
|
||||
m_membershipPane->SetSizer( bLowerSizer );
|
||||
m_membershipPane->Layout();
|
||||
sbMembership->Fit( m_membershipPane );
|
||||
bMargins->Add( m_membershipPane, 5, wxALL|wxEXPAND, 5 );
|
||||
bLowerSizer->Fit( m_membershipPane );
|
||||
m_splitter->SplitHorizontally( m_netclassesPane, m_membershipPane, -1 );
|
||||
bMargins->Add( m_splitter, 1, wxEXPAND|wxRIGHT|wxLEFT, 10 );
|
||||
|
||||
|
||||
bpanelNetClassesSizer->Add( bMargins, 1, wxEXPAND, 5 );
|
||||
bpanelNetClassesSizer->Add( bMargins, 1, wxEXPAND|wxTOP, 2 );
|
||||
|
||||
|
||||
this->SetSizer( bpanelNetClassesSizer );
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -24,11 +24,12 @@ class WX_GRID;
|
||||
#include <wx/icon.h>
|
||||
#include <wx/button.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/statbox.h>
|
||||
#include <wx/panel.h>
|
||||
#include <wx/stattext.h>
|
||||
#include <wx/choice.h>
|
||||
#include <wx/textctrl.h>
|
||||
#include <wx/statbox.h>
|
||||
#include <wx/splitter.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -40,6 +41,7 @@ class PANEL_SETUP_NETCLASSES_BASE : public wxPanel
|
||||
private:
|
||||
|
||||
protected:
|
||||
wxSplitterWindow* m_splitter;
|
||||
wxPanel* m_netclassesPane;
|
||||
WX_GRID* m_netclassGrid;
|
||||
wxBitmapButton* m_addButton;
|
||||
|
@ -181,7 +181,10 @@ COMMON_SETTINGS::COMMON_SETTINGS() :
|
||||
&m_System.clear_3d_cache_interval, 30 ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<bool>( "session.remember_open_files",
|
||||
&m_Session.remember_open_files, false ) );
|
||||
&m_Session.remember_open_files, false ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<int>( "netclass_panel.sash_pos",
|
||||
&m_NetclassPanel.sash_pos, 160 ) );
|
||||
|
||||
registerMigration( 0, 1, std::bind( &COMMON_SETTINGS::migrateSchema0to1, this ) );
|
||||
registerMigration( 1, 2, std::bind( &COMMON_SETTINGS::migrateSchema1to2, this ) );
|
||||
|
@ -41,7 +41,6 @@ private:
|
||||
|
||||
int* m_originalColWidths;
|
||||
bool m_netclassesDirty; // The netclass drop-down menus need rebuilding
|
||||
wxSize m_membershipSize; // The size needed to show the membership list
|
||||
int m_hoveredCol; // Column being hovered over, for tooltips
|
||||
|
||||
private:
|
||||
|
@ -109,6 +109,11 @@ public:
|
||||
int clear_3d_cache_interval;
|
||||
};
|
||||
|
||||
struct NETCLASS_PANEL
|
||||
{
|
||||
int sash_pos;
|
||||
};
|
||||
|
||||
COMMON_SETTINGS();
|
||||
|
||||
virtual ~COMMON_SETTINGS() {}
|
||||
@ -134,6 +139,8 @@ public:
|
||||
|
||||
SYSTEM m_System;
|
||||
|
||||
NETCLASS_PANEL m_NetclassPanel;
|
||||
|
||||
// TODO: These may not want to be in common
|
||||
wxString m_3DLibsUrl;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user