KiCad PCB EDA Suite
LAYER_WIDGET Class Referenceabstract

Manage a list of layers with the notion of a "current" layer, and layer specific visibility control. More...

#include <layer_widget.h>

Inheritance diagram for LAYER_WIDGET:
GERBER_LAYER_WIDGET

Classes

struct  ROW
 Provide all the data needed to add a row to a LAYER_WIDGET. More...
 

Public Member Functions

 LAYER_WIDGET (wxWindow *aParent, wxWindow *aFocusOwner, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL)
 
virtual ~LAYER_WIDGET ()
 
void SetSmallestLayerString (const wxString &aString)
 Set the string that is used for determining the smallest string displayed in the layer's tab. More...
 
wxSize GetBestSize () const
 Return the preferred minimum size, taking into consideration the dynamic content. More...
 
int GetLayerRowCount () const
 Return the number of rows in the layer tab. More...
 
int GetRenderRowCount () const
 Return the number of rows in the render tab. More...
 
void AppendLayerRow (const ROW &aRow)
 Append a new row in the layer portion of the widget. More...
 
void AppendLayerRows (const ROW *aRowsArray, int aRowCount)
 Append new rows in the layer portion of the widget. More...
 
void ClearLayerRows ()
 Empty out the layer rows. More...
 
void AppendRenderRow (const ROW &aRow)
 Append a new row in the render portion of the widget. More...
 
void AppendRenderRows (const ROW *aRowsArray, int aRowCount)
 Append new rows in the render portion of the widget. More...
 
void ClearRenderRows ()
 Empty out the render rows. More...
 
void SelectLayerRow (int aRow)
 Change the row selection in the layer list to the given row. More...
 
void SelectLayer (int aLayer)
 Change the row selection in the layer list to aLayer provided. More...
 
int GetSelectedLayer ()
 Return the selected layer or -1 if none. More...
 
void SetLayerVisible (int aLayer, bool isVisible)
 Set aLayer visible or not. More...
 
bool IsLayerVisible (int aLayer)
 Return the visible state of the layer ROW associated with aLayer id. More...
 
void SetLayerColor (int aLayer, const COLOR4D &aColor)
 Change the color of aLayer. More...
 
COLOR4D GetLayerColor (int aLayer) const
 Return the color of the layer ROW associated with aLayer id. More...
 
COLOR4D GetRenderColor (int aRow) const
 Return the color of the Render ROW in position aRow. More...
 
void SetRenderState (int aId, bool isSet)
 Set the state of the checkbox associated with aId within the Render tab group of the widget. More...
 
bool GetRenderState (int aId)
 Return the state of the checkbox associated with aId. More...
 
void UpdateLayouts ()
 
void UpdateLayerIcons ()
 Update all layer manager icons (layers only). More...
 
virtual void OnLayerColorChange (int aLayer, const COLOR4D &aColor)=0
 Notify client code about a layer color change. More...
 
virtual bool OnLayerSelect (int aLayer)=0
 Notify client code whenever the user selects a different layer. More...
 
virtual void OnLayerVisible (int aLayer, bool isVisible, bool isFinal=true)=0
 Notify client code about a layer visibility change. More...
 
virtual void OnLayerRightClick (wxMenu &aMenu)=0
 Notify client code about a layer being right-clicked. More...
 
virtual void OnRenderColorChange (int aId, const COLOR4D &aColor)=0
 Notify client code whenever the user changes a rendering color. More...
 
virtual void OnRenderEnable (int aId, bool isEnabled)=0
 Notify client code whenever the user changes an rendering enable in one of the rendering checkboxes. More...
 

Static Public Attributes

static const wxEventType EVT_LAYER_COLOR_CHANGE = wxNewEventType()
 

Protected Types

enum  POPUP_ID { ID_CHANGE_LAYER_COLOR = wxID_HIGHEST , ID_CHANGE_RENDER_COLOR , ID_LAST_VALUE }
 

Protected Member Functions

virtual bool useAlternateBitmap (int aRow)
 
virtual COLOR4D getBackgroundLayerColor ()
 Subclasses can override this to provide accurate representation of transparent color swatches. More...
 
void OnLeftDownLayers (wxMouseEvent &event)
 
void OnRightDownLayer (wxMouseEvent &event, COLOR_SWATCH *aColorSwatch, const wxString &aLayerName)
 Called when user right-clicks a layer. More...
 
void OnLayerSwatchChanged (wxCommandEvent &aEvent)
 Called when a user changes a swatch color. More...
 
void OnLayerCheckBox (wxCommandEvent &event)
 Handle the "is layer visible" checkbox and propagates the event to the client's notification function. More...
 
void OnRightDownRender (wxMouseEvent &aEvent, COLOR_SWATCH *aColorSwatch, const wxString &aRenderName)
 Notify when user right-clicks a render option. More...
 
void OnRenderSwatchChanged (wxCommandEvent &aEvent)
 Called when user has changed the swatch color of a render entry. More...
 
void OnRenderCheckBox (wxCommandEvent &event)
 
void OnTabChange (wxNotebookEvent &event)
 
wxWindow * getLayerComp (int aRow, int aColumn) const
 Return the component within the m_LayersFlexGridSizer at aRow and aCol or NULL if these parameters are out of range. More...
 
wxWindow * getRenderComp (int aRow, int aColumn) const
 
int findLayerRow (int aLayer) const
 Return the row index that aLayer resides in, or -1 if not found. More...
 
int findRenderRow (int aId) const
 
void insertLayerRow (int aRow, const ROW &aSpec)
 Append or insert a new row in the layer portion of the widget. More...
 
void insertRenderRow (int aRow, const ROW &aSpec)
 
void setLayerCheckbox (int aLayer, bool isVisible)
 
void updateLayerRow (int aRow, const wxString &aName)
 
void passOnFocus ()
 Give away the keyboard focus up to the main parent window. More...
 

Static Protected Member Functions

static int encodeId (int aColumn, int aId)
 Allow saving a layer index within a control as its wxControl id. More...
 
static int getDecodedId (int aControlId)
 Decode aControlId to original un-encoded value. More...
 

Protected Attributes

wxNotebook * m_notebook
 
wxPanel * m_LayerPanel
 
wxScrolledWindow * m_LayerScrolledWindow
 
wxFlexGridSizer * m_LayersFlexGridSizer
 
wxPanel * m_RenderingPanel
 
wxScrolledWindow * m_RenderScrolledWindow
 
wxFlexGridSizer * m_RenderFlexGridSizer
 
wxWindow * m_FocusOwner
 
int m_CurrentRow
 selected row of layer list More...
 
int m_PointSize
 
ROW_ICON_PROVIDERm_IconProvider
 
wxString m_smallestLayerString
 

Detailed Description

Manage a list of layers with the notion of a "current" layer, and layer specific visibility control.

You must derive from it to use it so you can implement the abstract functions which receive the events. Each layer is given its own color, and that color can be changed within the UI provided here. This widget knows nothing of the client code, meaning it has no knowledge of a BOARD or anything. To use it you must derive from this class and implement the abstract functions:

void OnLayerColorChange( int aLayer, int aColor );

bool OnLayerSelect( int aLayer );

void OnLayerVisible( int aLayer, bool isVisible );

void OnRenderColorChange( int id, int aColor );

void OnRenderEnable( int id, bool isEnabled );

Note
Even if designed toward layers, it is used to contain other stuff, too (the second page in pcbnew contains render items, for example).

Definition at line 77 of file layer_widget.h.

Member Enumeration Documentation

◆ POPUP_ID

enum LAYER_WIDGET::POPUP_ID
protected
Enumerator
ID_CHANGE_LAYER_COLOR 
ID_CHANGE_RENDER_COLOR 
ID_LAST_VALUE 

Definition at line 458 of file layer_widget.h.

459 {
460 ID_CHANGE_LAYER_COLOR = wxID_HIGHEST,
463 };
@ ID_CHANGE_RENDER_COLOR
Definition: layer_widget.h:461

Constructor & Destructor Documentation

◆ LAYER_WIDGET()

