From fb21069c5ac53c686598a754ef65ef013abe760d Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 30 Jun 2018 21:22:01 +0100 Subject: [PATCH] Refresh layer selection dialogs. Use platform-native widgets to show selection and draw layer colours over the PCB background colour. (cherry picked from commit 4f95f7f) --- .../dialogs/dialog_layer_selection_base.cpp | 50 ++--- .../dialogs/dialog_layer_selection_base.fbp | 57 +++--- pcbnew/dialogs/dialog_layer_selection_base.h | 6 +- pcbnew/sel_layer.cpp | 188 +++++++----------- 4 files changed, 127 insertions(+), 174 deletions(-) diff --git a/pcbnew/dialogs/dialog_layer_selection_base.cpp b/pcbnew/dialogs/dialog_layer_selection_base.cpp index 7b3cfbc4fc..6cce563e8f 100644 --- a/pcbnew/dialogs/dialog_layer_selection_base.cpp +++ b/pcbnew/dialogs/dialog_layer_selection_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 19 2018) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -24,11 +24,14 @@ DIALOG_LAYER_SELECTION_BASE::DIALOG_LAYER_SELECTION_BASE( wxWindow* parent, wxWi // Grid m_leftGridLayers->CreateGrid( 1, 3 ); m_leftGridLayers->EnableEditing( false ); - m_leftGridLayers->EnableGridLines( true ); + m_leftGridLayers->EnableGridLines( false ); m_leftGridLayers->EnableDragGridSize( false ); m_leftGridLayers->SetMargins( 5, 3 ); // Columns + m_leftGridLayers->SetColSize( 0, 24 ); + m_leftGridLayers->SetColSize( 1, 20 ); + m_leftGridLayers->SetColSize( 2, 72 ); m_leftGridLayers->EnableDragColMove( false ); m_leftGridLayers->EnableDragColSize( false ); m_leftGridLayers->SetColLabelSize( 0 ); @@ -45,8 +48,6 @@ DIALOG_LAYER_SELECTION_BASE::DIALOG_LAYER_SELECTION_BASE( wxWindow* parent, wxWi // Cell Defaults m_leftGridLayers->SetDefaultCellBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_MENU ) ); m_leftGridLayers->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); - m_leftGridLayers->SetMinSize( wxSize( -1,100 ) ); - bSizerUpper->Add( m_leftGridLayers, 1, wxALL|wxEXPAND, 5 ); m_rightGridLayers = new wxGrid( this, ID_RIGHT_LIST, wxDefaultPosition, wxDefaultSize, 0 ); @@ -54,11 +55,14 @@ DIALOG_LAYER_SELECTION_BASE::DIALOG_LAYER_SELECTION_BASE( wxWindow* parent, wxWi // Grid m_rightGridLayers->CreateGrid( 1, 3 ); m_rightGridLayers->EnableEditing( false ); - m_rightGridLayers->EnableGridLines( true ); + m_rightGridLayers->EnableGridLines( false ); m_rightGridLayers->EnableDragGridSize( false ); m_rightGridLayers->SetMargins( 5, 3 ); // Columns + m_rightGridLayers->SetColSize( 0, 24 ); + m_rightGridLayers->SetColSize( 1, 20 ); + m_rightGridLayers->SetColSize( 2, 72 ); m_rightGridLayers->EnableDragColMove( false ); m_rightGridLayers->EnableDragColSize( false ); m_rightGridLayers->SetColLabelSize( 0 ); @@ -77,7 +81,7 @@ DIALOG_LAYER_SELECTION_BASE::DIALOG_LAYER_SELECTION_BASE( wxWindow* parent, wxWi bSizerUpper->Add( m_rightGridLayers, 1, wxALL|wxEXPAND, 5 ); - bSizerMain->Add( bSizerUpper, 1, wxEXPAND|wxALL, 5 ); + bSizerMain->Add( bSizerUpper, 1, wxEXPAND|wxALL, 10 ); this->SetSizer( bSizerMain ); @@ -125,11 +129,14 @@ DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE // Grid m_leftGridLayers->CreateGrid( 1, 3 ); m_leftGridLayers->EnableEditing( false ); - m_leftGridLayers->EnableGridLines( true ); + m_leftGridLayers->EnableGridLines( false ); m_leftGridLayers->EnableDragGridSize( false ); - m_leftGridLayers->SetMargins( 0, 3 ); + m_leftGridLayers->SetMargins( 3, 3 ); // Columns + m_leftGridLayers->SetColSize( 0, 24 ); + m_leftGridLayers->SetColSize( 1, 20 ); + m_leftGridLayers->SetColSize( 2, 72 ); m_leftGridLayers->EnableDragColMove( false ); m_leftGridLayers->EnableDragColSize( false ); m_leftGridLayers->SetColLabelSize( 0 ); @@ -145,11 +152,11 @@ DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE // Cell Defaults m_leftGridLayers->SetDefaultCellBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_MENU ) ); - m_leftGridLayers->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); - bSizerLeft->Add( m_leftGridLayers, 1, wxALL|wxEXPAND, 5 ); + m_leftGridLayers->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_CENTRE ); + bSizerLeft->Add( m_leftGridLayers, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 ); - bSizerUpper->Add( bSizerLeft, 1, wxEXPAND, 5 ); + bSizerUpper->Add( bSizerLeft, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); wxBoxSizer* bSizerRight; bSizerRight = new wxBoxSizer( wxVERTICAL ); @@ -163,11 +170,14 @@ DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE // Grid m_rightGridLayers->CreateGrid( 1, 3 ); m_rightGridLayers->EnableEditing( false ); - m_rightGridLayers->EnableGridLines( true ); + m_rightGridLayers->EnableGridLines( false ); m_rightGridLayers->EnableDragGridSize( false ); - m_rightGridLayers->SetMargins( 0, 3 ); + m_rightGridLayers->SetMargins( 3, 3 ); // Columns + m_rightGridLayers->SetColSize( 0, 24 ); + m_rightGridLayers->SetColSize( 1, 20 ); + m_rightGridLayers->SetColSize( 2, 72 ); m_rightGridLayers->EnableDragColMove( false ); m_rightGridLayers->EnableDragColSize( false ); m_rightGridLayers->SetColLabelSize( 0 ); @@ -182,16 +192,14 @@ DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE // Cell Defaults m_rightGridLayers->SetDefaultCellBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_MENU ) ); - m_rightGridLayers->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); - m_rightGridLayers->SetMinSize( wxSize( -1,100 ) ); - - bSizerRight->Add( m_rightGridLayers, 1, wxALL|wxEXPAND, 5 ); + m_rightGridLayers->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_CENTRE ); + bSizerRight->Add( m_rightGridLayers, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 ); - bSizerUpper->Add( bSizerRight, 1, wxEXPAND, 5 ); + bSizerUpper->Add( bSizerRight, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); - bSizerMain->Add( bSizerUpper, 1, wxEXPAND, 5 ); + bSizerMain->Add( bSizerUpper, 0, wxALL|wxEXPAND, 5 ); m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); bSizerMain->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 ); @@ -215,8 +223,6 @@ DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE // Connect Events m_leftGridLayers->Connect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::OnLeftGridCellClick ), NULL, this ); m_rightGridLayers->Connect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::OnRightGridCellClick ), NULL, this ); - m_sdbSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::OnCancelClick ), NULL, this ); - m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::OnOKClick ), NULL, this ); } DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::~DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE() @@ -224,7 +230,5 @@ DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::~DIALOG_COPPER_LAYER_PAIR_SELECTION_BAS // Disconnect Events m_leftGridLayers->Disconnect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::OnLeftGridCellClick ), NULL, this ); m_rightGridLayers->Disconnect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::OnRightGridCellClick ), NULL, this ); - m_sdbSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::OnCancelClick ), NULL, this ); - m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE::OnOKClick ), NULL, this ); } diff --git a/pcbnew/dialogs/dialog_layer_selection_base.fbp b/pcbnew/dialogs/dialog_layer_selection_base.fbp index dbc140a657..e08e4e5633 100644 --- a/pcbnew/dialogs/dialog_layer_selection_base.fbp +++ b/pcbnew/dialogs/dialog_layer_selection_base.fbp @@ -14,7 +14,6 @@ dialog_layer_selection_base 1000 none - 1 dialog_layer_selection_base @@ -95,7 +94,7 @@ wxVERTICAL none - 5 + 10 wxEXPAND|wxALL 1 @@ -134,7 +133,7 @@ wxALIGN_CENTRE 3 - + 24,20,72 1 0 @@ -151,7 +150,7 @@ 1 - 1 + 0 0 0 ID_LEFT_LIST @@ -165,7 +164,7 @@ 0 - -1,100 + -1,-1 1 m_leftGridLayers 1 @@ -277,7 +276,7 @@ wxALIGN_CENTRE 3 - + 24,20,72 1 0 @@ -294,7 +293,7 @@ 1 - 1 + 0 0 0 ID_RIGHT_LIST @@ -414,7 +413,7 @@ -1,-1 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER - Select Copper Layer Pair: + Select Copper Layer Pair @@ -462,8 +461,8 @@ none 5 - wxEXPAND - 1 + wxALL|wxEXPAND + 0 bSizerUpper @@ -471,8 +470,8 @@ none 5 - wxEXPAND - 1 + wxEXPAND|wxRIGHT|wxLEFT + 0 bSizerLeft @@ -563,8 +562,8 @@ 5 - wxALL|wxEXPAND - 1 + wxALL|wxALIGN_CENTER_HORIZONTAL + 0 1 1 @@ -584,7 +583,7 @@ wxALIGN_LEFT - wxALIGN_TOP + wxALIGN_CENTRE 0 1 wxALIGN_CENTRE @@ -592,7 +591,7 @@ wxALIGN_CENTRE 3 - + 24,20,72 1 0 @@ -609,7 +608,7 @@ 1 - 1 + 0 0 0 ID_LEFT_LIST @@ -617,7 +616,7 @@ 3 - 0 + 3 0 @@ -708,8 +707,8 @@ 5 - wxEXPAND - 1 + wxEXPAND|wxRIGHT|wxLEFT + 0 bSizerRight @@ -800,8 +799,8 @@ 5 - wxALL|wxEXPAND - 1 + wxALL|wxALIGN_CENTER_HORIZONTAL + 0 1 1 @@ -821,7 +820,7 @@ wxALIGN_LEFT - wxALIGN_TOP + wxALIGN_CENTRE 0 1 wxALIGN_CENTRE @@ -829,7 +828,7 @@ wxALIGN_CENTRE 3 - + 24,20,72 1 0 @@ -846,7 +845,7 @@ 1 - 1 + 0 0 0 ID_RIGHT_LIST @@ -854,13 +853,13 @@ 3 - 0 + 3 0 0 - -1,100 + -1,-1 1 m_rightGridLayers 1 @@ -1043,11 +1042,11 @@ m_sdbSizer protected - OnCancelClick + - OnOKClick + diff --git a/pcbnew/dialogs/dialog_layer_selection_base.h b/pcbnew/dialogs/dialog_layer_selection_base.h index adaf7a1751..c529a629c7 100644 --- a/pcbnew/dialogs/dialog_layer_selection_base.h +++ b/pcbnew/dialogs/dialog_layer_selection_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 19 2018) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -72,13 +72,11 @@ class DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE : public wxDialog // Virtual event handlers, overide them in your derived class virtual void OnLeftGridCellClick( wxGridEvent& event ) { event.Skip(); } virtual void OnRightGridCellClick( wxGridEvent& event ) { event.Skip(); } - virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); } - virtual void OnOKClick( wxCommandEvent& event ) { event.Skip(); } public: - DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Select Copper Layer Pair:"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Select Copper Layer Pair"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE(); }; diff --git a/pcbnew/sel_layer.cpp b/pcbnew/sel_layer.cpp index 5fc59ec35a..f55e28b04d 100644 --- a/pcbnew/sel_layer.cpp +++ b/pcbnew/sel_layer.cpp @@ -37,6 +37,12 @@ #include +// Column position by function: +#define SELECT_COLNUM 0 +#define COLOR_COLNUM 1 +#define LAYERNAME_COLNUM 2 + + /* classes to display a layer list using a wxGrid. */ class PCB_LAYER_SELECTOR: public LAYER_SELECTOR @@ -79,16 +85,15 @@ protected: class PCB_ONE_LAYER_SELECTOR : public PCB_LAYER_SELECTOR, public DIALOG_LAYER_SELECTION_BASE { - PCB_LAYER_ID m_layerSelected; - LSET m_notAllowedLayersMask; - BOARD* m_brd; + PCB_LAYER_ID m_layerSelected; + LSET m_notAllowedLayersMask; + BOARD* m_brd; std::vector m_layersIdLeftColumn; std::vector m_layersIdRightColumn; public: - PCB_ONE_LAYER_SELECTOR( PCB_BASE_FRAME* aParent, BOARD * aBrd, - PCB_LAYER_ID aDefaultLayer, - LSET aNotAllowedLayersMask ); + PCB_ONE_LAYER_SELECTOR( PCB_BASE_FRAME* aParent, BOARD * aBrd, PCB_LAYER_ID aDefaultLayer, + LSET aNotAllowedLayersMask ); LAYER_NUM GetLayerSelection() { return m_layerSelected; } @@ -101,65 +106,59 @@ private: }; -PCB_ONE_LAYER_SELECTOR::PCB_ONE_LAYER_SELECTOR( PCB_BASE_FRAME* aParent, - BOARD* aBrd, PCB_LAYER_ID aDefaultLayer, LSET aNotAllowedLayersMask ) - : PCB_LAYER_SELECTOR( aParent ), DIALOG_LAYER_SELECTION_BASE( aParent ) +PCB_ONE_LAYER_SELECTOR::PCB_ONE_LAYER_SELECTOR( PCB_BASE_FRAME* aParent, BOARD* aBrd, + PCB_LAYER_ID aDefaultLayer, + LSET aNotAllowedLayersMask ) : + PCB_LAYER_SELECTOR( aParent ), + DIALOG_LAYER_SELECTION_BASE( aParent ) { m_layerSelected = aDefaultLayer; m_notAllowedLayersMask = aNotAllowedLayersMask; m_brd = aBrd; + + m_leftGridLayers->SetCellHighlightPenWidth( 0 ); + m_rightGridLayers->SetCellHighlightPenWidth( 0 ); + m_leftGridLayers->SetColFormatBool( SELECT_COLNUM ); + m_rightGridLayers->SetColFormatBool( SELECT_COLNUM ); buildList(); + Layout(); GetSizer()->SetSizeHints( this ); SetFocus(); } -// Build the layers list -// Column position by function: -#define SELECT_COLNUM 0 -#define COLOR_COLNUM 1 -#define LAYERNAME_COLNUM 2 - void PCB_ONE_LAYER_SELECTOR::buildList() { - // Hide layerid column which is used only to know the layer id - // not to be shown in dialogs - m_leftGridLayers->SetColSize( COLOR_COLNUM, 20 ); - m_rightGridLayers->SetColSize( COLOR_COLNUM, 20 ); + wxColour bg = GetLayerColor( LAYER_PCB_BACKGROUND ).ToColour(); + int left_row = 0; + int right_row = 0; + wxString layername; - int left_row = 0; - int right_row = 0; - wxString layername; - - for( LSEQ ui_seq = m_brd->GetEnabledLayers().UIOrder(); ui_seq; ++ui_seq ) + for( LSEQ ui_seq = m_brd->GetEnabledLayers().UIOrder(); ui_seq; ++ui_seq ) { PCB_LAYER_ID layerid = *ui_seq; if( m_notAllowedLayersMask[layerid] ) continue; - COLOR4D color = GetLayerColor( layerid ); - layername = GetLayerName( layerid ); + wxColour fg = GetLayerColor( layerid ).ToColour(); + wxColour color( wxColour::AlphaBlend( fg.Red(), bg.Red(), fg.Alpha() / 255.0 ), + wxColour::AlphaBlend( fg.Green(), bg.Green(), fg.Alpha() / 255.0 ), + wxColour::AlphaBlend( fg.Blue(), bg.Blue(), fg.Alpha() / 255.0 ) ); + + layername = wxT( " " ) + GetLayerName( layerid ); if( IsCopperLayer( layerid ) ) { if( left_row ) m_leftGridLayers->AppendRows( 1 ); - m_leftGridLayers->SetCellBackgroundColour ( left_row, COLOR_COLNUM, - color.ToColour() ); - m_leftGridLayers->SetCellValue( left_row, LAYERNAME_COLNUM, - layername ); + m_leftGridLayers->SetCellBackgroundColour ( left_row, COLOR_COLNUM, color ); + m_leftGridLayers->SetCellValue( left_row, LAYERNAME_COLNUM, layername ); if( m_layerSelected == layerid ) - { - m_leftGridLayers->SetCellValue( left_row, SELECT_COLNUM, - wxT("X") ); - m_leftGridLayers->SetCellBackgroundColour ( left_row, SELECT_COLNUM, - color.ToColour() ); - m_leftGridLayers->SetGridCursor( left_row, LAYERNAME_COLNUM ); - } + m_leftGridLayers->SetCellValue( left_row, SELECT_COLNUM, "1" ); m_layersIdLeftColumn.push_back( layerid ); left_row++; @@ -169,19 +168,11 @@ void PCB_ONE_LAYER_SELECTOR::buildList() if( right_row ) m_rightGridLayers->AppendRows( 1 ); - m_rightGridLayers->SetCellBackgroundColour ( right_row, COLOR_COLNUM, - color.ToColour() ); - m_rightGridLayers->SetCellValue( right_row, LAYERNAME_COLNUM, - layername ); + m_rightGridLayers->SetCellBackgroundColour( right_row, COLOR_COLNUM, color ); + m_rightGridLayers->SetCellValue( right_row, LAYERNAME_COLNUM, layername ); if( m_layerSelected == layerid ) - { - m_rightGridLayers->SetCellValue( right_row, SELECT_COLNUM, - wxT("X") ); - m_rightGridLayers->SetCellBackgroundColour ( right_row, SELECT_COLNUM, - color.ToColour() ); - m_rightGridLayers->SetGridCursor( right_row, LAYERNAME_COLNUM ); - } + m_rightGridLayers->SetCellValue( right_row, SELECT_COLNUM, "1" ); m_layersIdRightColumn.push_back( layerid ); right_row++; @@ -194,18 +185,12 @@ void PCB_ONE_LAYER_SELECTOR::buildList() if( right_row <= 0 ) m_rightGridLayers->Show( false ); - - m_leftGridLayers->AutoSizeColumn(LAYERNAME_COLNUM); - m_rightGridLayers->AutoSizeColumn(LAYERNAME_COLNUM); - m_leftGridLayers->AutoSizeColumn(SELECT_COLNUM); - m_rightGridLayers->AutoSizeColumn(SELECT_COLNUM); } void PCB_ONE_LAYER_SELECTOR::OnLeftGridCellClick( wxGridEvent& event ) { m_layerSelected = m_layersIdLeftColumn[ event.GetRow() ]; - m_leftGridLayers->SetGridCursor( event.GetRow(), LAYERNAME_COLNUM ); EndModal( 1 ); } @@ -213,13 +198,12 @@ void PCB_ONE_LAYER_SELECTOR::OnLeftGridCellClick( wxGridEvent& event ) void PCB_ONE_LAYER_SELECTOR::OnRightGridCellClick( wxGridEvent& event ) { m_layerSelected = m_layersIdRightColumn[ event.GetRow() ]; - m_rightGridLayers->SetGridCursor( event.GetRow(), LAYERNAME_COLNUM ); EndModal( 2 ); } -PCB_LAYER_ID PCB_BASE_FRAME::SelectLayer( PCB_LAYER_ID aDefaultLayer, - LSET aNotAllowedLayersMask, wxPoint aDlgPosition ) +PCB_LAYER_ID PCB_BASE_FRAME::SelectLayer( PCB_LAYER_ID aDefaultLayer, LSET aNotAllowedLayersMask, + wxPoint aDlgPosition ) { PCB_ONE_LAYER_SELECTOR dlg( this, GetBoard(), aDefaultLayer, aNotAllowedLayersMask ); @@ -269,18 +253,7 @@ private: void OnLeftGridCellClick( wxGridEvent& event ) override; void OnRightGridCellClick( wxGridEvent& event ) override; - void OnOkClick( wxCommandEvent& event ) - { - EndModal( wxID_OK ); - } - - void OnCancelClick( wxCommandEvent& event ) override - { - EndModal( wxID_CANCEL ); - } - void buildList(); - void SetGridCursor( wxGrid* aGrid, int aRow, bool aEnable ); }; @@ -299,8 +272,7 @@ void PCB_BASE_FRAME::SelectCopperLayerPair() // select the same layer for both layers is allowed (normal in some boards) // but could be a mistake. So display an info message if( screen->m_Route_Layer_TOP == screen->m_Route_Layer_BOTTOM ) - DisplayInfoMessage( this, - _( "Warning: The Top Layer and Bottom Layer are same." ) ); + DisplayInfoMessage( this, _( "Warning: top and bottom layers are same." ) ); } m_canvas->MoveCursorToCrossHair(); @@ -317,8 +289,15 @@ SELECT_COPPER_LAYERS_PAIR_DIALOG::SELECT_COPPER_LAYERS_PAIR_DIALOG( m_leftRowSelected = 0; m_rightRowSelected = 0; m_brd = aPcb; + + m_leftGridLayers->SetCellHighlightPenWidth( 0 ); + m_rightGridLayers->SetCellHighlightPenWidth( 0 ); + m_leftGridLayers->SetColFormatBool( SELECT_COLNUM ); + m_rightGridLayers->SetColFormatBool( SELECT_COLNUM ); buildList(); + SetFocus(); + GetSizer()->SetSizeHints( this ); Center(); } @@ -326,79 +305,52 @@ SELECT_COPPER_LAYERS_PAIR_DIALOG::SELECT_COPPER_LAYERS_PAIR_DIALOG( void SELECT_COPPER_LAYERS_PAIR_DIALOG::buildList() { - m_leftGridLayers->SetColSize( COLOR_COLNUM, 20 ); - m_rightGridLayers->SetColSize( COLOR_COLNUM, 20 ); + wxColour bg = GetLayerColor( LAYER_PCB_BACKGROUND ).ToColour(); + int row = 0; + wxString layername; - // Select a not show cell, to avoid a wrong cell selection for user - - int row = 0; - wxString layername; - - for( LSEQ ui_seq = m_brd->GetEnabledLayers().UIOrder(); ui_seq; ++ui_seq ) + for( LSEQ ui_seq = m_brd->GetEnabledLayers().UIOrder(); ui_seq; ++ui_seq ) { PCB_LAYER_ID layerid = *ui_seq; if( !IsCopperLayer( layerid ) ) - break; + continue; - COLOR4D color = GetLayerColor( layerid ); + wxColour fg = GetLayerColor( layerid ).ToColour(); + wxColour color( wxColour::AlphaBlend( fg.Red(), bg.Red(), fg.Alpha() / 255.0 ), + wxColour::AlphaBlend( fg.Green(), bg.Green(), fg.Alpha() / 255.0 ), + wxColour::AlphaBlend( fg.Blue(), bg.Blue(), fg.Alpha() / 255.0 ) ); - layername = GetLayerName( layerid ); + layername = wxT( " " ) + GetLayerName( layerid ); if( row ) m_leftGridLayers->AppendRows( 1 ); - m_leftGridLayers->SetCellBackgroundColour( row, COLOR_COLNUM, color.ToColour() ); + m_leftGridLayers->SetCellBackgroundColour( row, COLOR_COLNUM, color ); m_leftGridLayers->SetCellValue( row, LAYERNAME_COLNUM, layername ); m_layersId.push_back( layerid ); if( m_frontLayer == layerid ) { - SetGridCursor( m_leftGridLayers, row, true ); + m_leftGridLayers->SetCellValue( row, SELECT_COLNUM, "1" ); + m_leftGridLayers->SetGridCursor( row, COLOR_COLNUM ); m_leftRowSelected = row; } if( row ) m_rightGridLayers->AppendRows( 1 ); - m_rightGridLayers->SetCellBackgroundColour ( row, COLOR_COLNUM, - color.ToColour() ); - m_rightGridLayers->SetCellValue( row, LAYERNAME_COLNUM, - layername ); + + m_rightGridLayers->SetCellBackgroundColour( row, COLOR_COLNUM, color ); + m_rightGridLayers->SetCellValue( row, LAYERNAME_COLNUM, layername ); if( m_backLayer == layerid ) { - SetGridCursor( m_rightGridLayers, row, true ); + m_rightGridLayers->SetCellValue( row, SELECT_COLNUM, "1" ); m_rightRowSelected = row; } row++; } - - m_leftGridLayers->AutoSizeColumn(LAYERNAME_COLNUM); - m_rightGridLayers->AutoSizeColumn(LAYERNAME_COLNUM); - m_leftGridLayers->AutoSizeColumn(SELECT_COLNUM); - m_rightGridLayers->AutoSizeColumn(SELECT_COLNUM); -} - - -void SELECT_COPPER_LAYERS_PAIR_DIALOG::SetGridCursor( wxGrid* aGrid, int aRow, - bool aEnable ) -{ - if( aEnable ) - { - PCB_LAYER_ID layerid = m_layersId[aRow]; - COLOR4D color = GetLayerColor( layerid ); - aGrid->SetCellValue( aRow, SELECT_COLNUM, wxT("X") ); - aGrid->SetCellBackgroundColour( aRow, SELECT_COLNUM, color.ToColour() ); - aGrid->SetGridCursor( aRow, LAYERNAME_COLNUM ); - } - else - { - aGrid->SetCellValue( aRow, SELECT_COLNUM, wxEmptyString ); - aGrid->SetCellBackgroundColour( aRow, SELECT_COLNUM, - aGrid->GetDefaultCellBackgroundColour() ); - aGrid->SetGridCursor( aRow, LAYERNAME_COLNUM ); - } } @@ -410,10 +362,10 @@ void SELECT_COPPER_LAYERS_PAIR_DIALOG::OnLeftGridCellClick( wxGridEvent& event ) if( m_frontLayer == layer ) return; - SetGridCursor( m_leftGridLayers, m_leftRowSelected, false ); + m_leftGridLayers->SetCellValue( m_leftRowSelected, SELECT_COLNUM, wxEmptyString ); m_frontLayer = layer; m_leftRowSelected = row; - SetGridCursor( m_leftGridLayers, m_leftRowSelected, true ); + m_leftGridLayers->SetCellValue( m_leftRowSelected, SELECT_COLNUM, "1" ); } @@ -425,8 +377,8 @@ void SELECT_COPPER_LAYERS_PAIR_DIALOG::OnRightGridCellClick( wxGridEvent& event if( m_backLayer == layer ) return; - SetGridCursor( m_rightGridLayers, m_rightRowSelected, false ); + m_rightGridLayers->SetCellValue( m_rightRowSelected, SELECT_COLNUM, wxEmptyString ); m_backLayer = layer; m_rightRowSelected = row; - SetGridCursor( m_rightGridLayers, m_rightRowSelected, true ); + m_rightGridLayers->SetCellValue( m_rightRowSelected, SELECT_COLNUM, "1" ); }