diff --git a/pcbnew/layer_panel_base.cpp b/pcbnew/layer_panel_base.cpp index 4cc8bda0c8..47b325dfc4 100644 --- a/pcbnew/layer_panel_base.cpp +++ b/pcbnew/layer_panel_base.cpp @@ -20,45 +20,33 @@ LAYER_PANEL_BASE::LAYER_PANEL_BASE( wxWindow* parent, wxWindowID id, const wxPoi m_LayerPanel = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); m_LayerPanel->SetToolTip( _("Layer selection and visibility control") ); - wxStaticBoxSizer* sbSizer3; - sbSizer3 = new wxStaticBoxSizer( new wxStaticBox( m_LayerPanel, wxID_ANY, _("Layers") ), wxVERTICAL ); + wxBoxSizer* bSizer3; + bSizer3 = new wxBoxSizer( wxVERTICAL ); m_LayerScrolledWindow = new wxScrolledWindow( m_LayerPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL ); m_LayerScrolledWindow->SetScrollRate( 5, 5 ); - m_LayersFlexGridSizer = new wxFlexGridSizer( 0, 3, 3, 3 ); + m_LayersFlexGridSizer = new wxFlexGridSizer( 0, 4, 3, 3 ); m_LayersFlexGridSizer->SetFlexibleDirection( wxHORIZONTAL ); m_LayersFlexGridSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); m_LayerScrolledWindow->SetSizer( m_LayersFlexGridSizer ); m_LayerScrolledWindow->Layout(); m_LayersFlexGridSizer->Fit( m_LayerScrolledWindow ); - sbSizer3->Add( m_LayerScrolledWindow, 1, wxEXPAND | wxALL, 5 ); + bSizer3->Add( m_LayerScrolledWindow, 1, wxBOTTOM|wxEXPAND|wxTOP, 5 ); - m_LayerPanel->SetSizer( sbSizer3 ); + m_LayerPanel->SetSizer( bSizer3 ); m_LayerPanel->Layout(); - sbSizer3->Fit( m_LayerPanel ); + bSizer3->Fit( m_LayerPanel ); m_notebook->AddPage( m_LayerPanel, _("Layers"), true ); m_Page1Panel = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); m_Page1Panel->SetToolTip( _("Part depiction and visibility") ); - wxStaticBoxSizer* sbSizer4; - sbSizer4 = new wxStaticBoxSizer( new wxStaticBox( m_Page1Panel, wxID_ANY, _("Rendering") ), wxVERTICAL ); + wxBoxSizer* bSizer4; + bSizer4 = new wxBoxSizer( wxVERTICAL ); - m_scrolledWindow2 = new wxScrolledWindow( m_Page1Panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL ); - m_scrolledWindow2->SetScrollRate( 5, 5 ); - wxFlexGridSizer* fgSizer2; - fgSizer2 = new wxFlexGridSizer( 0, 2, 0, 0 ); - fgSizer2->SetFlexibleDirection( wxBOTH ); - fgSizer2->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - - m_scrolledWindow2->SetSizer( fgSizer2 ); - m_scrolledWindow2->Layout(); - fgSizer2->Fit( m_scrolledWindow2 ); - sbSizer4->Add( m_scrolledWindow2, 1, wxEXPAND | wxALL, 5 ); - - m_Page1Panel->SetSizer( sbSizer4 ); + m_Page1Panel->SetSizer( bSizer4 ); m_Page1Panel->Layout(); - sbSizer4->Fit( m_Page1Panel ); + bSizer4->Fit( m_Page1Panel ); m_notebook->AddPage( m_Page1Panel, _("Rendering"), false ); boxSizer->Add( m_notebook, 1, wxEXPAND | wxALL, 5 ); @@ -68,6 +56,7 @@ LAYER_PANEL_BASE::LAYER_PANEL_BASE( wxWindow* parent, wxWindowID id, const wxPoi boxSizer->Fit( this ); // Connect Events + m_LayerScrolledWindow->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( LAYER_PANEL_BASE::OnLeftDblClickLayers ), NULL, this ); m_LayerScrolledWindow->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( LAYER_PANEL_BASE::OnLeftDownLayers ), NULL, this ); m_LayerScrolledWindow->Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( LAYER_PANEL_BASE::OnRightDownLayers ), NULL, this ); } @@ -75,6 +64,7 @@ LAYER_PANEL_BASE::LAYER_PANEL_BASE( wxWindow* parent, wxWindowID id, const wxPoi LAYER_PANEL_BASE::~LAYER_PANEL_BASE() { // Disconnect Events + m_LayerScrolledWindow->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( LAYER_PANEL_BASE::OnLeftDblClickLayers ), NULL, this ); m_LayerScrolledWindow->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( LAYER_PANEL_BASE::OnLeftDownLayers ), NULL, this ); m_LayerScrolledWindow->Disconnect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( LAYER_PANEL_BASE::OnRightDownLayers ), NULL, this ); } diff --git a/pcbnew/layer_panel_base.h b/pcbnew/layer_panel_base.h index 7c4c497fbc..d698f73b22 100644 --- a/pcbnew/layer_panel_base.h +++ b/pcbnew/layer_panel_base.h @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -40,9 +39,9 @@ class LAYER_PANEL_BASE : public wxPanel wxScrolledWindow* m_LayerScrolledWindow; wxFlexGridSizer* m_LayersFlexGridSizer; wxPanel* m_Page1Panel; - wxScrolledWindow* m_scrolledWindow2; // Virtual event handlers, overide them in your derived class + virtual void OnLeftDblClickLayers( wxMouseEvent& event ){ event.Skip(); } virtual void OnLeftDownLayers( wxMouseEvent& event ){ event.Skip(); } virtual void OnRightDownLayers( wxMouseEvent& event ){ event.Skip(); } diff --git a/pcbnew/layer_widget.cpp b/pcbnew/layer_widget.cpp index 2ff11ba33d..c1a8915f41 100644 --- a/pcbnew/layer_widget.cpp +++ b/pcbnew/layer_widget.cpp @@ -38,8 +38,56 @@ #include "layer_panel_base.h" #include "colors.h" #include +#include #include +//#include "rightarrow.xpm" + + + +/* XPM */ +static const char * clear_xpm[] = { +"32 14 1 1", +" c None", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; + +/* XPM */ +static const char * rightarrow_xpm[] = { +"32 14 5 1", +" c None", +". c white", +"X c #8080ff", +"o c BLUE", +"O c gray56", +" . .. ", +" .XX ", +" .XXX ", +" .XXXX ", +" ....................XXXXX ", +" .XXXXXXXXXXXXXXXXXXXXXXXX ", +" .XXXXXXXXXXXXXXXXXXXXXXXXX ", +" .oooooooooooooooooooooooooO ", +" .ooooooooooooooooooooooooO ", +" OOOOOOOOOOOOOOOOOoooooO ", +" ooooO ", +" oooO ", +" ooO ", +" oO "}; + + /** * Struct LAYER_SPEC @@ -70,26 +118,36 @@ class BOARD; */ class LAYER_PANEL : public LAYER_PANEL_BASE { - BOARD* m_Board; + BOARD* m_Board; + + wxBitmap* m_BlankBitmap; + wxBitmap* m_RightArrowBitmap; + wxSize m_BitmapSize; + + wxStaticBitmap* m_Bitmaps[32]; + + int m_CurrentRow; + + +#define LAYER_COLUMN_COUNT 4 -#define LAYER_COLUMN_COUNT 3 class MYSTATICTEXT : public wxStaticText { public: - MYSTATICTEXT( wxWindow *parent, wxWindowID id, const wxString &label, + MYSTATICTEXT( LAYER_PANEL* aLayerPanel, wxWindowID id, const wxString &label, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxString &name=wxStaticTextNameStr) : - wxStaticText( parent, id, label, pos, size, style, name ) + wxStaticText( aLayerPanel->m_LayerScrolledWindow, id, label, pos, size, style, name ) { - //Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( LAYER_PANEL::OnLeftDownLayers ), NULL, parent ); - //Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( LAYER_PANEL::OnRightDownLayers ), NULL, parent ); + Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( LAYER_PANEL::OnLeftDownLayers ), NULL, aLayerPanel ); + Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( LAYER_PANEL::OnRightDownLayers ), NULL, aLayerPanel ); } ~MYSTATICTEXT() { - //Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( LAYER_PANEL::OnLeftDownLayers ), NULL, GetParent() ); - //Disconnect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( LAYER_PANEL::OnRightDownLayers ), NULL, GetParent() ); + Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( LAYER_PANEL::OnLeftDownLayers ), NULL, NULL ); + Disconnect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( LAYER_PANEL::OnRightDownLayers ), NULL, NULL ); } }; @@ -113,10 +171,11 @@ class LAYER_PANEL : public LAYER_PANEL_BASE } */ + static wxBitmapButton* makeColorButton( int aColorIndex, int aID, wxWindow* aParent ) { - const int BUTT_SIZE_X = 25; - const int BUTT_SIZE_Y = 20; + const int BUTT_SIZE_X = 32; + const int BUTT_SIZE_Y = 22; // dynamically make a wxBitMap and brush it with the appropriate color, // then create a wxBitmapButton from it. @@ -126,16 +185,18 @@ class LAYER_PANEL : public LAYER_PANEL_BASE wxMemoryDC iconDC; iconDC.SelectObject( bitmap ); - iconDC.SetPen( *wxBLACK_PEN ); brush.SetColour( MakeColour( aColorIndex ) ); + brush.SetStyle( wxSOLID ); iconDC.SetBrush( brush ); iconDC.DrawRectangle( 0, 0, BUTT_SIZE_X, BUTT_SIZE_Y ); - return new wxBitmapButton( aParent, aID, bitmap, - wxDefaultPosition, wxSize(BUTT_SIZE_X, BUTT_SIZE_Y) ); + wxBitmapButton* ret = new wxBitmapButton( aParent, aID, bitmap, + wxDefaultPosition, wxSize(BUTT_SIZE_X, BUTT_SIZE_Y), wxBORDER_RAISED ); + + return ret; } void insertLayerRow( int aRow, const LAYER_SPEC& aSpec ) @@ -149,19 +210,32 @@ class LAYER_PANEL : public LAYER_PANEL_BASE flags.Align(wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL); // column 0 +#if 1 + m_Bitmaps[aRow] = new wxStaticBitmap( m_LayerScrolledWindow, -1, *m_BlankBitmap, + wxDefaultPosition, m_BitmapSize ); + + m_LayersFlexGridSizer->Insert( index+0, m_Bitmaps[aRow], wxSizerFlags().Align( wxALIGN_CENTER_VERTICAL ) ); +#else m_LayersFlexGridSizer->Insert( index+0, makeColorButton( aSpec.colorIndex, 0, m_LayerScrolledWindow ), flags ); +#endif // column 1 - m_LayersFlexGridSizer->Insert( index+1, - new wxCheckBox( m_LayerScrolledWindow, aSpec.checkBoxId, wxEmptyString ), - flags ); + wxBitmapButton* bb = makeColorButton( aSpec.colorIndex, 0, m_LayerScrolledWindow ); + bb->SetToolTip( _("Double click to change layer color" ) ); + m_LayersFlexGridSizer->Insert( index+1, bb, flags ); // column 2 - m_LayersFlexGridSizer->Insert( index+2, - new MYSTATICTEXT( m_LayerScrolledWindow, -1, aSpec.layerName ), - wxSizerFlags() ); + MYSTATICTEXT* st = new MYSTATICTEXT( this, -1, aSpec.layerName ); + st->SetToolTip( _( "Click here to select this layer" ) ); + m_LayersFlexGridSizer->Insert( index+2, st, + wxSizerFlags().Align( wxALIGN_CENTER_VERTICAL ) ); + + // column 3 + wxCheckBox* cb = new wxCheckBox( m_LayerScrolledWindow, aSpec.checkBoxId, wxEmptyString ); + cb->SetToolTip( _( "Enable this for visibility" ) ); + m_LayersFlexGridSizer->Insert( index+3, cb, flags ); } @@ -173,21 +247,70 @@ class LAYER_PANEL : public LAYER_PANEL_BASE { printf("OnRightDownLayers\n"); } + void OnLeftDClickLayers( wxMouseEvent& event ) + { + printf("OnLeftDblClickLayers\n"); + } + + + /** + * Function getLayerComp + * returns the component within the m_LayersFlexGridSizer at aSizerNdx. + */ + wxWindow* getLayerComp( int aSizerNdx ) + { + return m_LayersFlexGridSizer->GetChildren()[aSizerNdx]->GetWindow(); + } public: + /** + * Function GetLayerRowCount + * returns the number of rows in the layer tab. + */ + int GetLayerRowCount() + { + int controlCount = m_LayersFlexGridSizer->GetChildren().GetCount(); + return controlCount / LAYER_COLUMN_COUNT; + } + + + void SelectLayerRow( int aRow ) + { + int newNdx = LAYER_COLUMN_COUNT * aRow; + int oldNdx = LAYER_COLUMN_COUNT * m_CurrentRow; + + wxStaticBitmap* oldbm = (wxStaticBitmap*) getLayerComp( oldNdx ); + wxStaticBitmap* newbm = (wxStaticBitmap*) getLayerComp( newNdx ); + + oldbm->SetBitmap( *m_BlankBitmap ); + newbm->SetBitmap( *m_RightArrowBitmap ); + } + + /** Constructor */ LAYER_PANEL( wxWindow* parent, BOARD* aBoard ) : LAYER_PANEL_BASE( parent ) { m_Board = aBoard; - insertLayerRow( 0, LAYER_SPEC( wxT("layer 1"), RED ) ); + m_CurrentRow = 0; + m_RightArrowBitmap = new wxBitmap( rightarrow_xpm ); + m_BlankBitmap = new wxBitmap( clear_xpm ); // translucent + + m_BitmapSize = wxSize(m_BlankBitmap->GetWidth(), m_BlankBitmap->GetHeight()); + + insertLayerRow( 0, LAYER_SPEC( wxT("layer 1"), RED ) ); insertLayerRow( 1, LAYER_SPEC( wxT("layer 2"), GREEN ) ); + insertLayerRow( 2, LAYER_SPEC( wxT("layer_3_you"), BLUE ) ); + insertLayerRow( 3, LAYER_SPEC( wxT("brown_layer"), BROWN ) ); + + SelectLayerRow( 1 ); } + }; diff --git a/pcbnew/panel_layer_select.fbp b/pcbnew/panel_layer_select.fbp index b789378446..0ca9992d85 100644 --- a/pcbnew/panel_layer_select.fbp +++ b/pcbnew/panel_layer_select.fbp @@ -161,17 +161,14 @@ - - wxID_ANY - Layers + - sbSizer3 + bSizer3 wxVERTICAL none - 5 - wxEXPAND | wxALL + wxBOTTOM|wxEXPAND|wxTOP 1 @@ -201,7 +198,7 @@ - + OnLeftDblClickLayers OnLeftDownLayers @@ -218,7 +215,7 @@ - 3 + 4 wxHORIZONTAL @@ -281,77 +278,11 @@ - - wxID_ANY - Rendering + - sbSizer4 + bSizer4 wxVERTICAL none - - - 5 - wxEXPAND | wxALL - 1 - - - - 1 - - - 0 - wxID_ANY - - - m_scrolledWindow2 - protected - - 5 - 5 - - - - - - wxVSCROLL - - - - - - - - - - - - - - - - - - - - - - - - - 2 - wxBOTH - - - 0 - - fgSizer2 - wxFLEX_GROWMODE_SPECIFIED - none - 0 - 0 - - -