LAYER_WIDGET::LAYER_WIDGET ( wxWindow *  aParent,
wxWindow *  aFocusOwner,
wxWindowID  id = wxID_ANY,
const wxPoint &  pos = wxDefaultPosition,
const wxSize &  size = wxDefaultSize,
long  style = wxTAB_TRAVERSAL 
)
Parameters
aParentis the parent window.
aFocusOwneris the window that should be sent the focus after.
idis the wxWindow id ( default = wxID_ANY).
posis the window position.
sizeis the window size.
styleis the window style.

Definition at line 485 of file layer_widget.cpp.

486 :
487 wxPanel( aParent, id, pos, size, style ),
488 m_smallestLayerString( wxT( "M...M" ) )
489{
490 int indicatorSize = ConvertDialogToPixels( wxSize( 6, 6 ) ).x;
491 m_IconProvider = new ROW_ICON_PROVIDER( indicatorSize );
492
493 int pointSize = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ).GetPointSize();
494 int screenHeight = wxSystemSettings::GetMetric( wxSYS_SCREEN_Y );
495
496 if( screenHeight <= 900 && pointSize >= indicatorSize )
497 pointSize = pointSize * 8 / 10;
498
499 m_PointSize = pointSize;
500
501 wxBoxSizer* mainSizer = new wxBoxSizer( wxVERTICAL );
502
503 m_notebook = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP );
504
505 wxFont font = m_notebook->GetFont();
506
507 // change the font size on the notebook's tabs to match aPointSize
508 font.SetPointSize( pointSize );
509 m_notebook->SetFont( font );
510
511 m_LayerPanel = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize,
512 wxTAB_TRAVERSAL );
513
514 wxBoxSizer* layerPanelSizer;
515 layerPanelSizer = new wxBoxSizer( wxVERTICAL );
516
517 m_LayerScrolledWindow = new wxScrolledWindow( m_LayerPanel, wxID_ANY, wxDefaultPosition,
518 wxDefaultSize, wxNO_BORDER );
519 m_LayerScrolledWindow->SetScrollRate( 5, 5 );
520 m_LayersFlexGridSizer = new wxFlexGridSizer( 0, LYR_COLUMN_COUNT, 0, 1 );
521 m_LayersFlexGridSizer->SetFlexibleDirection( wxHORIZONTAL );
522 m_LayersFlexGridSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_NONE );
523
524 // Make column 3 growable/stretchable
525 m_LayersFlexGridSizer->AddGrowableCol( 3, 1 );
526
528 m_LayerScrolledWindow->Layout();
530 layerPanelSizer->Add( m_LayerScrolledWindow, 1, wxBOTTOM | wxEXPAND | wxLEFT | wxTOP, 2 );
531
532 m_LayerPanel->SetSizer( layerPanelSizer );
533 m_LayerPanel->Layout();
534 layerPanelSizer->Fit( m_LayerPanel );
535 m_notebook->AddPage( m_LayerPanel, _( "Layers" ), true );
536 m_RenderingPanel = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize,
537 wxTAB_TRAVERSAL );
538
539 wxBoxSizer* renderPanelSizer;
540 renderPanelSizer = new wxBoxSizer( wxVERTICAL );
541
542 m_RenderScrolledWindow = new wxScrolledWindow( m_RenderingPanel, wxID_ANY, wxDefaultPosition,
543 wxDefaultSize, wxNO_BORDER );
544 m_RenderScrolledWindow->SetScrollRate( 5, 5 );
545 m_RenderFlexGridSizer = new wxFlexGridSizer( 0, RND_COLUMN_COUNT, 0, 1 );
546 m_RenderFlexGridSizer->SetFlexibleDirection( wxHORIZONTAL );
547 m_RenderFlexGridSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_NONE );
548
550 m_RenderScrolledWindow->Layout();
552 renderPanelSizer->Add( m_RenderScrolledWindow, 1, wxALL | wxEXPAND, 5 );
553
554 m_RenderingPanel->SetSizer( renderPanelSizer );
555 m_RenderingPanel->Layout();
556 renderPanelSizer->Fit( m_RenderingPanel );
557 m_notebook->AddPage( m_RenderingPanel, _( "Items" ), false );
558
559 mainSizer->Add( m_notebook, 1, wxEXPAND, 5 );
560
561 SetSizer( mainSizer );
562
563 m_FocusOwner = aFocusOwner;
564
565 m_CurrentRow = -1; // hide the arrow initially
566
567 // trap the tab changes so that we can call passOnFocus().
568 m_notebook->Bind( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, &LAYER_WIDGET::OnTabChange, this );
569
570 Layout();
571}
wxWindow * m_FocusOwner
Definition: layer_widget.h:473
wxScrolledWindow * m_RenderScrolledWindow
Definition: layer_widget.h:470
ROW_ICON_PROVIDER * m_IconProvider
Definition: layer_widget.h:477
wxPanel * m_RenderingPanel
Definition: layer_widget.h:469
wxFlexGridSizer * m_LayersFlexGridSizer
Definition: layer_widget.h:468
void OnTabChange(wxNotebookEvent &event)
int m_CurrentRow
selected row of layer list
Definition: layer_widget.h:474
wxString m_smallestLayerString
Definition: layer_widget.h:479
wxFlexGridSizer * m_RenderFlexGridSizer
Definition: layer_widget.h:471
wxPanel * m_LayerPanel
Definition: layer_widget.h:466
wxNotebook * m_notebook
Definition: layer_widget.h:465
wxScrolledWindow * m_LayerScrolledWindow
Definition: layer_widget.h:467
Icon provider for the "standard" row indicators, for example in layer selection lists.
#define _(s)
#define LYR_COLUMN_COUNT
Layer tab column count.
Definition: layer_widget.h:48
#define RND_COLUMN_COUNT
Rendering tab column count.
Definition: layer_widget.h:49

References _, LYR_COLUMN_COUNT, m_CurrentRow, m_FocusOwner, m_IconProvider, m_LayerPanel, m_LayerScrolledWindow, m_LayersFlexGridSizer, m_notebook, m_PointSize, m_RenderFlexGridSizer, m_RenderingPanel, m_RenderScrolledWindow, OnTabChange(), and RND_COLUMN_COUNT.

◆ ~LAYER_WIDGET()

LAYER_WIDGET::~LAYER_WIDGET ( )
virtual

Definition at line 574 of file layer_widget.cpp.

575{
576 delete m_IconProvider;
577}

References m_IconProvider.

Member Function Documentation

◆ AppendLayerRow()

void LAYER_WIDGET::AppendLayerRow ( const ROW aRow)

Append a new row in the layer portion of the widget.

The user must ensure that ROW::id is unique for all existing rows on Windows.

Definition at line 646 of file layer_widget.cpp.

647{
648 int nextRow = GetLayerRowCount();
649 insertLayerRow( nextRow, aRow );
650}
void insertLayerRow(int aRow, const ROW &aSpec)
Append or insert a new row in the layer portion of the widget.
int GetLayerRowCount() const
Return the number of rows in the layer tab.

References GetLayerRowCount(), and insertLayerRow().

Referenced by AppendLayerRows(), and GERBER_LAYER_WIDGET::ReFill().

◆ AppendLayerRows()

void LAYER_WIDGET::AppendLayerRows ( const ROW aRowsArray,
int  aRowCount 
)
inline

Append new rows in the layer portion of the widget.

The user must ensure that ROW::id is unique for all existing rows on Windows.

Definition at line 175 of file layer_widget.h.

176 {
177 for( int row=0; row<aRowCount; ++row )
178 AppendLayerRow( aRowsArray[row] );
179
181 }
void UpdateLayouts()
void AppendLayerRow(const ROW &aRow)
Append a new row in the layer portion of the widget.

References AppendLayerRow(), and UpdateLayouts().

◆ AppendRenderRow()

void LAYER_WIDGET::AppendRenderRow ( const ROW aRow)

Append a new row in the render portion of the widget.

The user must ensure that ROW::id is unique for all existing rows on Windows.

Definition at line 659 of file layer_widget.cpp.

