Overhaul cursor code for new tool/action framework.
Includes the addition of an onSetCursor() handler which must be called from both the GAL canvas AND the GAL backend (at least on OSX) to prevent cursor flickering between (for instance) pencil and arrow. Also includes new architecture for point editors which allows them to coordiate cursors with the editing tools (so we can switch to an arrow when over a point).
This commit is contained in:
parent
42e14b5a4e
commit
981072598b
|
@ -78,6 +78,7 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
|
||||||
Connect( wxEVT_SIZE, wxSizeEventHandler( EDA_DRAW_PANEL_GAL::onSize ), NULL, this );
|
Connect( wxEVT_SIZE, wxSizeEventHandler( EDA_DRAW_PANEL_GAL::onSize ), NULL, this );
|
||||||
Connect( wxEVT_ENTER_WINDOW, wxEventHandler( EDA_DRAW_PANEL_GAL::onEnter ), NULL, this );
|
Connect( wxEVT_ENTER_WINDOW, wxEventHandler( EDA_DRAW_PANEL_GAL::onEnter ), NULL, this );
|
||||||
Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( EDA_DRAW_PANEL_GAL::onLostFocus ), NULL, this );
|
Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( EDA_DRAW_PANEL_GAL::onLostFocus ), NULL, this );
|
||||||
|
Connect( wxEVT_SET_CURSOR, wxSetCursorEventHandler( EDA_DRAW_PANEL_GAL::onSetCursor ), NULL, this );
|
||||||
|
|
||||||
const wxEventType events[] =
|
const wxEventType events[] =
|
||||||
{
|
{
|
||||||
|
@ -408,7 +409,11 @@ bool EDA_DRAW_PANEL_GAL::SwitchBackend( GAL_TYPE aGalType )
|
||||||
// from the defaults
|
// from the defaults
|
||||||
m_options.NotifyChanged();
|
m_options.NotifyChanged();
|
||||||
|
|
||||||
wxASSERT( new_gal );
|
wxWindow* galWindow = dynamic_cast<wxWindow*>( new_gal );
|
||||||
|
|
||||||
|
if( galWindow )
|
||||||
|
galWindow->Connect( wxEVT_SET_CURSOR, wxSetCursorEventHandler( EDA_DRAW_PANEL_GAL::onSetCursor ), NULL, this );
|
||||||
|
|
||||||
delete m_gal;
|
delete m_gal;
|
||||||
m_gal = new_gal;
|
m_gal = new_gal;
|
||||||
|
|
||||||
|
@ -495,6 +500,8 @@ void EDA_DRAW_PANEL_GAL::onShowTimer( wxTimerEvent& aEvent )
|
||||||
OnShow();
|
OnShow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDA_DRAW_PANEL_GAL::SetCurrentCursor( int aCursor )
|
void EDA_DRAW_PANEL_GAL::SetCurrentCursor( int aCursor )
|
||||||
{
|
{
|
||||||
if ( aCursor > wxCURSOR_NONE && aCursor < wxCURSOR_MAX )
|
if ( aCursor > wxCURSOR_NONE && aCursor < wxCURSOR_MAX )
|
||||||
|
@ -505,3 +512,8 @@ void EDA_DRAW_PANEL_GAL::SetCurrentCursor( int aCursor )
|
||||||
SetCursor( (wxStockCursor) m_currentCursor );
|
SetCursor( (wxStockCursor) m_currentCursor );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void EDA_DRAW_PANEL_GAL::onSetCursor( wxSetCursorEvent& event )
|
||||||
|
{
|
||||||
|
event.SetCursor( (wxStockCursor) m_currentCursor );
|
||||||
|
}
|
||||||
|
|
|
@ -48,8 +48,10 @@ int ZOOM_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
m_frame->PushTool( aEvent.GetCommandStr().get() );
|
m_frame->PushTool( aEvent.GetCommandStr().get() );
|
||||||
|
|
||||||
while( auto evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
|
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
|
||||||
|
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -80,7 +82,7 @@ bool ZOOM_TOOL::selectRegion()
|
||||||
KIGFX::PREVIEW::SELECTION_AREA area;
|
KIGFX::PREVIEW::SELECTION_AREA area;
|
||||||
view->Add( &area );
|
view->Add( &area );
|
||||||
|
|
||||||
while( auto evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
|
|
|
@ -56,6 +56,9 @@ int CVPCB_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
// Main loop: keep receiving events
|
// Main loop: keep receiving events
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
|
if( m_frame->ToolStackIsEmpty() )
|
||||||
|
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
|
||||||
|
|
||||||
// This is kind of hacky: activate RMB drag on any event.
|
// This is kind of hacky: activate RMB drag on any event.
|
||||||
// There doesn't seem to be any other good way to tell when another tool
|
// There doesn't seem to be any other good way to tell when another tool
|
||||||
// is canceled and control returns to the selection tool, except by the
|
// is canceled and control returns to the selection tool, except by the
|
||||||
|
@ -120,8 +123,9 @@ int CVPCB_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
|
||||||
controls.SetSnapping( true );
|
controls.SetSnapping( true );
|
||||||
controls.SetAdditionalPanButtons( false, true );
|
controls.SetAdditionalPanButtons( false, true );
|
||||||
|
|
||||||
while( auto evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
|
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
|
||||||
const VECTOR2I cursorPos = controls.GetCursorPosition();
|
const VECTOR2I cursorPos = controls.GetCursorPosition();
|
||||||
|
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
|
|
|
@ -44,6 +44,7 @@ int EE_PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
|
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_BULLSEYE );
|
||||||
VECTOR2D cursorPos = controls->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
VECTOR2D cursorPos = controls->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
||||||
|
|
||||||
if( evt->IsClick( BUT_LEFT ) )
|
if( evt->IsClick( BUT_LEFT ) )
|
||||||
|
|
|
@ -242,9 +242,16 @@ void EE_POINT_EDITOR::updateEditedPoint( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
point = m_editPoints->FindPoint( aEvent.DragOrigin(), getView() );
|
point = m_editPoints->FindPoint( aEvent.DragOrigin(), getView() );
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
point = m_editPoints->FindPoint( getViewControls()->GetCursorPosition(), getView() );
|
||||||
|
}
|
||||||
|
|
||||||
if( m_editedPoint != point )
|
if( m_editedPoint != point )
|
||||||
setEditedPoint( point );
|
setEditedPoint( point );
|
||||||
|
|
||||||
|
if( point )
|
||||||
|
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -284,6 +291,7 @@ int EE_POINT_EDITOR::Main( const TOOL_EVENT& aEvent )
|
||||||
m_editPoints = EDIT_POINTS_FACTORY::Make( item, m_frame );
|
m_editPoints = EDIT_POINTS_FACTORY::Make( item, m_frame );
|
||||||
view->Add( m_editPoints.get() );
|
view->Add( m_editPoints.get() );
|
||||||
setEditedPoint( nullptr );
|
setEditedPoint( nullptr );
|
||||||
|
updateEditedPoint( aEvent );
|
||||||
bool inDrag = false;
|
bool inDrag = false;
|
||||||
bool modified = false;
|
bool modified = false;
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,12 @@ public:
|
||||||
|
|
||||||
int Main( const TOOL_EVENT& aEvent );
|
int Main( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates the cursor is over an edit point. Used to coordinate cursor shapes with
|
||||||
|
* other tools.
|
||||||
|
*/
|
||||||
|
bool HasPoint() { return m_editedPoint != nullptr; }
|
||||||
|
|
||||||
///> Sets up handlers for various events.
|
///> Sets up handlers for various events.
|
||||||
void setTransitions() override;
|
void setTransitions() override;
|
||||||
|
|
||||||
|
|
|
@ -285,6 +285,9 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
// Main loop: keep receiving events
|
// Main loop: keep receiving events
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
|
if( m_frame->ToolStackIsEmpty() )
|
||||||
|
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
|
||||||
|
|
||||||
// Should selected items be added to the current selection or
|
// Should selected items be added to the current selection or
|
||||||
// become the new selection (discarding previously selected items)
|
// become the new selection (discarding previously selected items)
|
||||||
m_additive = evt->Modifier( MD_SHIFT );
|
m_additive = evt->Modifier( MD_SHIFT );
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
#include <lib_circle.h>
|
#include <lib_circle.h>
|
||||||
#include <lib_polyline.h>
|
#include <lib_polyline.h>
|
||||||
#include <lib_rectangle.h>
|
#include <lib_rectangle.h>
|
||||||
|
#include "ee_point_editor.h"
|
||||||
|
|
||||||
static void* g_lastPinWeakPtr;
|
static void* g_lastPinWeakPtr;
|
||||||
|
|
||||||
|
@ -86,6 +86,7 @@ int LIB_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
||||||
// Main loop: keep receiving events
|
// Main loop: keep receiving events
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
|
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
|
||||||
cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
||||||
|
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
|
@ -214,6 +215,7 @@ int LIB_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
||||||
int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
KICAD_T type = aEvent.Parameter<KICAD_T>();
|
KICAD_T type = aEvent.Parameter<KICAD_T>();
|
||||||
|
EE_POINT_EDITOR* pointEditor = m_toolMgr->GetTool<EE_POINT_EDITOR>();
|
||||||
|
|
||||||
// We might be running as the same shape in another co-routine. Make sure that one
|
// We might be running as the same shape in another co-routine. Make sure that one
|
||||||
// gets whacked.
|
// gets whacked.
|
||||||
|
@ -233,8 +235,11 @@ int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
||||||
m_toolMgr->RunAction( ACTIONS::cursorClick );
|
m_toolMgr->RunAction( ACTIONS::cursorClick );
|
||||||
|
|
||||||
// Main loop: keep receiving events
|
// Main loop: keep receiving events
|
||||||
while( auto evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
|
if( !pointEditor->HasPoint() )
|
||||||
|
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
|
||||||
|
|
||||||
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
||||||
|
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
|
@ -350,6 +355,8 @@ int LIB_DRAWING_TOOLS::PlaceAnchor( const TOOL_EVENT& aEvent )
|
||||||
// Main loop: keep receiving events
|
// Main loop: keep receiving events
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
|
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_BULLSEYE );
|
||||||
|
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -100,6 +100,7 @@ int LIB_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
// Main loop: keep receiving events
|
// Main loop: keep receiving events
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
|
||||||
controls->SetSnapping( !evt->Modifier( MD_ALT ) );
|
controls->SetSnapping( !evt->Modifier( MD_ALT ) );
|
||||||
|
|
||||||
if( evt->IsAction( &EE_ACTIONS::move ) || evt->IsMotion() || evt->IsDrag( BUT_LEFT )
|
if( evt->IsAction( &EE_ACTIONS::move ) || evt->IsMotion() || evt->IsDrag( BUT_LEFT )
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
#include "sch_drawing_tools.h"
|
#include "sch_drawing_tools.h"
|
||||||
#include "ee_selection_tool.h"
|
#include "ee_selection_tool.h"
|
||||||
|
#include "ee_point_editor.h"
|
||||||
#include <ee_actions.h>
|
#include <ee_actions.h>
|
||||||
#include <sch_edit_frame.h>
|
#include <sch_edit_frame.h>
|
||||||
#include <sch_view.h>
|
#include <sch_view.h>
|
||||||
|
@ -114,6 +115,7 @@ int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent )
|
||||||
// Main loop: keep receiving events
|
// Main loop: keep receiving events
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
|
m_frame->GetCanvas()->SetCurrentCursor( component ? wxCURSOR_ARROW : wxCURSOR_PENCIL );
|
||||||
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
||||||
|
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
|
@ -242,6 +244,7 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
|
||||||
// Main loop: keep receiving events
|
// Main loop: keep receiving events
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
|
m_frame->GetCanvas()->SetCurrentCursor( image ? wxCURSOR_ARROW : wxCURSOR_PENCIL );
|
||||||
cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
||||||
|
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
|
@ -379,6 +382,7 @@ int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent )
|
||||||
// Main loop: keep receiving events
|
// Main loop: keep receiving events
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
|
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
|
||||||
cursorPos = (wxPoint) getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
cursorPos = (wxPoint) getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
||||||
|
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
|
@ -452,6 +456,7 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
||||||
// Main loop: keep receiving events
|
// Main loop: keep receiving events
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
|
m_frame->GetCanvas()->SetCurrentCursor( item ? wxCURSOR_ARROW : wxCURSOR_PENCIL );
|
||||||
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
||||||
|
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
|
@ -603,6 +608,7 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
|
int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
|
EE_POINT_EDITOR* pointEditor = m_toolMgr->GetTool<EE_POINT_EDITOR>();
|
||||||
SCH_SHEET* sheet = nullptr;
|
SCH_SHEET* sheet = nullptr;
|
||||||
|
|
||||||
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
||||||
|
@ -618,6 +624,9 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
|
||||||
// Main loop: keep receiving events
|
// Main loop: keep receiving events
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
|
if( !pointEditor->HasPoint() )
|
||||||
|
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
|
||||||
|
|
||||||
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
||||||
|
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
#include <sch_text.h>
|
#include <sch_text.h>
|
||||||
#include <sch_sheet.h>
|
#include <sch_sheet.h>
|
||||||
#include <advanced_config.h>
|
#include <advanced_config.h>
|
||||||
|
#include "ee_point_editor.h"
|
||||||
|
|
||||||
class BUS_UNFOLD_MENU : public ACTION_MENU
|
class BUS_UNFOLD_MENU : public ACTION_MENU
|
||||||
{
|
{
|
||||||
|
@ -442,6 +442,7 @@ int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( int aType, SCH_LINE* aSegment )
|
||||||
{
|
{
|
||||||
bool forceHV = m_frame->GetForceHVLines();
|
bool forceHV = m_frame->GetForceHVLines();
|
||||||
SCH_SCREEN* screen = m_frame->GetScreen();
|
SCH_SCREEN* screen = m_frame->GetScreen();
|
||||||
|
EE_POINT_EDITOR* pointEditor = m_toolMgr->GetTool<EE_POINT_EDITOR>();
|
||||||
wxPoint cursorPos;
|
wxPoint cursorPos;
|
||||||
|
|
||||||
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
||||||
|
@ -452,6 +453,9 @@ int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( int aType, SCH_LINE* aSegment )
|
||||||
// Main loop: keep receiving events
|
// Main loop: keep receiving events
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
|
if( !pointEditor->HasPoint() )
|
||||||
|
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
|
||||||
|
|
||||||
cursorPos = (wxPoint) getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
cursorPos = (wxPoint) getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
||||||
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
|
|
|
@ -160,6 +160,7 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
// Main loop: keep receiving events
|
// Main loop: keep receiving events
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
|
||||||
controls->SetSnapping( !evt->Modifier( MD_ALT ) );
|
controls->SetSnapping( !evt->Modifier( MD_ALT ) );
|
||||||
|
|
||||||
if( evt->IsAction( &EE_ACTIONS::moveActivate ) || evt->IsAction( &EE_ACTIONS::restartMove )
|
if( evt->IsAction( &EE_ACTIONS::moveActivate ) || evt->IsAction( &EE_ACTIONS::restartMove )
|
||||||
|
|
|
@ -183,6 +183,9 @@ int GERBVIEW_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
// Main loop: keep receiving events
|
// Main loop: keep receiving events
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
|
if( m_frame->ToolStackIsEmpty() )
|
||||||
|
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
|
||||||
|
|
||||||
// This is kind of hacky: activate RMB drag on any event.
|
// This is kind of hacky: activate RMB drag on any event.
|
||||||
// There doesn't seem to be any other good way to tell when another tool
|
// There doesn't seem to be any other good way to tell when another tool
|
||||||
// is canceled and control returns to the selection tool, except by the
|
// is canceled and control returns to the selection tool, except by the
|
||||||
|
@ -769,8 +772,9 @@ int GERBVIEW_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
|
||||||
controls.SetSnapping( true );
|
controls.SetSnapping( true );
|
||||||
controls.SetAdditionalPanButtons( false, true );
|
controls.SetAdditionalPanButtons( false, true );
|
||||||
|
|
||||||
while( auto evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
|
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
|
||||||
const VECTOR2I cursorPos = controls.GetCursorPosition();
|
const VECTOR2I cursorPos = controls.GetCursorPosition();
|
||||||
|
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
|
|
|
@ -209,6 +209,7 @@ protected:
|
||||||
void onLostFocus( wxFocusEvent& aEvent );
|
void onLostFocus( wxFocusEvent& aEvent );
|
||||||
void onRefreshTimer( wxTimerEvent& aEvent );
|
void onRefreshTimer( wxTimerEvent& aEvent );
|
||||||
void onShowTimer( wxTimerEvent& aEvent );
|
void onShowTimer( wxTimerEvent& aEvent );
|
||||||
|
void onSetCursor( wxSetCursorEvent& event );
|
||||||
|
|
||||||
static const int MinRefreshPeriod = 17; ///< 60 FPS.
|
static const int MinRefreshPeriod = 17; ///< 60 FPS.
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
#include <ws_draw_item.h>
|
#include <ws_draw_item.h>
|
||||||
#include <ws_data_item.h>
|
#include <ws_data_item.h>
|
||||||
#include <invoke_pl_editor_dialog.h>
|
#include <invoke_pl_editor_dialog.h>
|
||||||
|
#include "pl_point_editor.h"
|
||||||
|
|
||||||
PL_DRAWING_TOOLS::PL_DRAWING_TOOLS() :
|
PL_DRAWING_TOOLS::PL_DRAWING_TOOLS() :
|
||||||
TOOL_INTERACTIVE( "plEditor.InteractiveDrawing" ),
|
TOOL_INTERACTIVE( "plEditor.InteractiveDrawing" ),
|
||||||
|
@ -90,6 +90,7 @@ int PL_DRAWING_TOOLS::PlaceItem( const TOOL_EVENT& aEvent )
|
||||||
// Main loop: keep receiving events
|
// Main loop: keep receiving events
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
|
m_frame->GetCanvas()->SetCurrentCursor( item ? wxCURSOR_ARROW : wxCURSOR_PENCIL );
|
||||||
cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
||||||
|
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
|
@ -169,6 +170,7 @@ int PL_DRAWING_TOOLS::PlaceItem( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
int PL_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
int PL_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
|
PL_POINT_EDITOR* pointEditor = m_toolMgr->GetTool<PL_POINT_EDITOR>();
|
||||||
WS_DATA_ITEM::WS_ITEM_TYPE type = aEvent.Parameter<WS_DATA_ITEM::WS_ITEM_TYPE>();
|
WS_DATA_ITEM::WS_ITEM_TYPE type = aEvent.Parameter<WS_DATA_ITEM::WS_ITEM_TYPE>();
|
||||||
WS_DRAW_ITEM_BASE* item = nullptr;
|
WS_DRAW_ITEM_BASE* item = nullptr;
|
||||||
|
|
||||||
|
@ -189,6 +191,9 @@ int PL_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
||||||
// Main loop: keep receiving events
|
// Main loop: keep receiving events
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
|
if( !pointEditor->HasPoint() )
|
||||||
|
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
|
||||||
|
|
||||||
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
||||||
|
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
|
|
|
@ -118,6 +118,7 @@ int PL_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
// Main loop: keep receiving events
|
// Main loop: keep receiving events
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
|
||||||
controls->SetSnapping( !evt->Modifier( MD_ALT ) );
|
controls->SetSnapping( !evt->Modifier( MD_ALT ) );
|
||||||
|
|
||||||
if( evt->IsAction( &PL_ACTIONS::move ) || evt->IsMotion() || evt->IsDrag( BUT_LEFT )
|
if( evt->IsAction( &PL_ACTIONS::move ) || evt->IsMotion() || evt->IsDrag( BUT_LEFT )
|
||||||
|
|
|
@ -72,6 +72,7 @@ int PL_PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
|
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_BULLSEYE );
|
||||||
VECTOR2I cursorPos = controls->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
VECTOR2I cursorPos = controls->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
||||||
|
|
||||||
if( evt->IsClick( BUT_LEFT ) )
|
if( evt->IsClick( BUT_LEFT ) )
|
||||||
|
|
|
@ -137,9 +137,16 @@ void PL_POINT_EDITOR::updateEditedPoint( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
point = m_editPoints->FindPoint( aEvent.DragOrigin(), getView() );
|
point = m_editPoints->FindPoint( aEvent.DragOrigin(), getView() );
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
point = m_editPoints->FindPoint( getViewControls()->GetCursorPosition(), getView() );
|
||||||
|
}
|
||||||
|
|
||||||
if( m_editedPoint != point )
|
if( m_editedPoint != point )
|
||||||
setEditedPoint( point );
|
setEditedPoint( point );
|
||||||
|
|
||||||
|
if( point )
|
||||||
|
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -174,6 +181,7 @@ int PL_POINT_EDITOR::Main( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
view->Add( m_editPoints.get() );
|
view->Add( m_editPoints.get() );
|
||||||
setEditedPoint( nullptr );
|
setEditedPoint( nullptr );
|
||||||
|
updateEditedPoint( aEvent );
|
||||||
bool inDrag = false;
|
bool inDrag = false;
|
||||||
bool modified = false;
|
bool modified = false;
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,12 @@ public:
|
||||||
|
|
||||||
int Main( const TOOL_EVENT& aEvent );
|
int Main( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates the cursor is over an edit point. Used to coordinate cursor shapes with
|
||||||
|
* other tools.
|
||||||
|
*/
|
||||||
|
bool HasPoint() { return m_editedPoint != nullptr; }
|
||||||
|
|
||||||
///> Sets up handlers for various events.
|
///> Sets up handlers for various events.
|
||||||
void setTransitions() override;
|
void setTransitions() override;
|
||||||
|
|
||||||
|
|
|
@ -111,6 +111,9 @@ int PL_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
// Main loop: keep receiving events
|
// Main loop: keep receiving events
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
|
if( m_frame->ToolStackIsEmpty() )
|
||||||
|
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
|
||||||
|
|
||||||
// Should selected items be added to the current selection or
|
// Should selected items be added to the current selection or
|
||||||
// become the new selection (discarding previously selected items)
|
// become the new selection (discarding previously selected items)
|
||||||
m_additive = evt->Modifier( MD_SHIFT );
|
m_additive = evt->Modifier( MD_SHIFT );
|
||||||
|
|
|
@ -190,6 +190,8 @@ void LENGTH_TUNER_TOOL::performTuning()
|
||||||
|
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
|
frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
|
||||||
|
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
break;
|
break;
|
||||||
else if( evt->IsMotion() )
|
else if( evt->IsMotion() )
|
||||||
|
@ -276,6 +278,8 @@ int LENGTH_TUNER_TOOL::MainLoop( const TOOL_EVENT& aEvent )
|
||||||
// Main loop: keep receiving events
|
// Main loop: keep receiving events
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
|
frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
|
||||||
|
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
break; // Finish
|
break; // Finish
|
||||||
|
|
|
@ -754,6 +754,8 @@ void ROUTER_TOOL::performRouting()
|
||||||
|
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
|
frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
|
||||||
|
|
||||||
// Don't crash if we missed an operation that cancelled routing.
|
// Don't crash if we missed an operation that cancelled routing.
|
||||||
wxCHECK2( m_router->RoutingInProgress(), break );
|
wxCHECK2( m_router->RoutingInProgress(), break );
|
||||||
|
|
||||||
|
@ -881,6 +883,8 @@ int ROUTER_TOOL::MainLoop( const TOOL_EVENT& aEvent )
|
||||||
// Main loop: keep receiving events
|
// Main loop: keep receiving events
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
|
frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
|
||||||
|
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
break; // Finish
|
break; // Finish
|
||||||
|
@ -1129,6 +1133,8 @@ int ROUTER_TOOL::InlineDrag( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
|
frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
|
||||||
|
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
#include <painter.h>
|
#include <painter.h>
|
||||||
#include <status_popup.h>
|
#include <status_popup.h>
|
||||||
#include "grid_helper.h"
|
#include "grid_helper.h"
|
||||||
|
#include "point_editor.h"
|
||||||
#include <dialogs/dialog_text_properties.h>
|
#include <dialogs/dialog_text_properties.h>
|
||||||
#include <preview_items/arc_assistant.h>
|
#include <preview_items/arc_assistant.h>
|
||||||
|
|
||||||
|
@ -153,9 +154,6 @@ int DRAWING_TOOL::DrawLine( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
while( drawSegment( S_SEGMENT, line, startingPoint ) )
|
while( drawSegment( S_SEGMENT, line, startingPoint ) )
|
||||||
{
|
{
|
||||||
// This can be reset by some actions (e.g. Save Board), so ensure it stays set.
|
|
||||||
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
|
|
||||||
|
|
||||||
if( line )
|
if( line )
|
||||||
{
|
{
|
||||||
if( m_editModules )
|
if( m_editModules )
|
||||||
|
@ -200,9 +198,6 @@ int DRAWING_TOOL::DrawCircle( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
while( drawSegment( S_CIRCLE, circle, startingPoint ) )
|
while( drawSegment( S_CIRCLE, circle, startingPoint ) )
|
||||||
{
|
{
|
||||||
// This can be reset by some actions (e.g. Save Board), so ensure it stays set.
|
|
||||||
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
|
|
||||||
|
|
||||||
if( circle )
|
if( circle )
|
||||||
{
|
{
|
||||||
if( m_editModules )
|
if( m_editModules )
|
||||||
|
@ -242,9 +237,6 @@ int DRAWING_TOOL::DrawArc( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
while( drawArc( arc, immediateMode ) )
|
while( drawArc( arc, immediateMode ) )
|
||||||
{
|
{
|
||||||
// This can be reset by some actions (e.g. Save Board), so ensure it stays set.
|
|
||||||
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
|
|
||||||
|
|
||||||
if( arc )
|
if( arc )
|
||||||
{
|
{
|
||||||
if( m_editModules )
|
if( m_editModules )
|
||||||
|
@ -293,8 +285,7 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
|
||||||
// Main loop: keep receiving events
|
// Main loop: keep receiving events
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
// This can be reset by some actions (e.g. Save Board), so ensure it stays set.
|
m_frame->GetCanvas()->SetCurrentCursor( text ? wxCURSOR_ARROW : wxCURSOR_PENCIL );
|
||||||
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
|
|
||||||
VECTOR2I cursorPos = m_controls->GetCursorPosition();
|
VECTOR2I cursorPos = m_controls->GetCursorPosition();
|
||||||
|
|
||||||
if( reselect && text )
|
if( reselect && text )
|
||||||
|
@ -461,6 +452,7 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
|
||||||
if( m_editModules && !m_frame->GetModel() )
|
if( m_editModules && !m_frame->GetModel() )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
POINT_EDITOR* pointEditor = m_toolMgr->GetTool<POINT_EDITOR>();
|
||||||
DIMENSION* dimension = NULL;
|
DIMENSION* dimension = NULL;
|
||||||
BOARD_COMMIT commit( m_frame );
|
BOARD_COMMIT commit( m_frame );
|
||||||
GRID_HELPER grid( m_frame );
|
GRID_HELPER grid( m_frame );
|
||||||
|
@ -494,8 +486,9 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
|
||||||
// Main loop: keep receiving events
|
// Main loop: keep receiving events
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
// This can be reset by some actions (e.g. Save Board), so ensure it stays set.
|
if( !pointEditor->HasPoint() )
|
||||||
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
|
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
|
||||||
|
|
||||||
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
||||||
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
|
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
|
||||||
m_controls->SetSnapping( !evt->Modifier( MD_ALT ) );
|
m_controls->SetSnapping( !evt->Modifier( MD_ALT ) );
|
||||||
|
@ -736,6 +729,7 @@ int DRAWING_TOOL::PlaceImportedGraphics( const TOOL_EVENT& aEvent )
|
||||||
// Main loop: keep receiving events
|
// Main loop: keep receiving events
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
|
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
|
||||||
cursorPos = m_controls->GetCursorPosition();
|
cursorPos = m_controls->GetCursorPosition();
|
||||||
|
|
||||||
if( evt->IsMotion() )
|
if( evt->IsMotion() )
|
||||||
|
@ -814,8 +808,7 @@ int DRAWING_TOOL::SetAnchor( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
// This can be reset by some actions (e.g. Save Board), so ensure it stays set.
|
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_BULLSEYE );
|
||||||
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
|
|
||||||
|
|
||||||
if( evt->IsClick( BUT_LEFT ) )
|
if( evt->IsClick( BUT_LEFT ) )
|
||||||
{
|
{
|
||||||
|
@ -852,6 +845,7 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic, OPT<VECTOR2D
|
||||||
// Only two shapes are currently supported
|
// Only two shapes are currently supported
|
||||||
assert( aShape == S_SEGMENT || aShape == S_CIRCLE );
|
assert( aShape == S_SEGMENT || aShape == S_CIRCLE );
|
||||||
GRID_HELPER grid( m_frame );
|
GRID_HELPER grid( m_frame );
|
||||||
|
POINT_EDITOR* pointEditor = m_toolMgr->GetTool<POINT_EDITOR>();
|
||||||
|
|
||||||
m_lineWidth = getSegmentWidth( getDrawingLayer() );
|
m_lineWidth = getSegmentWidth( getDrawingLayer() );
|
||||||
m_frame->SetActiveLayer( getDrawingLayer() );
|
m_frame->SetActiveLayer( getDrawingLayer() );
|
||||||
|
@ -874,6 +868,9 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic, OPT<VECTOR2D
|
||||||
// Main loop: keep receiving events
|
// Main loop: keep receiving events
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
|
if( !pointEditor->HasPoint() )
|
||||||
|
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
|
||||||
|
|
||||||
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
||||||
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
|
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
|
||||||
m_controls->SetSnapping( !evt->Modifier( MD_ALT ) );
|
m_controls->SetSnapping( !evt->Modifier( MD_ALT ) );
|
||||||
|
@ -1103,6 +1100,7 @@ bool DRAWING_TOOL::drawArc( DRAWSEGMENT*& aGraphic, bool aImmediateMode )
|
||||||
PCB_LAYER_ID layer = getDrawingLayer();
|
PCB_LAYER_ID layer = getDrawingLayer();
|
||||||
aGraphic->SetLayer( layer );
|
aGraphic->SetLayer( layer );
|
||||||
|
|
||||||
|
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
|
||||||
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
||||||
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
|
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
|
||||||
m_controls->SetSnapping( !evt->Modifier( MD_ALT ) );
|
m_controls->SetSnapping( !evt->Modifier( MD_ALT ) );
|
||||||
|
@ -1307,7 +1305,6 @@ int DRAWING_TOOL::DrawZone( const TOOL_EVENT& aEvent )
|
||||||
// Main loop: keep receiving events
|
// Main loop: keep receiving events
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
// This can be reset by some actions (e.g. Save Board), so ensure it stays set.
|
|
||||||
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
|
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
|
||||||
LSET layers( m_frame->GetActiveLayer() );
|
LSET layers( m_frame->GetActiveLayer() );
|
||||||
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
||||||
|
|
|
@ -301,6 +301,7 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
// Main loop: keep receiving events
|
// Main loop: keep receiving events
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
editFrame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
|
||||||
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
||||||
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
|
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
|
||||||
controls->SetSnapping( !evt->Modifier( MD_ALT ) );
|
controls->SetSnapping( !evt->Modifier( MD_ALT ) );
|
||||||
|
@ -1127,8 +1128,7 @@ int EDIT_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
while( auto evt = Wait() )
|
while( auto evt = Wait() )
|
||||||
{
|
{
|
||||||
// This can be reset by some actions (e.g. Save Board), so ensure it stays set.
|
frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
|
||||||
frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
|
|
||||||
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
||||||
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
|
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
|
||||||
controls.SetSnapping( !evt->Modifier( MD_ALT ) );
|
controls.SetSnapping( !evt->Modifier( MD_ALT ) );
|
||||||
|
|
|
@ -209,6 +209,7 @@ int MICROWAVE_TOOL::drawMicrowaveInductor( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
while( auto evt = Wait() )
|
while( auto evt = Wait() )
|
||||||
{
|
{
|
||||||
|
frame.GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
|
||||||
VECTOR2I cursorPos = controls.GetCursorPosition();
|
VECTOR2I cursorPos = controls.GetCursorPosition();
|
||||||
|
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
|
|
|
@ -364,6 +364,8 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
|
frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_BULLSEYE );
|
||||||
|
|
||||||
if( evt->IsDrag( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) )
|
if( evt->IsDrag( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) )
|
||||||
{
|
{
|
||||||
selectedPads.clear();
|
selectedPads.clear();
|
||||||
|
|
|
@ -536,7 +536,6 @@ int PCB_EDITOR_CONTROL::PlaceModule( const TOOL_EVENT& aEvent )
|
||||||
// Main loop: keep receiving events
|
// Main loop: keep receiving events
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
// This can be reset by some actions (e.g. Save Board), so ensure it stays set.
|
|
||||||
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
|
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
|
||||||
cursorPos = controls->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
cursorPos = controls->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
||||||
|
|
||||||
|
@ -717,8 +716,7 @@ int PCB_EDITOR_CONTROL::PlaceTarget( const TOOL_EVENT& aEvent )
|
||||||
// Main loop: keep receiving events
|
// Main loop: keep receiving events
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
// This can be reset by some actions (e.g. Save Board), so ensure it stays set.
|
frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
|
||||||
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
|
|
||||||
cursorPos = controls->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
cursorPos = controls->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
||||||
|
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
|
|
|
@ -49,6 +49,7 @@ int PCBNEW_PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
|
frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_BULLSEYE );
|
||||||
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
||||||
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
|
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
|
||||||
controls->SetSnapping( !evt->Modifier( MD_ALT ) );
|
controls->SetSnapping( !evt->Modifier( MD_ALT ) );
|
||||||
|
|
|
@ -270,7 +270,7 @@ bool POINT_EDITOR::Init()
|
||||||
|
|
||||||
void POINT_EDITOR::updateEditedPoint( const TOOL_EVENT& aEvent )
|
void POINT_EDITOR::updateEditedPoint( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
EDIT_POINT* point = m_editedPoint;
|
EDIT_POINT* point;
|
||||||
|
|
||||||
if( aEvent.IsMotion() )
|
if( aEvent.IsMotion() )
|
||||||
{
|
{
|
||||||
|
@ -280,9 +280,16 @@ void POINT_EDITOR::updateEditedPoint( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
point = m_editPoints->FindPoint( aEvent.DragOrigin(), getView() );
|
point = m_editPoints->FindPoint( aEvent.DragOrigin(), getView() );
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
point = m_editPoints->FindPoint( getViewControls()->GetCursorPosition(), getView() );
|
||||||
|
}
|
||||||
|
|
||||||
if( m_editedPoint != point )
|
if( m_editedPoint != point )
|
||||||
setEditedPoint( point );
|
setEditedPoint( point );
|
||||||
|
|
||||||
|
if( point )
|
||||||
|
frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -317,6 +324,7 @@ int POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
view->Add( m_editPoints.get() );
|
view->Add( m_editPoints.get() );
|
||||||
setEditedPoint( nullptr );
|
setEditedPoint( nullptr );
|
||||||
|
updateEditedPoint( aEvent );
|
||||||
m_refill = false;
|
m_refill = false;
|
||||||
bool inDrag = false;
|
bool inDrag = false;
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,12 @@ public:
|
||||||
*/
|
*/
|
||||||
int OnSelectionChange( const TOOL_EVENT& aEvent );
|
int OnSelectionChange( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates the cursor is over an edit point. Used to coordinate cursor shapes with
|
||||||
|
* other tools.
|
||||||
|
*/
|
||||||
|
bool HasPoint() { return m_editedPoint != nullptr; }
|
||||||
|
|
||||||
///> Sets up handlers for various events.
|
///> Sets up handlers for various events.
|
||||||
void setTransitions() override;
|
void setTransitions() override;
|
||||||
|
|
||||||
|
|
|
@ -190,6 +190,9 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
// Main loop: keep receiving events
|
// Main loop: keep receiving events
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
|
if( m_frame->ToolStackIsEmpty() )
|
||||||
|
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
|
||||||
|
|
||||||
// Should selected items be added to the current selection or
|
// Should selected items be added to the current selection or
|
||||||
// become the new selection (discarding previously selected items)
|
// become the new selection (discarding previously selected items)
|
||||||
m_additive = evt->Modifier( MD_SHIFT );
|
m_additive = evt->Modifier( MD_SHIFT );
|
||||||
|
|
Loading…
Reference in New Issue