7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-21 00:21:25 +00:00

Make arrow keys respect grid overrides.

This commit is contained in:
Jeff Young 2024-08-28 19:54:14 +01:00
parent 94f7f073f2
commit 3441861988
11 changed files with 51 additions and 2 deletions

View File

@ -40,6 +40,8 @@
#include <tool/actions.h>
#include <tool/common_tools.h>
#include <tool/tool_manager.h>
#include <tool/selection_tool.h>
#include <tool/grid_helper.h>
#include <view/view.h>
#include <view/view_controls.h>
#include "macros.h"
@ -103,11 +105,17 @@ int COMMON_TOOLS::SelectionTool( const TOOL_EVENT& aEvent )
// Cursor control
int COMMON_TOOLS::CursorControl( const TOOL_EVENT& aEvent )
{
ACTIONS::CURSOR_EVENT_TYPE type = aEvent.Parameter<ACTIONS::CURSOR_EVENT_TYPE>();
ACTIONS::CURSOR_EVENT_TYPE type = aEvent.Parameter<ACTIONS::CURSOR_EVENT_TYPE>();
std::unique_ptr<GRID_HELPER> grid = m_frame->MakeGridHelper();
VECTOR2D gridSize;
if( grid )
gridSize = grid->GetGridSize( grid->GetSelectionGrid( m_frame->GetCurrentSelection() ) );
else
gridSize = getView()->GetGAL()->GetGridSize();
bool mirroredX = getView()->IsMirroredX();
VECTOR2D cursor = getViewControls()->GetRawCursorPosition( false );
VECTOR2D gridSize = getView()->GetGAL()->GetGridSize();
switch( type )
{

View File

@ -74,6 +74,7 @@
#include <tool/tool_manager.h>
#include <tool/zoom_tool.h>
#include <tools/ee_actions.h>
#include <tools/ee_grid_helper.h>
#include <tools/ee_inspection_tool.h>
#include <tools/ee_point_editor.h>
#include <tools/sch_drawing_tools.h>
@ -2080,6 +2081,12 @@ void SCH_EDIT_FRAME::ShowAllIntersheetRefs( bool aShow )
}
std::unique_ptr<GRID_HELPER> SCH_EDIT_FRAME::MakeGridHelper()
{
return std::make_unique<EE_GRID_HELPER>( m_toolManager );
}
void SCH_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
{
SCH_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );

View File

@ -142,6 +142,8 @@ public:
SCHEMATIC& Schematic() const;
std::unique_ptr<GRID_HELPER> MakeGridHelper() override;
/**
* Allow edit frame to show/hide hidden pins.
*/

View File

@ -62,6 +62,7 @@
#include <tools/ee_actions.h>
#include <tools/ee_inspection_tool.h>
#include <tools/ee_point_editor.h>
#include <tools/ee_grid_helper.h>
#include <tools/ee_selection_tool.h>
#include <tools/symbol_editor_control.h>
#include <tools/symbol_editor_drawing_tools.h>
@ -1554,6 +1555,12 @@ void SYMBOL_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
}
std::unique_ptr<GRID_HELPER> SYMBOL_EDIT_FRAME::MakeGridHelper()
{
return std::make_unique<EE_GRID_HELPER>( m_toolManager );
}
void SYMBOL_EDIT_FRAME::SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType )
{
// switches currently used canvas ( Cairo / OpenGL):

View File

@ -54,6 +54,8 @@ public:
~SYMBOL_EDIT_FRAME() override;
std::unique_ptr<GRID_HELPER> MakeGridHelper() override;
/**
* Switch currently used canvas ( Cairo / OpenGL).
*/

View File

@ -41,6 +41,7 @@
class EDA_ITEM;
class wxSingleInstanceChecker;
class ACTION_TOOLBAR;
class GRID_HELPER;
class COLOR_SETTINGS;
class LOCKFILE;
class TOOL_MENU;
@ -150,6 +151,8 @@ public:
virtual const VECTOR2I& GetGridOrigin() const = 0;
virtual void SetGridOrigin( const VECTOR2I& aPosition ) = 0;
virtual std::unique_ptr<GRID_HELPER> MakeGridHelper() { return nullptr; }
/**
* Return the nearest \a aGridSize location to \a aPosition.
*

View File

@ -75,6 +75,8 @@ public:
*/
int SelectionMenu( const TOOL_EVENT& aEvent );
SELECTION& GetSelection() { return selection(); }
protected:
/**
* Return a reference to the selection.

View File

@ -62,6 +62,7 @@
#include <tool/tool_dispatcher.h>
#include <tool/tool_manager.h>
#include <tool/zoom_tool.h>
#include <tools/pcb_grid_helper.h>
#include <tools/pcb_editor_conditions.h>
#include <tools/pcb_viewer_tools.h>
#include <tools/group_tool.h>
@ -1345,6 +1346,12 @@ void FOOTPRINT_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTe
}
std::unique_ptr<GRID_HELPER> FOOTPRINT_EDIT_FRAME::MakeGridHelper()
{
return std::make_unique<PCB_GRID_HELPER>( m_toolManager, GetMagneticItemsSettings() );
}
void FOOTPRINT_EDIT_FRAME::OnSaveFootprintAsPng( wxCommandEvent& event )
{
LIB_ID id = GetLoadedFPID();

View File

@ -84,6 +84,8 @@ public:
COLOR_SETTINGS* GetColorSettings( bool aForceRefresh = false ) const override;
std::unique_ptr<GRID_HELPER> MakeGridHelper() override;
const BOX2I GetDocumentExtents( bool aIncludeAllVisible = true ) const override;
bool canCloseWindow( wxCloseEvent& Event ) override;

View File

@ -67,6 +67,7 @@
#include <tool/properties_tool.h>
#include <tool/selection.h>
#include <tool/zoom_tool.h>
#include <tools/pcb_grid_helper.h>
#include <tools/pcb_selection_tool.h>
#include <tools/pcb_picker_tool.h>
#include <tools/pcb_point_editor.h>
@ -610,6 +611,12 @@ BOARD_ITEM_CONTAINER* PCB_EDIT_FRAME::GetModel() const
}
std::unique_ptr<GRID_HELPER> PCB_EDIT_FRAME::MakeGridHelper()
{
return std::make_unique<PCB_GRID_HELPER>( m_toolManager, GetMagneticItemsSettings() );
}
void PCB_EDIT_FRAME::redrawNetnames()
{
/*

View File

@ -443,6 +443,8 @@ public:
///< @copydoc PCB_BASE_FRAME::GetModel()
BOARD_ITEM_CONTAINER* GetModel() const override;
std::unique_ptr<GRID_HELPER> MakeGridHelper() override;
///< @copydoc PCB_BASE_FRAME::SetPageSettings()
void SetPageSettings( const PAGE_INFO& aPageSettings ) override;