660{
661 int nextRow = GetRenderRowCount();
662 insertRenderRow( nextRow, aRow );
663}
void insertRenderRow(int aRow, const ROW &aSpec)
int GetRenderRowCount() const
Return the number of rows in the render tab.

References GetRenderRowCount(), and insertRenderRow().

Referenced by AppendRenderRows().

◆ AppendRenderRows()

void LAYER_WIDGET::AppendRenderRows ( const ROW aRowsArray,
int  aRowCount 
)
inline

Append new rows in the render portion of the widget.

The user must ensure that ROW::id is unique for all existing rows on Windows.

Definition at line 200 of file layer_widget.h.

201 {
202 for( int row=0; row<aRowCount; ++row )
203 AppendRenderRow( aRowsArray[row] );
204
206 }
void AppendRenderRow(const ROW &aRow)
Append a new row in the render portion of the widget.

References AppendRenderRow(), and UpdateLayouts().

Referenced by GERBER_LAYER_WIDGET::ReFillRender().

◆ ClearLayerRows()

void LAYER_WIDGET::ClearLayerRows ( )

Empty out the layer rows.

Definition at line 653 of file layer_widget.cpp.

654{
655 m_LayersFlexGridSizer->Clear( true );
656}

References m_LayersFlexGridSizer.

Referenced by GERBER_LAYER_WIDGET::ReFill().

◆ ClearRenderRows()

void LAYER_WIDGET::ClearRenderRows ( )

Empty out the render rows.

Definition at line 666 of file layer_widget.cpp.

667{
668 m_RenderFlexGridSizer->Clear( true );
669}

References m_RenderFlexGridSizer.

Referenced by GERBER_LAYER_WIDGET::ReFillRender().

◆ encodeId()

int LAYER_WIDGET::encodeId ( int  aColumn,
int  aId 
)
staticprotected

Allow saving a layer index within a control as its wxControl id.

To do so in a way that all child wxControl ids within a wxWindow are unique, since this is required by Windows.

See also
getDecodedId()

Definition at line 62 of file layer_widget.cpp.

63{
64 int id = aId * LYR_COLUMN_COUNT + aColumn;
65 return id;
66}

References LYR_COLUMN_COUNT.

Referenced by insertLayerRow(), and insertRenderRow().

◆ findLayerRow()

int LAYER_WIDGET::findLayerRow ( int  aLayer) const
protected

Return the row index that aLayer resides in, or -1 if not found.

Definition at line 271 of file layer_widget.cpp.

272{
273 int count = GetLayerRowCount();
274
275 for( int row = 0; row < count; ++row )
276 {
277 // column 0 in the layer scroll window has a wxStaticBitmap, get its ID.
278 wxWindow* w = getLayerComp( row, 0 );
279 wxASSERT( w );
280
281 if( aLayer == getDecodedId( w->GetId() ) )
282 return row;
283 }
284
285 return -1;
286}
static int getDecodedId(int aControlId)
Decode aControlId to original un-encoded value.
wxWindow * getLayerComp(int aRow, int aColumn) const
Return the component within the m_LayersFlexGridSizer at aRow and aCol or NULL if these parameters ar...

References getDecodedId(), getLayerComp(), and GetLayerRowCount().

Referenced by GERBER_LAYER_WIDGET::CollectCurrentColorSettings(), GetLayerColor(), IsLayerVisible(), OnLeftDownLayers(), GERBER_LAYER_WIDGET::ReFill(), SelectLayer(), setLayerCheckbox(), and SetLayerColor().

◆ findRenderRow()

int LAYER_WIDGET::findRenderRow ( int  aId) const
protected

Definition at line 300 of file layer_widget.cpp.

301{
302 int count = GetRenderRowCount();
303
304 for( int row = 0; row < count; ++row )
305 {
306 // column 0 in the layer scroll window has a wxStaticBitmap, get its ID.
307 wxWindow* w = getRenderComp( row, 0 );
308 wxASSERT( w );
309
310 if( aId == getDecodedId( w->GetId() ) )
311 return row;
312 }
313
314 return -1;
315}
wxWindow * getRenderComp(int aRow, int aColumn) const

References getDecodedId(), getRenderComp(), and GetRenderRowCount().

Referenced by GERBER_LAYER_WIDGET::CollectCurrentColorSettings(), GetRenderState(), and SetRenderState().

◆ getBackgroundLayerColor()

virtual COLOR4D LAYER_WIDGET::getBackgroundLayerColor ( )
inlineprotectedvirtual

Subclasses can override this to provide accurate representation of transparent color swatches.

Definition at line 369 of file layer_widget.h.

369{ return COLOR4D::BLACK; }
@ BLACK
Definition: color4d.h:44

References BLACK.

Referenced by insertLayerRow(), and insertRenderRow().

◆ GetBestSize()

wxSize LAYER_WIDGET::GetBestSize ( ) const

Return the preferred minimum size, taking into consideration the dynamic content.

Nothing in wxWidgets was reliable enough so this overrides one of their functions.

Definition at line 580 of file layer_widget.cpp.

581{
582 // size of m_LayerScrolledWindow --------------
583 wxArrayInt widths = m_LayersFlexGridSizer->GetColWidths();
584 int totWidth = 0;
585
586 if( widths.GetCount() )
587 {
588 for( int i = 0; i < LYR_COLUMN_COUNT; ++i )
589 {
590 totWidth += widths[i] + m_LayersFlexGridSizer->GetHGap();
591 }
592 }
593
594 // Account for the parent's frame:
595 totWidth += 15;
596
597 /* The minimum height is a small size to properly force computation
598 * of the panel's scrollbars (otherwise it will assume it *has* all
599 * this space) */
600 unsigned totHeight = 32;
601
602 wxSize layerz( totWidth, totHeight );
603
604 layerz += m_LayerPanel->GetWindowBorderSize();
605
606 // size of m_RenderScrolledWindow --------------
607 widths = m_RenderFlexGridSizer->GetColWidths();
608 totWidth = 0;
609
610 if( widths.GetCount() )
611 {
612 for( int i = 0; i < RND_COLUMN_COUNT; ++i )
613 {
614 totWidth += widths[i] + m_RenderFlexGridSizer->GetHGap();
615 }
616 }
617
618 // account for the parent's frame, this one has void space of 10 PLUS a border:
619 totWidth += 15;
620
621 // For totHeight re-use the previous small one
622 wxSize renderz( totWidth, totHeight );
623
624 renderz += m_RenderingPanel->GetWindowBorderSize();
625
626 wxSize clientz( std::max(renderz.x,layerz.x), std::max(renderz.y,layerz.y) );
627
628 return clientz;
629}

References LYR_COLUMN_COUNT, m_LayerPanel, m_LayersFlexGridSizer, m_RenderFlexGridSizer, m_RenderingPanel, and RND_COLUMN_COUNT.

Referenced by GERBVIEW_FRAME::GERBVIEW_FRAME(), and GERBVIEW_FRAME::ReFillLayerWidget().

◆ getDecodedId()

int LAYER_WIDGET::getDecodedId ( int  aControlId)
staticprotected

Decode aControlId to original un-encoded value.

This holds if encodedId was called with a layer (this box is used for other things than layers, too).

Definition at line 69 of file layer_widget.cpp.

70{
71 int id = aControlId / LYR_COLUMN_COUNT; // rounding is OK.
72 return id;
73}

References LYR_COLUMN_COUNT.

Referenced by findLayerRow(), findRenderRow(), GetSelectedLayer(), OnLayerCheckBox(), OnLayerSwatchChanged(), OnLeftDownLayers(), GERBER_LAYER_WIDGET::onPopupSelection(), OnRenderCheckBox(), and OnRenderSwatchChanged().

◆ GetLayerColor()

COLOR4D LAYER_WIDGET::GetLayerColor ( int  aLayer) const

Return the color of the layer ROW associated with aLayer id.

Definition at line 761 of file layer_widget.cpp.

