Browse Source
Move more frames to the new UI condition framework
Move more frames to the new UI condition framework
* Frames moved: cvpcb, cvpcb footprints frame, gerbview, pagelayout editor This also introduces new EDITOR_CONDITIONS that are used to set the conditions of very common editor settings. Also, some IDs were converted to tools in the pagelayout editor.pull/16/head
28 changed files with 966 additions and 425 deletions
-
1common/CMakeLists.txt
-
166common/tool/editor_conditions.cpp
-
32common/tool/selection_conditions.cpp
-
49cvpcb/cvpcb_mainframe.cpp
-
17cvpcb/cvpcb_mainframe.h
-
95cvpcb/display_footprints_frame.cpp
-
7cvpcb/display_footprints_frame.h
-
60cvpcb/menubar.cpp
-
24cvpcb/toolbars_cvpcb.cpp
-
2eeschema/toolbars_sch_editor.cpp
-
18eeschema/tools/ee_selection_tool.cpp
-
4eeschema/tools/ee_selection_tool.h
-
108gerbview/gerbview_frame.cpp
-
5gerbview/gerbview_frame.h
-
231gerbview/menubar.cpp
-
30gerbview/toolbars_gerber.cpp
-
4include/eda_base_frame.h
-
156include/tool/editor_conditions.h
-
57include/tool/selection_conditions.h
-
151pagelayout_editor/menubar.cpp
-
96pagelayout_editor/pl_editor_frame.cpp
-
8pagelayout_editor/pl_editor_frame.h
-
2pagelayout_editor/pl_editor_id.h
-
35pagelayout_editor/toolbars_pl_editor.cpp
-
14pagelayout_editor/tools/pl_actions.cpp
-
3pagelayout_editor/tools/pl_actions.h
-
15pagelayout_editor/tools/pl_editor_control.cpp
-
1pagelayout_editor/tools/pl_editor_control.h
@ -0,0 +1,166 @@ |
|||
/*
|
|||
* 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 |
|||
*/ |
|||
|
|||
|
|||
#include <class_draw_panel_gal.h>
|
|||
#include <eda_base_frame.h>
|
|||
#include <eda_draw_frame.h>
|
|||
#include <tool/editor_conditions.h>
|
|||
#include <tool/selection.h>
|
|||
|
|||
#include <functional>
|
|||
#include <wx/debug.h>
|
|||
|
|||
using namespace std::placeholders; |
|||
|
|||
|
|||
SELECTION_CONDITION EDITOR_CONDITIONS::ContentModified() |
|||
{ |
|||
return std::bind( &EDITOR_CONDITIONS::contentModifiedFunc, _1, m_frame ); |
|||
} |
|||
|
|||
|
|||
SELECTION_CONDITION EDITOR_CONDITIONS::UndoAvailable() |
|||
{ |
|||
return std::bind( &EDITOR_CONDITIONS::undoFunc, _1, m_frame ); |
|||
} |
|||
|
|||
|
|||
SELECTION_CONDITION EDITOR_CONDITIONS::RedoAvailable() |
|||
{ |
|||
return std::bind( &EDITOR_CONDITIONS::redoFunc, _1, m_frame ); |
|||
} |
|||
|
|||
|
|||
SELECTION_CONDITION EDITOR_CONDITIONS::Units( EDA_UNITS aUnit ) |
|||
{ |
|||
return std::bind( &EDITOR_CONDITIONS::unitsFunc, _1, m_frame, aUnit ); |
|||
} |
|||
|
|||
|
|||
SELECTION_CONDITION EDITOR_CONDITIONS::CurrentTool( const TOOL_ACTION& aTool ) |
|||
{ |
|||
return std::bind( &EDITOR_CONDITIONS::toolFunc, _1, m_frame, std::cref( aTool ) ); |
|||
} |
|||
|
|||
|
|||
SELECTION_CONDITION EDITOR_CONDITIONS::GridVisible() |
|||
{ |
|||
// The grid visibility check requires a draw frame
|
|||
EDA_DRAW_FRAME* drwFrame = dynamic_cast<EDA_DRAW_FRAME*>( m_frame ); |
|||
|
|||
wxASSERT( drwFrame ); |
|||
|
|||
return std::bind( &EDITOR_CONDITIONS::gridFunc, _1, drwFrame ); |
|||
} |
|||
|
|||
|
|||
SELECTION_CONDITION EDITOR_CONDITIONS::PolarCoordinates() |
|||
{ |
|||
// The polar coordinates require a draw frame
|
|||
EDA_DRAW_FRAME* drwFrame = dynamic_cast<EDA_DRAW_FRAME*>( m_frame ); |
|||
|
|||
wxASSERT( drwFrame ); |
|||
|
|||
return std::bind( &EDITOR_CONDITIONS::polarCoordFunc, _1, drwFrame ); |
|||
} |
|||
|
|||
|
|||
SELECTION_CONDITION EDITOR_CONDITIONS::FullscreenCursor() |
|||
{ |
|||
// The fullscreen cursor requires a draw frame
|
|||
EDA_DRAW_FRAME* drwFrame = dynamic_cast<EDA_DRAW_FRAME*>( m_frame ); |
|||
|
|||
wxASSERT( drwFrame ); |
|||
|
|||
return std::bind( &EDITOR_CONDITIONS::gridFunc, _1, drwFrame ); |
|||
} |
|||
|
|||
|
|||
SELECTION_CONDITION EDITOR_CONDITIONS::CanvasType( EDA_DRAW_PANEL_GAL::GAL_TYPE aType ) |
|||
{ |
|||
// The canvas type requires a draw frame
|
|||
EDA_DRAW_FRAME* drwFrame = dynamic_cast<EDA_DRAW_FRAME*>( m_frame ); |
|||
|
|||
wxASSERT( drwFrame ); |
|||
|
|||
return std::bind( &EDITOR_CONDITIONS::canvasTypeFunc, _1, drwFrame, aType ); |
|||
} |
|||
|
|||
|
|||
bool EDITOR_CONDITIONS::contentModifiedFunc( const SELECTION& aSelection, EDA_BASE_FRAME* aFrame ) |
|||
{ |
|||
return aFrame->IsContentModified(); |
|||
} |
|||
|
|||
|
|||
bool EDITOR_CONDITIONS::undoFunc( const SELECTION& aSelection, EDA_BASE_FRAME* aFrame ) |
|||
{ |
|||
return aFrame->GetUndoCommandCount() > 0; |
|||
} |
|||
|
|||
|
|||
bool EDITOR_CONDITIONS::redoFunc( const SELECTION& aSelection, EDA_BASE_FRAME* aFrame ) |
|||
{ |
|||
return aFrame->GetRedoCommandCount() > 0; |
|||
} |
|||
|
|||
|
|||
bool EDITOR_CONDITIONS::unitsFunc( const SELECTION& aSelection, EDA_BASE_FRAME* aFrame, |
|||
EDA_UNITS aUnits ) |
|||
{ |
|||
return aFrame->GetUserUnits() == aUnits; |
|||
} |
|||
|
|||
|
|||
bool EDITOR_CONDITIONS::toolFunc( const SELECTION& aSelection, EDA_BASE_FRAME* aFrame, |
|||
const TOOL_ACTION& aTool ) |
|||
{ |
|||
return aFrame->IsCurrentTool( aTool ); |
|||
} |
|||
|
|||
|
|||
bool EDITOR_CONDITIONS::gridFunc( const SELECTION& aSelection, EDA_DRAW_FRAME* aFrame ) |
|||
{ |
|||
return aFrame->IsGridVisible(); |
|||
} |
|||
|
|||
|
|||
bool EDITOR_CONDITIONS::polarCoordFunc( const SELECTION& aSelection, EDA_DRAW_FRAME* aFrame ) |
|||
{ |
|||
return aFrame->GetShowPolarCoords(); |
|||
} |
|||
|
|||
|
|||
bool EDITOR_CONDITIONS::cursorFunc( const SELECTION& aSelection, EDA_DRAW_FRAME* aFrame ) |
|||
{ |
|||
return aFrame->GetGalDisplayOptions().m_fullscreenCursor; |
|||
} |
|||
|
|||
|
|||
bool EDITOR_CONDITIONS::canvasTypeFunc( const SELECTION& aSelection, EDA_DRAW_FRAME* aFrame, |
|||
EDA_DRAW_PANEL_GAL::GAL_TYPE aType ) |
|||
{ |
|||
return aFrame->GetCanvas()->GetBackend() == aType; |
|||
} |
@ -0,0 +1,156 @@ |
|||
/* |
|||
* 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 <common.h> |
|||
#include <functional> |
|||
#include <tool/selection.h> |
|||
#include <tool/selection_conditions.h> |
|||
#include <tool/tool_action.h> |
|||
|
|||
class EDA_BASE_FRAME; |
|||
class EDA_DRAW_FRAME; |
|||
/** |
|||
* 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 ) |
|||
{} |
|||
|
|||
/** |
|||
* Creates a functor that tests if the content of the frame is modified. |
|||
* |
|||
* @return Functor testing for modified content |
|||
*/ |
|||
SELECTION_CONDITION ContentModified(); |
|||
|
|||
/** |
|||
* Creates a functor that tests if there are any items in the undo queue |
|||
* |
|||
* @return Functor testing if the undo queue has items. |
|||
*/ |
|||
SELECTION_CONDITION UndoAvailable(); |
|||
|
|||
/** |
|||
* Creates a functor that tests if there are any items in the redo queue |
|||
* |
|||
* @return Functor testing if the redo queue has items. |
|||
*/ |
|||
SELECTION_CONDITION RedoAvailable(); |
|||
|
|||
/** |
|||
* Creates a functor that tests if the frame has the specified units |
|||
* |
|||
* @return Functor testing the units of a frame. |
|||
*/ |
|||
SELECTION_CONDITION Units( EDA_UNITS aUnit ); |
|||
|
|||
/** |
|||
* Creates a functor testing if the specified tool is the current active tool in the frame. |
|||
* |
|||
* @return Functor testing the current tool of a frame |
|||
*/ |
|||
SELECTION_CONDITION CurrentTool( const TOOL_ACTION& aTool ); |
|||
|
|||
/** |
|||
* Creates a functor testing if the grid is visible in a frame. |
|||
* |
|||
* @note this requires the frame passed into the constructor be be derived from EDA_DRAW_FRAME. |
|||
* |
|||
* @return Functor testing if the grid is visible |
|||
*/ |
|||
SELECTION_CONDITION GridVisible(); |
|||
|
|||
/** |
|||
* Creates a functor testing if polar coordinates are current being used. |
|||
* |
|||
* @note this requires the frame passed into the constructor be be derived from EDA_DRAW_FRAME. |
|||
* |
|||
* @return Functor testing if the grid is visible |
|||
*/ |
|||
SELECTION_CONDITION PolarCoordinates(); |
|||
|
|||
/** |
|||
* Creates a functor testing if the cursor is full screen in a frame. |
|||
* |
|||
* @note this requires the frame passed into the constructor be be derived from EDA_DRAW_FRAME. |
|||
* |
|||
* @return Functor testing if the cursor is full screen |
|||
*/ |
|||
SELECTION_CONDITION FullscreenCursor(); |
|||
|
|||
/** |
|||
* Creates a functor testing if the specified canvas is active in the frame. |
|||
* |
|||
* @note this requires the frame passed into the constructor be be derived from EDA_DRAW_FRAME. |
|||
* |
|||
* @return Functor testing the canvas type of the frame |
|||
*/ |
|||
SELECTION_CONDITION CanvasType( EDA_DRAW_PANEL_GAL::GAL_TYPE aType ); |
|||
|
|||
private: |
|||
///> Helper function used by ContentModified() |
|||
static bool contentModifiedFunc( const SELECTION& aSelection, EDA_BASE_FRAME* aFrame ); |
|||
|
|||
///> Helper function used by UndoAvailable() |
|||
static bool undoFunc( const SELECTION& aSelection, EDA_BASE_FRAME* aFrame ); |
|||
|
|||
///> Helper function used by RedoAvailable() |
|||
static bool redoFunc( const SELECTION& aSelection, EDA_BASE_FRAME* aFrame ); |
|||
|
|||
///> Helper function used by Units() |
|||
static bool unitsFunc( const SELECTION& aSelection, EDA_BASE_FRAME* aFrame, EDA_UNITS aUnits ); |
|||
|
|||
///> Helper function used by CurrentTool() |
|||
static bool toolFunc( const SELECTION& aSelection, EDA_BASE_FRAME* aFrame, const TOOL_ACTION& aTool ); |
|||
|
|||
///> Helper function used by GridVisible() |
|||
static bool gridFunc( const SELECTION& aSelection, EDA_DRAW_FRAME* aFrame ); |
|||
|
|||
///> Helper function used by PolarCoordinates() |
|||
static bool polarCoordFunc( const SELECTION& aSelection, EDA_DRAW_FRAME* aFrame ); |
|||
|
|||
///> Helper function used by FullscreenCursor() |
|||
static bool cursorFunc( const SELECTION& aSelection, EDA_DRAW_FRAME* aFrame ); |
|||
|
|||
///> Helper function used by CanvasType() |
|||
static bool canvasTypeFunc( const SELECTION& aSelection, EDA_DRAW_FRAME* aFrame, |
|||
EDA_DRAW_PANEL_GAL::GAL_TYPE aType ); |
|||
|
|||
///> The frame to apply the conditions to |
|||
EDA_BASE_FRAME* m_frame; |
|||
}; |
|||
|
|||
#endif /* EDITOR_CONDITIONS_H_ */ |
Write
Preview
Loading…
Cancel
Save
Reference in new issue