Read-only dialogs for symbols in legacy libraries.
Fixes https://gitlab.com/kicad/code/kicad/issues/5211
This commit is contained in:
parent
ad1ee40441
commit
fb7ac450d9
|
@ -43,7 +43,17 @@ DIALOG_LIB_EDIT_DRAW_ITEM::DIALOG_LIB_EDIT_DRAW_ITEM( SYMBOL_EDIT_FRAME* aParent
|
|||
|
||||
// Required under wxGTK if we want to dismiss the dialog with the ESC key
|
||||
SetFocus();
|
||||
m_sdbSizerOK->SetDefault();
|
||||
|
||||
if( aParent->IsSymbolFromLegacyLibrary() )
|
||||
{
|
||||
m_sdbSizerCancel->SetDefault();
|
||||
m_sdbSizerOK->SetLabel( _( "Read Only" ) );
|
||||
m_sdbSizerOK->Enable( false );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_sdbSizerOK->SetDefault();
|
||||
}
|
||||
|
||||
// Now all widgets have the size fixed, call FinishDialogSettings
|
||||
finishDialogSettings();
|
||||
|
|
|
@ -449,6 +449,17 @@ DIALOG_LIB_EDIT_PIN_TABLE::DIALOG_LIB_EDIT_PIN_TABLE( SYMBOL_EDIT_FRAME* parent,
|
|||
GetSizer()->SetSizeHints(this);
|
||||
Centre();
|
||||
|
||||
if( parent->IsSymbolFromLegacyLibrary() )
|
||||
{
|
||||
m_ButtonsCancel->SetDefault();
|
||||
m_ButtonsOK->SetLabel( _( "Read Only" ) );
|
||||
m_ButtonsOK->Enable( false );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ButtonsOK->SetDefault();
|
||||
}
|
||||
|
||||
m_ButtonsOK->SetDefault();
|
||||
m_initialized = true;
|
||||
m_modified = false;
|
||||
|
|
|
@ -52,7 +52,16 @@ DIALOG_LIB_EDIT_TEXT::DIALOG_LIB_EDIT_TEXT( SYMBOL_EDIT_FRAME* aParent, LIB_TEXT
|
|||
SetInitialFocus( m_TextCtrl );
|
||||
m_StyledTextCtrl->Show( false );
|
||||
|
||||
m_sdbSizerButtonsOK->SetDefault();
|
||||
if( aParent->IsSymbolFromLegacyLibrary() )
|
||||
{
|
||||
m_sdbSizerButtonsCancel->SetDefault();
|
||||
m_sdbSizerButtonsOK->SetLabel( _( "Read Only" ) );
|
||||
m_sdbSizerButtonsOK->Enable( false );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_sdbSizerButtonsOK->SetDefault();
|
||||
}
|
||||
|
||||
// Now all widgets have the size fixed, call FinishDialogSettings
|
||||
finishDialogSettings();
|
||||
|
|
|
@ -86,7 +86,16 @@ DIALOG_LIB_SYMBOL_PROPERTIES::DIALOG_LIB_SYMBOL_PROPERTIES( SYMBOL_EDIT_FRAME* a
|
|||
m_deleteFilterButton->SetBitmap( KiBitmap( trash_xpm ) );
|
||||
m_editFilterButton->SetBitmap( KiBitmap( small_edit_xpm ) );
|
||||
|
||||
m_stdSizerButtonOK->SetDefault();
|
||||
if( aParent->IsSymbolFromLegacyLibrary() )
|
||||
{
|
||||
m_stdSizerButtonCancel->SetDefault();
|
||||
m_stdSizerButtonOK->SetLabel( _( "Read Only" ) );
|
||||
m_stdSizerButtonOK->Enable( false );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_stdSizerButtonOK->SetDefault();
|
||||
}
|
||||
|
||||
#ifndef KICAD_SPICE
|
||||
m_spiceFieldsButton->Hide();
|
||||
|
|
|
@ -327,10 +327,11 @@ void SYMBOL_EDIT_FRAME::setupUIConditions()
|
|||
return m_my_part;
|
||||
};
|
||||
|
||||
auto haveRootSymbolCond =
|
||||
auto isEditableCond =
|
||||
[this] ( const SELECTION& )
|
||||
{
|
||||
return m_my_part && m_my_part->IsRoot();
|
||||
// Only root symbols are editable
|
||||
return m_my_part && m_my_part->IsRoot() && !IsSymbolFromLegacyLibrary();
|
||||
};
|
||||
|
||||
auto libMgrModifiedCond =
|
||||
|
@ -384,17 +385,17 @@ void SYMBOL_EDIT_FRAME::setupUIConditions()
|
|||
CHECK( cond.CanvasType( EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO ) ) );
|
||||
|
||||
mgr->SetConditions( ACTIONS::cut,
|
||||
ENABLE( haveRootSymbolCond && SELECTION_CONDITIONS::NotEmpty ) );
|
||||
ENABLE( isEditableCond && SELECTION_CONDITIONS::NotEmpty ) );
|
||||
mgr->SetConditions( ACTIONS::copy,
|
||||
ENABLE( haveRootSymbolCond && SELECTION_CONDITIONS::NotEmpty ) );
|
||||
ENABLE( haveSymbolCond && SELECTION_CONDITIONS::NotEmpty ) );
|
||||
mgr->SetConditions( ACTIONS::paste,
|
||||
ENABLE( haveRootSymbolCond && SELECTION_CONDITIONS::Idle ) );
|
||||
ENABLE( isEditableCond && SELECTION_CONDITIONS::Idle ) );
|
||||
mgr->SetConditions( ACTIONS::doDelete,
|
||||
ENABLE( haveRootSymbolCond && SELECTION_CONDITIONS::NotEmpty ) );
|
||||
ENABLE( isEditableCond && SELECTION_CONDITIONS::NotEmpty ) );
|
||||
mgr->SetConditions( ACTIONS::duplicate,
|
||||
ENABLE( haveRootSymbolCond && SELECTION_CONDITIONS::NotEmpty ) );
|
||||
ENABLE( isEditableCond && SELECTION_CONDITIONS::NotEmpty ) );
|
||||
mgr->SetConditions( ACTIONS::selectAll,
|
||||
ENABLE( haveRootSymbolCond ) );
|
||||
ENABLE( haveSymbolCond ) );
|
||||
|
||||
mgr->SetConditions( ACTIONS::zoomTool,
|
||||
CHECK( cond.CurrentTool( ACTIONS::zoomTool ) ) );
|
||||
|
@ -416,13 +417,6 @@ void SYMBOL_EDIT_FRAME::setupUIConditions()
|
|||
mgr->SetConditions( EE_ACTIONS::showElectricalTypes, CHECK( pinTypeCond ) );
|
||||
mgr->SetConditions( EE_ACTIONS::showComponentTree, CHECK( showCompTreeCond ) );
|
||||
|
||||
auto isEditableCond =
|
||||
[this] ( const SELECTION& )
|
||||
{
|
||||
// Only root symbols are editable
|
||||
return m_my_part && m_my_part->IsRoot();
|
||||
};
|
||||
|
||||
auto demorganCond =
|
||||
[this] ( const SELECTION& )
|
||||
{
|
||||
|
@ -461,8 +455,8 @@ void SYMBOL_EDIT_FRAME::setupUIConditions()
|
|||
|
||||
mgr->SetConditions( EE_ACTIONS::showDatasheet, ENABLE( haveDatasheetCond ) );
|
||||
mgr->SetConditions( EE_ACTIONS::symbolProperties, ENABLE( haveSymbolCond ) );
|
||||
mgr->SetConditions( EE_ACTIONS::runERC, ENABLE( isEditableCond) );
|
||||
mgr->SetConditions( EE_ACTIONS::pinTable, ENABLE( isEditableCond) );
|
||||
mgr->SetConditions( EE_ACTIONS::runERC, ENABLE( haveSymbolCond ) );
|
||||
mgr->SetConditions( EE_ACTIONS::pinTable, ENABLE( haveSymbolCond ) );
|
||||
|
||||
mgr->SetConditions( EE_ACTIONS::showDeMorganStandard,
|
||||
ACTION_CONDITIONS().Enable( demorganCond ).Check( demorganStandardCond ) );
|
||||
|
@ -477,17 +471,14 @@ void SYMBOL_EDIT_FRAME::setupUIConditions()
|
|||
mgr->SetConditions( ACTIONS::deleteTool, EDIT_TOOL( ACTIONS::deleteTool ) );
|
||||
mgr->SetConditions( EE_ACTIONS::placeSymbolPin, EDIT_TOOL( EE_ACTIONS::placeSymbolPin ) );
|
||||
mgr->SetConditions( EE_ACTIONS::placeSymbolText, EDIT_TOOL( EE_ACTIONS::placeSymbolText ) );
|
||||
mgr->SetConditions( EE_ACTIONS::drawSymbolRectangle,
|
||||
EDIT_TOOL( EE_ACTIONS::drawSymbolRectangle ) );
|
||||
mgr->SetConditions( EE_ACTIONS::drawSymbolCircle,
|
||||
EDIT_TOOL( EE_ACTIONS::drawSymbolCircle ) );
|
||||
mgr->SetConditions( EE_ACTIONS::drawSymbolRectangle, EDIT_TOOL( EE_ACTIONS::drawSymbolRectangle ) );
|
||||
mgr->SetConditions( EE_ACTIONS::drawSymbolCircle, EDIT_TOOL( EE_ACTIONS::drawSymbolCircle ) );
|
||||
mgr->SetConditions( EE_ACTIONS::drawSymbolArc, EDIT_TOOL( EE_ACTIONS::drawSymbolArc ) );
|
||||
mgr->SetConditions( EE_ACTIONS::drawSymbolLines, EDIT_TOOL( EE_ACTIONS::drawSymbolLines ) );
|
||||
mgr->SetConditions( EE_ACTIONS::placeSymbolAnchor,
|
||||
EDIT_TOOL( EE_ACTIONS::placeSymbolAnchor ) );
|
||||
mgr->SetConditions( EE_ACTIONS::placeSymbolAnchor, EDIT_TOOL( EE_ACTIONS::placeSymbolAnchor ) );
|
||||
|
||||
RegisterUIUpdateHandler( ID_LIBEDIT_IMPORT_BODY_BUTT, ENABLE( isEditableCond ) );
|
||||
RegisterUIUpdateHandler( ID_LIBEDIT_EXPORT_BODY_BUTT, ENABLE( isEditableCond ) );
|
||||
RegisterUIUpdateHandler( ID_LIBEDIT_EXPORT_BODY_BUTT, ENABLE( haveSymbolCond ) );
|
||||
|
||||
#undef CHECK
|
||||
#undef ENABLE
|
||||
|
@ -673,8 +664,6 @@ wxString SYMBOL_EDIT_FRAME::SetCurLib( const wxString& aLibNickname )
|
|||
else
|
||||
Prj().SetRString( PROJECT::SCH_LIBEDIT_CUR_LIB, aLibNickname );
|
||||
|
||||
m_libMgr->SetCurrentLib( aLibNickname );
|
||||
|
||||
return old;
|
||||
}
|
||||
|
||||
|
@ -689,15 +678,9 @@ void SYMBOL_EDIT_FRAME::SetCurPart( LIB_PART* aPart, bool aUpdateZoom )
|
|||
|
||||
// select the current component in the tree widget
|
||||
if( !IsSymbolFromSchematic() && m_my_part )
|
||||
{
|
||||
m_treePane->GetLibTree()->SelectLibId( m_my_part->GetLibId() );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_treePane->GetLibTree()->Unselect();
|
||||
m_libMgr->SetCurrentLib( wxEmptyString );
|
||||
m_libMgr->SetCurrentPart( wxEmptyString );
|
||||
}
|
||||
|
||||
wxString partName = m_my_part ? m_my_part->GetName() : wxString();
|
||||
bool isAlias = !IsSymbolFromSchematic() && m_my_part && m_my_part->IsAlias();
|
||||
|
|
|
@ -439,7 +439,6 @@ bool SYMBOL_LIBRARY_MANAGER::UpdatePartAfterRename( LIB_PART* aPart, const wxStr
|
|||
wxCHECK( partBuf, false );
|
||||
|
||||
libBuf.UpdateBuffer( partBuf, aPart );
|
||||
SetCurrentPart( aPart->GetName() );
|
||||
m_frame.SyncLibraries( false );
|
||||
|
||||
return true;
|
||||
|
|
|
@ -278,26 +278,6 @@ public:
|
|||
*/
|
||||
wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>& GetAdapter() { return m_adapter; }
|
||||
|
||||
/**
|
||||
* Returns the currently modified library name.
|
||||
*/
|
||||
const wxString& GetCurrentLib() const { return m_currentLib; }
|
||||
void SetCurrentLib( const wxString& aLibrary ) { m_currentLib = aLibrary; }
|
||||
|
||||
/**
|
||||
* Returns the currently modified part name.
|
||||
*/
|
||||
const wxString& GetCurrentPart() const { return m_currentPart; }
|
||||
void SetCurrentPart( const wxString& aPart ) { m_currentPart = aPart; }
|
||||
|
||||
/**
|
||||
* Returns the current library and part name as LIB_ID.
|
||||
*/
|
||||
LIB_ID GetCurrentLibId() const
|
||||
{
|
||||
return LIB_ID( m_currentLib, m_currentPart );
|
||||
}
|
||||
|
||||
void GetRootSymbolNames( const wxString& aLibName, wxArrayString& aRootSymbolNames );
|
||||
|
||||
/**
|
||||
|
@ -480,9 +460,6 @@ private:
|
|||
LIB_LOGGER m_logger;
|
||||
int m_syncHash; ///< Symbol lib table hash value from last synchronization
|
||||
|
||||
wxString m_currentLib; ///< Currently modified part
|
||||
wxString m_currentPart; ///< Currently modified library
|
||||
|
||||
wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER> m_adapter;
|
||||
};
|
||||
|
||||
|
|
|
@ -280,25 +280,26 @@ bool SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetAttr( wxDataViewItem const& aItem, un
|
|||
if( aCol != 0 )
|
||||
return false;
|
||||
|
||||
LIB_PART* curPart = m_frame->GetCurPart();
|
||||
|
||||
switch( node->m_Type )
|
||||
{
|
||||
case LIB_TREE_NODE::LIB:
|
||||
// mark modified libs with bold font
|
||||
aAttr.SetBold( m_libMgr->IsLibraryModified( node->m_Name ) );
|
||||
|
||||
// mark the current library with background color
|
||||
if( curPart && curPart->GetLibId().GetLibNickname() == node->m_LibId.GetLibNickname() )
|
||||
{
|
||||
#ifdef __WXGTK__
|
||||
// The native wxGTK+ impl ignores background colour, so set the text colour instead.
|
||||
// This works reasonably well in dark themes, and quite poorly in light ones....
|
||||
if( node->m_Name == m_libMgr->GetCurrentLib() )
|
||||
// The native wxGTK+ impl ignores background colour, so set the text colour instead.
|
||||
// This works reasonably well in dark themes, and quite poorly in light ones....
|
||||
aAttr.SetColour( wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) );
|
||||
#else
|
||||
// mark the current library with background color
|
||||
if( node->m_Name == m_libMgr->GetCurrentLib() )
|
||||
{
|
||||
aAttr.SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) );
|
||||
aAttr.SetColour( wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOXHIGHLIGHTTEXT ) );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
case LIB_TREE_NODE::LIBID:
|
||||
|
@ -308,19 +309,18 @@ bool SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetAttr( wxDataViewItem const& aItem, un
|
|||
// mark aliases with italic font
|
||||
aAttr.SetItalic( !node->m_IsRoot );
|
||||
|
||||
// mark the current part with background color
|
||||
if( curPart && curPart->GetLibId() == node->m_LibId )
|
||||
{
|
||||
#ifdef __WXGTK__
|
||||
// The native wxGTK+ impl ignores background colour, so set the text colour instead.
|
||||
// This works reasonably well in dark themes, and quite poorly in light ones....
|
||||
if( node->m_LibId == m_libMgr->GetCurrentLibId() )
|
||||
aAttr.SetColour( wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) );
|
||||
#else
|
||||
// mark the current part with background color
|
||||
if( node->m_LibId == m_libMgr->GetCurrentLibId() )
|
||||
{
|
||||
aAttr.SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) );
|
||||
aAttr.SetColour( wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOXHIGHLIGHTTEXT ) );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include <symbol_edit_frame.h>
|
||||
#include <view/view_controls.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tools/ee_selection_tool.h>
|
||||
#include <tools/symbol_editor_drawing_tools.h>
|
||||
#include <tools/symbol_editor_pin_tool.h>
|
||||
#include <class_libentry.h>
|
||||
|
@ -41,7 +40,6 @@
|
|||
#include <symbol_editor/symbol_editor_settings.h>
|
||||
#include <settings/settings_manager.h>
|
||||
#include <kicad_string.h>
|
||||
#include "ee_point_editor.h"
|
||||
|
||||
static void* g_lastPinWeakPtr;
|
||||
|
||||
|
|
Loading…
Reference in New Issue