762{
763 int row = findLayerRow( aLayer );
764
765 if( row >= 0 )
766 {
767 const int col = 1; // bitmap button is column 1
768 auto swatch = static_cast<COLOR_SWATCH*>( getLayerComp( row, col ) );
769 wxASSERT( swatch );
770
771 return swatch->GetSwatchColor();
772 }
773
774 return COLOR4D::UNSPECIFIED; // it's caller fault, gave me a bad layer
775}
A simple color swatch of the kind used to set layer colors.
Definition: color_swatch.h:57
int findLayerRow(int aLayer) const
Return the row index that aLayer resides in, or -1 if not found.

References findLayerRow(), and getLayerComp().

Referenced by GERBER_LAYER_WIDGET::CollectCurrentColorSettings().

◆ getLayerComp()

wxWindow * LAYER_WIDGET::getLayerComp ( int  aRow,
int  aColumn 
) const
protected

Return the component within the m_LayersFlexGridSizer at aRow and aCol or NULL if these parameters are out of range.

Parameters
aRowis the row index
aColumnis the column
Returns
the component installed within the sizer at given grid coordinate.

Definition at line 260 of file layer_widget.cpp.

261{
262 unsigned ndx = aRow * LYR_COLUMN_COUNT + aColumn;
263
264 if( ndx < m_LayersFlexGridSizer->GetChildren().GetCount() )
265 return m_LayersFlexGridSizer->GetChildren()[ndx]->GetWindow();
266
267 return nullptr;
268}

References LYR_COLUMN_COUNT, and m_LayersFlexGridSizer.

Referenced by findLayerRow(), GetLayerColor(), GetSelectedLayer(), IsLayerVisible(), OnLeftDownLayers(), GERBER_LAYER_WIDGET::onPopupSelection(), OnRenderSwatchChanged(), SelectLayerRow(), setLayerCheckbox(), SetLayerColor(), UpdateLayerIcons(), and updateLayerRow().

◆ GetLayerRowCount()

int LAYER_WIDGET::GetLayerRowCount ( ) const

Return the number of rows in the layer tab.

Definition at line 632 of file layer_widget.cpp.

633{
634 int controlCount = m_LayersFlexGridSizer->GetChildren().GetCount();
635 return controlCount / LYR_COLUMN_COUNT;
636}

References LYR_COLUMN_COUNT, and m_LayersFlexGridSizer.

Referenced by AppendLayerRow(), findLayerRow(), OnLeftDownLayers(), GERBER_LAYER_WIDGET::onPopupSelection(), OnRenderSwatchChanged(), and UpdateLayerIcons().

◆ GetRenderColor()

COLOR4D LAYER_WIDGET::GetRenderColor ( int  aRow) const

Return the color of the Render ROW in position aRow.

Definition at line 778 of file layer_widget.cpp.

779{
780 int row = aRow;
781
782 if( row >= 0 )
783 {
784 const int col = 0; // bitmap button (swatch) is column 0
785 auto swatch = static_cast<COLOR_SWATCH*>( getRenderComp( row, col ) );
786 wxASSERT( swatch );
787
788 return swatch->GetSwatchColor();
789 }
790
791 return COLOR4D::UNSPECIFIED; // it's caller fault, gave me a bad layer
792}

References getRenderComp().

Referenced by GERBER_LAYER_WIDGET::CollectCurrentColorSettings().

◆ getRenderComp()

wxWindow * LAYER_WIDGET::getRenderComp ( int  aRow,
int  aColumn 
) const
protected

Definition at line 289 of file layer_widget.cpp.

290{
291 int ndx = aRow * RND_COLUMN_COUNT + aColumn;
292
293 if( (unsigned) ndx < m_RenderFlexGridSizer->GetChildren().GetCount() )
294 return m_RenderFlexGridSizer->GetChildren()[ndx]->GetWindow();
295
296 return nullptr;
297}

References m_RenderFlexGridSizer, and RND_COLUMN_COUNT.

Referenced by findRenderRow(), GetRenderColor(), GetRenderState(), OnRenderSwatchChanged(), and SetRenderState().

◆ GetRenderRowCount()

int LAYER_WIDGET::GetRenderRowCount ( ) const

Return the number of rows in the render tab.

Definition at line 639 of file layer_widget.cpp.

640{
641 int controlCount = m_RenderFlexGridSizer->GetChildren().GetCount();
642 return controlCount / RND_COLUMN_COUNT;
643}

References m_RenderFlexGridSizer, and RND_COLUMN_COUNT.

Referenced by AppendRenderRow(), findRenderRow(), and OnRenderSwatchChanged().

◆ GetRenderState()

bool LAYER_WIDGET::GetRenderState ( int  aId)

Return the state of the checkbox associated with aId.

Returns
true if checked, else false.

Definition at line 809 of file layer_widget.cpp.

810{
811 int row = findRenderRow( aId );
812
813 if( row >= 0 )
814 {
815 int col = 1; // checkbox is column 1
816 wxCheckBox* cb = (wxCheckBox*) getRenderComp( row, col );
817 wxASSERT( cb );
818 return cb->GetValue();
819 }
820
821 return false; // the value of a non-existent row
822}
int findRenderRow(int aId) const

References findRenderRow(), and getRenderComp().

◆ GetSelectedLayer()

int LAYER_WIDGET::GetSelectedLayer ( )

Return the selected layer or -1 if none.

Definition at line 700 of file layer_widget.cpp.

701{
702 wxWindow* w = getLayerComp( m_CurrentRow, 0 );
703
704 if( w )
705 return getDecodedId( w->GetId() );
706
707 return UNDEFINED_LAYER;
708}
@ UNDEFINED_LAYER
Definition: layer_ids.h:60

References getDecodedId(), getLayerComp(), m_CurrentRow, and UNDEFINED_LAYER.

◆ insertLayerRow()

void LAYER_WIDGET::insertLayerRow ( int  aRow,
const ROW aSpec 
)
protected

Append or insert a new row in the layer portion of the widget.

Definition at line 318 of file layer_widget.cpp.

