mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 10:13:19 +02:00
Don't presume a selection (potentially KICAD-8VP).
This commit is contained in:
parent
fc0bcdc8a3
commit
34367020c4
@ -282,49 +282,52 @@ void PANEL_COLOR_SETTINGS::createSwatch( int aLayer, const wxString& aName )
|
|||||||
|
|
||||||
void PANEL_COLOR_SETTINGS::ShowColorContextMenu( wxMouseEvent& aEvent, int aLayer )
|
void PANEL_COLOR_SETTINGS::ShowColorContextMenu( wxMouseEvent& aEvent, int aLayer )
|
||||||
{
|
{
|
||||||
auto selected =
|
int themeSel = m_cbTheme->GetSelection();
|
||||||
static_cast<COLOR_SETTINGS*>( m_cbTheme->GetClientData( m_cbTheme->GetSelection() ) );
|
|
||||||
|
|
||||||
wxCHECK_RET( selected, wxT( "Invalid color theme selected" ) );
|
if( themeSel >= 0 )
|
||||||
|
{
|
||||||
|
COLOR_SETTINGS* selected = static_cast<COLOR_SETTINGS*>( m_cbTheme->GetClientData( themeSel ) );
|
||||||
|
|
||||||
COLOR4D current = m_currentSettings->GetColor( aLayer );
|
wxCHECK_RET( selected, wxT( "Invalid color theme selected" ) );
|
||||||
COLOR4D saved = selected->GetColor( aLayer );
|
|
||||||
bool readOnly = m_currentSettings->IsReadOnly();
|
|
||||||
|
|
||||||
wxMenu menu;
|
COLOR4D current = m_currentSettings->GetColor( aLayer );
|
||||||
|
COLOR4D saved = selected->GetColor( aLayer );
|
||||||
|
bool readOnly = m_currentSettings->IsReadOnly();
|
||||||
|
|
||||||
KIUI::AddMenuItem( &menu, ID_COPY, _( "Copy color" ), KiBitmap( BITMAPS::copy ) );
|
wxMenu menu;
|
||||||
|
|
||||||
if( !readOnly && m_copied != COLOR4D::UNSPECIFIED )
|
KIUI::AddMenuItem( &menu, ID_COPY, _( "Copy color" ), KiBitmap( BITMAPS::copy ) );
|
||||||
KIUI::AddMenuItem( &menu, ID_PASTE, _( "Paste color" ), KiBitmap( BITMAPS::paste ) );
|
|
||||||
|
|
||||||
if( !readOnly && current != saved )
|
if( !readOnly && m_copied != COLOR4D::UNSPECIFIED )
|
||||||
KIUI::AddMenuItem( &menu, ID_REVERT, _( "Revert to saved color" ),
|
KIUI::AddMenuItem( &menu, ID_PASTE, _( "Paste color" ), KiBitmap( BITMAPS::paste ) );
|
||||||
KiBitmap( BITMAPS::undo ) );
|
|
||||||
|
|
||||||
menu.Bind( wxEVT_COMMAND_MENU_SELECTED,
|
if( !readOnly && current != saved )
|
||||||
[&]( wxCommandEvent& aCmd )
|
KIUI::AddMenuItem( &menu, ID_REVERT, _( "Revert to saved color" ), KiBitmap( BITMAPS::undo ) );
|
||||||
{
|
|
||||||
switch( aCmd.GetId() )
|
menu.Bind( wxEVT_COMMAND_MENU_SELECTED,
|
||||||
|
[&]( wxCommandEvent& aCmd )
|
||||||
{
|
{
|
||||||
case ID_COPY:
|
switch( aCmd.GetId() )
|
||||||
m_copied = current;
|
{
|
||||||
break;
|
case ID_COPY:
|
||||||
|
m_copied = current;
|
||||||
|
break;
|
||||||
|
|
||||||
case ID_PASTE:
|
case ID_PASTE:
|
||||||
updateColor( aLayer, m_copied );
|
updateColor( aLayer, m_copied );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_REVERT:
|
case ID_REVERT:
|
||||||
updateColor( aLayer, saved );
|
updateColor( aLayer, saved );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
aCmd.Skip();
|
aCmd.Skip();
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
PopupMenu( &menu );
|
PopupMenu( &menu );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user