diff --git a/pcbnew/dialogs/dialog_keepout_area_properties.cpp b/pcbnew/dialogs/dialog_keepout_area_properties.cpp index 732a344e43..f0cb4c7707 100644 --- a/pcbnew/dialogs/dialog_keepout_area_properties.cpp +++ b/pcbnew/dialogs/dialog_keepout_area_properties.cpp @@ -61,9 +61,6 @@ private: ZONE_SETTINGS m_zonesettings; ZONE_SETTINGS* m_ptr; - std::vector m_layerId; ///< Handle the real layer number from layer - ///< name position in m_LayerSelectionCtrl - /** * Function initDialog * fills in the dialog controls using the current settings. @@ -72,6 +69,8 @@ private: virtual void OnOkClick( wxCommandEvent& event ) override; + virtual void OnLayerSelection( wxDataViewEvent& event ) override; + /** * Function AcceptOptionsForKeepOut * Test validity of options, and copy options in m_zonesettings, for keepout zones @@ -80,15 +79,15 @@ private: bool AcceptOptionsForKeepOut(); /** - * Function makeLayerBitmap - * creates the colored rectangle bitmaps used in the layer selection widget. + * Function makeLayerIcon + * creates the colored rectangle icons used in the layer selection widget. * @param aColor is the color to fill the rectangle with. */ - wxBitmap makeLayerBitmap( COLOR4D aColor ); + wxIcon makeLayerIcon( COLOR4D aColor ); }; -#define LAYER_BITMAP_SIZE_X 20 +#define LAYER_BITMAP_SIZE_X 25 #define LAYER_BITMAP_SIZE_Y 15 ZONE_EDIT_T InvokeKeepoutAreaEditor( PCB_BASE_FRAME* aCaller, ZONE_SETTINGS* aSettings ) @@ -145,52 +144,50 @@ void DIALOG_KEEPOUT_AREA_PROPERTIES::initDialog() break; } - // Create one column in m_LayerSelectionCtrl - wxListItem column0; - column0.SetId( 0 ); - m_LayerSelectionCtrl->InsertColumn( 0, column0 ); - - wxImageList* imageList = new wxImageList( LAYER_BITMAP_SIZE_X, LAYER_BITMAP_SIZE_Y ); - m_LayerSelectionCtrl->AssignImageList( imageList, wxIMAGE_LIST_SMALL ); - // Build copper layer list and append to layer widget LSET show = LSET::AllCuMask( board->GetCopperLayerCount() ); + auto* checkColumn = m_layers->AppendToggleColumn( wxEmptyString ); + auto* layerColumn = m_layers->AppendIconTextColumn( wxEmptyString ); + + wxVector row; + int imgIdx = 0; for( LSEQ cu_stack = show.UIOrder(); cu_stack; ++cu_stack, imgIdx++ ) { PCB_LAYER_ID layer = *cu_stack; - m_layerId.push_back( layer ); - msg = board->GetLayerName( layer ); COLOR4D layerColor = m_parent->Settings().Colors().GetLayerColor( layer ); - imageList->Add( makeLayerBitmap( layerColor ) ); + row.clear(); - int itemIndex = m_LayerSelectionCtrl->InsertItem( - m_LayerSelectionCtrl->GetItemCount(), msg, imgIdx ); + row.push_back( m_zonesettings.m_Layers.test( layer ) ); - if( m_zonesettings.m_CurrentZone_Layer == layer ) - { - //m_LayerSelectionCtrl->Select( itemIndex ); - } + auto iconItem = wxDataViewIconText( msg, makeLayerIcon( layerColor ) ); - if( m_zonesettings.m_Layers.test( layer ) ) - { - m_LayerSelectionCtrl->Select( itemIndex ); - } + row.push_back( wxVariant( iconItem ) ); - } + m_layers->AppendItem( row ); - m_LayerSelectionCtrl->SetColumnWidth( 0, wxLIST_AUTOSIZE); + } // Init keepout parameters: m_cbTracksCtrl->SetValue( m_zonesettings.GetDoNotAllowTracks() ); m_cbViasCtrl->SetValue( m_zonesettings.GetDoNotAllowVias() ); m_cbCopperPourCtrl->SetValue( m_zonesettings.GetDoNotAllowCopperPour() ); + + checkColumn->SetWidth( wxCOL_WIDTH_AUTOSIZE ); + checkColumn->SetMinWidth( 50 ); + layerColumn->SetMinWidth( 350 ); + + m_layers->SetExpanderColumn( layerColumn ); + + m_layers->Update(); + + Update(); } @@ -204,6 +201,31 @@ void DIALOG_KEEPOUT_AREA_PROPERTIES::OnOkClick( wxCommandEvent& event ) } +void DIALOG_KEEPOUT_AREA_PROPERTIES::OnLayerSelection( wxDataViewEvent& event ) +{ + if( event.GetColumn() != 0 ) + { + return; + } + + wxDataViewItem item = event.GetItem(); + + int row = m_layers->ItemToRow( item ); + + bool selected = m_layers->GetToggleValue( row, 0 ); + + BOARD* board = m_parent->GetBoard(); + LSEQ cu_stack = LSET::AllCuMask( board->GetCopperLayerCount() ).UIOrder(); + + if( row < cu_stack.size() ) + { + m_zonesettings.m_Layers.set( cu_stack[ row ], selected ); + } + + m_sdbSizerButtonsOK->Enable( m_zonesettings.m_Layers.count() > 0 ); +} + + bool DIALOG_KEEPOUT_AREA_PROPERTIES::AcceptOptionsForKeepOut() { // Init keepout parameters: @@ -222,38 +244,12 @@ bool DIALOG_KEEPOUT_AREA_PROPERTIES::AcceptOptionsForKeepOut() return false; } - // Copy the layers across - LSET layers; - - for( int ii = 0; ii < m_LayerSelectionCtrl->GetItemCount(); ii++ ) - { - if( m_LayerSelectionCtrl->IsSelected( ii ) ) - { - layers.set( ToLAYER_ID( m_layerId[ii] ) ); - } - } - - if( layers.count() == 0 ) + if( m_zonesettings.m_Layers.count() == 0 ) { DisplayError( NULL, _( "No layers selected." ) ); return false; } - m_zonesettings.m_Layers = layers; - - // Get the layer selection for this zone - int ii = m_LayerSelectionCtrl->GetFirstSelected(); - - if( ii < 0 ) - { - DisplayError( NULL, _( "No layer selected." ) ); - return false; - } - - m_zonesettings.m_CurrentZone_Layer = ToLAYER_ID( m_layerId[ii] ); - - // Set zone layers - switch( m_OutlineAppearanceCtrl->GetSelection() ) { case 0: @@ -286,7 +282,7 @@ bool DIALOG_KEEPOUT_AREA_PROPERTIES::AcceptOptionsForKeepOut() } -wxBitmap DIALOG_KEEPOUT_AREA_PROPERTIES::makeLayerBitmap( COLOR4D aColor ) +wxIcon DIALOG_KEEPOUT_AREA_PROPERTIES::makeLayerIcon( COLOR4D aColor ) { wxBitmap bitmap( LAYER_BITMAP_SIZE_X, LAYER_BITMAP_SIZE_Y ); wxBrush brush; @@ -299,5 +295,9 @@ wxBitmap DIALOG_KEEPOUT_AREA_PROPERTIES::makeLayerBitmap( COLOR4D aColor ) iconDC.SetBrush( brush ); iconDC.DrawRectangle( 0, 0, LAYER_BITMAP_SIZE_X, LAYER_BITMAP_SIZE_Y ); - return bitmap; + wxIcon icon; + + icon.CopyFromBitmap( bitmap ); + + return icon; } diff --git a/pcbnew/dialogs/dialog_keepout_area_properties_base.cpp b/pcbnew/dialogs/dialog_keepout_area_properties_base.cpp index 7f09851fc5..784001e9a3 100644 --- a/pcbnew/dialogs/dialog_keepout_area_properties_base.cpp +++ b/pcbnew/dialogs/dialog_keepout_area_properties_base.cpp @@ -10,12 +10,13 @@ /////////////////////////////////////////////////////////////////////////// BEGIN_EVENT_TABLE( DIALOG_KEEPOUT_AREA_PROPERTIES_BASE, DIALOG_SHIM ) + EVT_DATAVIEW_ITEM_VALUE_CHANGED( wxID_ANY, DIALOG_KEEPOUT_AREA_PROPERTIES_BASE::_wxFB_OnLayerSelection ) EVT_BUTTON( wxID_OK, DIALOG_KEEPOUT_AREA_PROPERTIES_BASE::_wxFB_OnOkClick ) END_EVENT_TABLE() DIALOG_KEEPOUT_AREA_PROPERTIES_BASE::DIALOG_KEEPOUT_AREA_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) { - this->SetSizeHints( wxDefaultSize, wxDefaultSize ); + this->SetSizeHints( wxSize( 500,-1 ), wxDefaultSize ); wxBoxSizer* m_MainSizer; m_MainSizer = new wxBoxSizer( wxVERTICAL ); @@ -26,12 +27,12 @@ DIALOG_KEEPOUT_AREA_PROPERTIES_BASE::DIALOG_KEEPOUT_AREA_PROPERTIES_BASE( wxWind wxBoxSizer* m_layersListSizer; m_layersListSizer = new wxBoxSizer( wxVERTICAL ); - m_staticTextLayerSelection = new wxStaticText( this, wxID_ANY, _("Keepout Zone Layers"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextLayerSelection = new wxStaticText( this, wxID_ANY, _("Keepout Area Layers:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextLayerSelection->Wrap( -1 ); m_layersListSizer->Add( m_staticTextLayerSelection, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); - m_LayerSelectionCtrl = new wxListView( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_ALIGN_LEFT|wxLC_HRULES|wxLC_NO_HEADER|wxLC_REPORT ); - m_layersListSizer->Add( m_LayerSelectionCtrl, 1, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); + m_layers = new wxDataViewListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxDV_HORIZ_RULES|wxDV_NO_HEADER ); + m_layersListSizer->Add( m_layers, 1, wxALL|wxEXPAND, 5 ); m_UpperSizer->Add( m_layersListSizer, 1, wxEXPAND, 5 ); @@ -91,7 +92,6 @@ DIALOG_KEEPOUT_AREA_PROPERTIES_BASE::DIALOG_KEEPOUT_AREA_PROPERTIES_BASE( wxWind this->SetSizer( m_MainSizer ); this->Layout(); - m_MainSizer->Fit( this ); this->Centre( wxBOTH ); } diff --git a/pcbnew/dialogs/dialog_keepout_area_properties_base.fbp b/pcbnew/dialogs/dialog_keepout_area_properties_base.fbp index b1ae001fca..d49acffd07 100644 --- a/pcbnew/dialogs/dialog_keepout_area_properties_base.fbp +++ b/pcbnew/dialogs/dialog_keepout_area_properties_base.fbp @@ -41,10 +41,10 @@ 0 wxID_ANY - + 500,-1 DIALOG_KEEPOUT_AREA_PROPERTIES_BASE - -1,-1 + 650,402 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h Keepout Area Properties @@ -88,34 +88,34 @@ - + m_MainSizer wxVERTICAL none - + 5 wxEXPAND 1 - + m_UpperSizer wxHORIZONTAL none - + 5 wxEXPAND 1 - + m_layersListSizer wxVERTICAL none - + 5 wxTOP|wxRIGHT|wxLEFT 0 - + 1 1 1 @@ -143,7 +143,7 @@ 0 0 wxID_ANY - Keepout Zone Layers + Keepout Area Layers: 0 @@ -194,67 +194,50 @@ - + 5 - wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND + wxALL|wxEXPAND 1 - - 1 - 1 - 1 - 1 - - - - - + - - 1 - 0 - 1 1 - 0 - Dock - 0 - Left 1 - 1 - 0 0 wxID_ANY - - 0 - - 0 - 1 - m_LayerSelectionCtrl - 1 - - + m_layers protected - 1 - Resizable - 1 - wxLC_ALIGN_LEFT|wxLC_HRULES|wxLC_NO_HEADER|wxLC_REPORT - wxListView; - 0 + wxDV_HORIZ_RULES|wxDV_NO_HEADER + - - wxFILTER_NONE - wxDefaultValidator - + + + + + + + + + + + + + + + + + OnLayerSelection + @@ -264,26 +247,6 @@ - - - - - - - - - - - - - - - - - - - - @@ -301,20 +264,20 @@ - + 5 wxEXPAND 0 - + bSizerRight wxVERTICAL none - + 5 wxTOP|wxRIGHT|wxLEFT 0 - + 1 1 1 @@ -393,11 +356,11 @@ - + 5 wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT 0 - + 1 1 1 @@ -483,11 +446,11 @@ - + 5 wxALL|wxEXPAND 0 - + 1 1 1 @@ -573,11 +536,11 @@ - + 5 wxEXPAND|wxALL 0 - + wxID_ANY Keepout Options: @@ -586,11 +549,11 @@ 1 none - + 5 wxTOP|wxRIGHT|wxLEFT|wxEXPAND 0 - + 1 1 1 @@ -674,11 +637,11 @@ - + 5 wxTOP|wxRIGHT|wxLEFT|wxEXPAND 0 - + 1 1 1 @@ -762,11 +725,11 @@ - + 5 wxALL|wxEXPAND 0 - + 1 1 1 @@ -856,11 +819,11 @@ - + 5 wxEXPAND | wxALL 0 - + 1 1 1 @@ -937,11 +900,11 @@ - + 5 wxEXPAND|wxALL 0 - + 0 1 0 diff --git a/pcbnew/dialogs/dialog_keepout_area_properties_base.h b/pcbnew/dialogs/dialog_keepout_area_properties_base.h index 1fc015d946..831c64fb78 100644 --- a/pcbnew/dialogs/dialog_keepout_area_properties_base.h +++ b/pcbnew/dialogs/dialog_keepout_area_properties_base.h @@ -12,7 +12,6 @@ #include #include class DIALOG_SHIM; -class wxListView; #include "dialog_shim.h" #include @@ -21,7 +20,7 @@ class wxListView; #include #include #include -#include +#include #include #include #include @@ -42,12 +41,13 @@ class DIALOG_KEEPOUT_AREA_PROPERTIES_BASE : public DIALOG_SHIM private: // Private event handlers + void _wxFB_OnLayerSelection( wxDataViewEvent& event ){ OnLayerSelection( event ); } void _wxFB_OnOkClick( wxCommandEvent& event ){ OnOkClick( event ); } protected: wxStaticText* m_staticTextLayerSelection; - wxListView* m_LayerSelectionCtrl; + wxDataViewListCtrl* m_layers; wxStaticText* m_staticTextprops; wxRadioBox* m_OrientEdgesOpt; wxRadioBox* m_OutlineAppearanceCtrl; @@ -60,12 +60,13 @@ class DIALOG_KEEPOUT_AREA_PROPERTIES_BASE : public DIALOG_SHIM wxButton* m_sdbSizerButtonsCancel; // Virtual event handlers, overide them in your derived class + virtual void OnLayerSelection( wxDataViewEvent& event ) { event.Skip(); } virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); } public: - DIALOG_KEEPOUT_AREA_PROPERTIES_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Keepout Area Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxFULL_REPAINT_ON_RESIZE|wxSUNKEN_BORDER ); + DIALOG_KEEPOUT_AREA_PROPERTIES_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Keepout Area Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 650,402 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxFULL_REPAINT_ON_RESIZE|wxSUNKEN_BORDER ); ~DIALOG_KEEPOUT_AREA_PROPERTIES_BASE(); };