From 39d35a8beccf363763b0fc1936f91812f9e8773b Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 31 Jan 2023 17:29:46 +0000 Subject: [PATCH] Better cursor feedback for plot window. --- common/widgets/mathplot.cpp | 99 +++++++++++++++------------- eeschema/sim/sim_plot_frame_base.cpp | 14 ++-- eeschema/sim/sim_plot_frame_base.fbp | 4 +- eeschema/sim/sim_plot_panel.cpp | 2 +- eeschema/sim/sim_plot_panel.h | 2 +- include/widgets/mathplot.h | 2 +- 6 files changed, 64 insertions(+), 59 deletions(-) diff --git a/common/widgets/mathplot.cpp b/common/widgets/mathplot.cpp index 8e9cd46fdd..8f1e2e541f 100644 --- a/common/widgets/mathplot.cpp +++ b/common/widgets/mathplot.cpp @@ -28,6 +28,7 @@ #include "wx/intl.h" #include "wx/dcclient.h" #include "wx/cursor.h" +#include "gal/cursors.h" #endif #include @@ -103,7 +104,8 @@ mpInfoLayer::mpInfoLayer() } -mpInfoLayer::mpInfoLayer( wxRect rect, const wxBrush* brush ) : m_dim( rect ) +mpInfoLayer::mpInfoLayer( wxRect rect, const wxBrush* brush ) : + m_dim( rect ) { m_brush = *brush; m_reference.x = rect.x; @@ -124,7 +126,7 @@ void mpInfoLayer::UpdateInfo( mpWindow& w, wxEvent& event ) } -bool mpInfoLayer::Inside( wxPoint& point ) +bool mpInfoLayer::Inside( const wxPoint& point ) const { return m_dim.Contains( point ); } @@ -1812,8 +1814,12 @@ void mpWindow::OnMouseMove( wxMouseEvent& event ) return; } + wxCursor cursor = wxCURSOR_MAGNIFIER; + if( event.m_middleDown ) { + cursor = wxCURSOR_ARROW; + // The change: int Ax = m_mouseMClick.x - event.GetX(); int Ay = m_mouseMClick.y - event.GetY(); @@ -1836,60 +1842,59 @@ void mpWindow::OnMouseMove( wxMouseEvent& event ) if( updateRequired ) UpdateAll(); } - else + else if( event.m_leftDown ) { - if( event.m_leftDown ) + if( m_movingInfoLayer ) { - if( m_movingInfoLayer == NULL ) - { - wxClientDC dc( this ); - wxPen pen( m_fgColour, 1, wxPENSTYLE_DOT ); - dc.SetPen( pen ); - dc.SetBrush( *wxTRANSPARENT_BRUSH ); - dc.DrawRectangle( m_mouseLClick.x, m_mouseLClick.y, - event.GetX() - m_mouseLClick.x, event.GetY() - m_mouseLClick.y ); - m_zooming = true; - m_zoomRect.x = m_mouseLClick.x; - m_zoomRect.y = m_mouseLClick.y; - m_zoomRect.width = event.GetX() - m_mouseLClick.x; - m_zoomRect.height = event.GetY() - m_mouseLClick.y; - } - else - { - wxPoint moveVector( event.GetX() - m_mouseLClick.x, event.GetY() - m_mouseLClick.y ); - m_movingInfoLayer->Move( moveVector ); - m_zooming = false; - } + cursor = wxCURSOR_SIZEWE; - UpdateAll(); + wxPoint moveVector( event.GetX() - m_mouseLClick.x, event.GetY() - m_mouseLClick.y ); + m_movingInfoLayer->Move( moveVector ); + m_zooming = false; } else { -#if 0 - wxLayerList::iterator li; + cursor = wxCURSOR_MAGNIFIER; - for( li = m_layers.begin(); li != m_layers.end(); li++ ) - { - if( (*li)->IsInfo() && (*li)->IsVisible() ) - { - mpInfoLayer* tmpLyr = (mpInfoLayer*) (*li); - tmpLyr->UpdateInfo( *this, event ); - // UpdateAll(); - RefreshRect( tmpLyr->GetRectangle() ); - } - } - -#endif - /* if (m_coordTooltip) { - * wxString toolTipContent; - * toolTipContent.Printf( "X = %f\nY = %f", p2x(event.GetX()), p2y(event.GetY())); - * wxTipWindow** ptr = NULL; - * wxRect rectBounds(event.GetX(), event.GetY(), 5, 5); - * wxTipWindow* tip = new wxTipWindow(this, toolTipContent, 100, ptr, &rectBounds); - * - * } */ + wxClientDC dc( this ); + wxPen pen( m_fgColour, 1, wxPENSTYLE_DOT ); + dc.SetPen( pen ); + dc.SetBrush( *wxTRANSPARENT_BRUSH ); + dc.DrawRectangle( m_mouseLClick.x, m_mouseLClick.y, + event.GetX() - m_mouseLClick.x, event.GetY() - m_mouseLClick.y ); + m_zooming = true; + m_zoomRect.x = m_mouseLClick.x; + m_zoomRect.y = m_mouseLClick.y; + m_zoomRect.width = event.GetX() - m_mouseLClick.x; + m_zoomRect.height = event.GetY() - m_mouseLClick.y; } + + UpdateAll(); } + else + { + for( mpLayer* layer : m_layers) + { + if( layer->IsInfo() && layer->IsVisible() ) + { + mpInfoLayer* infoLayer = (mpInfoLayer*) layer; + + if( infoLayer->Inside( event.GetPosition() ) ) + cursor = wxCURSOR_SIZEWE; + } + } + + /* if (m_coordTooltip) { + * wxString toolTipContent; + * toolTipContent.Printf( "X = %f\nY = %f", p2x(event.GetX()), p2y(event.GetY())); + * wxTipWindow** ptr = NULL; + * wxRect rectBounds(event.GetX(), event.GetY(), 5, 5); + * wxTipWindow* tip = new wxTipWindow(this, toolTipContent, 100, ptr, &rectBounds); + * + * } */ + } + + SetCursor( cursor ); event.Skip(); } diff --git a/eeschema/sim/sim_plot_frame_base.cpp b/eeschema/sim/sim_plot_frame_base.cpp index 88dc3cae18..28df5b8b22 100644 --- a/eeschema/sim/sim_plot_frame_base.cpp +++ b/eeschema/sim/sim_plot_frame_base.cpp @@ -114,11 +114,11 @@ SIM_PLOT_FRAME_BASE::SIM_PLOT_FRAME_BASE( wxWindow* parent, wxWindowID id, const m_signalsGrid->SetMargins( 0, 0 ); // Columns - m_signalsGrid->SetColSize( 0, 196 ); - m_signalsGrid->SetColSize( 1, 50 ); - m_signalsGrid->SetColSize( 2, 50 ); - m_signalsGrid->SetColSize( 3, 54 ); - m_signalsGrid->SetColSize( 4, 54 ); + m_signalsGrid->SetColSize( 0, 204 ); + m_signalsGrid->SetColSize( 1, 45 ); + m_signalsGrid->SetColSize( 2, 45 ); + m_signalsGrid->SetColSize( 3, 55 ); + m_signalsGrid->SetColSize( 4, 55 ); m_signalsGrid->EnableDragColMove( false ); m_signalsGrid->EnableDragColSize( true ); m_signalsGrid->SetColLabelValue( 0, _("Signal") ); @@ -173,8 +173,8 @@ SIM_PLOT_FRAME_BASE::SIM_PLOT_FRAME_BASE( wxWindow* parent, wxWindowID id, const // Columns m_cursorsGrid->SetColSize( 0, 44 ); m_cursorsGrid->SetColSize( 1, 152 ); - m_cursorsGrid->SetColSize( 2, 110 ); - m_cursorsGrid->SetColSize( 3, 110 ); + m_cursorsGrid->SetColSize( 2, 103 ); + m_cursorsGrid->SetColSize( 3, 106 ); m_cursorsGrid->EnableDragColMove( false ); m_cursorsGrid->EnableDragColSize( true ); m_cursorsGrid->SetColLabelValue( 0, _("Cursor") ); diff --git a/eeschema/sim/sim_plot_frame_base.fbp b/eeschema/sim/sim_plot_frame_base.fbp index c7fa53daec..a5659487b1 100644 --- a/eeschema/sim/sim_plot_frame_base.fbp +++ b/eeschema/sim/sim_plot_frame_base.fbp @@ -843,7 +843,7 @@ "Signal" "Plot" "Color" "Cursor 1" "Cursor 2" wxALIGN_CENTER 5 - 196,50,50,54,54 + 204,45,45,55,55 1 0 @@ -1110,7 +1110,7 @@ "Cursor" "Signal" "Time" "Voltage / Current" wxALIGN_CENTER 4 - 44,152,110,110 + 44,152,103,106 1 0 diff --git a/eeschema/sim/sim_plot_panel.cpp b/eeschema/sim/sim_plot_panel.cpp index ca49fd4424..bc803adf49 100644 --- a/eeschema/sim/sim_plot_panel.cpp +++ b/eeschema/sim/sim_plot_panel.cpp @@ -353,7 +353,7 @@ void CURSOR::Plot( wxDC& aDC, mpWindow& aWindow ) } -bool CURSOR::Inside( wxPoint& aPoint ) +bool CURSOR::Inside( const wxPoint& aPoint ) const { if( !m_window ) return false; diff --git a/eeschema/sim/sim_plot_panel.h b/eeschema/sim/sim_plot_panel.h index 1365a7f41f..883d6c4617 100644 --- a/eeschema/sim/sim_plot_panel.h +++ b/eeschema/sim/sim_plot_panel.h @@ -69,7 +69,7 @@ public: m_updateRequired = true; } - bool Inside( wxPoint& aPoint ) override; + bool Inside( const wxPoint& aPoint ) const override; void Move( wxPoint aDelta ) override { diff --git a/include/widgets/mathplot.h b/include/widgets/mathplot.h index a5d2a8696c..516a87270a 100644 --- a/include/widgets/mathplot.h +++ b/include/widgets/mathplot.h @@ -370,7 +370,7 @@ public: /** Checks whether a point is inside the info box rectangle. * @param point The point to be checked * @return \a true if the point is inside the bounding box */ - virtual bool Inside( wxPoint& point ); + virtual bool Inside( const wxPoint& point ) const; /** Moves the layer rectangle of given pixel deltas. * @param delta The wxPoint container for delta coordinates along x and y. Units are in pixels. */