319{
320 wxASSERT( aRow >= 0 );
321
322 int col;
323 int index = aRow * LYR_COLUMN_COUNT;
324 const int flags = wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT;
325
326 // column 0
327 col = COLUMN_ICON_ACTIVE;
329 ROW_ICON_PROVIDER::STATE::OFF, encodeId( col, aSpec.id ) );
330 sbm->Bind( wxEVT_LEFT_DOWN, &LAYER_WIDGET::OnLeftDownLayers, this );
331 m_LayersFlexGridSizer->wxSizer::Insert( index+col, sbm, 0, flags );
332
333 // column 1 (COLUMN_COLORBM)
334 col = COLUMN_COLORBM;
335
336 auto bmb = new COLOR_SWATCH( m_LayerScrolledWindow, aSpec.color, encodeId( col, aSpec.id ),
337 getBackgroundLayerColor(), aSpec.defaultColor, SWATCH_SMALL );
338 bmb->Bind( wxEVT_LEFT_DOWN, &LAYER_WIDGET::OnLeftDownLayers, this );
339 bmb->Bind( COLOR_SWATCH_CHANGED, &LAYER_WIDGET::OnLayerSwatchChanged, this );
340 bmb->SetToolTip( _( "Left double click or middle click for color change, right click for "
341 "menu" ) );
342 m_LayersFlexGridSizer->wxSizer::Insert( index+col, bmb, 0, flags );
343
344 // column 2 (COLUMN_COLOR_LYR_CB)
346 wxCheckBox* cb = new wxCheckBox( m_LayerScrolledWindow, encodeId( col, aSpec.id ),
347 wxEmptyString );
348 cb->SetValue( aSpec.state );
349 cb->Bind( wxEVT_COMMAND_CHECKBOX_CLICKED, &LAYER_WIDGET::OnLayerCheckBox, this );
350 cb->SetToolTip( _( "Enable this for visibility" ) );
351 m_LayersFlexGridSizer->wxSizer::Insert( index+col, cb, 0, flags );
352
353 // column 3 (COLUMN_COLOR_LYRNAME)
356 encodeId( col, aSpec.id ),
357 aSpec.rowName, wxDefaultPosition,
358 wxDefaultSize,
359 wxST_ELLIPSIZE_MIDDLE );
360 shrinkFont( st, m_PointSize );
361 st->Bind( wxEVT_LEFT_DOWN, &LAYER_WIDGET::OnLeftDownLayers, this );
362 st->SetToolTip( aSpec.tooltip );
364 m_LayersFlexGridSizer->wxSizer::Insert( index+col, st, 0, flags | wxEXPAND );
365
366 // column 4 (COLUMN_ALPHA_INDICATOR)
369 ROW_ICON_PROVIDER::STATE::OFF, wxID_ANY );
370 m_LayersFlexGridSizer->wxSizer::Insert( index+col, sbm, 0, flags );
371
372 // Bind right click eventhandler to all columns
373 wxString layerName( aSpec.rowName );
374
375 sbm->Bind( wxEVT_RIGHT_DOWN, [this, bmb, layerName] ( wxMouseEvent& aEvt )
376 {
377 OnRightDownLayer( aEvt, bmb, layerName );
378 } );
379 bmb->Bind( wxEVT_RIGHT_DOWN, [this, bmb, layerName] ( wxMouseEvent& aEvt )
380 {
381 OnRightDownLayer( aEvt, bmb, layerName );
382 } );
383 cb->Bind( wxEVT_RIGHT_DOWN, [this, bmb, layerName] ( wxMouseEvent& aEvt )
384 {
385 OnRightDownLayer( aEvt, bmb, layerName );
386 } );
387 st->Bind( wxEVT_RIGHT_DOWN, [this, bmb, layerName] ( wxMouseEvent& aEvt )
388 {
389 OnRightDownLayer( aEvt, bmb, layerName );
390 } );
391}
representing a row indicator icon for use in places like the layer widget
static int encodeId(int aColumn, int aId)
Allow saving a layer index within a control as its wxControl id.
void OnLeftDownLayers(wxMouseEvent &event)
virtual COLOR4D getBackgroundLayerColor()
Subclasses can override this to provide accurate representation of transparent color swatches.
Definition: layer_widget.h:369
void OnLayerSwatchChanged(wxCommandEvent &aEvent)
Called when a user changes a swatch color.
void OnLayerCheckBox(wxCommandEvent &event)
Handle the "is layer visible" checkbox and propagates the event to the client's notification function...
void OnRightDownLayer(wxMouseEvent &event, COLOR_SWATCH *aColorSwatch, const wxString &aLayerName)
Called when user right-clicks a layer.
A version of a wxStaticText control that will request a smaller size than the full string.
void SetMinimumStringLength(const wxString &aString)
Set the string that is used for determining the requested size of the control.
@ SWATCH_SMALL
Definition: color_swatch.h:40
static void shrinkFont(wxWindow *aControl, int aPointSize)
Reduce the size of the wxFont associated with aControl.
#define COLUMN_COLOR_LYRNAME
Definition: layer_widget.h:54
#define COLUMN_ALPHA_INDICATOR
Definition: layer_widget.h:55
#define COLUMN_COLOR_LYR_CB
Definition: layer_widget.h:53
#define COLUMN_ICON_ACTIVE
Definition: layer_widget.h:51
#define COLUMN_COLORBM
Definition: layer_widget.h:52

References _, LAYER_WIDGET::ROW::color, COLUMN_ALPHA_INDICATOR, COLUMN_COLOR_LYR_CB, COLUMN_COLOR_LYRNAME, COLUMN_COLORBM, COLUMN_ICON_ACTIVE, LAYER_WIDGET::ROW::defaultColor, encodeId(), getBackgroundLayerColor(), LAYER_WIDGET::ROW::id, LYR_COLUMN_COUNT, m_IconProvider, m_LayerScrolledWindow, m_LayersFlexGridSizer, m_PointSize, m_smallestLayerString, OnLayerCheckBox(), OnLayerSwatchChanged(), OnLeftDownLayers(), OnRightDownLayer(), LAYER_WIDGET::ROW::rowName, WX_ELLIPSIZED_STATIC_TEXT::SetMinimumStringLength(), shrinkFont(), LAYER_WIDGET::ROW::state, SWATCH_SMALL, and LAYER_WIDGET::ROW::tooltip.

Referenced by AppendLayerRow().

◆ insertRenderRow()

void LAYER_WIDGET::insertRenderRow ( int  aRow,
const ROW aSpec 
)
protected

Definition at line 413 of file layer_widget.cpp.

414{
415 wxASSERT( aRow >= 0 );
416
417 int col;
418 int index = aRow * RND_COLUMN_COUNT;
419 const int flags = wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT;
420
421 wxString renderName( aSpec.rowName );
422 wxCheckBox* cb = nullptr;
423
424 // column 1
425 if( !aSpec.spacer )
426 {
427 col = 1;
428 cb = new wxCheckBox( m_RenderScrolledWindow, encodeId( col, aSpec.id ),
429 aSpec.rowName, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT );
430 shrinkFont( cb, m_PointSize );
431 cb->SetValue( aSpec.state );
432 cb->Enable( aSpec.changeable );
433 cb->Bind( wxEVT_COMMAND_CHECKBOX_CLICKED, &LAYER_WIDGET::OnRenderCheckBox, this );
434 cb->SetToolTip( aSpec.tooltip );
435 }
436
437 // column 0
438 col = 0;
439
440 if( aSpec.color != COLOR4D::UNSPECIFIED )
441 {
442 auto bmb = new COLOR_SWATCH( m_RenderScrolledWindow, aSpec.color, encodeId( col, aSpec.id ),
443 getBackgroundLayerColor(), aSpec.defaultColor, SWATCH_SMALL );
444 bmb->Bind( COLOR_SWATCH_CHANGED, &LAYER_WIDGET::OnRenderSwatchChanged, this );
445 bmb->SetToolTip( _( "Left double click or middle click for color change" ) );
446 m_RenderFlexGridSizer->wxSizer::Insert( index+col, bmb, 0, flags );
447
448 bmb->Bind( wxEVT_RIGHT_DOWN, [this, bmb, renderName] ( wxMouseEvent& aEvt ) {
449 OnRightDownRender( aEvt, bmb, renderName );
450 } );
451 cb->Bind( wxEVT_RIGHT_DOWN, [this, bmb, renderName] ( wxMouseEvent& aEvt ) {
452 OnRightDownRender( aEvt, bmb, renderName );
453 } );
454
455 // could add a left click handler on the color button that toggles checkbox.
456 }
457 else // == -1, no color selection wanted
458 {
459 // need a place holder within the sizer to keep grid full.
460 wxPanel* invisible = new wxPanel( m_RenderScrolledWindow, encodeId( col, aSpec.id ) );
461 m_RenderFlexGridSizer->wxSizer::Insert( index+col, invisible, 0, flags );
462 }
463
464 // Items have to be inserted in order
465 col = 1;
466
467 if( aSpec.spacer )
468 {
469 wxPanel* invisible = new wxPanel( m_RenderScrolledWindow, wxID_ANY );
470 m_RenderFlexGridSizer->wxSizer::Insert( index+col, invisible, 0, flags );
471 }
472 else
473 {
474 m_RenderFlexGridSizer->wxSizer::Insert( index+col, cb, 0, flags );
475 }
476}
void OnRenderSwatchChanged(wxCommandEvent &aEvent)
Called when user has changed the swatch color of a render entry.
void OnRenderCheckBox(wxCommandEvent &event)
void OnRightDownRender(wxMouseEvent &aEvent, COLOR_SWATCH *aColorSwatch, const wxString &aRenderName)
Notify when user right-clicks a render option.

References _, LAYER_WIDGET::ROW::changeable, LAYER_WIDGET::ROW::color, LAYER_WIDGET::ROW::defaultColor, encodeId(), getBackgroundLayerColor(), LAYER_WIDGET::ROW::id, m_PointSize, m_RenderFlexGridSizer, m_RenderScrolledWindow, OnRenderCheckBox(), OnRenderSwatchChanged(), OnRightDownRender(), RND_COLUMN_COUNT, LAYER_WIDGET::ROW::rowName, shrinkFont(), LAYER_WIDGET::ROW::spacer, LAYER_WIDGET::ROW::state, SWATCH_SMALL, and LAYER_WIDGET::ROW::tooltip.

