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 ) ...@@ -312,21 +312,19 @@ BOARD_ITEM* SELECTION_TOOL::disambiguationMenu( GENERAL_COLLECTOR* aCollector )
{ {
BOARD_ITEM* current = NULL; BOARD_ITEM* current = NULL;
boost::shared_ptr<BRIGHT_BOX> brightBox; boost::shared_ptr<BRIGHT_BOX> brightBox;
CONTEXT_MENU m_menu;
m_menu.reset( new CONTEXT_MENU() );
m_menu->SetTitle( _( "Clarify selection" ) );
int limit = std::min( 10, aCollector->GetCount() ); int limit = std::min( 10, aCollector->GetCount() );
for( int i = 0; i < limit; ++i ) for( int i = 0; i < limit; ++i )
{ {
wxString text; wxString text;
BOARD_ITEM* item = ( *aCollector )[i]; BOARD_ITEM* item = ( *aCollector )[i];
text = item->GetSelectMenuText(); 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() ) while( OPT_TOOL_EVENT evt = Wait() )
{ {
...@@ -350,14 +348,8 @@ BOARD_ITEM* SELECTION_TOOL::disambiguationMenu( GENERAL_COLLECTOR* aCollector ) ...@@ -350,14 +348,8 @@ BOARD_ITEM* SELECTION_TOOL::disambiguationMenu( GENERAL_COLLECTOR* aCollector )
{ {
optional<int> id = evt->GetCommandId(); optional<int> id = evt->GetCommandId();
if( current )
current->ClearSelected();
if( id && ( *id >= 0 ) ) if( id && ( *id >= 0 ) )
{
current = ( *aCollector )[*id]; current = ( *aCollector )[*id];
current->SetSelected();
}
break; break;
} }
...@@ -371,11 +363,12 @@ BOARD_ITEM* SELECTION_TOOL::disambiguationMenu( GENERAL_COLLECTOR* aCollector ) ...@@ -371,11 +363,12 @@ BOARD_ITEM* SELECTION_TOOL::disambiguationMenu( GENERAL_COLLECTOR* aCollector )
} }
getView()->MarkTargetDirty( TARGET_OVERLAY ); getView()->MarkTargetDirty( TARGET_OVERLAY );
return current; 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(); bool highContrast = getView()->GetPainter()->GetSettings()->GetHighContrast();
...@@ -443,8 +436,12 @@ bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem ) ...@@ -443,8 +436,12 @@ bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem )
// These are not selectable, otherwise silkscreen drawings would be easily destroyed // These are not selectable, otherwise silkscreen drawings would be easily destroyed
return false; return false;
break; break;
default: // Suppress warnings
break;
} }
// All other items are selected only if the layer on which they exist is visible // All other items are selected only if the layer on which they exist is visible
return board->IsLayerVisible( aItem->GetLayer() ); return board->IsLayerVisible( aItem->GetLayer() );
} }
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#define __SELECTION_TOOL_H #define __SELECTION_TOOL_H
#include <set> #include <set>
#include <boost/shared_ptr.hpp>
#include <math/vector2d.h> #include <math/vector2d.h>
#include <tool/tool_interactive.h> #include <tool/tool_interactive.h>
...@@ -134,7 +133,7 @@ private: ...@@ -134,7 +133,7 @@ private:
* *
* @return True if the item fulfills conditions to be selected. * @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() * Function containsSelected()
...@@ -150,9 +149,6 @@ private: ...@@ -150,9 +149,6 @@ private:
/// Visual representation of selection box /// Visual representation of selection box
SELECTION_AREA* m_selArea; 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 /// Flag saying if items should be added to the current selection or rather replace it
bool m_additive; 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