From 68b07d1aff67f3b8375bfe72090729757cf6c4f5 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 4 Nov 2018 00:58:28 +0000 Subject: [PATCH] Add show/hide search tree to modedit, and fix it in libedit. Fixes: lp:1801531 * https://bugs.launchpad.net/kicad/+bug/1801531 --- eeschema/libedit/lib_edit_frame.cpp | 3 +-- eeschema/libedit/menubar_libedit.cpp | 2 +- pcbnew/footprint_edit_frame.cpp | 22 ++++++++++++++++++++++ pcbnew/footprint_edit_frame.h | 3 +++ pcbnew/menubar_footprint_editor.cpp | 9 +++++++-- pcbnew/pcbnew_id.h | 1 + pcbnew/tool_footprint_editor.cpp | 5 +++++ 7 files changed, 40 insertions(+), 5 deletions(-) diff --git a/eeschema/libedit/lib_edit_frame.cpp b/eeschema/libedit/lib_edit_frame.cpp index 762fb9822e..96e6b7ff4b 100644 --- a/eeschema/libedit/lib_edit_frame.cpp +++ b/eeschema/libedit/lib_edit_frame.cpp @@ -428,8 +428,7 @@ void LIB_EDIT_FRAME::OnUpdateElectricalType( wxUpdateUIEvent& aEvent ) void LIB_EDIT_FRAME::OnUpdateSearchTreeTool( wxUpdateUIEvent& aEvent ) { - if( aEvent.GetEventObject() == m_optionsToolBar ) - aEvent.Check( IsSearchTreeShown() ); + aEvent.Check( IsSearchTreeShown() ); } diff --git a/eeschema/libedit/menubar_libedit.cpp b/eeschema/libedit/menubar_libedit.cpp index 272a366889..47e9f96c79 100644 --- a/eeschema/libedit/menubar_libedit.cpp +++ b/eeschema/libedit/menubar_libedit.cpp @@ -225,7 +225,7 @@ void LIB_EDIT_FRAME::ReCreateMenuBar() ID_LIBEDIT_SHOW_HIDE_SEARCH_TREE, _( "&Search Tree" ), _( "Toggles the search tree visibility" ), - KiBitmap( search_tree_xpm ) ); + KiBitmap( search_tree_xpm ), wxITEM_CHECK ); // Menu Place: wxMenu* placeMenu = new wxMenu; diff --git a/pcbnew/footprint_edit_frame.cpp b/pcbnew/footprint_edit_frame.cpp index 415c7cc9bc..4409f91bfb 100644 --- a/pcbnew/footprint_edit_frame.cpp +++ b/pcbnew/footprint_edit_frame.cpp @@ -133,6 +133,7 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME ) // ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH id is managed in PCB_BASE_FRAME // ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH id is managed in PCB_BASE_FRAME EVT_TOOL( ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE, FOOTPRINT_EDIT_FRAME::OnSelectOptionToolbar ) + EVT_TOOL( ID_MODEDIT_SHOW_HIDE_SEARCH_TREE, FOOTPRINT_EDIT_FRAME::OnToggleSearchTree ) // Preferences and option menus EVT_MENU( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, @@ -200,6 +201,8 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME ) // Option toolbar: EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE, FOOTPRINT_EDIT_FRAME::OnUpdateOptionsToolbar ) + EVT_UPDATE_UI( ID_MODEDIT_SHOW_HIDE_SEARCH_TREE, + FOOTPRINT_EDIT_FRAME::OnUpdateOptionsToolbar ) EVT_UPDATE_UI( ID_GEN_IMPORT_DXF_FILE, FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected ) @@ -345,6 +348,21 @@ void FOOTPRINT_EDIT_FRAME::OnSwitchCanvas( wxCommandEvent& aEvent ) UpdateUserInterface(); } + +void FOOTPRINT_EDIT_FRAME::OnToggleSearchTree( wxCommandEvent& event ) +{ + auto& treePane = m_auimgr.GetPane( m_treePane ); + treePane.Show( !IsSearchTreeShown() ); + m_auimgr.Update(); +} + + +bool FOOTPRINT_EDIT_FRAME::IsSearchTreeShown() +{ + return m_auimgr.GetPane( m_treePane ).IsShown(); +} + + BOARD_ITEM_CONTAINER* FOOTPRINT_EDIT_FRAME::GetModel() const { return GetBoard()->m_Modules; @@ -577,6 +595,10 @@ void FOOTPRINT_EDIT_FRAME::OnUpdateOptionsToolbar( wxUpdateUIEvent& aEvent ) state = displ_opts->m_ContrastModeDisplay; break; + case ID_MODEDIT_SHOW_HIDE_SEARCH_TREE: + state = IsSearchTreeShown(); + break; + default: wxMessageBox( "FOOTPRINT_EDIT_FRAME::OnUpdateOptionsToolbar error" ); break; diff --git a/pcbnew/footprint_edit_frame.h b/pcbnew/footprint_edit_frame.h index c1b9179663..fece6fce76 100644 --- a/pcbnew/footprint_edit_frame.h +++ b/pcbnew/footprint_edit_frame.h @@ -153,6 +153,9 @@ public: void ToolOnRightClick( wxCommandEvent& event ) override; void OnSelectOptionToolbar( wxCommandEvent& event ); void OnConfigurePaths( wxCommandEvent& aEvent ); + void OnToggleSearchTree( wxCommandEvent& event ); + + bool IsSearchTreeShown(); /** * Function SaveLibraryAs diff --git a/pcbnew/menubar_footprint_editor.cpp b/pcbnew/menubar_footprint_editor.cpp index 36b9ae51e9..487a41495c 100644 --- a/pcbnew/menubar_footprint_editor.cpp +++ b/pcbnew/menubar_footprint_editor.cpp @@ -315,9 +315,14 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar() _( "Select how items are displayed" ), KiBitmap( contrast_mode_xpm ) ); -#ifdef __APPLE__ + // Separator viewMenu->AppendSeparator(); -#endif + + AddMenuItem( viewMenu, + ID_MODEDIT_SHOW_HIDE_SEARCH_TREE, + _( "&Search Tree" ), + _( "Toggles the search tree visibility" ), + KiBitmap( search_tree_xpm ), wxITEM_CHECK ); //-------- Place menu -------------------- diff --git a/pcbnew/pcbnew_id.h b/pcbnew/pcbnew_id.h index 33069f4385..0dba8f1879 100644 --- a/pcbnew/pcbnew_id.h +++ b/pcbnew/pcbnew_id.h @@ -369,6 +369,7 @@ enum pcbnew_ids ID_MODEDIT_MODULE_MOVE_EXACT, ID_MODEDIT_IMPORT_PART, ID_MODEDIT_EXPORT_PART, + ID_MODEDIT_SHOW_HIDE_SEARCH_TREE, ID_POPUP_MODEDIT_EDIT_BODY_ITEM, ID_MODVIEW_LIB_LIST, diff --git a/pcbnew/tool_footprint_editor.cpp b/pcbnew/tool_footprint_editor.cpp index 1b34af611e..77102002ea 100644 --- a/pcbnew/tool_footprint_editor.cpp +++ b/pcbnew/tool_footprint_editor.cpp @@ -234,6 +234,11 @@ void FOOTPRINT_EDIT_FRAME::ReCreateOptToolbar() _( "Enable high contrast display mode" ), wxITEM_CHECK ); + KiScaledSeparator( m_optionsToolBar, this ); + m_optionsToolBar->AddTool( ID_MODEDIT_SHOW_HIDE_SEARCH_TREE, wxEmptyString, + KiScaledBitmap( search_tree_xpm, this ), + _( "Toggles the search tree" ), wxITEM_CHECK ); + m_optionsToolBar->Realize(); }