From cee19a56365f6dc5cbbc3c7cca92ec7da4228aa6 Mon Sep 17 00:00:00 2001
From: Septen <gammerxpower@gmail.com>
Date: Mon, 20 Jun 2016 14:39:05 +0400
Subject: [PATCH] ParameterEditor class refactoring and stylystic fixes. Minor
 fixes.

---
 Source/Processors/Editors/GenericEditor.cpp   |   5 +-
 Source/Processors/Editors/GenericEditor.h     |  19 +-
 .../GenericProcessor/GenericProcessor.cpp     |   5 +-
 .../GenericProcessor/GenericProcessor.h       |   3 -
 .../Processors/Parameter/ParameterEditor.cpp  | 586 ++++++++----------
 Source/Processors/Parameter/ParameterEditor.h | 110 ++--
 6 files changed, 301 insertions(+), 427 deletions(-)

diff --git a/Source/Processors/Editors/GenericEditor.cpp b/Source/Processors/Editors/GenericEditor.cpp
index c2183d064..3eee68795 100755
--- a/Source/Processors/Editors/GenericEditor.cpp
+++ b/Source/Processors/Editors/GenericEditor.cpp
@@ -1082,7 +1082,6 @@ SaveButton::~SaveButton()
 
 void GenericEditor::updateParameterButtons(int parameterIndex)
 {
-
     if (parameterEditors.size() == 0)
     {
         //Checks if there is a parameter editor, and stops a bug if there isn't.
@@ -1094,12 +1093,12 @@ void GenericEditor::updateParameterButtons(int parameterIndex)
         {
             for (int i = 0; i < parameterEditors.size(); ++i)
             {
-                parameterEditors[i]->channelSelectionUI();
+                parameterEditors[i]->updateChannelSelectionUI();
             }
         }
         else
         {
-            parameterEditors[parameterIndex]->channelSelectionUI();
+            parameterEditors[parameterIndex]->updateChannelSelectionUI();
         }
         //std::cout << "updateParameterButtons" << std::endl;
     }
diff --git a/Source/Processors/Editors/GenericEditor.h b/Source/Processors/Editors/GenericEditor.h
index 61aaafc01..4e96c7dd0 100755
--- a/Source/Processors/Editors/GenericEditor.h
+++ b/Source/Processors/Editors/GenericEditor.h
@@ -42,17 +42,15 @@ class Channel;
 
 
 /**
-  Base class for creating processor editors.
+    Base class for creating processor editors.
 
-  If a processor doesn't havesign an editor defined, a GenericEditor will be used.
+    If a processor doesn't havesign an editor defined, a GenericEditor will be used.
 
-  Classes derived from this class must place their controls as child components.
-  They shouldn't try to re-draw any aspects of their background.
+    Classes derived from this class must place their controls as child components.
+    They shouldn't try to re-draw any aspects of their background.
 
-  @see GenericProcessor, EditorViewport
+    @see GenericProcessor, EditorViewport
 */
-
-
 class PLUGIN_API GenericEditor  : public AudioProcessorEditor
                                 , public Timer
                                 , public Button::Listener
@@ -60,12 +58,9 @@ class PLUGIN_API GenericEditor  : public AudioProcessorEditor
 {
 public:
     /** Constructor. Loads fonts and creates default buttons.
-     useDefaultParameter Editors false means custom parameter editors will be used.*/
+        useDefaultParameter Editors false means custom parameter editors will be used.*/
     GenericEditor (GenericProcessor* owner, bool useDefaultParameterEditors);
 
-    /** Constructor. Loads fonts and creates default buttons.*/
-    //GenericEditor (GenericProcessor* owner);
-
     /** Destructor.*/
     virtual ~GenericEditor();
 
@@ -73,8 +68,8 @@ public:
     ========================================================================
     ============================= JUCE METHODS =============================
     ========================================================================
-    */
 
+    */
     /** Draws the editor's background.*/
     void paint (Graphics& g) override;
 
diff --git a/Source/Processors/GenericProcessor/GenericProcessor.cpp b/Source/Processors/GenericProcessor/GenericProcessor.cpp
index 743808275..ad9ffd7be 100755
--- a/Source/Processors/GenericProcessor/GenericProcessor.cpp
+++ b/Source/Processors/GenericProcessor/GenericProcessor.cpp
@@ -39,7 +39,7 @@ GenericProcessor::GenericProcessor (const String& name)
     , saveOrder                     (-1)
     , loadOrder                     (-1)
     , currentChannel                (-1)
-    , editor                        (0)
+    , editor                        (nullptr)
     , parametersAsXml               (nullptr)
     , sendSampleCount               (true)
     , m_name                            (name)
@@ -129,7 +129,7 @@ const String GenericProcessor::getParameterText (int parameterIndex)
 
 var GenericProcessor::getParameterVar (int parameterIndex, int parameterChannel)
 {
-    Parameter& p=parameters.getReference (parameterIndex);
+    Parameter& p = parameters.getReference (parameterIndex);
     return p.operator[] (parameterChannel);
 }
 
@@ -1016,7 +1016,6 @@ bool GenericProcessor::isEnabledState() const   { return isEnabled; }
 
 bool GenericProcessor::isGeneratesTimestamps() const { return false; }
 
-bool GenericProcessor::isDataFormatter() const  { return getProcessorType() == PROCESSOR_TYPE_DATA_FORMAT;   }
 bool GenericProcessor::isFilter()        const  { return getProcessorType() == PROCESSOR_TYPE_FILTER;        }
 bool GenericProcessor::isSource()        const  { return getProcessorType() == PROCESSOR_TYPE_SOURCE;        }
 bool GenericProcessor::isSink()          const  { return getProcessorType() == PROCESSOR_TYPE_SINK;          }
diff --git a/Source/Processors/GenericProcessor/GenericProcessor.h b/Source/Processors/GenericProcessor/GenericProcessor.h
index bf526f074..af4e1b6f3 100755
--- a/Source/Processors/GenericProcessor/GenericProcessor.h
+++ b/Source/Processors/GenericProcessor/GenericProcessor.h
@@ -298,9 +298,6 @@ public:
     /** Returns trus if a processor generates its own timestamps, false otherwise.*/
     virtual bool isGeneratesTimestamps() const;
 
-    /** Returns true if a processor is a data format processor (e.g. KWIKFormat), false otherwise. */
-    virtual bool isDataFormatter() const;
-
     /** Returns true if a processor is a filter processor, false otherwise. */
     virtual bool isFilter() const;
 
diff --git a/Source/Processors/Parameter/ParameterEditor.cpp b/Source/Processors/Parameter/ParameterEditor.cpp
index d863f54f8..131654116 100755
--- a/Source/Processors/Parameter/ParameterEditor.cpp
+++ b/Source/Processors/Parameter/ParameterEditor.cpp
@@ -2,7 +2,7 @@
     ------------------------------------------------------------------
 
     This file is part of the Open Ephys GUI
-    Copyright (C) 2014 Open Ephys
+    Copyright (C) 2016 Open Ephys
 
     ------------------------------------------------------------------
 
@@ -18,548 +18,450 @@
 
     You should have received a copy of the GNU General Public License
     along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
 */
 
 #include "ParameterEditor.h"
 
-ParameterEditor::ParameterEditor(GenericProcessor* proc, Parameter& p, Font labelFont)
-{
-
-    activationState = true;
 
-    processor = proc;
-
-    parameter = &p;
-
-    shouldDeactivateDuringAcquisition = p.shouldDeactivateDuringAcquisition;
+ParameterEditor::ParameterEditor (GenericProcessor* processor, Parameter& parameter, Font labelFont)
+    : m_activationState     (true)
+    , m_processor           (processor)
+    , m_parameter           (&parameter)
+{
+    shouldDeactivateDuringAcquisition = parameter.shouldDeactivateDuringAcquisition;
 
-    if (p.isBoolean())
+    if (parameter.isBoolean())
     {
         std::cout << "Boolean parameter. Creating checkbox." << std::endl;
 
         // create checkbox
-        ParameterCheckbox* pc = new ParameterCheckbox((bool) p.getDefaultValue());
-        addAndMakeVisible(pc);
-        pc->setBounds(0,0,12, 12);
-        pc->setName(String(p.getID()));
-        checkboxArray.add(pc);
-        //buttonIdArray.add(p.getID());
-        pc->addListener(this);
-
-        Label* label = new Label(p.getName(), p.getName());
-        labelFont.setHeight(10);
-        label->setColour(Label::textColourId, Colours::darkgrey);
-        label->setFont(labelFont);
-        label->setBounds(10, 1, 100, 10);
-        addAndMakeVisible(label);
+        ParameterCheckbox* pc = new ParameterCheckbox ((bool) parameter.getDefaultValue());
+        pc->setBounds (0, 0, 12, 12);
+        pc->setName (String (parameter.getID()));
+        pc->addListener (this);
+        m_checkboxArray.add (pc);
+        addAndMakeVisible (pc);
+
+        Label* label = new Label (parameter.getName(), parameter.getName());
+        labelFont.setHeight (10);
+        label->setColour (Label::textColourId, Colours::darkgrey);
+        label->setFont (labelFont);
+        label->setBounds (10, 1, 100, 10);
+        addAndMakeVisible (label);
 
         desiredWidth = 120;
         desiredHeight = 25;
-
     }
-    else if (p.isContinuous())
+    else if (parameter.isContinuous())
     {
         std::cout << "Continuous parameter. Creating slider." << std::endl;
+
         // create slider
-        Array<var> possibleValues = p.getPossibleValues();
-        ParameterSlider* ps = new ParameterSlider((float) possibleValues[0],
-                                                  (float) possibleValues[1],
-                                                  (float) p.getDefaultValue(),
-                                                  labelFont);
-
-        ps->setBounds(0,0, 80, 80);
-        ps->setName(String(p.getID()));
-        addAndMakeVisible(ps);
-        sliderArray.add(ps);
-        //sliderIdArray.add(p.getID());
-        ps->addListener(this);
-
-        Label* label = new Label(p.getName(), p.getName());
-        labelFont.setHeight(10);
-        int width = labelFont.getStringWidth(p.getName());
-        label->setColour(Label::textColourId, Colours::darkgrey);
-        label->setFont(labelFont);
-        label->setBounds((80-width)/2-5, 70, 100, 10);
-        addAndMakeVisible(label);
+        Array<var> possibleValues = parameter.getPossibleValues();
+        ParameterSlider* ps = new ParameterSlider ((float) possibleValues[0],
+                                                   (float) possibleValues[1],
+                                                   (float) parameter.getDefaultValue(),
+                                                   labelFont);
+
+        ps->setBounds (0, 0, 80, 80);
+        ps->setName (String (parameter.getID()));
+        ps->addListener (this);
+        addAndMakeVisible (ps);
+        m_sliderArray.add (ps);
+
+        Label* label = new Label (parameter.getName(), parameter.getName());
+        labelFont.setHeight (10);
+        const int width = labelFont.getStringWidth (parameter.getName());
+        label->setColour (Label::textColourId, Colours::darkgrey);
+        label->setFont (labelFont);
+        label->setBounds ((80 - width) / 2 - 5, 70, 100, 10);
+        addAndMakeVisible (label);
 
         desiredWidth = 80;
         desiredHeight = 80;
-
     }
-    else if (p.isDiscrete())
+    else if (parameter.isDiscrete())
     {
         std::cout << "Discrete parameter. Creating buttons." << std::endl;
+
         // create buttons
-        Label* label = new Label(p.getName(), p.getName());
-        labelFont.setHeight(10);
-        label->setColour(Label::textColourId, Colours::darkgrey);
-        label->setFont(labelFont);
-        label->setBounds(0, 0, 100, 10);
-        addAndMakeVisible(label);
+        Label* label = new Label (parameter.getName(), parameter.getName());
+        labelFont.setHeight (10);
+        label->setColour (Label::textColourId, Colours::darkgrey);
+        label->setFont (labelFont);
+        label->setBounds (0, 0, 100, 10);
+        addAndMakeVisible (label);
 
-        Array<var> possibleValues = p.getPossibleValues();
+        Array<var> possibleValues = parameter.getPossibleValues();
 
         int buttonWidth = 35;
 
         std::cout << "Button width: " << buttonWidth << std::endl;
+        std::cout << "Default value: " << (int) parameter.getDefaultValue() << std::endl;
 
-        std::cout << "Default value: " << (int) p.getDefaultValue() << std::endl;
-
-        int i;
-
-        for (i = 0; i < possibleValues.size(); i++)
+        int i = 0;
+        for (; i < possibleValues.size(); ++i)
         {
             std::cout << "Creating button " << i << std::endl;
+
             int buttonType = MIDDLE;
             if (i == 0)
                 buttonType = LEFT;
-            else if (i == possibleValues.size()-1)
+            else if (i == possibleValues.size() - 1)
                 buttonType = RIGHT;
 
-            ParameterButton* pb = new ParameterButton(possibleValues[i], buttonType, labelFont);
-            pb->setBounds(buttonWidth*i, 12, buttonWidth, 18);
-            pb->setName(String(p.getID()));
-            buttonArray.add(pb);
-            //buttonIdArray.add(p.getID());
-            pb->addListener(this);
-
-            if (i == (int) p.getDefaultValue())
-                pb->setToggleState(true, dontSendNotification);
+            ParameterButton* pb = new ParameterButton (possibleValues[i], buttonType, labelFont);
+            pb->setBounds (buttonWidth * i, 12, buttonWidth, 18);
+            pb->setName (String (parameter.getID()));
+            pb->addListener (this);
+            m_buttonArray.add (pb);
 
-            addAndMakeVisible(pb);
+            if (i == (int) parameter.getDefaultValue())
+                pb->setToggleState (true, dontSendNotification);
 
+            addAndMakeVisible (pb);
         }
 
-        desiredWidth = buttonWidth*i;
+        desiredWidth = buttonWidth * i;
         desiredHeight = 30;
     }
 }
 
-ParameterEditor::~ParameterEditor()
-{
-    deleteAllChildren();
-}
 
 void ParameterEditor::parentHierarchyChanged()
 {
-    // std::cout << "Parent hierarchy changed." << std::endl;
-
-    // // register all children with parent --> not currently working
-    // if (getParentComponent() != 0) {
-
-    // 	for (int i = 0; i < sliderArray.size(); i++)
-    // 	{
-    // 		sliderArray[i]->addListener((Slider::Listener*) getParentComponent());
-    // 	}
-
-    // 	for (int i = 0; i < buttonArray.size(); i++)
-    // 	{
-    // 		buttonArray[i]->addListener((Button::Listener*) getParentComponent());
-    // 	}
-    // }
-
 }
 
-void ParameterEditor::setChannelSelector(ChannelSelector* ch)
+
+void ParameterEditor::setChannelSelector (ChannelSelector* channelSelector)
 {
-	channelSelector = ch;
+    m_channelSelector = channelSelector;
 }
 
-void ParameterEditor::setEnabled(bool state)
-{
 
+void ParameterEditor::setEnabled (bool isEnabled)
+{
     std::cout << "Changing editor state!" << std::endl;
 
     if (shouldDeactivateDuringAcquisition)
     {
-
-        for (int i = 0; i < sliderArray.size(); i++)
+        for (int i = 0; i < m_sliderArray.size(); ++i)
         {
-            sliderArray[i]->isEnabled = state;
-            sliderArray[i]->setInterceptsMouseClicks(state, state);
-            sliderArray[i]->repaint();
+            m_sliderArray[i]->isEnabled = isEnabled;
+            m_sliderArray[i]->setInterceptsMouseClicks (isEnabled, isEnabled);
+            m_sliderArray[i]->repaint();
         }
 
-        for (int i = 0; i < buttonArray.size(); i++)
+        for (int i = 0; i < m_buttonArray.size(); ++i)
         {
-            buttonArray[i]->isEnabled = state;
-            buttonArray[i]->setInterceptsMouseClicks(state, state);
-            buttonArray[i]->repaint();
+            m_buttonArray[i]->isEnabled = isEnabled;
+            m_buttonArray[i]->setInterceptsMouseClicks (isEnabled, isEnabled);
+            m_buttonArray[i]->repaint();
         }
 
-        for (int i = 0; i < checkboxArray.size(); i++)
+        for (int i = 0; i < m_checkboxArray.size(); ++i)
         {
-            checkboxArray[i]->isEnabled = state;
-            checkboxArray[i]->setInterceptsMouseClicks(state, state);
-            checkboxArray[i]->repaint();
+            m_checkboxArray[i]->isEnabled = isEnabled;
+            m_checkboxArray[i]->setInterceptsMouseClicks (isEnabled, isEnabled);
+            m_checkboxArray[i]->repaint();
         }
-
     }
-
 }
 
-void ParameterEditor::buttonClicked(Button* button)
+
+void ParameterEditor::buttonClicked (Button* buttonThatWasClicked)
 {
-    std::cout << "Button name: " << button->getName() << std::endl;
-    std::cout << "Button value: " << button->getButtonText() << std::endl;
+    std::cout << "Button name: " << buttonThatWasClicked->getName() << std::endl;
+    std::cout << "Button value: " << buttonThatWasClicked->getButtonText() << std::endl;
 
-    ParameterButton* b = (ParameterButton*) button;
+    ParameterButton* b = (ParameterButton*) buttonThatWasClicked;
 
     if (b->isEnabled)
     {
-
-        Array<int> a = channelSelector->getActiveChannels();
+        Array<int> activeChannels = m_channelSelector->getActiveChannels();
         {
-            for (int i = 0; i < a.size(); i++)
+            for (int i = 0; i < activeChannels.size(); ++i)
             {
-                //std::cout << a[i] << " ";
-                processor->setCurrentChannel(a[i]);
-                processor->setParameter(button->getName().getIntValue(),
-                                        button->getButtonText().getFloatValue());
-                //processor->
+                m_processor->setCurrentChannel (activeChannels[i]);
+                m_processor->setParameter (buttonThatWasClicked->getName().getIntValue(),
+                                           buttonThatWasClicked->getButtonText().getFloatValue());
             }
-            //std::cout << std::endl;
         }
     }
-    //processor->sliderValueChanged(slider);
-
 }
 
-void ParameterEditor::sliderValueChanged(Slider* slider)
-{
-
 
-    //std::cout << "Slider name: " << slider->getName() << std::endl;
-    //std::cout << "Slider value: " << slider->getValue() << std::endl;
-
-    ParameterSlider* s = (ParameterSlider*) slider;
+void ParameterEditor::sliderValueChanged (Slider* sliderWhichValueHasChanged)
+{
+    ParameterSlider* s = (ParameterSlider*) sliderWhichValueHasChanged;
 
     if (s->isEnabled)
     {
-        Array<int> a = channelSelector->getActiveChannels();
+        Array<int> activeChannels = m_channelSelector->getActiveChannels();
         {
-            for (int i = 0; i < a.size(); i++)
+            for (int i = 0; i < activeChannels.size(); ++i)
             {
-                //std::cout << a[i] << " ";
-                processor->setCurrentChannel(a[i]);
-                processor->setParameter(slider->getName().getIntValue(),
-                                        slider->getValue());
-                //processor->
+                m_processor->setCurrentChannel (activeChannels[i]);
+                m_processor->setParameter (sliderWhichValueHasChanged->getName().getIntValue(),
+                                           sliderWhichValueHasChanged->getValue());
             }
-            //std::cout << std::endl;
         }
     }
 }
 
 
-
 /// ============= PARAMETER BUTTON ==================
-
-ParameterButton::ParameterButton(var value, int buttonType, Font labelFont) :
-    Button("parameter"), isEnabled(true), type(buttonType),
-    valueString(value.toString()), font(labelFont)
+ParameterButton::ParameterButton (var value, int buttonType, Font labelFont) 
+    : Button        ("parameter")
+    , isEnabled     (true)
+    , type          (buttonType)
+    , valueString   (value.toString())
+    , font          (labelFont)
 {
-
-    setButtonText(valueString);
-    setRadioGroupId(1999);
-    setClickingTogglesState(true);
-
-
-    selectedGrad = ColourGradient(Colour(240,179,12),0.0,0.0,
-                                  Colour(207,160,33),0.0, 20.0f,
-                                  false);
-    selectedOverGrad = ColourGradient(Colour(209,162,33),0.0, 5.0f,
-                                      Colour(190,150,25),0.0, 0.0f,
-                                      false);
-    usedByNonActiveGrad = ColourGradient(Colour(200,100,0),0.0,0.0,
-                                         Colour(158,95,32),0.0, 20.0f,
-                                         false);
-    usedByNonActiveOverGrad = ColourGradient(Colour(158,95,32),0.0, 5.0f,
-                                             Colour(128,70,13),0.0, 0.0f,
-                                             false);
-    neutralGrad = ColourGradient(Colour(220,220,220),0.0,0.0,
-                                 Colour(170,170,170),0.0, 20.0f,
-                                 false);
-    neutralOverGrad = ColourGradient(Colour(180,180,180),0.0,5.0f,
-                                     Colour(150,150,150),0.0, 0.0,
-                                     false);
-    deactivatedGrad = ColourGradient(Colour(120, 120, 120), 0.0, 5.0f,
-                                     Colour(100, 100, 100), 0.0, 0.0,
-                                     false);
-
+    setButtonText (valueString);
+    setRadioGroupId (1999);
+    setClickingTogglesState (true);
+
+    selectedGrad            = ColourGradient (Colour (240, 179, 12),  0.0, 0.0,
+                                              Colour (207, 160, 33),  0.0, 20.0f,
+                                              false);
+    selectedOverGrad        = ColourGradient (Colour (209, 162, 33),  0.0, 5.0f,
+                                              Colour (190, 150, 25),  0.0, 0.0f,
+                                              false);
+    usedByNonActiveGrad     = ColourGradient (Colour (200, 100, 0),   0.0, 0.0,
+                                              Colour (158, 95,  32),  0.0, 20.0f,
+                                              false);
+    usedByNonActiveOverGrad = ColourGradient (Colour (158, 95,  32),  0.0, 5.0f,
+                                              Colour (128, 70,  13),  0.0, 0.0f,
+                                              false);
+    neutralGrad             = ColourGradient (Colour (220, 220, 220), 0.0, 0.0,
+                                              Colour (170, 170, 170), 0.0, 20.0f,
+                                              false);
+    neutralOverGrad         = ColourGradient (Colour (180, 180, 180), 0.0, 5.0f,
+                                              Colour (150, 150, 150), 0.0, 0.0,
+                                              false);
+    deactivatedGrad         = ColourGradient (Colour (120, 120, 120), 0.0, 5.0f,
+                                              Colour (100, 100, 100), 0.0, 0.0,
+                                              false);
 }
 
-ParameterButton::~ParameterButton() {}
 
-void ParameterButton::paintButton(Graphics& g, bool isMouseOver, bool isButtonDown)
+void ParameterButton::paintButton (Graphics& g, bool isMouseOver, bool isButtonDown)
 {
-    g.setColour(Colours::grey);
-    g.fillPath(outlinePath);
+    g.setColour (Colours::grey);
+    g.fillPath (outlinePath);
 
-    if (colorState==1)
-    {
-        if (isMouseOver)
-            g.setGradientFill(selectedOverGrad);
-        else
-            g.setGradientFill(selectedGrad);
-    }
-    else if (colorState==2)
-    {
-        if (isMouseOver)
-            g.setGradientFill(usedByNonActiveOverGrad);
-        else
-            g.setGradientFill(usedByNonActiveGrad);
-    }
+    if (colorState == 1)
+        g.setGradientFill (isMouseOver ? selectedOverGrad : selectedGrad);
+    else if (colorState == 2)
+        g.setGradientFill (isMouseOver ? usedByNonActiveOverGrad : usedByNonActiveGrad);
     else
-    {
-        if (isMouseOver)
-            g.setGradientFill(neutralOverGrad);
-        else
-            g.setGradientFill(neutralGrad);
-    }
-
-    if (!isEnabled)
-    {
-        g.setGradientFill(deactivatedGrad);
-    }
+        g.setGradientFill (isMouseOver ? neutralOverGrad : neutralGrad);
 
-    AffineTransform a = AffineTransform::scale(0.98f, 0.94f, float(getWidth())/2.0f,
-                                               float(getHeight())/2.0f);
-    g.fillPath(outlinePath, a);
+    if (! isEnabled)
+        g.setGradientFill (deactivatedGrad);
 
-    font.setHeight(12.0f);
-    int stringWidth = font.getStringWidth(valueString);
+    AffineTransform a = AffineTransform::scale (0.98f, 0.94f, float (getWidth()) / 2.0f,
+                                                float (getHeight()) / 2.0f);
+    g.fillPath (outlinePath, a);
 
-    g.setFont(font);
+    font.setHeight (12.0f);
+    int stringWidth = font.getStringWidth (valueString);
 
-    g.setColour(Colours::darkgrey);
-    g.drawSingleLineText(valueString, getWidth()/2 - stringWidth/2, 12);
+    g.setFont (font);
 
+    g.setColour (Colours::darkgrey);
+    g.drawSingleLineText (valueString, getWidth() / 2 - stringWidth / 2, 12);
 };
 
+
 void ParameterButton::resized()
 {
-
-
     float radius = 5.0f;
 
     if (type == LEFT)
     {
-        outlinePath.startNewSubPath(0, radius);
-        outlinePath.addArc(0, 0, radius*2, radius*2, 1.5*double_Pi, 2.0*double_Pi);
+        outlinePath.startNewSubPath (0, radius);
+        outlinePath.addArc (0, 0, radius * 2, radius * 2, 1.5 * double_Pi, 2.0 * double_Pi);
 
-        outlinePath.lineTo(getWidth(), 0);//getHeight());
+        outlinePath.lineTo (getWidth(), 0);
+        outlinePath.lineTo (getWidth(), getHeight());
+        outlinePath.lineTo (radius, getHeight());
 
-        outlinePath.lineTo(getWidth(), getHeight());
-
-        outlinePath.lineTo(radius, getHeight());
-        outlinePath.addArc(0, getHeight()-radius*2, radius*2, radius*2, double_Pi, 1.5*double_Pi);
+        outlinePath.addArc (0, getHeight() - radius * 2, radius * 2, radius * 2, double_Pi, 1.5 * double_Pi);
         outlinePath.closeSubPath();
-
     }
     else if (type == RIGHT)
     {
-        outlinePath.startNewSubPath(0, 0);
+        outlinePath.startNewSubPath (0, 0);
 
-        outlinePath.lineTo(getWidth()-radius, 0);
+        outlinePath.lineTo (getWidth() - radius, 0);
 
-        outlinePath.addArc(getWidth()-radius*2, 0, radius*2, radius*2, 0, 0.5*double_Pi);
+        outlinePath.addArc (getWidth() - radius * 2, 0, radius * 2, radius * 2, 0, 0.5 * double_Pi);
 
-        outlinePath.lineTo(getWidth(), getHeight()-radius);
+        outlinePath.lineTo (getWidth(), getHeight() - radius);
 
-        outlinePath.addArc(getWidth()-radius*2, getHeight()-radius*2, radius*2, radius*2, 0.5*double_Pi, double_Pi);
+        outlinePath.addArc (getWidth() - radius * 2, getHeight() - radius * 2, radius * 2, radius * 2, 0.5 * double_Pi, double_Pi);
 
-        outlinePath.lineTo(0, getHeight());
+        outlinePath.lineTo (0, getHeight());
         outlinePath.closeSubPath();
-
-
     }
     else if (type == MIDDLE)
     {
-        outlinePath.addRectangle(0,0,getWidth(),getHeight());
+        outlinePath.addRectangle (0, 0, getWidth(), getHeight());
     }
 }
 
 
 // ==== PARAMETER CHECKBOX =======================
-
-
-ParameterCheckbox::ParameterCheckbox(bool defaultState) : Button("name"), isEnabled(true)
+ParameterCheckbox::ParameterCheckbox (bool defaultState) 
+    : Button    ("name")
+    , isEnabled (true)
 {
-    setToggleState(defaultState, dontSendNotification);
-    setClickingTogglesState(true);
-
-    selectedGrad = ColourGradient(Colour(240,179,12),0.0,0.0,
-                                  Colour(207,160,33),0.0, 20.0f,
-                                  true);
-    selectedOverGrad = ColourGradient(Colour(209,162,33),0.0, 5.0f,
-                                      Colour(190,150,25),0.0, 0.0f,
-                                      true);
-    neutralGrad = ColourGradient(Colour(220,220,220),0.0,0.0,
-                                 Colour(170,170,170),0.0, 20.0f,
-                                 true);
-    neutralOverGrad = ColourGradient(Colour(180,180,180),0.0,5.0f,
-                                     Colour(150,150,150),0.0, 0.0,
-                                     true);
-    deactivatedGrad = ColourGradient(Colour(120, 120, 120), 0.0, 5.0f,
-                                     Colour(100, 100, 100), 0.0, 0.0,
-                                     false);
+    setToggleState (defaultState, dontSendNotification);
+    setClickingTogglesState (true);
+
+    selectedGrad        = ColourGradient (Colour (240, 179, 12),  0.0, 0.0,
+                                          Colour (207, 160, 33),  0.0, 20.0f,
+                                          true);
+    selectedOverGrad    = ColourGradient (Colour (209, 162, 33),  0.0, 5.0f,
+                                          Colour (190, 150, 25),  0.0, 0.0f,
+                                          true);
+    neutralGrad         = ColourGradient (Colour (220, 220, 220), 0.0, 0.0,
+                                          Colour (170, 170, 170), 0.0, 20.0f,
+                                          true);
+    neutralOverGrad     = ColourGradient (Colour (180, 180, 180), 0.0, 5.0f,
+                                          Colour (150, 150, 150), 0.0, 0.0,
+                                          true);
+    deactivatedGrad     = ColourGradient (Colour (120, 120, 120), 0.0, 5.0f,
+                                          Colour (100, 100, 100), 0.0, 0.0,
+                                          false);
 }
 
-ParameterCheckbox::~ParameterCheckbox() {}
 
-void ParameterCheckbox::paintButton(Graphics& g, bool isMouseOver, bool isButtonDown)
+void ParameterCheckbox::paintButton (Graphics& g, bool isMouseOver, bool isButtonDown)
 {
-
-    g.setColour(Colours::grey);
+    g.setColour (Colours::grey);
     g.fillRoundedRectangle(0, 0, getWidth(), getHeight(), 2.0f);
 
     if (getToggleState())
-    {
-        if (isMouseOver)
-            g.setGradientFill(selectedOverGrad);
-        else
-            g.setGradientFill(selectedGrad);
-    }
+        g.setGradientFill (isMouseOver ? selectedOverGrad : selectedGrad);
     else
-    {
-        if (isMouseOver)
-            g.setGradientFill(neutralOverGrad);
-        else
-            g.setGradientFill(neutralGrad);
-    }
-
-    if (!isEnabled)
-    {
-        g.setGradientFill(deactivatedGrad);
-    }
-
-    // AffineTransform a = AffineTransform::scale(0.98f, 0.94f, float(getWidth())/2.0f,
-    //                                           float(getHeight())/2.0f);
+        g.setGradientFill (isMouseOver ? neutralOverGrad : neutralGrad);
 
-    g.fillRoundedRectangle(1, 1, getWidth()-2, getHeight()-2, 2.0f);
+    if (! isEnabled)
+        g.setGradientFill (deactivatedGrad);
 
+    g.fillRoundedRectangle (1, 1, getWidth() - 2, getHeight() - 2, 2.0f);
 }
 
-// ========== PARAMETER SLIDER ====================
 
-ParameterSlider::ParameterSlider(float min, float max, float def, Font labelFont) :
-    Slider("name"), isEnabled(true), font(labelFont)
+// ========== PARAMETER SLIDER ====================
+ParameterSlider::ParameterSlider (float minValue, float maxValue, float def, Font labelFont) 
+    : Slider    ("name")
+    , isEnabled (true)
+    , font      (labelFont)
 {
-    setSliderStyle(Slider::Rotary);
-    setRange(min,max,1.0f);
-    setValue(def);
-    setTextBoxStyle(Slider::NoTextBox, false, 40, 20);
+    setSliderStyle (Slider::Rotary);
+    setRange (minValue, maxValue, 1.0f);
+    setValue (def);
+    setTextBoxStyle (Slider::NoTextBox, false, 40, 20);
 
     setColour (Slider::rotarySliderFillColourId, Colour (240, 179, 12));
 }
 
-ParameterSlider::~ParameterSlider() {}
 
-void ParameterSlider::paint(Graphics& g)
+void ParameterSlider::paint (Graphics& g)
 {
-
-    ColourGradient grad = ColourGradient(Colour(40, 40, 40), 0.0f, 0.0f,
-
-                                         Colour(80, 80, 80), 0.0, 40.0f, false);
+    ColourGradient grad = ColourGradient (Colour (40, 40, 40), 0.0f, 0.0f,
+                                          Colour (80, 80, 80), 0.0f, 40.0f,
+                                          false);
 
     Path p;
-    p.addPieSegment(3, 3, getWidth()-6, getHeight()-6, 5*double_Pi/4-0.2, 5*double_Pi/4+3*double_Pi/2+0.2, 0.5);
-
-    g.setGradientFill(grad);
-    g.fillPath(p);
-    //g.fillEllipse(3, 3, getWidth()-6, getHeight()-6);
+    p.addPieSegment (3, 3,
+                     getWidth() - 6, getHeight() - 6,
+                     5 * double_Pi / 4 - 0.2, 5 * double_Pi / 4 + 3 * double_Pi / 2 + 0.2,
+                     0.5);
 
-    //g.setColour(Colours::lightgrey);
-    //g.fillEllipse(12, 12, getWidth()-24, getHeight()-24);
+    g.setGradientFill (grad);
+    g.fillPath (p);
 
-    p = makeRotaryPath(getMinimum(), getMaximum(), getValue());
+    p = makeRotaryPath (getMinimum(), getMaximum(), getValue());
 
     if (isEnabled)
         g.setColour (findColour (Slider::rotarySliderFillColourId));
     else
-        g.setColour(Colour(75,75,75));
-
-    g.fillPath(p);
-
-    //g.setColour(Colours::darkgrey);
-    font.setHeight(9.0);
-    g.setFont(font);
+        g.setColour (Colour (75, 75, 75));
 
+    g.fillPath (p);
 
-    String valueString = String((int) getValue());
+    font.setHeight (9.0);
+    g.setFont (font);
 
-    int stringWidth = font.getStringWidth(valueString);
+    String valueString = String ((int) getValue());
 
-    g.setFont(font);
+    const int stringWidth = font.getStringWidth (valueString);
 
-    g.setColour(Colours::darkgrey);
-    g.drawSingleLineText(valueString, getWidth()/2 - stringWidth/2, getHeight()/2+3);
+    g.setFont (font);
 
+    g.setColour (Colours::darkgrey);
+    g.drawSingleLineText (valueString, getWidth() / 2 - stringWidth / 2, getHeight() / 2 + 3);
 }
 
-Path ParameterSlider::makeRotaryPath(double min, double max, double val)
+
+Path ParameterSlider::makeRotaryPath (double minValue, double maxValue, double value)
 {
     Path p;
 
-    double start = 5*double_Pi/4 - 0.11;
-
-    double range = (val-min)/(max - min)*1.5*double_Pi + start + 0.22;
-
-    p.addPieSegment(6,6, getWidth()-12, getHeight()-12, start, range, 0.65);
+    const double start = 5 * double_Pi / 4 - 0.11;
+    const double range = (value - minValue) / (maxValue - minValue) *1.5 * double_Pi + start + 0.22;
 
-    // p.startNewSubPath(5, getHeight()-5);
-    // p.addArc(5, 5, getWidth()-10, getWidth()-10, 5/4*double_Pi, range);
-    // //p.addArc(getWidth()-5, getHeight()-5, getWidth()-16, getWidth()-16, 5/4*double_Pi, range);
-    // p.closeSubPath();
+    p.addPieSegment (6, 6,
+                     getWidth() - 12, getHeight() - 12,
+                     start, range,
+                     0.65);
 
     return p;
 }
 
-void ParameterEditor::channelSelectionUI()
-{
 
-    int numChannels=channelSelector->getNumChannels();
-    if (parameter->isBoolean())
+void ParameterEditor::updateChannelSelectionUI()
+{
+    const int numChannels = m_channelSelector->getNumChannels();
+    if (m_parameter->isBoolean())
     {
     }
-    else if (parameter->isContinuous())
+    else if (m_parameter->isContinuous())
     {
 
     }
-    else if (parameter->isDiscrete())
+    else if (m_parameter->isDiscrete())
     {
         std::cout << "Calculating colors for discrete buttons" << std::endl;
-        Array<var> possibleValues=parameter->getPossibleValues();
+        Array<var> possibleValues = m_parameter->getPossibleValues();
 
-        for (int i = 0; i < buttonArray.size(); i++)
+        for (int i = 0; i < m_buttonArray.size(); ++i)
         {
-            buttonArray[i]->colorState=0;
+            m_buttonArray[i]->colorState = 0;
 
-            for (int j = 0; j < numChannels; j++)
+            for (int j = 0; j < numChannels; ++j)
             {
-
-                if (possibleValues[i]==parameter->getValue(j))
+                if (possibleValues[i] == m_parameter->getValue (j))
                 {
-
-                    if (channelSelector->getParamStatus(j))
+                    if (m_channelSelector->getParamStatus (j))
                     {
                         /* Set button as usedbyactive */
-                        buttonArray[i]->colorState=1;
-
+                        m_buttonArray[i]->colorState = 1;
                     }
-                    else if (buttonArray[i]->colorState==0)
+                    else if (m_buttonArray[i]->colorState == 0)
                     {
                         // Set button as used by non-selected
-                        buttonArray[i]->colorState=2;
+                        m_buttonArray[i]->colorState = 2;
                     }
-
                 }
             }
-            buttonArray[i]->repaint();
-
 
+            m_buttonArray[i]->repaint();
         }
     }
 }
diff --git a/Source/Processors/Parameter/ParameterEditor.h b/Source/Processors/Parameter/ParameterEditor.h
index 65ab696c0..43ce8ffe4 100755
--- a/Source/Processors/Parameter/ParameterEditor.h
+++ b/Source/Processors/Parameter/ParameterEditor.h
@@ -2,7 +2,7 @@
     ------------------------------------------------------------------
 
     This file is part of the Open Ephys GUI
-    Copyright (C) 2014 Open Ephys
+    Copyright (C) 2016 Open Ephys
 
     ------------------------------------------------------------------
 
@@ -18,7 +18,6 @@
 
     You should have received a copy of the GNU General Public License
     along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
 */
 
 #ifndef __PARAMETEREDITOR_H_44537DA9__
@@ -35,52 +34,51 @@ class ParameterButton;
 class ParameterSlider;
 class ParameterCheckbox;
 
-/**
-
-  Automatically creates an interactive editor for a particular
-  parameter.
 
-  @see GenericEditor, GenericProcessor, Parameter
+/**
+    Automatically creates an interactive editor for a particular
+    parameter.
 
+    @see GenericEditor, GenericProcessor, Parameter
 */
-
-class PLUGIN_API ParameterEditor : public Component,
-    public Button::Listener,
-    public Slider::Listener
-
+class PLUGIN_API ParameterEditor : public Component
+                                 , public Button::Listener
+                                 , public Slider::Listener
 {
 public:
-    ParameterEditor(GenericProcessor* proc, Parameter& p, Font labelFont);
-    ~ParameterEditor();
+    ParameterEditor (GenericProcessor* proccessor, Parameter& parameter, Font labelFont);
 
+    void parentHierarchyChanged() override;
 
-    int desiredWidth;
-    int desiredHeight;
+    void buttonClicked (Button* buttonThatWasClicked) override;
+    void sliderValueChanged (Slider* sliderWhichValueHasChanged) override;
 
-    void parentHierarchyChanged();
+    void setChannelSelector (ChannelSelector* channelSelector);
 
-    void buttonClicked(Button* button);
-    void sliderValueChanged(Slider* slider);
+    // for inactivation during acquisition:
+    void setEnabled (bool isEnabled);
+    void updateChannelSelectionUI();
 
-	void setChannelSelector(ChannelSelector* ch);
+    int desiredWidth;
+    int desiredHeight;
 
-    // for inactivation during acquisition:
-    void setEnabled(bool t);
     bool shouldDeactivateDuringAcquisition;
-    bool activationState;
-    void channelSelectionUI();
+
+
 private:
+    bool m_activationState;
 
-    Array<ParameterSlider*> sliderArray;
-    Array<ParameterButton*> buttonArray;
-    Array<ParameterCheckbox*> checkboxArray;
-    Array<int> buttonIdArray;
-    Array<int> sliderIdArray;
-    Array<int> checkboxIdArray;
+    GenericProcessor* m_processor;
+    Parameter* m_parameter;
+    ScopedPointer<ChannelSelector> m_channelSelector;
 
-    Parameter* parameter;
-    GenericProcessor* processor;
-    ScopedPointer<ChannelSelector> channelSelector;
+    OwnedArray<ParameterSlider>     m_sliderArray;
+    OwnedArray<ParameterButton>     m_buttonArray;
+    OwnedArray<ParameterCheckbox>   m_checkboxArray;
+
+    Array<int> m_buttonIdArray;
+    Array<int> m_sliderIdArray;
+    Array<int> m_checkboxIdArray;
 
     enum
     {
@@ -88,29 +86,24 @@ private:
         MIDDLE,
         RIGHT
     };
-
 };
 
-/**
-
-  Used to edit discrete parameters.
-
-*/
 
+/** Used to edit discrete parameters.  */
 class PLUGIN_API ParameterButton : public Button
-
 {
 public:
-    ParameterButton(var value, int buttonType, Font labelFont);
-	~ParameterButton();
+    ParameterButton (var value, int buttonType, Font labelFont);
 
     bool isEnabled;
     //Used to mark if unused, usedByActive, or usedby inactive
     int colorState;
+
+
 private:
-    void paintButton(Graphics& g, bool isMouseOver, bool isButtonDown);
+    void paintButton (Graphics& g, bool isMouseOver, bool isButtonDown) override;
 
-    void resized();
+    void resized() override;
 
     int type;
 
@@ -134,26 +127,20 @@ private:
         MIDDLE,
         RIGHT
     };
-
 };
 
-/**
-
-  Used to edit boolean parameters.
-
-*/
 
+/** Used to edit boolean parameters.  */
 class PLUGIN_API ParameterCheckbox : public Button
-
 {
 public:
-    ParameterCheckbox(bool defaultState);
-	~ParameterCheckbox();
+    ParameterCheckbox (bool defaultState);
 
     bool isEnabled;
 
+
 private:
-    void paintButton(Graphics& g, bool isMouseOver, bool isButtonDown);
+    void paintButton (Graphics& g, bool isMouseOver, bool isButtonDown);
 
     ColourGradient selectedGrad;
     ColourGradient selectedOverGrad;
@@ -162,25 +149,20 @@ private:
     ColourGradient deactivatedGrad;
 };
 
-/**
-
-  Used to edit continuous parameters.
-
-*/
 
+/** Used to edit continuous parameters.  */
 class PLUGIN_API ParameterSlider : public Slider
-
 {
 public:
-    ParameterSlider(float min, float max, float defaultValue, Font f);
-	~ParameterSlider();
+    ParameterSlider (float minValue, float maxValue, float defaultValue, Font f);
 
     bool isEnabled;
 
+
 private:
-    void paint(Graphics& g);//Button(Graphics& g, bool isMouseOver, bool isButtonDown);
+    void paint (Graphics& g);//Button(Graphics& g, bool isMouseOver, bool isButtonDown);
 
-    Path makeRotaryPath(double, double, double);
+    Path makeRotaryPath (double minValue, double maxValue, double value);
 
     Font font;
 };
-- 
GitLab