Referenced by AppendRenderRow().

◆ IsLayerVisible()

bool LAYER_WIDGET::IsLayerVisible ( int  aLayer)

Return the visible state of the layer ROW associated with aLayer id.

Definition at line 731 of file layer_widget.cpp.

732{
733 int row = findLayerRow( aLayer );
734
735 if( row >= 0 )
736 {
737 wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB );
738 wxASSERT( cb );
739 return cb->GetValue();
740 }
741
742 return false;
743}

References COLUMN_COLOR_LYR_CB, findLayerRow(), and getLayerComp().

Referenced by GERBVIEW_FRAME::IsLayerVisible().

◆ OnLayerCheckBox()

void LAYER_WIDGET::OnLayerCheckBox ( wxCommandEvent &  event)
protected

Handle the "is layer visible" checkbox and propagates the event to the client's notification function.

Definition at line 170 of file layer_widget.cpp.

171{
172 wxCheckBox* eventSource = (wxCheckBox*) event.GetEventObject();
173 int layer = getDecodedId( eventSource->GetId() );
174
175 OnLayerVisible( layer, eventSource->IsChecked() );
176 passOnFocus();
177}
virtual void OnLayerVisible(int aLayer, bool isVisible, bool isFinal=true)=0
Notify client code about a layer visibility change.
void passOnFocus()
Give away the keyboard focus up to the main parent window.

References getDecodedId(), OnLayerVisible(), and passOnFocus().

Referenced by insertLayerRow().

◆ OnLayerColorChange()

virtual void LAYER_WIDGET::OnLayerColorChange ( int  aLayer,
const COLOR4D aColor 
)
pure virtual

Notify client code about a layer color change.

Derived objects will handle this accordingly.

Parameters
aLayeris the board layer to change.
aColoris the new color.

Implemented in GERBER_LAYER_WIDGET.

Referenced by OnLayerSwatchChanged().

◆ OnLayerRightClick()

virtual void LAYER_WIDGET::OnLayerRightClick ( wxMenu &  aMenu)
pure virtual

Notify client code about a layer being right-clicked.

Parameters
aMenuis the right-click menu containing layer-scoped options.

Implemented in GERBER_LAYER_WIDGET.

Referenced by OnRightDownLayer().

◆ OnLayerSelect()

virtual bool LAYER_WIDGET::OnLayerSelect ( int  aLayer)
pure virtual

Notify client code whenever the user selects a different layer.

Derived classes will handle this accordingly, and can deny the change by returning false.

Parameters
aLayeris the board layer to select.

Implemented in GERBER_LAYER_WIDGET.

Referenced by OnLeftDownLayers().

◆ OnLayerSwatchChanged()

void LAYER_WIDGET::OnLayerSwatchChanged ( wxCommandEvent &  aEvent)
protected

Called when a user changes a swatch color.

Definition at line 153 of file layer_widget.cpp.

154{
155 COLOR_SWATCH* eventSource = static_cast<COLOR_SWATCH*>( aEvent.GetEventObject() );
156 COLOR4D newColor = eventSource->GetSwatchColor();
157 int layer = getDecodedId( eventSource->GetId() );
158
159 // tell the client code.
160 OnLayerColorChange( layer, newColor );
161
162 // notify others
163 wxCommandEvent event( EVT_LAYER_COLOR_CHANGE );
164 wxPostEvent( this, event );
165
166 passOnFocus();
167}
KIGFX::COLOR4D GetSwatchColor() const
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
static const wxEventType EVT_LAYER_COLOR_CHANGE
Definition: layer_widget.h:120
virtual void OnLayerColorChange(int aLayer, const COLOR4D &aColor)=0
Notify client code about a layer color change.

References EVT_LAYER_COLOR_CHANGE, getDecodedId(), COLOR_SWATCH::GetSwatchColor(), OnLayerColorChange(), and passOnFocus().

Referenced by insertLayerRow().

◆ OnLayerVisible()

virtual void LAYER_WIDGET::OnLayerVisible ( int  aLayer,
bool  isVisible,
bool  isFinal = true 
)
pure virtual

Notify client code about a layer visibility change.

Parameters
aLayeris the board layer to select.
isVisibleis the new visible state.
isFinalis true when this is the last of potentially several such calls, and can be used to decide when to update the screen only one time instead of several times in the midst of a multiple layer change.

Implemented in GERBER_LAYER_WIDGET.

Referenced by OnLayerCheckBox(), and SetLayerVisible().

◆ OnLeftDownLayers()

void LAYER_WIDGET::OnLeftDownLayers ( wxMouseEvent &  event)
protected

Definition at line 76 of file layer_widget.cpp.

77{
78 int row;
79 int layer;
80
81 wxWindow* eventSource = (wxWindow*) event.GetEventObject();
82
83 // if mouse event is coming from the m_LayerScrolledWindow and not one
84 // of its children, we have to find the row manually based on y coord.
85 if( eventSource == m_LayerScrolledWindow )
86 {
87 int y = event.GetY();
88
89 wxArrayInt heights = m_LayersFlexGridSizer->GetRowHeights();
90
91 int height = 0;
92
93 int rowCount = GetLayerRowCount();
94
95 for( row = 0; row<rowCount; ++row )
96 {
97 if( y < height + heights[row] )
98 break;
99
100 height += heights[row];
101 }
102
103 if( row >= rowCount )
104 row = rowCount - 1;
105
106 layer = getDecodedId( getLayerComp( row, 0 )->GetId() );
107 }
108 else
109 {
110 // all nested controls on a given row will have their ID encoded with
111 // encodeId(), and the corresponding decoding is getDecodedId()
112 int id = eventSource->GetId();
113 layer = getDecodedId( id );
114 row = findLayerRow( layer );
115 }
116
117 if( OnLayerSelect( layer ) ) // if client allows this change.
118 SelectLayerRow( row );
119
120 passOnFocus();
121}
void SelectLayerRow(int aRow)
Change the row selection in the layer list to the given row.
virtual bool OnLayerSelect(int aLayer)=0
Notify client code whenever the user selects a different layer.

References findLayerRow(), getDecodedId(), getLayerComp(), GetLayerRowCount(), m_LayerScrolledWindow, m_LayersFlexGridSizer, OnLayerSelect(), passOnFocus(), and SelectLayerRow().

Referenced by insertLayerRow().

◆ OnRenderCheckBox()

void LAYER_WIDGET::OnRenderCheckBox ( wxCommandEvent &  event)
protected

Definition at line 240 of file layer_widget.cpp.

241{
242 wxCheckBox* eventSource = (wxCheckBox*) event.GetEventObject();
243 int id = getDecodedId( eventSource->GetId() );
244
245 OnRenderEnable( id, eventSource->IsChecked() );
246 passOnFocus();
247}
virtual void OnRenderEnable(int aId, bool isEnabled)=0
Notify client code whenever the user changes an rendering enable in one of the rendering checkboxes.

References getDecodedId(), OnRenderEnable(), and passOnFocus().

Referenced by insertRenderRow().

◆ OnRenderColorChange()

virtual void LAYER_WIDGET::OnRenderColorChange ( int  aId,
const COLOR4D aColor 
)
pure virtual

Notify client code whenever the user changes a rendering color.

Parameters
aIdis the same id that was established in a Rendering row via the AddRenderRow() function.
aColoris the new color.

Implemented in GERBER_LAYER_WIDGET.

Referenced by OnRenderSwatchChanged().

◆ OnRenderEnable()

virtual void LAYER_WIDGET::OnRenderEnable ( int  aId,
bool  isEnabled 
)
pure virtual

Notify client code whenever the user changes an rendering enable in one of the rendering checkboxes.

Parameters
aIdis the same id that was established in a Rendering row via the AddRenderRow() function.
isEnabledis the state of the checkbox, true if checked.

Implemented in GERBER_LAYER_WIDGET.

Referenced by OnRenderCheckBox().

◆ OnRenderSwatchChanged()

void LAYER_WIDGET::OnRenderSwatchChanged ( wxCommandEvent &  aEvent)
protected

Called when user has changed the swatch color of a render entry.

