void GERBER_LAYER_WIDGET::ReFill()
{
    Freeze();

    ClearLayerRows();

    for( int layer = 0; layer < GERBER_DRAWLAYERS_COUNT; ++layer )
    {
        wxString msg = GetImagesList()->GetDisplayName( layer );

        bool visible = true;

        if( auto canvas = myframe->GetGalCanvas() )
        {
            visible = canvas->GetView()->IsLayerVisible( GERBER_DRAW_LAYER( layer ) );
        }
        else
        {
            visible = myframe->IsLayerVisible( layer );
        }

        AppendLayerRow( LAYER_WIDGET::ROW( msg, layer,
                        myframe->GetLayerColor( GERBER_DRAW_LAYER( layer ) ),
                        wxEmptyString, visible, true ) );
    }

    Thaw();
}
void GERBER_DRAW_ITEM::ViewGetLayers( int aLayers[], int& aCount ) const
{
    aCount = 2;

    aLayers[0] = GERBER_DRAW_LAYER( GetLayer() );
    aLayers[1] = GERBER_DCODE_LAYER( aLayers[0] );
}
void GERBER_LAYER_WIDGET::OnLayerColorChange( int aLayer, COLOR4D aColor )
{
    // NOTE: Active layer in GerbView is stored as 0-indexed, but layer color is
    //       stored according to the GERBER_DRAW_LAYER() offset.

    myframe->SetLayerColor( GERBER_DRAW_LAYER( aLayer ), aColor );
    myframe->m_SelLayerBox->ResyncBitmapOnly();

    if( myframe->IsGalCanvasActive() )
    {
        KIGFX::VIEW* view = myframe->GetGalCanvas()->GetView();
        view->GetPainter()->GetSettings()->ImportLegacyColors( myframe->m_colorsSettings );
        view->UpdateLayerColor( GERBER_DRAW_LAYER( aLayer ) );
    }

    myframe->GetCanvas()->Refresh();
}
// Returns a color index from the layer id
COLOR4D GBR_LAYER_BOX_SELECTOR::GetLayerColor( int aLayer ) const
{
    GERBVIEW_FRAME* frame = (GERBVIEW_FRAME*) GetParent()->GetParent();

    return frame->GetLayerColor( GERBER_DRAW_LAYER( aLayer ) );
}