Commit 12b8714a authored by Maciej Suminski's avatar Maciej Suminski

Different way of handling CONTEXT_MENU in the selection tool. Removed some unnecessary lines.

parent 61066fa6
......@@ -312,21 +312,19 @@ BOARD_ITEM* SELECTION_TOOL::disambiguationMenu( GENERAL_COLLECTOR* aCollector )
{
BOARD_ITEM* current = NULL;
boost::shared_ptr<BRIGHT_BOX> 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<int> 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() );
}
......
......@@ -27,7 +27,6 @@
#define __SELECTION_TOOL_H
#include <set>
#include <boost/shared_ptr.hpp>
#include <math/vector2d.h>
#include <tool/tool_interactive.h>
......@@ -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<CONTEXT_MENU> m_menu;
/// Flag saying if items should be added to the current selection or rather replace it
bool m_additive;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment