From e1c01e1e7f4e1ea3cbc037c44eb5f9c4ff3804f6 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 14 Jan 2018 19:41:01 +0000 Subject: [PATCH] Render transparent layer colors over the correct background. This fixes the layer comboboxes, the copper zones properties dialog, and the differental-pair icon in the htoolbar. Fixes: lp:1741049 * https://bugs.launchpad.net/kicad/+bug/1741049 --- common/class_layer_box_selector.cpp | 13 +++++++++++-- common/lset.cpp | 2 +- pcbnew/class_pcb_layer_widget.cpp | 4 ++++ pcbnew/dialogs/dialog_copper_zones.cpp | 15 +++++++++++---- pcbnew/tool_pcb.cpp | 19 +++++++++++++++++-- 5 files changed, 44 insertions(+), 9 deletions(-) diff --git a/common/class_layer_box_selector.cpp b/common/class_layer_box_selector.cpp index 23e6cd9f25..eef9e75638 100644 --- a/common/class_layer_box_selector.cpp +++ b/common/class_layer_box_selector.cpp @@ -54,11 +54,20 @@ void LAYER_SELECTOR::SetBitmapLayer( wxBitmap& aLayerbmp, LAYER_NUM aLayer ) // Prepare Bitmap bmpDC.SelectObject( aLayerbmp ); - brush.SetColour( GetLayerColor( aLayer ).ToColour() ); - brush.SetStyle( wxBRUSHSTYLE_SOLID ); + brush.SetStyle( wxBRUSHSTYLE_SOLID ); + COLOR4D backgroundColor = GetLayerColor( LAYER_PCB_BACKGROUND ); + if( backgroundColor != COLOR4D::UNSPECIFIED ) + { + brush.SetColour( backgroundColor.WithAlpha(1.0).ToColour() ); + bmpDC.SetBrush( brush ); + bmpDC.DrawRectangle( 0, 0, aLayerbmp.GetWidth(), aLayerbmp.GetHeight() ); + } + + brush.SetColour( GetLayerColor( aLayer ).ToColour() ); bmpDC.SetBrush( brush ); bmpDC.DrawRectangle( 0, 0, aLayerbmp.GetWidth(), aLayerbmp.GetHeight() ); + bmpDC.SetBrush( *wxTRANSPARENT_BRUSH ); bmpDC.SetPen( *wxBLACK_PEN ); bmpDC.DrawRectangle( 0, 0, aLayerbmp.GetWidth(), aLayerbmp.GetHeight() ); diff --git a/common/lset.cpp b/common/lset.cpp index 9ef9de2f51..5fc01fd13f 100644 --- a/common/lset.cpp +++ b/common/lset.cpp @@ -795,7 +795,7 @@ LSEQ LSET::UIOrder() const PCB_LAYER_ID ToLAYER_ID( int aLayer ) { - wxASSERT( unsigned( aLayer ) < PCB_LAYER_ID_COUNT ); + wxASSERT( unsigned( aLayer ) < GAL_LAYER_ID_END ); return PCB_LAYER_ID( aLayer ); } diff --git a/pcbnew/class_pcb_layer_widget.cpp b/pcbnew/class_pcb_layer_widget.cpp index 6e2af9410c..9c175b795e 100644 --- a/pcbnew/class_pcb_layer_widget.cpp +++ b/pcbnew/class_pcb_layer_widget.cpp @@ -555,6 +555,8 @@ void PCB_LAYER_WIDGET::OnLayerColorChange( int aLayer, COLOR4D aColor ) view->UpdateLayerColor( GetNetnameLayer( aLayer ) ); } + myframe->ReCreateHToolbar(); + myframe->GetCanvas()->Refresh(); } @@ -648,6 +650,8 @@ void PCB_LAYER_WIDGET::OnRenderColorChange( int aId, COLOR4D aColor ) galCanvas->ForceRefresh(); } + myframe->ReCreateHToolbar(); + myframe->GetCanvas()->Refresh(); } diff --git a/pcbnew/dialogs/dialog_copper_zones.cpp b/pcbnew/dialogs/dialog_copper_zones.cpp index 5243cdaf65..4749a037ca 100644 --- a/pcbnew/dialogs/dialog_copper_zones.cpp +++ b/pcbnew/dialogs/dialog_copper_zones.cpp @@ -115,8 +115,9 @@ private: * Function makeLayerBitmap * creates the colored rectangle bitmaps used in the layer selection widget. * @param aColor is the color to fill the rectangle with. + * @param aBackground is the background color in case aColor is transparent. */ - wxBitmap makeLayerBitmap( COLOR4D aColor ); + wxBitmap makeLayerBitmap( COLOR4D aColor, COLOR4D aBackground ); }; @@ -244,6 +245,7 @@ void DIALOG_COPPER_ZONE::initDialog() LSET cu_set = LSET::AllCuMask( board->GetCopperLayerCount() ); + COLOR4D backgroundColor = m_Parent->Settings().Colors().GetLayerColor( LAYER_PCB_BACKGROUND ); for( LSEQ cu_stack = cu_set.UIOrder(); cu_stack; ++cu_stack, imgIdx++ ) { PCB_LAYER_ID layer = *cu_stack; @@ -256,7 +258,7 @@ void DIALOG_COPPER_ZONE::initDialog() COLOR4D layerColor = m_Parent->Settings().Colors().GetLayerColor( layer ); - imageList->Add( makeLayerBitmap( layerColor ) ); + imageList->Add( makeLayerBitmap( layerColor, backgroundColor ) ); int itemIndex = m_LayerSelectionCtrl->InsertItem( m_LayerSelectionCtrl->GetItemCount(), msg, imgIdx ); @@ -682,15 +684,20 @@ void DIALOG_COPPER_ZONE::buildAvailableListOfNets() } -wxBitmap DIALOG_COPPER_ZONE::makeLayerBitmap( COLOR4D aColor ) +wxBitmap DIALOG_COPPER_ZONE::makeLayerBitmap( COLOR4D aColor, COLOR4D aBackground ) { wxBitmap bitmap( LAYER_BITMAP_SIZE_X, LAYER_BITMAP_SIZE_Y ); wxBrush brush; wxMemoryDC iconDC; iconDC.SelectObject( bitmap ); - brush.SetColour( aColor.ToColour() ); + brush.SetStyle( wxBRUSHSTYLE_SOLID ); + brush.SetColour( aBackground.WithAlpha(1.0).ToColour() ); + iconDC.SetBrush( brush ); + iconDC.DrawRectangle( 0, 0, LAYER_BITMAP_SIZE_X, LAYER_BITMAP_SIZE_Y ); + + brush.SetColour( aColor.ToColour() ); iconDC.SetBrush( brush ); iconDC.DrawRectangle( 0, 0, LAYER_BITMAP_SIZE_X, LAYER_BITMAP_SIZE_Y ); diff --git a/pcbnew/tool_pcb.cpp b/pcbnew/tool_pcb.cpp index a8e253a8c2..473d27390f 100644 --- a/pcbnew/tool_pcb.cpp +++ b/pcbnew/tool_pcb.cpp @@ -94,12 +94,13 @@ void PCB_EDIT_FRAME::PrepareLayerIndicator() { int ii, jj; COLOR4D active_layer_color, Route_Layer_TOP_color, - Route_Layer_BOTTOM_color, via_color; + Route_Layer_BOTTOM_color, via_color, background_color; bool change = false; static int previous_requested_scale; static COLOR4D previous_active_layer_color, previous_Route_Layer_TOP_color, - previous_Route_Layer_BOTTOM_color, previous_via_color; + previous_Route_Layer_BOTTOM_color, previous_via_color, + previous_background_color; const int requested_scale = GetIconScale(); @@ -144,6 +145,14 @@ void PCB_EDIT_FRAME::PrepareLayerIndicator() change = true; } + background_color = Settings().Colors().GetItemColor( LAYER_PCB_BACKGROUND ); + + if( previous_background_color != background_color ) + { + previous_background_color = background_color; + change = true; + } + if( !change && LayerPairBitmap ) return; @@ -154,9 +163,15 @@ void PCB_EDIT_FRAME::PrepareLayerIndicator() */ wxMemoryDC iconDC; iconDC.SelectObject( *LayerPairBitmap ); + wxBrush brush; wxPen pen; int buttonColor = -1; + brush.SetStyle( wxBRUSHSTYLE_SOLID ); + brush.SetColour( background_color.WithAlpha(1.0).ToColour() ); + iconDC.SetBrush( brush ); + iconDC.DrawRectangle( 0, 0, BM_LAYERICON_SIZE, BM_LAYERICON_SIZE ); + for( ii = 0; ii < BM_LAYERICON_SIZE; ii++ ) { for( jj = 0; jj < BM_LAYERICON_SIZE; jj++ )