Library Editor: fixed update UI event handlers

This commit is contained in:
Maciej Suminski 2017-11-13 11:38:20 +01:00
parent 24ddbbaf25
commit 26304c54ed
3 changed files with 25 additions and 12 deletions

View File

@ -224,6 +224,7 @@ bool LIB_EDIT_FRAME::LoadOneLibraryPartAux( LIB_ALIAS* aEntry, const wxString& a
// Display the document information based on the entry selected just in // Display the document information based on the entry selected just in
// case the entry is an alias. // case the entry is an alias.
DisplayCmpDoc(); DisplayCmpDoc();
Refresh();
return true; return true;
} }
@ -394,6 +395,7 @@ void LIB_EDIT_FRAME::OnSavePart( wxCommandEvent& aEvent )
{ {
LIB_ID libId = getTargetLibId(); LIB_ID libId = getTargetLibId();
m_libMgr->FlushPart( libId.GetLibItemName(), libId.GetLibNickname() ); m_libMgr->FlushPart( libId.GetLibItemName(), libId.GetLibNickname() );
m_treePane->Refresh();;
} }

View File

@ -162,15 +162,17 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
LIB_EDIT_FRAME::OnOrient ) LIB_EDIT_FRAME::OnOrient )
// Update user interface elements. // Update user interface elements.
EVT_UPDATE_UI( ID_LIBEDIT_REVERT_LIBRARY, LIB_EDIT_FRAME::OnUpdateLibModified )
EVT_UPDATE_UI( ID_LIBEDIT_EXPORT_PART, LIB_EDIT_FRAME::OnUpdateEditingPart ) EVT_UPDATE_UI( ID_LIBEDIT_EXPORT_PART, LIB_EDIT_FRAME::OnUpdateEditingPart )
EVT_UPDATE_UI( ID_LIBEDIT_SAVE_PART, LIB_EDIT_FRAME::OnUpdateEditingPart ) EVT_UPDATE_UI( ID_LIBEDIT_SAVE_PART, LIB_EDIT_FRAME::OnUpdatePartModified )
EVT_UPDATE_UI( ID_LIBEDIT_REVERT_PART, LIB_EDIT_FRAME::OnUpdatePartModified )
EVT_UPDATE_UI( ID_LIBEDIT_GET_FRAME_EDIT_FIELDS, LIB_EDIT_FRAME::OnUpdateEditingPart ) EVT_UPDATE_UI( ID_LIBEDIT_GET_FRAME_EDIT_FIELDS, LIB_EDIT_FRAME::OnUpdateEditingPart )
EVT_UPDATE_UI( ID_LIBEDIT_CHECK_PART, LIB_EDIT_FRAME::OnUpdateEditingPart ) EVT_UPDATE_UI( ID_LIBEDIT_CHECK_PART, LIB_EDIT_FRAME::OnUpdateEditingPart )
EVT_UPDATE_UI( ID_LIBEDIT_GET_FRAME_EDIT_PART, LIB_EDIT_FRAME::OnUpdateEditingPart ) EVT_UPDATE_UI( ID_LIBEDIT_GET_FRAME_EDIT_PART, LIB_EDIT_FRAME::OnUpdateEditingPart )
EVT_UPDATE_UI( wxID_UNDO, LIB_EDIT_FRAME::OnUpdateUndo ) EVT_UPDATE_UI( wxID_UNDO, LIB_EDIT_FRAME::OnUpdateUndo )
EVT_UPDATE_UI( wxID_REDO, LIB_EDIT_FRAME::OnUpdateRedo ) EVT_UPDATE_UI( wxID_REDO, LIB_EDIT_FRAME::OnUpdateRedo )
EVT_UPDATE_UI( ID_LIBEDIT_SAVE_LIBRARY, LIB_EDIT_FRAME::OnUpdateSaveCurrentLib ) EVT_UPDATE_UI( ID_LIBEDIT_SAVE_LIBRARY, LIB_EDIT_FRAME::OnUpdateSaveLib )
EVT_UPDATE_UI( ID_LIBEDIT_SAVE_LIBRARY_AS, LIB_EDIT_FRAME::OnUpdateSaveCurrentLibAs ) EVT_UPDATE_UI( ID_LIBEDIT_SAVE_LIBRARY_AS, LIB_EDIT_FRAME::OnUpdateSaveLibAs )
EVT_UPDATE_UI( ID_LIBEDIT_VIEW_DOC, LIB_EDIT_FRAME::OnUpdateViewDoc ) EVT_UPDATE_UI( ID_LIBEDIT_VIEW_DOC, LIB_EDIT_FRAME::OnUpdateViewDoc )
EVT_UPDATE_UI( ID_LIBEDIT_EDIT_PIN_BY_PIN, LIB_EDIT_FRAME::OnUpdatePinByPin ) EVT_UPDATE_UI( ID_LIBEDIT_EDIT_PIN_BY_PIN, LIB_EDIT_FRAME::OnUpdatePinByPin )
EVT_UPDATE_UI( ID_LIBEDIT_EDIT_PIN_BY_TABLE, LIB_EDIT_FRAME::OnUpdatePinTable ) EVT_UPDATE_UI( ID_LIBEDIT_EDIT_PIN_BY_TABLE, LIB_EDIT_FRAME::OnUpdatePinTable )
@ -492,7 +494,7 @@ void LIB_EDIT_FRAME::OnUpdateElectricalType( wxUpdateUIEvent& aEvent )
void LIB_EDIT_FRAME::OnUpdateEditingPart( wxUpdateUIEvent& aEvent ) void LIB_EDIT_FRAME::OnUpdateEditingPart( wxUpdateUIEvent& aEvent )
{ {
LIB_PART* part = GetCurPart(); LIB_PART* part = GetCurPart();
aEvent.Enable( part != NULL ); aEvent.Enable( part != NULL );
@ -501,9 +503,20 @@ void LIB_EDIT_FRAME::OnUpdateEditingPart( wxUpdateUIEvent& aEvent )
} }
void LIB_EDIT_FRAME::OnUpdateNotEditingPart( wxUpdateUIEvent& event ) void LIB_EDIT_FRAME::OnUpdatePartModified( wxUpdateUIEvent& aEvent )
{ {
event.Enable( !GetCurPart() ); LIB_ID libId = getTargetLibId();
const wxString& partName = libId.GetLibItemName();
const wxString& libName = libId.GetLibNickname();
aEvent.Enable( !partName.IsEmpty() && !libName.IsEmpty()
&& m_libMgr->IsPartModified( partName, libName ) );
}
void LIB_EDIT_FRAME::OnUpdateLibModified( wxUpdateUIEvent& aEvent )
{
aEvent.Enable( m_libMgr->IsLibraryModified( getTargetLib() ) );
} }
@ -521,7 +534,7 @@ void LIB_EDIT_FRAME::OnUpdateRedo( wxUpdateUIEvent& event )
} }
void LIB_EDIT_FRAME::OnUpdateSaveCurrentLib( wxUpdateUIEvent& event ) void LIB_EDIT_FRAME::OnUpdateSaveLib( wxUpdateUIEvent& event )
{ {
wxString lib = getTargetLib(); wxString lib = getTargetLib();
@ -530,7 +543,7 @@ void LIB_EDIT_FRAME::OnUpdateSaveCurrentLib( wxUpdateUIEvent& event )
} }
void LIB_EDIT_FRAME::OnUpdateSaveCurrentLibAs( wxUpdateUIEvent& event ) void LIB_EDIT_FRAME::OnUpdateSaveLibAs( wxUpdateUIEvent& event )
{ {
wxString lib = getTargetLib(); wxString lib = getTargetLib();

View File

@ -324,14 +324,12 @@ public:
void OnUpdateSelectTool( wxUpdateUIEvent& aEvent ); void OnUpdateSelectTool( wxUpdateUIEvent& aEvent );
void OnUpdateEditingPart( wxUpdateUIEvent& event ); void OnUpdateEditingPart( wxUpdateUIEvent& event );
void OnUpdateNotEditingPart( wxUpdateUIEvent& event ); // TODO?
void OnUpdatePartModified( wxUpdateUIEvent& aEvent ); void OnUpdatePartModified( wxUpdateUIEvent& aEvent );
void OnUpdateLibModified( wxUpdateUIEvent& aEvent ); void OnUpdateLibModified( wxUpdateUIEvent& aEvent );
void OnUpdateClipboardNotEmpty( wxUpdateUIEvent& aEvent );
void OnUpdateUndo( wxUpdateUIEvent& event ); void OnUpdateUndo( wxUpdateUIEvent& event );
void OnUpdateRedo( wxUpdateUIEvent& event ); void OnUpdateRedo( wxUpdateUIEvent& event );
void OnUpdateSaveCurrentLib( wxUpdateUIEvent& event ); void OnUpdateSaveLib( wxUpdateUIEvent& event );
void OnUpdateSaveCurrentLibAs( wxUpdateUIEvent& event ); void OnUpdateSaveLibAs( wxUpdateUIEvent& event );
void OnUpdateViewDoc( wxUpdateUIEvent& event ); void OnUpdateViewDoc( wxUpdateUIEvent& event );
void OnUpdatePinByPin( wxUpdateUIEvent& event ); void OnUpdatePinByPin( wxUpdateUIEvent& event );
void OnUpdatePinTable( wxUpdateUIEvent& event ); void OnUpdatePinTable( wxUpdateUIEvent& event );