doublemax wrote:
There is no such event. I'm also not quite sure what you're tying to do, but it sounds dirty. A paint event handler should be totally "passive", it should have no influence on other parts of the application. If the paint event handler just draws a "state", every information you need is also available outside the paint event handler.
I basically want that, when I hold CTRL + LMB and draw the selection, as soon as the LMB is released, i.e the selection area is draw, I want to take the x coordinates of the left and right part of the selection marked with arrows on the top, to be calculated according to the sample length, which in the case of this sample selected in the screenshot is 8 seconds, so say the selection is from 3 seconds to 5 seconds, both those text controls should get filled with 0:03 0:05 receptively. I'm treating these as loop points, from where to where the sample should loop between.
I already have the calculations set up, just want something that triggers this automatically.
Code: Select all
WaveformViewer::LoopPoints WaveformViewer::GetLoopPoints()
{
Database db(m_InfoBar);
int selected_row = m_Library.GetSelectedRow();
if (selected_row < 0)
return { 0.0f, 0.0f };
wxString selected = m_Library.GetTextValue(selected_row, 1);
std::string path = db.GetSamplePathByFilename(m_DatabaseFilepath, selected.BeforeLast('.').ToStdString());
Tags tags(path);
int length = tags.GetAudioInfo().length;
// double position = m_MediaCtrl.Tell();
int panel_width = this->GetSize().GetWidth();
// double line_pos = panel_width * (position / length);
int a = m_AnchorPoint.x, b = m_CurrentPoint.x;
double loopA = ((double)a / panel_width) * length;
double loopB = ((double)b / panel_width) * length;
return { loopA, loopB };
}
And then I can maybe in the MainFrame class do something like,
Code: Select all
wxLongLong loopA = m_TopWaveformPanel->GetLoopPoints().A;
wxLongLong loopB = m_TopWaveformPanel->GetLoopPoints().B;
int loopA_min = static_cast<int>((loopA / 60000).GetValue());
int loopA_sec = static_cast<int>(((loopA % 60000) / 1000).GetValue());
int loopB_min = static_cast<int>((loopB / 60000).GetValue());
int loopB_sec = static_cast<int>(((loopB % 60000) / 1000).GetValue());
wxLogDebug(wxString::Format("LoopA: %2i:%02i", loopA_min, loopA_sec));
wxLogDebug(wxString::Format("LoopB: %2i:%02i", loopA_min, loopA_sec));
if (m_TopWaveformPanel->IsAreaSelected())
{
m_LoopPointAText->SetValue(wxString::Format("%2i:%02i", loopA_min, loopA_sec));
m_LoopPointBText->SetValue(wxString::Format("%2i:%02i", loopB_min, loopB_sec));
}