Cursor centering fix

This commit is contained in:
Maciej Suminski 2016-08-11 14:42:14 +02:00
parent 2b041425e5
commit e452992a6c
2 changed files with 18 additions and 4 deletions

View File

@ -298,8 +298,14 @@ void CURSOR::Plot( wxDC& aDC, mpWindow& aWindow )
wxQueueEvent( aWindow.GetParent(), new wxCommandEvent( EVT_SIM_CURSOR_UPDATE ) );
}
else
{
m_updateRef = true;
}
if( m_updateRef )
{
UpdateReference();
m_updateRef = false;
}
// Line length in horizontal and vertical dimensions
@ -548,8 +554,8 @@ void SIM_PLOT_PANEL::EnableCursor( const wxString& aName, bool aEnable )
if( aEnable )
{
CURSOR* c = new CURSOR( t );
//int plotCenter = GetMarginLeft() + ( GetXScreen() - GetMarginLeft() - GetMarginRight() ) / 2;
//c->Move( wxPoint( plotCenter, 0 ) );
int plotCenter = GetMarginLeft() + ( GetXScreen() - GetMarginLeft() - GetMarginRight() ) / 2;
c->SetX( plotCenter );
t->SetCursor( c );
AddLayer( c );
}

View File

@ -37,13 +37,21 @@ class CURSOR : public mpInfoLayer
public:
CURSOR( const TRACE* aTrace )
: mpInfoLayer( wxRect( 0, 0, DRAG_MARGIN, DRAG_MARGIN ), wxTRANSPARENT_BRUSH ),
m_trace( aTrace ), m_updateRequired( true ), m_coords( 0.0, 0.0 ), m_window( nullptr )
m_trace( aTrace ), m_updateRequired( true ), m_updateRef( false ),
m_coords( 0.0, 0.0 ), m_window( nullptr )
{
SetDrawOutsideMargins( false );
}
void Plot( wxDC& aDC, mpWindow& aWindow ) override;
void SetX( int aX )
{
m_reference.x = 0;
m_updateRef = true;
Move( wxPoint( aX, 0 ) );
}
void Update()
{
m_updateRequired = true;
@ -66,7 +74,7 @@ public:
private:
const TRACE* m_trace;
bool m_updateRequired;
bool m_updateRequired, m_updateRef;
wxRealPoint m_coords;
mpWindow* m_window;