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
This commit is contained in:
Jeff Young 2018-01-20 17:15:46 +00:00 committed by Maciej Suminski
parent 9b7d499c51
commit 2201482e47
6 changed files with 64 additions and 4 deletions

View File

@ -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;

View File

@ -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:

View File

@ -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;

View File

@ -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() );

View File

@ -316,6 +316,7 @@ public:
void OnEditSymbolLibTable( wxCommandEvent& aEvent ) override;
bool IsSearchTreeShown();
void ClearSearchTreeSelection();
void OnEditComponentProperties( wxCommandEvent& event );
void InstallFieldsEditorDialog( wxCommandEvent& event );

View File

@ -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();
}