Example #1
0
void PCB_LAYER_WIDGET::SyncLayerAlphaIndicators()
{
    int count = GetLayerRowCount();
    TOOL_MANAGER* mgr = myframe->GetToolManager();
    KIGFX::PCB_PAINTER* painter = static_cast<KIGFX::PCB_PAINTER*>( mgr->GetView()->GetPainter() );
    KIGFX::PCB_RENDER_SETTINGS* settings = painter->GetSettings();

    for( int row = 0; row < count; ++row )
    {
        // this utilizes more implementation knowledge than ideal, eventually
        // add member ROW getRow() or similar to base LAYER_WIDGET.

        wxWindow* w = getLayerComp( row, COLUMN_ICON_ACTIVE );
        PCB_LAYER_ID layerId = ToLAYER_ID( getDecodedId( w->GetId() ) );
        KIGFX::COLOR4D screenColor = settings->GetLayerColor( layerId );

        COLOR_SWATCH* swatch = static_cast<COLOR_SWATCH*>( getLayerComp( row, COLUMN_COLORBM ) );
        KIGFX::COLOR4D layerColor = swatch->GetSwatchColor();

        INDICATOR_ICON* indicator = static_cast<INDICATOR_ICON*>( getLayerComp( row, COLUMN_ALPHA_INDICATOR ) );

        if( std::abs( screenColor.a - layerColor.a ) > ALPHA_EPSILON )
        {
            if( screenColor.a < layerColor.a )
                indicator->SetIndicatorState( ROW_ICON_PROVIDER::STATE::DOWN );
            else
                indicator->SetIndicatorState( ROW_ICON_PROVIDER::STATE::UP );
        }
        else
            indicator->SetIndicatorState( ROW_ICON_PROVIDER::STATE::OFF );
    }
}
Example #2
0
void LAYER_WIDGET::SelectLayerRow( int aRow )
{
    // enable the layer tab at index 0
    m_notebook->SetSelection( 0 );

    INDICATOR_ICON* oldIndicator = (INDICATOR_ICON*) getLayerComp( m_CurrentRow, 0 );
    if( oldIndicator )
        oldIndicator->SetIndicatorState( ROW_ICON_PROVIDER::STATE::OFF );

    INDICATOR_ICON* newIndicator = (INDICATOR_ICON*) getLayerComp( aRow, 0 );
    if( newIndicator )
    {
        newIndicator->SetIndicatorState( ROW_ICON_PROVIDER::STATE::ON );

        // Make sure the desired layer row is visible.
        // It seems that as of 2.8.2, setting the focus does this.
        // I don't expect the scrolling to be needed at all because
        // the minimum window size may end up being established so that the
        // scroll bars will not be visible.
        getLayerComp( aRow, 1 )->SetFocus();
    }

    m_CurrentRow = aRow;

    // give the focus back to the app.
    passOnFocus();
}
Example #3
0
void LAYER_WIDGET::UpdateLayerIcons()
{
    int rowCount = GetLayerRowCount();

    for( int row = 0; row < rowCount ; row++ )
    {
        INDICATOR_ICON* indicator = (INDICATOR_ICON*) getLayerComp( row, COLUMN_ICON_ACTIVE );

        if( indicator )
        {
            auto state = ( row == m_CurrentRow ) ? ROW_ICON_PROVIDER::STATE::ON
                                                 : ROW_ICON_PROVIDER::STATE::OFF;
            indicator->SetIndicatorState( state );
        }
    }
}