Definition at line 203 of file layer_widget.cpp.

204{
205 COLOR_SWATCH* eventSource = static_cast<COLOR_SWATCH*>( aEvent.GetEventObject() );
206 COLOR4D newColor = eventSource->GetSwatchColor();
207 int id = getDecodedId( eventSource->GetId() );
208
209 if( id == LAYER_PCB_BACKGROUND )
210 {
211 // Update all swatch backgrounds
212 int col = 1; // bitmap button is column 1 in layers tab
213
214 for( int row = 0; row < GetLayerRowCount(); ++row )
215 {
216 COLOR_SWATCH* swatch = dynamic_cast<COLOR_SWATCH*>( getLayerComp( row, col ) );
217
218 if( swatch )
219 swatch->SetSwatchBackground( newColor );
220 }
221
222 col = 0; // bitmap button is column 0 in render tab
223
224 for( int row = 0; row < GetRenderRowCount(); ++row )
225 {
226 COLOR_SWATCH* swatch = dynamic_cast<COLOR_SWATCH*>( getRenderComp( row, col ) );
227
228 if( swatch )
229 swatch->SetSwatchBackground( newColor );
230 }
231 }
232
233 // tell the client code.
234 OnRenderColorChange( id, newColor );
235
236 passOnFocus();
237}
void SetSwatchBackground(const KIGFX::COLOR4D &aBackground)
Set the swatch background color.
virtual void OnRenderColorChange(int aId, const COLOR4D &aColor)=0
Notify client code whenever the user changes a rendering color.
@ LAYER_PCB_BACKGROUND
PCB background color.
Definition: layer_ids.h:220

References getDecodedId(), getLayerComp(), GetLayerRowCount(), getRenderComp(), GetRenderRowCount(), COLOR_SWATCH::GetSwatchColor(), LAYER_PCB_BACKGROUND, OnRenderColorChange(), passOnFocus(), and COLOR_SWATCH::SetSwatchBackground().

Referenced by insertRenderRow().

◆ OnRightDownLayer()

void LAYER_WIDGET::OnRightDownLayer ( wxMouseEvent &  event,
COLOR_SWATCH aColorSwatch,
const wxString &  aLayerName 
)
protected

Called when user right-clicks a layer.

Definition at line 124 of file layer_widget.cpp.

126{
127 wxMenu menu;
128
130 _( "Change Layer Color for" ) + wxS( " " ) + aLayerName,
132 menu.AppendSeparator();
133
134 OnLayerRightClick( menu );
135
136 menu.Bind( wxEVT_COMMAND_MENU_SELECTED, [aColorSwatch]( wxCommandEvent& event )
137 {
138 if( event.GetId() == ID_CHANGE_LAYER_COLOR )
139 {
140 aColorSwatch->GetNewSwatchColor();
141 }
142 else
143 {
144 event.Skip();
145 }
146 } );
147
148 PopupMenu( &menu );
149 passOnFocus();
150}
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:105
wxMenuItem * AddMenuItem(wxMenu *aMenu, int aId, const wxString &aText, const wxBitmap &aImage, wxItemKind aType=wxITEM_NORMAL)
Create and insert a menu item with an icon into aMenu.
Definition: bitmap.cpp:257
@ color_materials
virtual void OnLayerRightClick(wxMenu &aMenu)=0
Notify client code about a layer being right-clicked.

References _, AddMenuItem(), color_materials, ID_CHANGE_LAYER_COLOR, KiBitmap(), OnLayerRightClick(), and passOnFocus().

Referenced by insertLayerRow().

◆ OnRightDownRender()

void LAYER_WIDGET::OnRightDownRender ( wxMouseEvent &  aEvent,
COLOR_SWATCH aColorSwatch,
const wxString &  aRenderName 
)
protected

Notify when user right-clicks a render option.

Definition at line 180 of file layer_widget.cpp.

182{
183 wxMenu menu;
184
186 _( "Change Render Color for" ) + wxS( " " )+ aRenderName,
188
189 menu.Bind( wxEVT_COMMAND_MENU_SELECTED,
190 [aColorSwatch]( wxCommandEvent& event )
191 {
192 if( event.GetId() == ID_CHANGE_RENDER_COLOR )
193 aColorSwatch->GetNewSwatchColor();
194 else
195 event.Skip();
196 } );
197
198 PopupMenu( &menu );
199 passOnFocus();
200}
void GetNewSwatchColor()
Prompt for a new colour, using the colour picker dialog.

References _, AddMenuItem(), color_materials, COLOR_SWATCH::GetNewSwatchColor(), ID_CHANGE_RENDER_COLOR, KiBitmap(), and passOnFocus().

Referenced by insertRenderRow().

◆ OnTabChange()

void LAYER_WIDGET::OnTabChange ( wxNotebookEvent &  event)
protected

Definition at line 250 of file layer_widget.cpp.

251{
252// wxFocusEvent event( wxEVT_SET_FOCUS );
253// m_FocusOwner->AddPendingEvent( event );
254
255 // Does not work in this context, probably because we have receive control here too early.
256 passOnFocus();
257}

References passOnFocus().

Referenced by LAYER_WIDGET().

◆ passOnFocus()

void LAYER_WIDGET::passOnFocus ( )
protected

Give away the keyboard focus up to the main parent window.

Definition at line 479 of file layer_widget.cpp.

480{
481 m_FocusOwner->SetFocus();
482}

References m_FocusOwner.

Referenced by OnLayerCheckBox(), OnLayerSwatchChanged(), OnLeftDownLayers(), OnRenderCheckBox(), OnRenderSwatchChanged(), OnRightDownLayer(), GERBER_LAYER_WIDGET::onRightDownLayers(), OnRightDownRender(), OnTabChange(), and SelectLayerRow().

◆ SelectLayer()

void LAYER_WIDGET::SelectLayer ( int  aLayer)

Change the row selection in the layer list to aLayer provided.

Definition at line 693 of file layer_widget.cpp.

694{
695 int row = findLayerRow( aLayer );
696 SelectLayerRow( row );
697}

References findLayerRow(), and SelectLayerRow().

Referenced by GERBVIEW_FRAME::SetActiveLayer(), and GERBVIEW_FRAME::syncLayerWidget().

◆ SelectLayerRow()

void LAYER_WIDGET::SelectLayerRow ( int  aRow)

Change the row selection in the layer list to the given row.

Definition at line 672 of file layer_widget.cpp.

673{
675
676 if( oldIndicator )
677 oldIndicator->SetIndicatorState( ROW_ICON_PROVIDER::STATE::OFF );
678
679 INDICATOR_ICON* newIndicator = (INDICATOR_ICON*) getLayerComp( aRow, 0 );
680
681 if( newIndicator )
682 {
684 }
685
686 m_CurrentRow = aRow;
687
688 // give the focus back to the app.
689 passOnFocus();
690}
#define ON
void SetIndicatorState(ICON_ID aIconId)
Set the row indicator to the given state.

References getLayerComp(), m_CurrentRow, ON, passOnFocus(), and INDICATOR_ICON::SetIndicatorState().

Referenced by OnLeftDownLayers(), and SelectLayer().

◆ setLayerCheckbox()

void LAYER_WIDGET::setLayerCheckbox ( int  aLayer,
bool  isVisible 
)
protected

Definition at line 718 of file layer_widget.cpp.

719{
720 int row = findLayerRow( aLayer );
721
722 if( row >= 0 )
723 {
724 wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB );
725 wxASSERT( cb );
726 cb->SetValue( isVisible ); // does not fire an event
727 }
728}

References COLUMN_COLOR_LYR_CB, findLayerRow(), and getLayerComp().

Referenced by SetLayerVisible().

◆ SetLayerColor()

void LAYER_WIDGET::SetLayerColor ( int  aLayer,
const COLOR4D aColor 
)

Change the color of aLayer.

Definition at line 746 of file layer_widget.cpp.

747{
748 int row = findLayerRow( aLayer );
749
750 if( row >= 0 )
751 {
752 int col = 1; // bitmap button is column 1
753 auto swatch = static_cast<COLOR_SWATCH*>( getLayerComp( row, col ) );
754 wxASSERT( swatch );
755
756 swatch->SetSwatchColor( aColor, false );
757 }
758}

