Library Editor: mark the current library/part with a different color

This commit is contained in:
Maciej Suminski 2017-11-13 12:19:14 +01:00
parent dfcd42f5ef
commit bb83b73f76
3 changed files with 59 additions and 2 deletions

View File

@ -203,6 +203,38 @@ public:
*/ */
CMP_TREE_MODEL_ADAPTER_BASE::PTR& GetAdapter() { return m_adapter; } CMP_TREE_MODEL_ADAPTER_BASE::PTR& GetAdapter() { return m_adapter; }
/**
* Returns the currently modified library name.
*/
const wxString& GetCurrentLib() const
{
return m_currentLib;
}
/**
* Sets the currently modified library name.
*/
void SetCurrentLib( const wxString& aLibrary )
{
m_currentLib = aLibrary;
}
/**
* Returns the currently modified part name.
*/
const wxString& GetCurrentPart() const
{
return m_currentPart;
}
/**
* Sets the currently modified part name.
*/
void SetCurrentPart( const wxString& aPart )
{
m_currentPart = aPart;
}
private: private:
///> Parent frame ///> Parent frame
LIB_EDIT_FRAME& m_frame; LIB_EDIT_FRAME& m_frame;
@ -346,9 +378,15 @@ private:
///> The library buffers ///> The library buffers
std::map<wxString, LIB_BUFFER> m_libs; std::map<wxString, LIB_BUFFER> m_libs;
// TODO ///> Symbol Lib Table hash value returned during the last synchronization
int m_syncHash; int m_syncHash;
///> Currently modified part
wxString m_currentLib;
///> Currently modified library
wxString m_currentPart;
LIB_MANAGER_ADAPTER::PTR m_adapter; LIB_MANAGER_ADAPTER::PTR m_adapter;
LIB_MANAGER_ADAPTER* getAdapter() { return static_cast<LIB_MANAGER_ADAPTER*>( m_adapter.get() ); } LIB_MANAGER_ADAPTER* getAdapter() { return static_cast<LIB_MANAGER_ADAPTER*>( m_adapter.get() ); }
}; };

View File

@ -230,6 +230,13 @@ bool LIB_MANAGER_ADAPTER::GetAttr( wxDataViewItem const& aItem, unsigned int aCo
case CMP_TREE_NODE::LIB: case CMP_TREE_NODE::LIB:
// mark modified libs with bold font // mark modified libs with bold font
aAttr.SetBold( m_libMgr->IsLibraryModified( node->Name ) ); aAttr.SetBold( m_libMgr->IsLibraryModified( node->Name ) );
// mark current library with inverted colors
if( node->Name == m_libMgr->GetCurrentLib() )
{
aAttr.SetColour( wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) );
aAttr.SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHTTEXT ) );
}
break; break;
case CMP_TREE_NODE::LIBID: case CMP_TREE_NODE::LIBID:
@ -238,6 +245,13 @@ bool LIB_MANAGER_ADAPTER::GetAttr( wxDataViewItem const& aItem, unsigned int aCo
// mark aliases with italic font // mark aliases with italic font
aAttr.SetItalic( !node->IsRoot ); aAttr.SetItalic( !node->IsRoot );
// mark current library with inverted colors
if( node->Name == m_libMgr->GetCurrentPart() )
{
aAttr.SetColour( wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) );
aAttr.SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHTTEXT ) );
}
break; break;
default: default:

View File

@ -983,6 +983,8 @@ wxString LIB_EDIT_FRAME::SetCurLib( const wxString& aLibNickname )
else else
Prj().SetRString( PROJECT::SCH_LIBEDIT_CUR_LIB, aLibNickname ); Prj().SetRString( PROJECT::SCH_LIBEDIT_CUR_LIB, aLibNickname );
m_libMgr->SetCurrentLib( aLibNickname );
return old; return old;
} }
@ -997,8 +999,11 @@ void LIB_EDIT_FRAME::SetCurPart( LIB_PART* aPart )
m_my_part = aPart; m_my_part = aPart;
} }
wxString partName = aPart ? aPart->GetName() : wxString();
m_libMgr->SetCurrentPart( partName );
// retain in case this wxFrame is re-opened later on the same PROJECT // retain in case this wxFrame is re-opened later on the same PROJECT
Prj().SetRString( PROJECT::SCH_LIBEDIT_CUR_PART, aPart ? aPart->GetName() : wxString() ); Prj().SetRString( PROJECT::SCH_LIBEDIT_CUR_PART, partName );
} }