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:
Jeff Young 2019-06-27 22:33:48 +01:00
parent 42e14b5a4e
commit 981072598b
31 changed files with 153 additions and 40 deletions

View File

@ -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_ENTER_WINDOW, wxEventHandler( EDA_DRAW_PANEL_GAL::onEnter ), 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[] =
{
@ -408,7 +409,11 @@ bool EDA_DRAW_PANEL_GAL::SwitchBackend( GAL_TYPE aGalType )
// from the defaults
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;
m_gal = new_gal;
@ -495,6 +500,8 @@ void EDA_DRAW_PANEL_GAL::onShowTimer( wxTimerEvent& aEvent )
OnShow();
}
}
void EDA_DRAW_PANEL_GAL::SetCurrentCursor( int aCursor )
{
if ( aCursor > wxCURSOR_NONE && aCursor < wxCURSOR_MAX )
@ -505,3 +512,8 @@ void EDA_DRAW_PANEL_GAL::SetCurrentCursor( int aCursor )
SetCursor( (wxStockCursor) m_currentCursor );
}
void EDA_DRAW_PANEL_GAL::onSetCursor( wxSetCursorEvent& event )
{
event.SetCursor( (wxStockCursor) m_currentCursor );
}

View File

@ -48,8 +48,10 @@ int ZOOM_TOOL::Main( const TOOL_EVENT& aEvent )
{
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() )
break;
@ -80,7 +82,7 @@ bool ZOOM_TOOL::selectRegion()
KIGFX::PREVIEW::SELECTION_AREA area;
view->Add( &area );
while( auto evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
{

View File

@ -56,6 +56,9 @@ int CVPCB_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
// Main loop: keep receiving events
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.
// 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
@ -120,8 +123,9 @@ int CVPCB_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
controls.SetSnapping( 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();
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )

View File

@ -44,6 +44,7 @@ int EE_PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
while( TOOL_EVENT* evt = Wait() )
{
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_BULLSEYE );
VECTOR2D cursorPos = controls->GetCursorPosition( !evt->Modifier( MD_ALT ) );
if( evt->IsClick( BUT_LEFT ) )

View File

@ -242,9 +242,16 @@ void EE_POINT_EDITOR::updateEditedPoint( const TOOL_EVENT& aEvent )
{
point = m_editPoints->FindPoint( aEvent.DragOrigin(), getView() );
}
else
{
point = m_editPoints->FindPoint( getViewControls()->GetCursorPosition(), getView() );
}
if( m_editedPoint != 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 );
view->Add( m_editPoints.get() );
setEditedPoint( nullptr );
updateEditedPoint( aEvent );
bool inDrag = false;
bool modified = false;

View File

@ -49,6 +49,12 @@ public:
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.
void setTransitions() override;

View File

@ -285,6 +285,9 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
// Main loop: keep receiving events
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
// become the new selection (discarding previously selected items)
m_additive = evt->Modifier( MD_SHIFT );

View File

@ -40,7 +40,7 @@
#include <lib_circle.h>
#include <lib_polyline.h>
#include <lib_rectangle.h>
#include "ee_point_editor.h"
static void* g_lastPinWeakPtr;
@ -86,6 +86,7 @@ int LIB_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
// Main loop: keep receiving events
while( TOOL_EVENT* evt = Wait() )
{
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
@ -213,7 +214,8 @@ int LIB_DRAWING_TOOLS::TwoClickPlace( 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
// gets whacked.
@ -233,8 +235,11 @@ int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( ACTIONS::cursorClick );
// 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 ) );
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
while( TOOL_EVENT* evt = Wait() )
{
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_BULLSEYE );
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
{
break;

View File

@ -100,6 +100,7 @@ int LIB_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
// Main loop: keep receiving events
do
{
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
controls->SetSnapping( !evt->Modifier( MD_ALT ) );
if( evt->IsAction( &EE_ACTIONS::move ) || evt->IsMotion() || evt->IsDrag( BUT_LEFT )

View File

@ -23,6 +23,7 @@
#include "sch_drawing_tools.h"
#include "ee_selection_tool.h"
#include "ee_point_editor.h"
#include <ee_actions.h>
#include <sch_edit_frame.h>
#include <sch_view.h>
@ -114,6 +115,7 @@ int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent )
// Main loop: keep receiving events
while( TOOL_EVENT* evt = Wait() )
{
m_frame->GetCanvas()->SetCurrentCursor( component ? wxCURSOR_ARROW : wxCURSOR_PENCIL );
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
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
while( TOOL_EVENT* evt = Wait() )
{
m_frame->GetCanvas()->SetCurrentCursor( image ? wxCURSOR_ARROW : wxCURSOR_PENCIL );
cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
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
while( TOOL_EVENT* evt = Wait() )
{
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
cursorPos = (wxPoint) getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
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
while( TOOL_EVENT* evt = Wait() )
{
m_frame->GetCanvas()->SetCurrentCursor( item ? wxCURSOR_ARROW : wxCURSOR_PENCIL );
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
@ -603,7 +608,8 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
{
SCH_SHEET* sheet = nullptr;
EE_POINT_EDITOR* pointEditor = m_toolMgr->GetTool<EE_POINT_EDITOR>();
SCH_SHEET* sheet = nullptr;
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
getViewControls()->ShowCursor( true );
@ -618,6 +624,9 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
// Main loop: keep receiving events
while( TOOL_EVENT* evt = Wait() )
{
if( !pointEditor->HasPoint() )
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )

View File

@ -41,7 +41,7 @@
#include <sch_text.h>
#include <sch_sheet.h>
#include <advanced_config.h>
#include "ee_point_editor.h"
class BUS_UNFOLD_MENU : public ACTION_MENU
{
@ -440,9 +440,10 @@ static void computeBreakPoint( SCH_SCREEN* aScreen, SCH_LINE* aSegment, wxPoint&
int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( int aType, SCH_LINE* aSegment )
{
bool forceHV = m_frame->GetForceHVLines();
SCH_SCREEN* screen = m_frame->GetScreen();
wxPoint cursorPos;
bool forceHV = m_frame->GetForceHVLines();
SCH_SCREEN* screen = m_frame->GetScreen();
EE_POINT_EDITOR* pointEditor = m_toolMgr->GetTool<EE_POINT_EDITOR>();
wxPoint cursorPos;
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
getViewControls()->ShowCursor( true );
@ -452,6 +453,9 @@ int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( int aType, SCH_LINE* aSegment )
// Main loop: keep receiving events
while( TOOL_EVENT* evt = Wait() )
{
if( !pointEditor->HasPoint() )
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
cursorPos = (wxPoint) getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
//------------------------------------------------------------------------

View File

@ -160,6 +160,7 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
// Main loop: keep receiving events
do
{
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
controls->SetSnapping( !evt->Modifier( MD_ALT ) );
if( evt->IsAction( &EE_ACTIONS::moveActivate ) || evt->IsAction( &EE_ACTIONS::restartMove )

View File

@ -183,6 +183,9 @@ int GERBVIEW_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
// Main loop: keep receiving events
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.
// 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
@ -769,8 +772,9 @@ int GERBVIEW_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
controls.SetSnapping( 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();
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )

View File

@ -209,6 +209,7 @@ protected:
void onLostFocus( wxFocusEvent& aEvent );
void onRefreshTimer( wxTimerEvent& aEvent );
void onShowTimer( wxTimerEvent& aEvent );
void onSetCursor( wxSetCursorEvent& event );
static const int MinRefreshPeriod = 17; ///< 60 FPS.

View File

@ -36,7 +36,7 @@
#include <ws_draw_item.h>
#include <ws_data_item.h>
#include <invoke_pl_editor_dialog.h>
#include "pl_point_editor.h"
PL_DRAWING_TOOLS::PL_DRAWING_TOOLS() :
TOOL_INTERACTIVE( "plEditor.InteractiveDrawing" ),
@ -90,6 +90,7 @@ int PL_DRAWING_TOOLS::PlaceItem( const TOOL_EVENT& aEvent )
// Main loop: keep receiving events
while( TOOL_EVENT* evt = Wait() )
{
m_frame->GetCanvas()->SetCurrentCursor( item ? wxCURSOR_ARROW : wxCURSOR_PENCIL );
cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
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 )
{
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_DRAW_ITEM_BASE* item = nullptr;
@ -189,6 +191,9 @@ int PL_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
// Main loop: keep receiving events
while( TOOL_EVENT* evt = Wait() )
{
if( !pointEditor->HasPoint() )
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )

View File

@ -118,6 +118,7 @@ int PL_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
// Main loop: keep receiving events
do
{
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
controls->SetSnapping( !evt->Modifier( MD_ALT ) );
if( evt->IsAction( &PL_ACTIONS::move ) || evt->IsMotion() || evt->IsDrag( BUT_LEFT )

View File

@ -72,6 +72,7 @@ int PL_PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
while( TOOL_EVENT* evt = Wait() )
{
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_BULLSEYE );
VECTOR2I cursorPos = controls->GetCursorPosition( !evt->Modifier( MD_ALT ) );
if( evt->IsClick( BUT_LEFT ) )

View File

@ -137,9 +137,16 @@ void PL_POINT_EDITOR::updateEditedPoint( const TOOL_EVENT& aEvent )
{
point = m_editPoints->FindPoint( aEvent.DragOrigin(), getView() );
}
else
{
point = m_editPoints->FindPoint( getViewControls()->GetCursorPosition(), getView() );
}
if( m_editedPoint != 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() );
setEditedPoint( nullptr );
updateEditedPoint( aEvent );
bool inDrag = false;
bool modified = false;

View File

@ -50,6 +50,12 @@ public:
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.
void setTransitions() override;

View File

@ -111,6 +111,9 @@ int PL_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
// Main loop: keep receiving events
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
// become the new selection (discarding previously selected items)
m_additive = evt->Modifier( MD_SHIFT );

View File

@ -190,6 +190,8 @@ void LENGTH_TUNER_TOOL::performTuning()
while( TOOL_EVENT* evt = Wait() )
{
frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
break;
else if( evt->IsMotion() )
@ -276,6 +278,8 @@ int LENGTH_TUNER_TOOL::MainLoop( const TOOL_EVENT& aEvent )
// Main loop: keep receiving events
while( TOOL_EVENT* evt = Wait() )
{
frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
{
break; // Finish

View File

@ -754,6 +754,8 @@ void ROUTER_TOOL::performRouting()
while( TOOL_EVENT* evt = Wait() )
{
frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
// Don't crash if we missed an operation that cancelled routing.
wxCHECK2( m_router->RoutingInProgress(), break );
@ -881,6 +883,8 @@ int ROUTER_TOOL::MainLoop( const TOOL_EVENT& aEvent )
// Main loop: keep receiving events
while( TOOL_EVENT* evt = Wait() )
{
frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
{
break; // Finish
@ -1129,6 +1133,8 @@ int ROUTER_TOOL::InlineDrag( const TOOL_EVENT& aEvent )
while( TOOL_EVENT* evt = Wait() )
{
frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
break;

View File

@ -47,6 +47,7 @@
#include <painter.h>
#include <status_popup.h>
#include "grid_helper.h"
#include "point_editor.h"
#include <dialogs/dialog_text_properties.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 ) )
{
// 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( m_editModules )
@ -200,9 +198,6 @@ int DRAWING_TOOL::DrawCircle( const TOOL_EVENT& aEvent )
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( m_editModules )
@ -242,9 +237,6 @@ int DRAWING_TOOL::DrawArc( const TOOL_EVENT& aEvent )
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( m_editModules )
@ -293,8 +285,7 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
// Main loop: keep receiving events
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( text ? wxCURSOR_ARROW : wxCURSOR_PENCIL );
VECTOR2I cursorPos = m_controls->GetCursorPosition();
if( reselect && text )
@ -461,9 +452,10 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
if( m_editModules && !m_frame->GetModel() )
return 0;
DIMENSION* dimension = NULL;
BOARD_COMMIT commit( m_frame );
GRID_HELPER grid( m_frame );
POINT_EDITOR* pointEditor = m_toolMgr->GetTool<POINT_EDITOR>();
DIMENSION* dimension = NULL;
BOARD_COMMIT commit( m_frame );
GRID_HELPER grid( m_frame );
// Add a VIEW_GROUP that serves as a preview for the new item
PCBNEW_SELECTION preview;
@ -494,8 +486,9 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
// Main loop: keep receiving events
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 );
if( !pointEditor->HasPoint() )
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
grid.SetUseGrid( !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
while( TOOL_EVENT* evt = Wait() )
{
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
cursorPos = m_controls->GetCursorPosition();
if( evt->IsMotion() )
@ -814,8 +808,7 @@ int DRAWING_TOOL::SetAnchor( const TOOL_EVENT& aEvent )
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_BULLSEYE );
if( evt->IsClick( BUT_LEFT ) )
{
@ -851,7 +844,8 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic, OPT<VECTOR2D
{
// Only two shapes are currently supported
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_frame->SetActiveLayer( getDrawingLayer() );
@ -874,6 +868,9 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic, OPT<VECTOR2D
// Main loop: keep receiving events
while( TOOL_EVENT* evt = Wait() )
{
if( !pointEditor->HasPoint() )
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
grid.SetUseGrid( !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();
aGraphic->SetLayer( layer );
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
grid.SetUseGrid( !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
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 );
LSET layers( m_frame->GetActiveLayer() );
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );

View File

@ -301,6 +301,7 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
// Main loop: keep receiving events
do
{
editFrame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
grid.SetUseGrid( !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() )
{
// This can be reset by some actions (e.g. Save Board), so ensure it stays set.
frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
controls.SetSnapping( !evt->Modifier( MD_ALT ) );

View File

@ -209,6 +209,7 @@ int MICROWAVE_TOOL::drawMicrowaveInductor( const TOOL_EVENT& aEvent )
while( auto evt = Wait() )
{
frame.GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
VECTOR2I cursorPos = controls.GetCursorPosition();
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )

View File

@ -364,6 +364,8 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent )
while( TOOL_EVENT* evt = Wait() )
{
frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_BULLSEYE );
if( evt->IsDrag( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) )
{
selectedPads.clear();

View File

@ -536,7 +536,6 @@ int PCB_EDITOR_CONTROL::PlaceModule( const TOOL_EVENT& aEvent )
// Main loop: keep receiving events
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 );
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
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 );
frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
cursorPos = controls->GetCursorPosition( !evt->Modifier( MD_ALT ) );
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )

View File

@ -49,6 +49,7 @@ int PCBNEW_PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
while( TOOL_EVENT* evt = Wait() )
{
frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_BULLSEYE );
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
controls->SetSnapping( !evt->Modifier( MD_ALT ) );

View File

@ -270,7 +270,7 @@ bool POINT_EDITOR::Init()
void POINT_EDITOR::updateEditedPoint( const TOOL_EVENT& aEvent )
{
EDIT_POINT* point = m_editedPoint;
EDIT_POINT* point;
if( aEvent.IsMotion() )
{
@ -280,9 +280,16 @@ void POINT_EDITOR::updateEditedPoint( const TOOL_EVENT& aEvent )
{
point = m_editPoints->FindPoint( aEvent.DragOrigin(), getView() );
}
else
{
point = m_editPoints->FindPoint( getViewControls()->GetCursorPosition(), getView() );
}
if( m_editedPoint != 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() );
setEditedPoint( nullptr );
updateEditedPoint( aEvent );
m_refill = false;
bool inDrag = false;

View File

@ -58,6 +58,12 @@ public:
*/
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.
void setTransitions() override;

View File

@ -190,6 +190,9 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
// Main loop: keep receiving events
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
// become the new selection (discarding previously selected items)
m_additive = evt->Modifier( MD_SHIFT );