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