Address inc/decAlpha bug fix code review comments.

Change menu names to reference Opacity instead of Brighness.
Implement a bottom-stop at 20%.
This commit is contained in:
Jeff Young 2018-02-23 13:04:07 +00:00 committed by jean-pierre charras
parent 63e113740b
commit d043ef5bb6
3 changed files with 22 additions and 12 deletions

View File

@ -313,16 +313,16 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
contrastModeSubMenu->AppendSeparator();
text = AddHotkeyName( _( "&Dim Current Layer" ), g_Pcbnew_Editor_Hotkeys_Descr,
text = AddHotkeyName( _( "&Decrease Layer Opacity" ), g_Pcbnew_Editor_Hotkeys_Descr,
HK_DEC_LAYER_ALHPA );
AddMenuItem( contrastModeSubMenu, ID_DEC_LAYER_ALPHA,
text, _( "Dim the current layer" ),
text, _( "Make the current layer more transparent" ),
KiBitmap( contrast_mode_xpm ) );
text = AddHotkeyName( _( "&Brighten Current Layer" ), g_Pcbnew_Editor_Hotkeys_Descr,
text = AddHotkeyName( _( "&Increase Layer Opacity" ), g_Pcbnew_Editor_Hotkeys_Descr,
HK_INC_LAYER_ALHPA );
AddMenuItem( contrastModeSubMenu, ID_INC_LAYER_ALPHA,
text, _( "Brighten the current layer" ),
text, _( "Make the current layer less transparent" ),
KiBitmap( contrast_mode_xpm ) );
AddMenuItem( viewMenu, contrastModeSubMenu,

View File

@ -755,16 +755,16 @@ void prepareViewMenu( wxMenu* aParentMenu, bool aUseGal )
contrastModeSubMenu->AppendSeparator();
text = AddHotkeyName( _( "&Dim Current Layer" ), g_Pcbnew_Editor_Hotkeys_Descr,
text = AddHotkeyName( _( "&Decrease Layer Opacity" ), g_Pcbnew_Editor_Hotkeys_Descr,
HK_DEC_LAYER_ALHPA );
AddMenuItem( contrastModeSubMenu, ID_DEC_LAYER_ALPHA,
text, _( "Dim the current layer" ),
text, _( "Make the current layer more transparent" ),
KiBitmap( contrast_mode_xpm ) );
text = AddHotkeyName( _( "&Brighten Current Layer" ), g_Pcbnew_Editor_Hotkeys_Descr,
text = AddHotkeyName( _( "&Increase Layer Opacity" ), g_Pcbnew_Editor_Hotkeys_Descr,
HK_INC_LAYER_ALHPA );
AddMenuItem( contrastModeSubMenu, ID_INC_LAYER_ALPHA,
text, _( "Brighten the current layer" ),
text, _( "Make the current layer less transparent" ),
KiBitmap( contrast_mode_xpm ) );
AddMenuItem( aParentMenu, contrastModeSubMenu,

View File

@ -515,6 +515,12 @@ int PCBNEW_CONTROL::LayerToggle( const TOOL_EVENT& aEvent )
}
// It'd be nice to share the min/max with the COLOR4D_PICKER_DLG, but those are
// set in wxFormBuilder.
#define ALPHA_MIN 0.20
#define ALPHA_MAX 1.00
#define ALPHA_STEP 0.05
int PCBNEW_CONTROL::LayerAlphaInc( const TOOL_EVENT& aEvent )
{
auto painter = static_cast<KIGFX::PCB_PAINTER*>( getView()->GetPainter() );
@ -523,15 +529,17 @@ int PCBNEW_CONTROL::LayerAlphaInc( const TOOL_EVENT& aEvent )
LAYER_NUM currentLayer = m_frame->GetActiveLayer();
KIGFX::COLOR4D currentColor = settings->GetLayerColor( currentLayer );
if( currentColor.a <= 0.95 )
if( currentColor.a <= ALPHA_MAX - ALPHA_STEP )
{
currentColor.a += 0.05;
currentColor.a += ALPHA_STEP;
settings->SetLayerColor( currentLayer, currentColor );
m_frame->GetGalCanvas()->GetView()->UpdateLayerColor( currentLayer );
wxUpdateUIEvent dummy;
static_cast<PCB_EDIT_FRAME*>( m_frame )->OnUpdateLayerAlpha( dummy );
}
else
wxBell();
return 0;
}
@ -545,15 +553,17 @@ int PCBNEW_CONTROL::LayerAlphaDec( const TOOL_EVENT& aEvent )
LAYER_NUM currentLayer = m_frame->GetActiveLayer();
KIGFX::COLOR4D currentColor = settings->GetLayerColor( currentLayer );
if( currentColor.a >= 0.05 )
if( currentColor.a >= ALPHA_MIN + ALPHA_STEP )
{
currentColor.a -= 0.05;
currentColor.a -= ALPHA_STEP;
settings->SetLayerColor( currentLayer, currentColor );
m_frame->GetGalCanvas()->GetView()->UpdateLayerColor( currentLayer );
wxUpdateUIEvent dummy;
static_cast<PCB_BASE_FRAME*>( m_frame )->OnUpdateLayerAlpha( dummy );
}
else
wxBell();
return 0;
}