Attempt implementing mousewheel zoom into waveform. Badly.
This commit is contained in:
parent
0b52559ab1
commit
0d6eb09958
@ -104,6 +104,10 @@ PaulstretchpluginAudioProcessorEditor::PaulstretchpluginAudioProcessorEditor(Pau
|
||||
};
|
||||
m_zs.setRange(processor.m_wave_view_range, true);
|
||||
|
||||
m_wavecomponent.ViewRangeChangedCallback = [this](Range<double> rng)
|
||||
{
|
||||
m_zs.setRange(rng, false);
|
||||
};
|
||||
m_wavecomponent.TimeSelectionChangedCallback = [this](Range<double> range, int which)
|
||||
{
|
||||
*processor.getFloatParameter(cpi_soundstart) = range.getStart();
|
||||
@ -745,6 +749,25 @@ void WaveformComponent::mouseDoubleClick(const MouseEvent & e)
|
||||
repaint();
|
||||
}
|
||||
|
||||
void WaveformComponent::mouseWheelMove(const MouseEvent & e, const MouseWheelDetails & wd)
|
||||
{
|
||||
double factor = 0.9;
|
||||
if (wd.deltaY < 0.0)
|
||||
factor = 1.11111;
|
||||
double normt = viewXToNormalized(e.x);
|
||||
double curlen = m_view_range.getLength();
|
||||
double newlen = curlen * factor;
|
||||
double t0 = jlimit(0.0,1.0, normt - newlen / 2.0);
|
||||
double t1 = jlimit(0.0,1.0, normt + newlen / 2.0);
|
||||
m_view_range = { t0,t1 };
|
||||
//m_view_range = m_view_range.constrainRange({ 0.0, 1.0 });
|
||||
jassert(m_view_range.getStart() >= 0.0 && m_view_range.getEnd() <= 1.0);
|
||||
if (ViewRangeChangedCallback)
|
||||
ViewRangeChangedCallback(m_view_range);
|
||||
m_image_dirty = true;
|
||||
repaint();
|
||||
}
|
||||
|
||||
Range<double> WaveformComponent::getTimeSelection()
|
||||
{
|
||||
if (m_time_sel_start >= 0.0 && m_time_sel_end>m_time_sel_start + 0.001)
|
||||
|
@ -134,11 +134,13 @@ public:
|
||||
std::function<void(double)> SeekCallback;
|
||||
std::function<void(Range<double>, int)> TimeSelectionChangedCallback;
|
||||
std::function<File()> GetFileCallback;
|
||||
std::function<void(Range<double>)> ViewRangeChangedCallback;
|
||||
void mouseDown(const MouseEvent& e) override;
|
||||
void mouseUp(const MouseEvent& e) override;
|
||||
void mouseDrag(const MouseEvent& e) override;
|
||||
void mouseMove(const MouseEvent& e) override;
|
||||
void mouseDoubleClick(const MouseEvent& e) override;
|
||||
void mouseWheelMove(const MouseEvent& e, const MouseWheelDetails& wd) override;
|
||||
Range<double> getTimeSelection();
|
||||
void setTimeSelection(Range<double> rng);
|
||||
void setFileCachedRange(std::pair<Range<double>, Range<double>> rng);
|
||||
|
Loading…
Reference in New Issue
Block a user