Commit 9ef9b7b8 authored by Maciej Suminski's avatar Maciej Suminski

Preliminary selection mode for SELECTION_TOOL.

parent b8295b6a
...@@ -111,7 +111,6 @@ void SELECTION_TOOL::Reset( RESET_REASON aReason ) ...@@ -111,7 +111,6 @@ void SELECTION_TOOL::Reset( RESET_REASON aReason )
// Remove pointers to the selected items from containers // Remove pointers to the selected items from containers
// without changing their properties (as they are already deleted // without changing their properties (as they are already deleted
// while a new board is loaded) // while a new board is loaded)
m_selection.group->Clear();
m_selection.clear(); m_selection.clear();
} }
else else
...@@ -120,6 +119,7 @@ void SELECTION_TOOL::Reset( RESET_REASON aReason ) ...@@ -120,6 +119,7 @@ void SELECTION_TOOL::Reset( RESET_REASON aReason )
m_frame = getEditFrame<PCB_BASE_FRAME>(); m_frame = getEditFrame<PCB_BASE_FRAME>();
m_locked = true; m_locked = true;
m_preliminary = true;
// Reinsert the VIEW_GROUP, in case it was removed from the VIEW // Reinsert the VIEW_GROUP, in case it was removed from the VIEW
getView()->Remove( m_selection.group ); getView()->Remove( m_selection.group );
...@@ -155,10 +155,13 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) ...@@ -155,10 +155,13 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
// right click? if there is any object - show the context menu // right click? if there is any object - show the context menu
else if( evt->IsClick( BUT_RIGHT ) ) else if( evt->IsClick( BUT_RIGHT ) )
{ {
if( m_selection.Empty() ) bool emptySelection = m_selection.Empty();
if( emptySelection )
selectCursor( evt->Position() ); selectCursor( evt->Position() );
generateMenu(); generateMenu();
m_preliminary = emptySelection;
} }
// double click? Display the properties window // double click? Display the properties window
...@@ -175,10 +178,14 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) ...@@ -175,10 +178,14 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
{ {
if( m_additive ) if( m_additive )
{ {
m_preliminary = false;
selectMultiple(); selectMultiple();
} }
else if( m_selection.Empty() ) else if( m_selection.Empty() )
{ {
m_preliminary = false;
// There is nothing selected, so try to select something // There is nothing selected, so try to select something
if( !selectCursor( getView()->ToWorld( getViewControls()->GetMousePosition() ), false ) ) if( !selectCursor( getView()->ToWorld( getViewControls()->GetMousePosition() ), false ) )
{ {
...@@ -249,6 +256,12 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) ...@@ -249,6 +256,12 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
{ {
selectNet( *evt ); selectNet( *evt );
} }
else if( evt->Action() == TA_CONTEXT_MENU_CLOSED )
{
if( m_preliminary )
clearSelection();
}
} }
// This tool is supposed to be active forever // This tool is supposed to be active forever
......
...@@ -122,8 +122,10 @@ public: ...@@ -122,8 +122,10 @@ public:
* *
* Returns the set of currently selected items. * Returns the set of currently selected items.
*/ */
const SELECTION& GetSelection() const const SELECTION& GetSelection()
{ {
// The selected items list has been requested, so it is no longer preliminary
m_preliminary = false;
return m_selection; return m_selection;
} }
...@@ -356,6 +358,9 @@ private: ...@@ -356,6 +358,9 @@ private:
/// Can other tools modify locked items. /// Can other tools modify locked items.
bool m_locked; bool m_locked;
/// Determines if the selection is preliminary or final.
bool m_preliminary;
/// Conditions for specific context menu entries. /// Conditions for specific context menu entries.
std::deque<SELECTION_CONDITION> m_menuConditions; std::deque<SELECTION_CONDITION> m_menuConditions;
}; };
......
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