From 12b8714aff1681ab7cfb6062ecdd4582fa335175 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Thu, 26 Sep 2013 14:09:56 +0200 Subject: [PATCH] Different way of handling CONTEXT_MENU in the selection tool. Removed some unnecessary lines. --- pcbnew/tools/selection_tool.cpp | 23 ++++++++++------------- pcbnew/tools/selection_tool.h | 6 +----- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index fd970863f9..c3c1467f74 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -312,21 +312,19 @@ BOARD_ITEM* SELECTION_TOOL::disambiguationMenu( GENERAL_COLLECTOR* aCollector ) { BOARD_ITEM* current = NULL; boost::shared_ptr brightBox; - - m_menu.reset( new CONTEXT_MENU() ); - m_menu->SetTitle( _( "Clarify selection" ) ); + CONTEXT_MENU m_menu; int limit = std::min( 10, aCollector->GetCount() ); - for( int i = 0; i < limit; ++i ) { wxString text; BOARD_ITEM* item = ( *aCollector )[i]; text = item->GetSelectMenuText(); - m_menu->Add( text, i ); + m_menu.Add( text, i ); } - SetContextMenu( m_menu.get(), CMENU_NOW ); + m_menu.SetTitle( _( "Clarify selection" ) ); + SetContextMenu( &m_menu, CMENU_NOW ); while( OPT_TOOL_EVENT evt = Wait() ) { @@ -350,14 +348,8 @@ BOARD_ITEM* SELECTION_TOOL::disambiguationMenu( GENERAL_COLLECTOR* aCollector ) { optional id = evt->GetCommandId(); - if( current ) - current->ClearSelected(); - if( id && ( *id >= 0 ) ) - { current = ( *aCollector )[*id]; - current->SetSelected(); - } break; } @@ -371,11 +363,12 @@ BOARD_ITEM* SELECTION_TOOL::disambiguationMenu( GENERAL_COLLECTOR* aCollector ) } getView()->MarkTargetDirty( TARGET_OVERLAY ); + return current; } -bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem ) +bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem ) const { bool highContrast = getView()->GetPainter()->GetSettings()->GetHighContrast(); @@ -443,8 +436,12 @@ bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem ) // These are not selectable, otherwise silkscreen drawings would be easily destroyed return false; break; + + default: // Suppress warnings + break; } + // All other items are selected only if the layer on which they exist is visible return board->IsLayerVisible( aItem->GetLayer() ); } diff --git a/pcbnew/tools/selection_tool.h b/pcbnew/tools/selection_tool.h index 622a9bcfa6..6540a57c99 100644 --- a/pcbnew/tools/selection_tool.h +++ b/pcbnew/tools/selection_tool.h @@ -27,7 +27,6 @@ #define __SELECTION_TOOL_H #include -#include #include #include @@ -134,7 +133,7 @@ private: * * @return True if the item fulfills conditions to be selected. */ - bool selectable( const BOARD_ITEM* aItem ); + bool selectable( const BOARD_ITEM* aItem ) const; /** * Function containsSelected() @@ -150,9 +149,6 @@ private: /// Visual representation of selection box SELECTION_AREA* m_selArea; - /// Menu shown in case of selection ambiguity - boost::shared_ptr m_menu; - /// Flag saying if items should be added to the current selection or rather replace it bool m_additive;