References findLayerRow(), and getLayerComp().

◆ SetLayerVisible()

void LAYER_WIDGET::SetLayerVisible ( int  aLayer,
bool  isVisible 
)

Set aLayer visible or not.

This does not invoke OnLayerVisible().

Definition at line 711 of file layer_widget.cpp.

712{
713 setLayerCheckbox( aLayer, isVisible );
714 OnLayerVisible( aLayer, isVisible );
715}
void setLayerCheckbox(int aLayer, bool isVisible)

References OnLayerVisible(), and setLayerCheckbox().

Referenced by GERBER_LAYER_WIDGET::ReFill().

◆ SetRenderState()

void LAYER_WIDGET::SetRenderState ( int  aId,
bool  isSet 
)

Set the state of the checkbox associated with aId within the Render tab group of the widget.

This does not fire an event, i.e. does not invoke OnRenderEnable().

Parameters
aIdis the same unique id used when adding a ROW to the Render tab.
isSetis the new checkbox state.

Definition at line 795 of file layer_widget.cpp.

796{
797 int row = findRenderRow( aId );
798
799 if( row >= 0 )
800 {
801 int col = 1; // checkbox is column 1
802 wxCheckBox* cb = (wxCheckBox*) getRenderComp( row, col );
803 wxASSERT( cb );
804 cb->SetValue( isSet ); // does not fire an event
805 }
806}

References findRenderRow(), and getRenderComp().

Referenced by GERBVIEW_FRAME::SetElementVisibility(), and GERBVIEW_FRAME::SetGridVisibility().

◆ SetSmallestLayerString()

void LAYER_WIDGET::SetSmallestLayerString ( const wxString &  aString)
inline

Set the string that is used for determining the smallest string displayed in the layer's tab.

Definition at line 141 of file layer_widget.h.

142 {
143 m_smallestLayerString = aString;
144 }

References m_smallestLayerString.

Referenced by GERBVIEW_FRAME::GERBVIEW_FRAME().

◆ UpdateLayerIcons()

void LAYER_WIDGET::UpdateLayerIcons ( )

Update all layer manager icons (layers only).

Useful when loading a file or clearing a layer because they change, and the indicator arrow icon needs to be updated

Definition at line 835 of file layer_widget.cpp.

836{
837 int rowCount = GetLayerRowCount();
838
839 for( int row = 0; row < rowCount ; row++ )
840 {
842
843 if( indicator )
844 {
846
847 if( row == m_CurrentRow )
849 else
850 state = ROW_ICON_PROVIDER::STATE::OFF;
851
852 indicator->SetIndicatorState( state );
853 }
854 }
855}
STATE
< State constants to select the right icons

References COLUMN_ICON_ACTIVE, getLayerComp(), GetLayerRowCount(), m_CurrentRow, ON, and INDICATOR_ICON::SetIndicatorState().

Referenced by GERBVIEW_FRAME::LoadListOfGerberAndDrillFiles(), and GERBVIEW_FRAME::LoadZipArchiveFile().

◆ updateLayerRow()

void LAYER_WIDGET::updateLayerRow ( int  aRow,
const wxString &  aName 
)
protected

Definition at line 394 of file layer_widget.cpp.

395{
396 wxStaticText* label = dynamic_cast<wxStaticText*>( getLayerComp( aRow, COLUMN_COLOR_LYRNAME ) );
397
398 if( label )
399 label->SetLabel( aName );
400
401 INDICATOR_ICON* indicator = (INDICATOR_ICON*) getLayerComp( aRow, 0 );
402
403 if( indicator )
404 {
405 if( aRow == m_CurrentRow )
407 else
408 indicator->SetIndicatorState( ROW_ICON_PROVIDER::STATE::OFF );
409 }
410}

References COLUMN_COLOR_LYRNAME, getLayerComp(), m_CurrentRow, ON, and INDICATOR_ICON::SetIndicatorState().

Referenced by GERBER_LAYER_WIDGET::ReFill().

◆ UpdateLayouts()

void LAYER_WIDGET::UpdateLayouts ( )

Definition at line 825 of file layer_widget.cpp.

826{
827 m_LayersFlexGridSizer->Layout();
828 m_RenderFlexGridSizer->Layout();
829 m_LayerPanel->Layout();
830 m_RenderingPanel->Layout();
831 FitInside();
832}

References m_LayerPanel, m_LayersFlexGridSizer, m_RenderFlexGridSizer, and m_RenderingPanel.

Referenced by AppendLayerRows(), AppendRenderRows(), and GERBER_LAYER_WIDGET::ReFill().

◆ useAlternateBitmap()

virtual bool LAYER_WIDGET::useAlternateBitmap ( int  aRow)
inlineprotectedvirtual
Returns
true if bitmaps shown in Render layer list are alternate bitmaps, or false if they are "normal" bitmaps This is a virtual function because Pcbnew uses normal bitmaps but GerbView uses both bitmaps (alternate bitmaps to show layers in use, normal for others)

Definition at line 363 of file layer_widget.h.

363{ return false; }

Member Data Documentation

◆ EVT_LAYER_COLOR_CHANGE

const wxEventType LAYER_WIDGET::EVT_LAYER_COLOR_CHANGE = wxNewEventType()
static

Definition at line 120 of file layer_widget.h.

Referenced by OnLayerSwatchChanged().

◆ m_CurrentRow

int LAYER_WIDGET::m_CurrentRow
protected

selected row of layer list

Definition at line 474 of file layer_widget.h.

Referenced by GetSelectedLayer(), LAYER_WIDGET(), SelectLayerRow(), UpdateLayerIcons(), and updateLayerRow().

◆ m_FocusOwner

wxWindow* LAYER_WIDGET::m_FocusOwner
protected

Definition at line 473 of file layer_widget.h.

Referenced by LAYER_WIDGET(), and passOnFocus().

◆ m_IconProvider

ROW_ICON_PROVIDER* LAYER_WIDGET::m_IconProvider
protected

Definition at line 477 of file layer_widget.h.

Referenced by insertLayerRow(), LAYER_WIDGET(), and ~LAYER_WIDGET().

◆ m_LayerPanel

wxPanel* LAYER_WIDGET::m_LayerPanel
protected

Definition at line 466 of file layer_widget.h.

Referenced by GetBestSize(), LAYER_WIDGET(), and UpdateLayouts().

◆ m_LayerScrolledWindow

wxScrolledWindow* LAYER_WIDGET::m_LayerScrolledWindow
protected

◆ m_LayersFlexGridSizer

wxFlexGridSizer* LAYER_WIDGET::m_LayersFlexGridSizer
protected

◆ m_notebook

wxNotebook* LAYER_WIDGET::m_notebook
protected

Definition at line 465 of file layer_widget.h.

Referenced by LAYER_WIDGET(), and GERBER_LAYER_WIDGET::SetLayersManagerTabsText().

◆ m_PointSize

int LAYER_WIDGET::m_PointSize
protected

Definition at line 475 of file layer_widget.h.

Referenced by insertLayerRow(), insertRenderRow(), and LAYER_WIDGET().

◆ m_RenderFlexGridSizer

wxFlexGridSizer* LAYER_WIDGET::m_RenderFlexGridSizer
protected

◆ m_RenderingPanel

wxPanel* LAYER_WIDGET::m_RenderingPanel
protected

Definition at line 469 of file layer_widget.h.

Referenced by GetBestSize(), LAYER_WIDGET(), and UpdateLayouts().

◆ m_RenderScrolledWindow

wxScrolledWindow* LAYER_WIDGET::m_RenderScrolledWindow
protected

Definition at line 470 of file layer_widget.h.

Referenced by insertRenderRow(), and LAYER_WIDGET().

◆ m_smallestLayerString

wxString LAYER_WIDGET::m_smallestLayerString
protected

Definition at line 479 of file layer_widget.h.

Referenced by insertLayerRow(), and SetSmallestLayerString().


The documentation for this class was generated from the following files: