KiCad PCB EDA Suite
editor_conditions.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2020 Ian McInerney <ian.s.mcinerney at ieee.org>
5  * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 #ifndef EDITOR_CONDITIONS_H_
26 #define EDITOR_CONDITIONS_H_
27 
28 #include <class_draw_panel_gal.h>
29 #include <functional>
30 #include <tool/selection.h>
32 #include <tool/tool_action.h>
33 
34 class EDA_BASE_FRAME;
35 class EDA_DRAW_FRAME;
40 {
41 public:
48  m_frame( aFrame )
49  {}
50 
57 
64 
71 
78 
85 
92 
101 
110 
119 
128 
129 protected:
131  static bool contentModifiedFunc( const SELECTION& aSelection, EDA_BASE_FRAME* aFrame );
132 
134  static bool undoFunc( const SELECTION& aSelection, EDA_BASE_FRAME* aFrame );
135 
137  static bool redoFunc( const SELECTION& aSelection, EDA_BASE_FRAME* aFrame );
138 
140  static bool unitsFunc( const SELECTION& aSelection, EDA_BASE_FRAME* aFrame, EDA_UNITS aUnits );
141 
143  static bool toolFunc( const SELECTION& aSelection, EDA_BASE_FRAME* aFrame, const TOOL_ACTION& aTool );
144 
146  static bool noToolFunc( const SELECTION& aSelection, EDA_BASE_FRAME* aFrame );
147 
149  static bool gridFunc( const SELECTION& aSelection, EDA_DRAW_FRAME* aFrame );
150 
152  static bool polarCoordFunc( const SELECTION& aSelection, EDA_DRAW_FRAME* aFrame );
153 
155  static bool cursorFunc( const SELECTION& aSelection, EDA_DRAW_FRAME* aFrame );
156 
158  static bool canvasTypeFunc( const SELECTION& aSelection, EDA_DRAW_FRAME* aFrame,
160 
163 };
164 
165 #endif /* EDITOR_CONDITIONS_H_ */
static bool canvasTypeFunc(const SELECTION &aSelection, EDA_DRAW_FRAME *aFrame, EDA_DRAW_PANEL_GAL::GAL_TYPE aType)
Helper function used by CanvasType()
static bool unitsFunc(const SELECTION &aSelection, EDA_BASE_FRAME *aFrame, EDA_UNITS aUnits)
Helper function used by Units()
SELECTION_CONDITION FullscreenCursor()
Creates a functor testing if the cursor is full screen in a frame.
static bool contentModifiedFunc(const SELECTION &aSelection, EDA_BASE_FRAME *aFrame)
Helper function used by ContentModified()
SELECTION_CONDITION CurrentTool(const TOOL_ACTION &aTool)
Creates a functor testing if the specified tool is the current active tool in the frame.
Class that groups generic conditions for selected items.
SELECTION_CONDITION CanvasType(EDA_DRAW_PANEL_GAL::GAL_TYPE aType)
Creates a functor testing if the specified canvas is active in the frame.
SELECTION_CONDITION RedoAvailable()
Creates a functor that tests if there are any items in the redo queue.
The base class for create windows for drawing purpose.
Class that groups generic conditions for editor states.
static bool cursorFunc(const SELECTION &aSelection, EDA_DRAW_FRAME *aFrame)
Helper function used by FullscreenCursor()
static bool polarCoordFunc(const SELECTION &aSelection, EDA_DRAW_FRAME *aFrame)
Helper function used by PolarCoordinates()
EDA_BASE_FRAME * m_frame
The frame to apply the conditions to
static bool noToolFunc(const SELECTION &aSelection, EDA_BASE_FRAME *aFrame)
Helper function used by NoActiveTool()
SELECTION_CONDITION GridVisible()
Creates a functor testing if the grid is visible in a frame.
SELECTION_CONDITION Units(EDA_UNITS aUnit)
Creates a functor that tests if the frame has the specified units.
static bool undoFunc(const SELECTION &aSelection, EDA_BASE_FRAME *aFrame)
Helper function used by UndoAvailable()
std::function< bool(const SELECTION &)> SELECTION_CONDITION
Functor type that checks a specific condition for selected items.
SELECTION_CONDITION PolarCoordinates()
Creates a functor testing if polar coordinates are current being used.
SELECTION_CONDITION ContentModified()
Creates a functor that tests if the content of the frame is modified.
SELECTION_CONDITION NoActiveTool()
Creates a functor testing if there are no tools active in the frame.
static bool gridFunc(const SELECTION &aSelection, EDA_DRAW_FRAME *aFrame)
Helper function used by GridVisible()
static bool toolFunc(const SELECTION &aSelection, EDA_BASE_FRAME *aFrame, const TOOL_ACTION &aTool)
Helper function used by CurrentTool()
EDA_UNITS
Definition: eda_units.h:38
static bool redoFunc(const SELECTION &aSelection, EDA_BASE_FRAME *aFrame)
Helper function used by RedoAvailable()
SELECTION_CONDITION UndoAvailable()
Creates a functor that tests if there are any items in the undo queue.
The base frame for deriving all KiCad main window classes.
Represents a single user action.
Definition: tool_action.h:44
EDITOR_CONDITIONS(EDA_BASE_FRAME *aFrame)
Create an object to define conditions dependent upon a specific frame.