When you capture the mouse in the mainframe, all mouse events will be redirected there, but your wxEVT_LEFT_UP handler is bound to the m_TopWaveformPanel. It's a general problem that your event handlers for m_TopWaveformPanel are all in the mainframe. This may be the time to derive your own class for m_TopWaveformPanel and move all event handlers there. This will make the code cleaner and more future proof.
I see.
After spending an hour or something this is what I got,
Code: Select all
WaveformViewer::WaveformViewer(wxWindow* parentFrame, wxWindow* window, bool dirtyBitmap, wxDataViewListCtrl& library, wxMediaCtrl& mediaCtrl,
wxTimer& timer, wxInfoBar& infoBar, const std::string& configFilepath, const std::string& databaseFilepath)
: wxPanel(window, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxNO_BORDER | wxFULL_REPAINT_ON_RESIZE),
m_ParentFrame(parentFrame), m_Window(window), bBitmapDirty(dirtyBitmap), m_Library(library), m_MediaCtrl(mediaCtrl), m_Timer(timer),
m_InfoBar(infoBar), m_ConfigFilepath(configFilepath), m_DatabaseFilepath(databaseFilepath)
{
Bind(wxEVT_PAINT, &WaveformViewer::OnPaint, this);
Bind(wxEVT_MOTION, &WaveformViewer::OnHoverPlayhead, this);
Bind(wxEVT_LEFT_DOWN, &WaveformViewer::OnGrabPlayhead, this);
Bind(wxEVT_LEFT_UP, &WaveformViewer::OnReleasePlayhead, this);
}
All the functions are still the same as before.
And in the MainFrame class,
Code: Select all
m_TopWaveformPanel = new WaveformViewer(this, m_TopPanel, IsBitmapDirty(), *m_Library, *m_MediaCtrl, *m_Timer, *m_InfoBar, m_ConfigFilepath, m_DatabaseFilepath);
At first I had the same problem with waveform only showing when frame or splitter is resized, so in WaveformViewer class I made a variable bool& BitmapDirty, and in MainFrame class I made this function,
Code: Select all
inline bool IsBitmapDirty() { return bBitmapDirty; }
which is initialized as false.
It seems to be working, however it looks like it is constantly updating something. App almost feels laggy.
Just a guess, try m_TopWaveformPanel->SetCursor(...)
Cursor seems to change now, so one problem fixed.