From 2201482e4798f9bfa9c506164c34bf33511ea50b Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 20 Jan 2018 17:15:46 +0000 Subject: [PATCH] Add '*' to modified files in libedit cmptree, and change highlighting. The highlight colour on some platforms (OSX, for instance) renders nearly invisible against a white background. However, wxWidgets doesn't handle background colours on OSX and GTK+. A separate commit to the new kicad/wxWidgets fork fixes OSX, and we continue to use the old highlighting on GTK+ Fixes: lp:1741719 * https://bugs.launchpad.net/kicad/+bug/1741719 --- eeschema/controle.cpp | 3 ++ eeschema/lib_manager_adapter.cpp | 53 +++++++++++++++++++++++++++--- eeschema/lib_manager_adapter.h | 2 ++ eeschema/libeditframe.cpp | 6 ++++ eeschema/libeditframe.h | 1 + eeschema/widgets/cmp_tree_pane.cpp | 3 ++ 6 files changed, 64 insertions(+), 4 deletions(-) diff --git a/eeschema/controle.cpp b/eeschema/controle.cpp index 37381007e6..ad7e3c4aa5 100644 --- a/eeschema/controle.cpp +++ b/eeschema/controle.cpp @@ -308,6 +308,9 @@ bool LIB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KE keyHandled = true; } + // Make sure current-part highlighting doesn't get lost in seleciton highlighting + ClearSearchTreeSelection(); + UpdateStatusBar(); return keyHandled; diff --git a/eeschema/lib_manager_adapter.cpp b/eeschema/lib_manager_adapter.cpp index 5cffedd073..2a01db656f 100644 --- a/eeschema/lib_manager_adapter.cpp +++ b/eeschema/lib_manager_adapter.cpp @@ -181,6 +181,39 @@ CMP_TREE_NODE* LIB_MANAGER_ADAPTER::findLibrary( const wxString& aLibNickName ) } +void LIB_MANAGER_ADAPTER::GetValue( wxVariant& aVariant, wxDataViewItem const& aItem, + unsigned int aCol ) const +{ + auto node = ToNode( aItem ); + wxASSERT( node ); + + switch( aCol ) + { + case 0: + aVariant = node->Name; + + // mark modified libs with an asterix + if( node->Type == CMP_TREE_NODE::LIB && m_libMgr->IsLibraryModified( node->Name ) ) + aVariant = node->Name + " *"; + + // mark modified parts with an asterix + if( node->Type == CMP_TREE_NODE::LIBID + && m_libMgr->IsPartModified( node->Name, node->Parent->Name ) ) + aVariant = node->Name + " *"; + + break; + + case 1: + aVariant = node->Desc; + break; + + default: // column == -1 is used for default Compare function + aVariant = node->Name; + break; + } +} + + bool LIB_MANAGER_ADAPTER::GetAttr( wxDataViewItem const& aItem, unsigned int aCol, wxDataViewItemAttr& aAttr ) const { @@ -197,10 +230,16 @@ bool LIB_MANAGER_ADAPTER::GetAttr( wxDataViewItem const& aItem, unsigned int aCo // mark modified libs with bold font aAttr.SetBold( m_libMgr->IsLibraryModified( node->Name ) ); - // mark the current library with inverted colors +#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->Name == m_libMgr->GetCurrentLib() ) aAttr.SetColour( wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) ); - +#else + // mark the current library with background color + if( node->Name == m_libMgr->GetCurrentLib() ) + aAttr.SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) ); +#endif break; case CMP_TREE_NODE::LIBID: @@ -210,10 +249,16 @@ bool LIB_MANAGER_ADAPTER::GetAttr( wxDataViewItem const& aItem, unsigned int aCo // mark aliases with italic font aAttr.SetItalic( !node->IsRoot ); - // mark the current part with inverted colors +#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->LibId == m_libMgr->GetCurrentLibId() ) aAttr.SetColour( wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) ); - +#else + // mark the current part with background color + if( node->LibId == m_libMgr->GetCurrentLibId() ) + aAttr.SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) ); +#endif break; default: diff --git a/eeschema/lib_manager_adapter.h b/eeschema/lib_manager_adapter.h index c2ca1f875c..4740860316 100644 --- a/eeschema/lib_manager_adapter.h +++ b/eeschema/lib_manager_adapter.h @@ -54,6 +54,8 @@ protected: CMP_TREE_NODE* findLibrary( const wxString& aLibNickName ); + void GetValue( wxVariant& aVariant, wxDataViewItem const& aItem, + unsigned int aCol ) const override; bool GetAttr( wxDataViewItem const& aItem, unsigned int aCol, wxDataViewItemAttr& aAttr ) const override; diff --git a/eeschema/libeditframe.cpp b/eeschema/libeditframe.cpp index df1d2ced54..b3f99a3b51 100644 --- a/eeschema/libeditframe.cpp +++ b/eeschema/libeditframe.cpp @@ -492,6 +492,12 @@ bool LIB_EDIT_FRAME::IsSearchTreeShown() } +void LIB_EDIT_FRAME::ClearSearchTreeSelection() +{ + m_treePane->GetCmpTree()->Unselect(); +} + + void LIB_EDIT_FRAME::OnUpdateSelectTool( wxUpdateUIEvent& aEvent ) { aEvent.Check( GetToolId() == aEvent.GetId() ); diff --git a/eeschema/libeditframe.h b/eeschema/libeditframe.h index 7a3d93fb82..ce8927fff7 100644 --- a/eeschema/libeditframe.h +++ b/eeschema/libeditframe.h @@ -316,6 +316,7 @@ public: void OnEditSymbolLibTable( wxCommandEvent& aEvent ) override; bool IsSearchTreeShown(); + void ClearSearchTreeSelection(); void OnEditComponentProperties( wxCommandEvent& event ); void InstallFieldsEditorDialog( wxCommandEvent& event ); diff --git a/eeschema/widgets/cmp_tree_pane.cpp b/eeschema/widgets/cmp_tree_pane.cpp index c2676760e6..6be59e0dcc 100644 --- a/eeschema/widgets/cmp_tree_pane.cpp +++ b/eeschema/widgets/cmp_tree_pane.cpp @@ -126,4 +126,7 @@ void CMP_TREE_PANE::onComponentSelected( wxCommandEvent& aEvent ) //wxPostEvent( libEditFrame, evt ); //wxQueueEvent( m_libEditFrame, new wxCommandEvent( ID_LIBEDIT_EDIT_PART ) ); m_libEditFrame->OnEditPart( evt ); + + // Make sure current-part highlighting doesn't get lost in seleciton highlighting + m_tree->Unselect(); }