mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
Allow dragging the flux viewer.
This commit is contained in:
@@ -30,6 +30,9 @@ FluxViewerControl::FluxViewerControl(wxWindow* parent,
|
||||
wxBEGIN_EVENT_TABLE(FluxViewerControl, wxPanel)
|
||||
EVT_PAINT(FluxViewerControl::OnPaint)
|
||||
EVT_MOUSEWHEEL(FluxViewerControl::OnMouseWheel)
|
||||
EVT_LEFT_DOWN(FluxViewerControl::OnMouseMotion)
|
||||
EVT_LEFT_UP(FluxViewerControl::OnMouseMotion)
|
||||
EVT_MOTION(FluxViewerControl::OnMouseMotion)
|
||||
wxEND_EVENT_TABLE()
|
||||
|
||||
void FluxViewerControl::SetScrollbar(wxScrollBar* scrollbar)
|
||||
@@ -300,3 +303,27 @@ void FluxViewerControl::OnScrollbarChanged(wxScrollEvent& event)
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void FluxViewerControl::OnMouseMotion(wxMouseEvent& event)
|
||||
{
|
||||
wxClientDC dc(this);
|
||||
event.Skip();
|
||||
|
||||
if (event.ButtonDown(wxMOUSE_BTN_LEFT))
|
||||
{
|
||||
_dragStartX = event.GetLogicalPosition(dc).x;
|
||||
_dragStartPosition = _scrollPosition;
|
||||
}
|
||||
else if (event.ButtonUp(wxMOUSE_BTN_LEFT))
|
||||
{
|
||||
/* end drag, do nothing */
|
||||
}
|
||||
else if (event.Dragging())
|
||||
{
|
||||
int dx = _dragStartX - event.GetLogicalPosition(dc).x;
|
||||
nanoseconds_t dt = dx * _nanosecondsPerPixel;
|
||||
_scrollPosition = _dragStartPosition + dt;
|
||||
UpdateScale();
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ private:
|
||||
void OnPaint(wxPaintEvent&);
|
||||
void OnMouseWheel(wxMouseEvent&);
|
||||
void OnScrollbarChanged(wxScrollEvent&);
|
||||
void OnMouseMotion(wxMouseEvent&);
|
||||
|
||||
private:
|
||||
wxScrollBar* _scrollbar;
|
||||
@@ -35,6 +36,8 @@ private:
|
||||
nanoseconds_t _totalDuration;
|
||||
double _nanosecondsPerPixel;
|
||||
std::vector<float> _densityMap;
|
||||
int _dragStartX;
|
||||
nanoseconds_t _dragStartPosition;
|
||||
wxDECLARE_EVENT_TABLE();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user