mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-21 17:53:45 +00:00
FP editor: add call-to-action to open a board footprint in the library
Useful both as a confusion reduction measure when confronted with the inforbar message, and also useful when you pressed Ctrl+E, not Ctrl+Shift+E. Also bind Ctrl+Shift+E in the editor to perform this action (again, useful when you used the wrong hotkey).
This commit is contained in:
parent
826794469d
commit
78d626d38c
@ -538,13 +538,25 @@ void FOOTPRINT_EDIT_FRAME::ReloadFootprint( FOOTPRINT* aFootprint )
|
||||
|
||||
if( IsCurrentFPFromBoard() )
|
||||
{
|
||||
wxString msg;
|
||||
msg.Printf( _( "Editing %s from board. Saving will update the board only." ),
|
||||
aFootprint->GetReference() );
|
||||
const wxString msg =
|
||||
wxString::Format( _( "Editing %s from board. Saving will update the board only." ),
|
||||
aFootprint->GetReference() );
|
||||
const wxString openLibLink =
|
||||
wxString::Format( _( "Open in library '%s'" ), UnescapeString( libName ) );
|
||||
|
||||
const auto openLibraryCopy = [this, aFootprint]( wxHyperlinkEvent& aEvent )
|
||||
{
|
||||
GetToolManager()->RunAction( PCB_ACTIONS::editLibFpInFpEditor );
|
||||
};
|
||||
|
||||
if( WX_INFOBAR* infobar = GetInfoBar() )
|
||||
{
|
||||
wxHyperlinkCtrl* button =
|
||||
new wxHyperlinkCtrl( infobar, wxID_ANY, openLibLink, wxEmptyString );
|
||||
button->Bind( wxEVT_COMMAND_HYPERLINK, openLibraryCopy );
|
||||
|
||||
infobar->RemoveAllButtons();
|
||||
infobar->AddButton( button );
|
||||
infobar->AddCloseButton();
|
||||
infobar->ShowMessage( msg, wxICON_INFORMATION );
|
||||
}
|
||||
@ -1199,9 +1211,17 @@ void FOOTPRINT_EDIT_FRAME::setupUIConditions()
|
||||
return !GetTargetFPID().GetLibItemName().empty();
|
||||
};
|
||||
|
||||
const auto footprintFromBoardCond =
|
||||
[this]( const SELECTION& )
|
||||
{
|
||||
return IsCurrentFPFromBoard();
|
||||
};
|
||||
|
||||
// clang-format off
|
||||
mgr->SetConditions( ACTIONS::saveAs, ENABLE( footprintTargettedCond ) );
|
||||
mgr->SetConditions( ACTIONS::revert, ENABLE( cond.ContentModified() ) );
|
||||
mgr->SetConditions( ACTIONS::save, ENABLE( SELECTION_CONDITIONS::ShowAlways ) );
|
||||
mgr->SetConditions( PCB_ACTIONS::editLibFpInFpEditor,ENABLE( footprintFromBoardCond ) );
|
||||
|
||||
mgr->SetConditions( ACTIONS::undo, ENABLE( cond.UndoAvailable() ) );
|
||||
mgr->SetConditions( ACTIONS::redo, ENABLE( cond.RedoAvailable() ) );
|
||||
@ -1235,6 +1255,7 @@ void FOOTPRINT_EDIT_FRAME::setupUIConditions()
|
||||
|
||||
mgr->SetConditions( ACTIONS::zoomTool, CHECK( cond.CurrentTool( ACTIONS::zoomTool ) ) );
|
||||
mgr->SetConditions( ACTIONS::selectionTool, CHECK( cond.CurrentTool( ACTIONS::selectionTool ) ) );
|
||||
// clang-format on
|
||||
|
||||
auto constrainedDrawingModeCond =
|
||||
[this]( const SELECTION& )
|
||||
|
@ -51,6 +51,7 @@ void FOOTPRINT_EDIT_FRAME::doReCreateMenuBar()
|
||||
fileMenu->Add( ACTIONS::addLibrary );
|
||||
fileMenu->Add( PCB_ACTIONS::newFootprint );
|
||||
fileMenu->Add( PCB_ACTIONS::createFootprint );
|
||||
fileMenu->Add( PCB_ACTIONS::editLibFpInFpEditor );
|
||||
|
||||
fileMenu->AppendSeparator();
|
||||
|
||||
|
@ -733,6 +733,25 @@ int FOOTPRINT_EDITOR_CONTROL::EditFootprint( const TOOL_EVENT& aEvent )
|
||||
}
|
||||
|
||||
|
||||
int FOOTPRINT_EDITOR_CONTROL::EditLibraryFootprint( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
FOOTPRINT* footprint = m_frame->GetBoard()->GetFirstFootprint();
|
||||
|
||||
if( !footprint || !m_frame->IsCurrentFPFromBoard() )
|
||||
{
|
||||
wxBell();
|
||||
return 0;
|
||||
}
|
||||
|
||||
m_frame->LoadFootprintFromLibrary( footprint->GetFPID() );
|
||||
|
||||
if( !m_frame->IsLibraryTreeShown() )
|
||||
m_frame->ToggleLibraryTree();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int FOOTPRINT_EDITOR_CONTROL::ToggleLayersManager( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
m_frame->ToggleLayersManager();
|
||||
@ -884,6 +903,7 @@ int FOOTPRINT_EDITOR_CONTROL::RepairFootprint( const TOOL_EVENT& aEvent )
|
||||
|
||||
void FOOTPRINT_EDITOR_CONTROL::setTransitions()
|
||||
{
|
||||
// clang-format off
|
||||
Go( &FOOTPRINT_EDITOR_CONTROL::NewFootprint, PCB_ACTIONS::newFootprint.MakeEvent() );
|
||||
Go( &FOOTPRINT_EDITOR_CONTROL::CreateFootprint, PCB_ACTIONS::createFootprint.MakeEvent() );
|
||||
Go( &FOOTPRINT_EDITOR_CONTROL::Save, ACTIONS::save.MakeEvent() );
|
||||
@ -894,6 +914,7 @@ void FOOTPRINT_EDITOR_CONTROL::setTransitions()
|
||||
Go( &FOOTPRINT_EDITOR_CONTROL::DeleteFootprint, PCB_ACTIONS::deleteFootprint.MakeEvent() );
|
||||
|
||||
Go( &FOOTPRINT_EDITOR_CONTROL::EditFootprint, PCB_ACTIONS::editFootprint.MakeEvent() );
|
||||
Go( &FOOTPRINT_EDITOR_CONTROL::EditLibraryFootprint, PCB_ACTIONS::editLibFpInFpEditor.MakeEvent() );
|
||||
Go( &FOOTPRINT_EDITOR_CONTROL::CutCopyFootprint, PCB_ACTIONS::cutFootprint.MakeEvent() );
|
||||
Go( &FOOTPRINT_EDITOR_CONTROL::CutCopyFootprint, PCB_ACTIONS::copyFootprint.MakeEvent() );
|
||||
Go( &FOOTPRINT_EDITOR_CONTROL::PasteFootprint, PCB_ACTIONS::pasteFootprint.MakeEvent() );
|
||||
@ -915,4 +936,5 @@ void FOOTPRINT_EDITOR_CONTROL::setTransitions()
|
||||
Go( &FOOTPRINT_EDITOR_CONTROL::DefaultPadProperties, PCB_ACTIONS::defaultPadProperties.MakeEvent() );
|
||||
Go( &FOOTPRINT_EDITOR_CONTROL::ToggleLayersManager, PCB_ACTIONS::showLayersManager.MakeEvent() );
|
||||
Go( &FOOTPRINT_EDITOR_CONTROL::ToggleProperties, PCB_ACTIONS::showProperties.MakeEvent() );
|
||||
// clang-format on
|
||||
}
|
||||
|
@ -55,6 +55,7 @@ public:
|
||||
int Revert( const TOOL_EVENT& aEvent );
|
||||
|
||||
int EditFootprint( const TOOL_EVENT& aEvent );
|
||||
int EditLibraryFootprint( const TOOL_EVENT& aEvent );
|
||||
int CutCopyFootprint( const TOOL_EVENT& aEvent );
|
||||
int PasteFootprint( const TOOL_EVENT& aEvent );
|
||||
int DuplicateFootprint( const TOOL_EVENT& aEvent );
|
||||
|
Loading…
Reference in New Issue
Block a user