diff --git a/pcbnew/class_text_mod.cpp b/pcbnew/class_text_mod.cpp index 6dfd2d1b47..b218243ef7 100644 --- a/pcbnew/class_text_mod.cpp +++ b/pcbnew/class_text_mod.cpp @@ -465,16 +465,16 @@ const BOX2I TEXTE_MODULE::ViewBBox() const void TEXTE_MODULE::ViewGetLayers( int aLayers[], int& aCount ) const { - if( !IsVisible() ) // Hidden text - aLayers[0] = LAYER_MOD_TEXT_INVISIBLE; - //else if( IsFrontLayer( m_Layer ) ) - //aLayers[0] = LAYER_MOD_TEXT_FR; - //else if( IsBackLayer( m_Layer ) ) - //aLayers[0] = LAYER_MOD_TEXT_BK; - else - aLayers[0] = GetLayer(); + PCB_LAYER_ID nativeLayer = GetLayer(); aCount = 1; + + if( IsVisible() ) + aLayers[0] = nativeLayer; + else if ( GetBoard()->IsLayerVisible( nativeLayer ) ) + aLayers[0] = LAYER_MOD_TEXT_INVISIBLE; + else + aCount = 0; } diff --git a/pcbnew/pcb_layer_widget.cpp b/pcbnew/pcb_layer_widget.cpp index ff8bc949e5..6c74cb6849 100644 --- a/pcbnew/pcb_layer_widget.cpp +++ b/pcbnew/pcb_layer_widget.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -654,7 +655,18 @@ void PCB_LAYER_WIDGET::OnLayerVisible( int aLayer, bool isVisible, bool isFinal EDA_DRAW_PANEL_GAL* galCanvas = myframe->GetGalCanvas(); if( galCanvas ) - galCanvas->GetView()->SetLayerVisible( aLayer, isVisible ); + { + KIGFX::VIEW* view = galCanvas->GetView(); + + view->SetLayerVisible( aLayer, isVisible ); + + // Special case hidden text which can move back and forth from the hidden layer. + view->UpdateAllItemsConditionally( KIGFX::LAYERS, []( KIGFX::VIEW_ITEM* aItem ) + { + TEXTE_MODULE* modText = dynamic_cast( aItem ); + return( modText && !modText->IsVisible() ); + } ); + } if( isFinal ) myframe->GetCanvas()->Refresh();