Make Eeschema cursors update without waiting for mouse movement.
This commit is contained in:
parent
bd1f262a6b
commit
cb5ec8bce1
|
@ -124,12 +124,12 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
|
||||||
// Set up timer that prevents too frequent redraw commands
|
// Set up timer that prevents too frequent redraw commands
|
||||||
m_refreshTimer.SetOwner( this );
|
m_refreshTimer.SetOwner( this );
|
||||||
Connect( m_refreshTimer.GetId(), wxEVT_TIMER,
|
Connect( m_refreshTimer.GetId(), wxEVT_TIMER,
|
||||||
wxTimerEventHandler( EDA_DRAW_PANEL_GAL::onRefreshTimer ), NULL, this );
|
wxTimerEventHandler( EDA_DRAW_PANEL_GAL::onRefreshTimer ), NULL, this );
|
||||||
|
|
||||||
// Set up timer to execute OnShow() method when the window appears on the screen
|
// Set up timer to execute OnShow() method when the window appears on the screen
|
||||||
m_onShowTimer.SetOwner( this );
|
m_onShowTimer.SetOwner( this );
|
||||||
Connect( m_onShowTimer.GetId(), wxEVT_TIMER,
|
Connect( m_onShowTimer.GetId(), wxEVT_TIMER,
|
||||||
wxTimerEventHandler( EDA_DRAW_PANEL_GAL::onShowTimer ), NULL, this );
|
wxTimerEventHandler( EDA_DRAW_PANEL_GAL::onShowTimer ), NULL, this );
|
||||||
m_onShowTimer.Start( 10 );
|
m_onShowTimer.Start( 10 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -464,7 +464,11 @@ bool EDA_DRAW_PANEL_GAL::SwitchBackend( GAL_TYPE aGalType )
|
||||||
wxWindow* galWindow = dynamic_cast<wxWindow*>( new_gal );
|
wxWindow* galWindow = dynamic_cast<wxWindow*>( new_gal );
|
||||||
|
|
||||||
if( galWindow )
|
if( galWindow )
|
||||||
galWindow->Connect( wxEVT_SET_CURSOR, wxSetCursorEventHandler( EDA_DRAW_PANEL_GAL::onSetCursor ), NULL, this );
|
{
|
||||||
|
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;
|
||||||
|
@ -581,9 +585,7 @@ void EDA_DRAW_PANEL_GAL::onShowTimer( wxTimerEvent& aEvent )
|
||||||
void EDA_DRAW_PANEL_GAL::SetCurrentCursor( KICURSOR cursor )
|
void EDA_DRAW_PANEL_GAL::SetCurrentCursor( KICURSOR cursor )
|
||||||
{
|
{
|
||||||
if( m_currentKiCursor == cursor )
|
if( m_currentKiCursor == cursor )
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
m_currentCursor = CURSOR_STORE::GetCursor( cursor );
|
m_currentCursor = CURSOR_STORE::GetCursor( cursor );
|
||||||
m_currentKiCursor = cursor;
|
m_currentKiCursor = cursor;
|
||||||
|
|
|
@ -88,6 +88,20 @@ SCH_BASE_FRAME::SCH_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aWindo
|
||||||
m_defaults( &m_base_frame_defaults )
|
m_defaults( &m_base_frame_defaults )
|
||||||
{
|
{
|
||||||
createCanvas();
|
createCanvas();
|
||||||
|
|
||||||
|
Bind( wxEVT_IDLE,
|
||||||
|
[this]( wxIdleEvent& aEvent )
|
||||||
|
{
|
||||||
|
// Handle cursor adjustments. While we can get motion and key events through
|
||||||
|
// wxWidgets, we can't get modifier-key-up events.
|
||||||
|
if( m_toolManager )
|
||||||
|
{
|
||||||
|
EE_SELECTION_TOOL* selTool = m_toolManager->GetTool<EE_SELECTION_TOOL>();
|
||||||
|
|
||||||
|
if( selTool )
|
||||||
|
selTool->OnIdle( aEvent );
|
||||||
|
}
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -557,28 +557,20 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
if( displayWireCursor )
|
if( displayWireCursor )
|
||||||
{
|
{
|
||||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::LINE_WIRE_ADD );
|
m_nonModifiedCursor = KICURSOR::LINE_WIRE_ADD;
|
||||||
}
|
}
|
||||||
else if( rolloverItem != niluuid )
|
else if( rolloverItem != niluuid )
|
||||||
{
|
{
|
||||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::HAND );
|
m_nonModifiedCursor = KICURSOR::HAND;
|
||||||
}
|
}
|
||||||
else if( !modifier_enabled && !m_selection.Empty()
|
else if( !m_selection.Empty() && !m_frame->GetDragSelects() && evt->HasPosition()
|
||||||
&& !m_frame->GetDragSelects() && evt->HasPosition()
|
|
||||||
&& selectionContains( evt->Position() ) ) //move/drag option prediction
|
&& selectionContains( evt->Position() ) ) //move/drag option prediction
|
||||||
{
|
{
|
||||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::MOVING );
|
m_nonModifiedCursor = KICURSOR::MOVING;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( m_additive )
|
m_nonModifiedCursor = KICURSOR::ARROW;
|
||||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ADD );
|
|
||||||
else if( m_subtractive )
|
|
||||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::SUBTRACT );
|
|
||||||
else if( m_exclusive_or )
|
|
||||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::XOR );
|
|
||||||
else
|
|
||||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -590,6 +582,33 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void EE_SELECTION_TOOL::OnIdle( wxIdleEvent& aEvent )
|
||||||
|
{
|
||||||
|
if( m_frame->ToolStackIsEmpty() )
|
||||||
|
{
|
||||||
|
wxMouseState keyboardState = wxGetMouseState();
|
||||||
|
|
||||||
|
m_subtractive = m_additive = m_exclusive_or = false;
|
||||||
|
|
||||||
|
if( keyboardState.ShiftDown() && keyboardState.ControlDown() )
|
||||||
|
m_subtractive = true;
|
||||||
|
else if( keyboardState.ShiftDown() )
|
||||||
|
m_additive = true;
|
||||||
|
else if( keyboardState.ControlDown() )
|
||||||
|
m_exclusive_or = true;
|
||||||
|
|
||||||
|
if( m_additive )
|
||||||
|
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ADD );
|
||||||
|
else if( m_subtractive )
|
||||||
|
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::SUBTRACT );
|
||||||
|
else if( m_exclusive_or )
|
||||||
|
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::XOR );
|
||||||
|
else
|
||||||
|
m_frame->GetCanvas()->SetCurrentCursor( m_nonModifiedCursor );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
EE_SELECTION& EE_SELECTION_TOOL::GetSelection()
|
EE_SELECTION& EE_SELECTION_TOOL::GetSelection()
|
||||||
{
|
{
|
||||||
return m_selection;
|
return m_selection;
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include <tools/ee_selection.h>
|
#include <tools/ee_selection.h>
|
||||||
#include <ee_collectors.h>
|
#include <ee_collectors.h>
|
||||||
#include <sch_component.h>
|
#include <sch_component.h>
|
||||||
|
#include <cursors.h>
|
||||||
|
|
||||||
class SCH_BASE_FRAME;
|
class SCH_BASE_FRAME;
|
||||||
class SCH_ITEM;
|
class SCH_ITEM;
|
||||||
|
@ -71,6 +72,8 @@ public:
|
||||||
*/
|
*/
|
||||||
int Main( const TOOL_EVENT& aEvent );
|
int Main( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
|
void OnIdle( wxIdleEvent& aEvent );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function GetSelection()
|
* Function GetSelection()
|
||||||
*
|
*
|
||||||
|
@ -277,19 +280,23 @@ private:
|
||||||
void setTransitions() override;
|
void setTransitions() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SCH_BASE_FRAME* m_frame; // Pointer to the parent frame
|
SCH_BASE_FRAME* m_frame; // Pointer to the parent frame
|
||||||
EE_SELECTION m_selection; // Current state of selection
|
EE_SELECTION m_selection; // Current state of selection
|
||||||
|
|
||||||
bool m_additive; // Items should be added to selection (instead of replacing)
|
bool m_additive; // Items should be added to sel (instead of replacing)
|
||||||
bool m_subtractive; // Items should be removed from selection
|
bool m_subtractive; // Items should be removed from sel
|
||||||
bool m_exclusive_or; // Items' selection state should be toggled
|
bool m_exclusive_or; // Items' selection state should be toggled
|
||||||
bool m_multiple; // Multiple selection mode is active
|
bool m_multiple; // Multiple selection mode is active
|
||||||
bool m_skip_heuristics; // Heuristics are not allowed when choosing item under cursor
|
bool m_skip_heuristics; // Show disambuguation menu for all items under the
|
||||||
|
// cursor rather than trying to narrow them down first
|
||||||
|
// using heuristics
|
||||||
|
|
||||||
bool m_isSymbolEditor; // True when the symbol editor is the parent frame
|
KICURSOR m_nonModifiedCursor; // Cursor in the absence of shift/ctrl/alt
|
||||||
bool m_isLibView; // True when libview is the parent frame
|
|
||||||
int m_unit; // Fixed unit filter (for symbol editor)
|
bool m_isSymbolEditor; // True when the symbol editor is the parent frame
|
||||||
int m_convert; // Fixed DeMorgan filter (for symbol editor)
|
bool m_isLibView; // True when libview is the parent frame
|
||||||
|
int m_unit; // Fixed unit filter (for symbol editor)
|
||||||
|
int m_convert; // Fixed DeMorgan filter (for symbol editor)
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //KICAD_SCH_SELECTION_TOOL_H
|
#endif //KICAD_SCH_SELECTION_TOOL_H
|
||||||
|
|
Loading…
Reference in New Issue