2017-01-11 17:22:53 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2019-05-13 20:42:40 +00:00
|
|
|
* Copyright (C) 2017-2019 KiCad Developers, see CHANGELOG.txt for contributors.
|
2017-01-11 17:22:53 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2019-06-08 22:14:57 +00:00
|
|
|
#include <eda_draw_frame.h>
|
2017-02-28 03:04:44 +00:00
|
|
|
#include <tool/tool_menu.h>
|
|
|
|
#include <tool/tool_interactive.h>
|
2019-05-14 11:14:00 +00:00
|
|
|
#include <tool/action_menu.h>
|
2017-02-28 03:04:44 +00:00
|
|
|
#include <tool/actions.h>
|
|
|
|
#include <tool/zoom_menu.h>
|
|
|
|
#include <tool/grid_menu.h>
|
|
|
|
#include <tool/selection.h>
|
2017-01-11 17:22:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
TOOL_MENU::TOOL_MENU( TOOL_INTERACTIVE& aTool ) :
|
2019-05-13 20:42:40 +00:00
|
|
|
m_menu( true, &aTool ),
|
2017-01-11 17:22:53 +00:00
|
|
|
m_tool( aTool )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TOOL_MENU::~TOOL_MENU()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CONDITIONAL_MENU& TOOL_MENU::GetMenu()
|
|
|
|
{
|
|
|
|
return m_menu;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-14 11:14:00 +00:00
|
|
|
void TOOL_MENU::AddSubMenu( std::shared_ptr<ACTION_MENU> aSubMenu )
|
2017-01-11 17:22:53 +00:00
|
|
|
{
|
|
|
|
// store a copy of the menu (keeps a reference)
|
|
|
|
m_subMenus.push_back( std::move( aSubMenu ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TOOL_MENU::ShowContextMenu( SELECTION& aSelection )
|
|
|
|
{
|
2019-05-13 20:42:40 +00:00
|
|
|
m_menu.Evaluate( aSelection );
|
|
|
|
m_menu.UpdateAll();
|
2019-05-22 21:11:05 +00:00
|
|
|
m_menu.ClearDirty();
|
2019-05-13 20:42:40 +00:00
|
|
|
m_tool.SetContextMenu( &m_menu, CMENU_NOW );
|
2017-01-11 17:22:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TOOL_MENU::ShowContextMenu()
|
|
|
|
{
|
2019-05-22 21:11:05 +00:00
|
|
|
m_menu.SetDirty();
|
2019-05-13 20:42:40 +00:00
|
|
|
m_tool.SetContextMenu( &m_menu, CMENU_NOW );
|
2017-01-11 17:22:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TOOL_MENU::CloseContextMenu( OPT_TOOL_EVENT& evt )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|