From cf173902934efbd41a38c95cc2f52a937851937a Mon Sep 17 00:00:00 2001 From: xenakios Date: Wed, 3 Jan 2018 19:32:53 +0200 Subject: [PATCH] Move methods to cpp file --- Source/PluginEditor.cpp | 43 +++++++++++++++++++++++++++++++++++++++++ Source/PluginEditor.h | 43 ++++++----------------------------------- 2 files changed, 49 insertions(+), 37 deletions(-) diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index 3eebc6c..f0079f9 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -641,6 +641,24 @@ void WaveformComponent::mouseMove(const MouseEvent & e) } +Range WaveformComponent::getTimeSelection() +{ + if (m_time_sel_start >= 0.0 && m_time_sel_end>m_time_sel_start + 0.001) + return { m_time_sel_start, m_time_sel_end }; + return { 0.0, 1.0 }; +} + +void WaveformComponent::setTimeSelection(Range rng) +{ + if (m_lock_timesel_set == true) + return; + if (rng.isEmpty()) + rng = { -1.0,1.0 }; + m_time_sel_start = rng.getStart(); + m_time_sel_end = rng.getEnd(); + repaint(); +} + int WaveformComponent::getTimeSelectionEdge(int x, int y) { int xcorleft = (int)jmap(m_time_sel_start, m_view_range.getStart(), m_view_range.getEnd(), 0, getWidth()); @@ -744,6 +762,13 @@ void SpectralChainEditor::paint(Graphics & g) drawBox(g, m_cur_index, m_drag_x, 0, box_w - 30, box_h); } +void SpectralChainEditor::setSource(StretchAudioSource * src) +{ + m_src = src; + m_order = m_src->getSpectrumProcessOrder(); + repaint(); +} + void SpectralChainEditor::mouseDown(const MouseEvent & ev) { m_did_drag = false; @@ -918,3 +943,21 @@ void ParameterComponent::updateComponent() m_togglebut->setToggleState(*boolpar, dontSendNotification); } } + +MySlider::MySlider(NormalisableRange* range) : m_range(range) +{ +} + +double MySlider::proportionOfLengthToValue(double x) +{ + if (m_range) + return m_range->convertFrom0to1(x); + return Slider::proportionOfLengthToValue(x); +} + +double MySlider::valueToProportionOfLength(double x) +{ + if (m_range) + return m_range->convertTo0to1(x); + return Slider::valueToProportionOfLength(x); +} diff --git a/Source/PluginEditor.h b/Source/PluginEditor.h index 186b8c5..3545d02 100644 --- a/Source/PluginEditor.h +++ b/Source/PluginEditor.h @@ -44,21 +44,9 @@ class MySlider : public Slider { public: MySlider() {} - MySlider(NormalisableRange* range) : m_range(range) - { - } - double proportionOfLengthToValue(double x) override - { - if (m_range) - return m_range->convertFrom0to1(x); - return Slider::proportionOfLengthToValue(x); - } - double valueToProportionOfLength(double x) override - { - if (m_range) - return m_range->convertTo0to1(x); - return Slider::valueToProportionOfLength(x); - } + MySlider(NormalisableRange* range); + double proportionOfLengthToValue(double x) override; + double valueToProportionOfLength(double x) override; private: NormalisableRange* m_range = nullptr; }; @@ -112,22 +100,8 @@ public: void mouseUp(const MouseEvent& e) override; void mouseDrag(const MouseEvent& e) override; void mouseMove(const MouseEvent& e) override; - Range getTimeSelection() - { - if (m_time_sel_start >= 0.0 && m_time_sel_end>m_time_sel_start + 0.001) - return { m_time_sel_start, m_time_sel_end }; - return { 0.0, 1.0 }; - } - void setTimeSelection(Range rng) - { - if (m_lock_timesel_set == true) - return; - if (rng.isEmpty()) - rng = { -1.0,1.0 }; - m_time_sel_start = rng.getStart(); - m_time_sel_end = rng.getEnd(); - repaint(); - } + Range getTimeSelection(); + void setTimeSelection(Range rng); void setFileCachedRange(std::pair, Range> rng); void setTimerEnabled(bool b); void setViewRange(Range rng); @@ -162,12 +136,7 @@ class SpectralChainEditor : public Component public: SpectralChainEditor() {} void paint(Graphics& g) override; - void setSource(StretchAudioSource* src) - { - m_src = src; - m_order = m_src->getSpectrumProcessOrder(); - repaint(); - } + void setSource(StretchAudioSource* src); void mouseDown(const MouseEvent& ev) override; void mouseDrag(const MouseEvent& ev) override; void mouseUp(const MouseEvent& ev) override;