2020-07-29 23:50:25 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2020 Ian McInerney <ian.s.mcinerney at ieee.org>
|
|
|
|
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef EDITOR_CONDITIONS_H_
|
|
|
|
#define EDITOR_CONDITIONS_H_
|
|
|
|
|
|
|
|
#include <class_draw_panel_gal.h>
|
|
|
|
#include <functional>
|
|
|
|
#include <tool/selection.h>
|
|
|
|
#include <tool/selection_conditions.h>
|
|
|
|
|
|
|
|
class EDA_BASE_FRAME;
|
|
|
|
class EDA_DRAW_FRAME;
|
2021-06-06 17:26:26 +00:00
|
|
|
class TOOL_ACTION;
|
2020-12-27 00:41:04 +00:00
|
|
|
|
2020-07-29 23:50:25 +00:00
|
|
|
/**
|
|
|
|
* Class that groups generic conditions for editor states.
|
|
|
|
*/
|
|
|
|
class EDITOR_CONDITIONS : public SELECTION_CONDITIONS
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Create an object to define conditions dependent upon a specific frame.
|
|
|
|
*
|
|
|
|
* @param aFrame is the frame to query for the conditions
|
|
|
|
*/
|
|
|
|
EDITOR_CONDITIONS( EDA_BASE_FRAME* aFrame ) :
|
|
|
|
m_frame( aFrame )
|
|
|
|
{}
|
|
|
|
|
|
|
|
/**
|
2020-12-27 00:41:04 +00:00
|
|
|
* Create a functor that tests if the content of the frame is modified.
|
2020-07-29 23:50:25 +00:00
|
|
|
*
|
2020-12-27 00:41:04 +00:00
|
|
|
* @return Functor testing for modified content.
|
2020-07-29 23:50:25 +00:00
|
|
|
*/
|
|
|
|
SELECTION_CONDITION ContentModified();
|
|
|
|
|
|
|
|
/**
|
2020-12-27 00:41:04 +00:00
|
|
|
* Create a functor that tests if there are any items in the undo queue.
|
2020-07-29 23:50:25 +00:00
|
|
|
*
|
|
|
|
* @return Functor testing if the undo queue has items.
|
|
|
|
*/
|
|
|
|
SELECTION_CONDITION UndoAvailable();
|
|
|
|
|
|
|
|
/**
|
2020-12-27 00:41:04 +00:00
|
|
|
* Create a functor that tests if there are any items in the redo queue.
|
2020-07-29 23:50:25 +00:00
|
|
|
*
|
|
|
|
* @return Functor testing if the redo queue has items.
|
|
|
|
*/
|
|
|
|
SELECTION_CONDITION RedoAvailable();
|
|
|
|
|
|
|
|
/**
|
2020-12-27 00:41:04 +00:00
|
|
|
* Create a functor that tests if the frame has the specified units.
|
2020-07-29 23:50:25 +00:00
|
|
|
*
|
|
|
|
* @return Functor testing the units of a frame.
|
|
|
|
*/
|
|
|
|
SELECTION_CONDITION Units( EDA_UNITS aUnit );
|
|
|
|
|
|
|
|
/**
|
2020-12-27 00:41:04 +00:00
|
|
|
* Create a functor testing if the specified tool is the current active tool in the frame.
|
2020-07-29 23:50:25 +00:00
|
|
|
*
|
2020-12-27 00:41:04 +00:00
|
|
|
* @return Functor testing the current tool of a frame.
|
2020-07-29 23:50:25 +00:00
|
|
|
*/
|
|
|
|
SELECTION_CONDITION CurrentTool( const TOOL_ACTION& aTool );
|
|
|
|
|
2020-08-13 23:09:17 +00:00
|
|
|
/**
|
2020-12-27 00:41:04 +00:00
|
|
|
* Create a functor testing if there are no tools active in the frame.
|
2020-08-13 23:09:17 +00:00
|
|
|
*
|
2020-12-27 00:41:04 +00:00
|
|
|
* @return Functor testing the frame has no tools running.
|
2020-08-13 23:09:17 +00:00
|
|
|
*/
|
|
|
|
SELECTION_CONDITION NoActiveTool();
|
|
|
|
|
2020-07-29 23:50:25 +00:00
|
|
|
/**
|
2020-12-27 00:41:04 +00:00
|
|
|
* Create a functor testing if the grid is visible in a frame.
|
2020-07-29 23:50:25 +00:00
|
|
|
*
|
2020-12-27 00:41:04 +00:00
|
|
|
* @note This requires the frame passed into the constructor be be derived from EDA_DRAW_FRAME.
|
2020-07-29 23:50:25 +00:00
|
|
|
*
|
|
|
|
* @return Functor testing if the grid is visible
|
|
|
|
*/
|
|
|
|
SELECTION_CONDITION GridVisible();
|
|
|
|
|
|
|
|
/**
|
2020-12-27 00:41:04 +00:00
|
|
|
* Create a functor testing if polar coordinates are current being used.
|
2020-07-29 23:50:25 +00:00
|
|
|
*
|
2020-12-27 00:41:04 +00:00
|
|
|
* @note This requires the frame passed into the constructor be be derived from EDA_DRAW_FRAME.
|
2020-07-29 23:50:25 +00:00
|
|
|
*
|
|
|
|
* @return Functor testing if the grid is visible
|
|
|
|
*/
|
|
|
|
SELECTION_CONDITION PolarCoordinates();
|
|
|
|
|
|
|
|
/**
|
2020-12-27 00:41:04 +00:00
|
|
|
* Create a functor testing if the cursor is full screen in a frame.
|
2020-07-29 23:50:25 +00:00
|
|
|
*
|
2020-12-27 00:41:04 +00:00
|
|
|
* @note This requires the frame passed into the constructor be be derived from EDA_DRAW_FRAME.
|
2020-07-29 23:50:25 +00:00
|
|
|
*
|
|
|
|
* @return Functor testing if the cursor is full screen
|
|
|
|
*/
|
|
|
|
SELECTION_CONDITION FullscreenCursor();
|
|
|
|
|
2021-07-02 19:05:16 +00:00
|
|
|
/**
|
|
|
|
* Create a functor testing if the python scripting console window is visible.
|
|
|
|
*
|
|
|
|
* @note This requires the frame passed into the constructor be be derived from EDA_DRAW_FRAME.
|
|
|
|
*
|
|
|
|
* @return Functor testing if the python scripting console window is visible
|
|
|
|
*/
|
|
|
|
SELECTION_CONDITION ScriptingConsoleVisible();
|
|
|
|
|
2020-08-13 23:09:17 +00:00
|
|
|
protected:
|
2020-12-27 00:41:04 +00:00
|
|
|
///< Helper function used by ContentModified().
|
2020-07-29 23:50:25 +00:00
|
|
|
static bool contentModifiedFunc( const SELECTION& aSelection, EDA_BASE_FRAME* aFrame );
|
|
|
|
|
2020-12-27 00:41:04 +00:00
|
|
|
///< Helper function used by UndoAvailable().
|
2020-07-29 23:50:25 +00:00
|
|
|
static bool undoFunc( const SELECTION& aSelection, EDA_BASE_FRAME* aFrame );
|
|
|
|
|
2020-12-27 00:41:04 +00:00
|
|
|
///< Helper function used by RedoAvailable().
|
2020-07-29 23:50:25 +00:00
|
|
|
static bool redoFunc( const SELECTION& aSelection, EDA_BASE_FRAME* aFrame );
|
|
|
|
|
2020-12-27 00:41:04 +00:00
|
|
|
///< Helper function used by Units().
|
2020-07-29 23:50:25 +00:00
|
|
|
static bool unitsFunc( const SELECTION& aSelection, EDA_BASE_FRAME* aFrame, EDA_UNITS aUnits );
|
|
|
|
|
2020-12-27 00:41:04 +00:00
|
|
|
///< Helper function used by CurrentTool().
|
|
|
|
static bool toolFunc( const SELECTION& aSelection, EDA_BASE_FRAME* aFrame,
|
|
|
|
const TOOL_ACTION& aTool );
|
2020-07-29 23:50:25 +00:00
|
|
|
|
2020-12-27 00:41:04 +00:00
|
|
|
///< Helper function used by NoActiveTool().
|
2020-08-13 23:09:17 +00:00
|
|
|
static bool noToolFunc( const SELECTION& aSelection, EDA_BASE_FRAME* aFrame );
|
|
|
|
|
2020-12-27 00:41:04 +00:00
|
|
|
///< Helper function used by GridVisible().
|
2020-07-29 23:50:25 +00:00
|
|
|
static bool gridFunc( const SELECTION& aSelection, EDA_DRAW_FRAME* aFrame );
|
|
|
|
|
2020-12-27 00:41:04 +00:00
|
|
|
///< Helper function used by PolarCoordinates().
|
2020-07-29 23:50:25 +00:00
|
|
|
static bool polarCoordFunc( const SELECTION& aSelection, EDA_DRAW_FRAME* aFrame );
|
|
|
|
|
2020-12-27 00:41:04 +00:00
|
|
|
///< Helper function used by FullscreenCursor().
|
2020-07-29 23:50:25 +00:00
|
|
|
static bool cursorFunc( const SELECTION& aSelection, EDA_DRAW_FRAME* aFrame );
|
|
|
|
|
2021-07-02 19:05:16 +00:00
|
|
|
///< Helper function used by ScriptingConsoleVisible().
|
|
|
|
static bool consoleVisibleFunc( const SELECTION& aSelection, EDA_DRAW_FRAME* aFrame );
|
2020-07-29 23:50:25 +00:00
|
|
|
|
2020-12-27 00:41:04 +00:00
|
|
|
///< The frame to apply the conditions to.
|
2020-07-29 23:50:25 +00:00
|
|
|
EDA_BASE_FRAME* m_frame;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* EDITOR_CONDITIONS_H_ */
|