From 13650eea44a1cf5953b5170b3e73c4b3d034c95e Mon Sep 17 00:00:00 2001
From: jsiegle <joshs@alleninstitute.org>
Date: Fri, 19 Sep 2014 13:22:26 -0700
Subject: [PATCH] Add scroll buttons to ChannelMappingEditor

---
 .../Editors/ChannelMappingEditor.cpp          | 51 +++++++++++++++----
 .../Processors/Editors/ChannelMappingEditor.h |  2 +
 Source/Processors/FileReader.cpp              |  2 +-
 3 files changed, 44 insertions(+), 11 deletions(-)

diff --git a/Source/Processors/Editors/ChannelMappingEditor.cpp b/Source/Processors/Editors/ChannelMappingEditor.cpp
index 6886d5a43..0b87d439b 100644
--- a/Source/Processors/Editors/ChannelMappingEditor.cpp
+++ b/Source/Processors/Editors/ChannelMappingEditor.cpp
@@ -58,17 +58,17 @@ ChannelMappingEditor::ChannelMappingEditor(GenericProcessor* parentNode, bool us
     resetButton->setClickingTogglesState(false);
     resetButton->setEnabled(false);
 
-    // upButton = new TriangleButton(1);
-    // upButton->addListener(this);
-    // upButton->setBounds(285,10,10,8);
-    // addAndMakeVisible(upButton);
-    // upButton->setVisible(false);
+    upButton = new TriangleButton(1);
+    upButton->addListener(this);
+    upButton->setBounds(320,30,10,8);
+    addAndMakeVisible(upButton);
+    upButton->setVisible(false);
 
-    // downButton = new TriangleButton(2);
-    // downButton->addListener(this);
-    // downButton->setBounds(285,25,10,8);
-    // addAndMakeVisible(downButton);
-    // downButton->setVisible(false);
+    downButton = new TriangleButton(2);
+    downButton->addListener(this);
+    downButton->setBounds(320,45,10,8);
+    addAndMakeVisible(downButton);
+    downButton->setVisible(false);
 
 
     //    channelSelector->setRadioStatus(true);
@@ -201,6 +201,15 @@ void ChannelMappingEditor::createElectrodeButtons(int numNeeded, bool clearPrevi
     channelSelector->setRadioStatus(true);
 
     refreshButtonLocations();
+
+    if (numNeeded > 100)
+    {
+        upButton->setVisible(true);
+        downButton->setVisible(true);
+    } else {
+        upButton->setVisible(false);
+        downButton->setVisible(false);
+    }
 }
 
 void ChannelMappingEditor::refreshButtonLocations()
@@ -484,6 +493,28 @@ void ChannelMappingEditor::buttonEvent(Button* button)
 
 
         }
+    } else if (button == upButton)
+    {
+
+        scrollDistance -= 1;
+
+        if (scrollDistance < 0)
+            scrollDistance = 0;
+
+        refreshButtonLocations();
+
+    } else if (button == downButton)
+    {
+
+        float maxScrollDistance = ceil(float(electrodeButtons.size() - 80) / 16.0f);
+        
+        scrollDistance += 1;
+
+        if (scrollDistance > maxScrollDistance)
+            scrollDistance = maxScrollDistance;
+
+        refreshButtonLocations();
+    
     }
 }
 
diff --git a/Source/Processors/Editors/ChannelMappingEditor.h b/Source/Processors/Editors/ChannelMappingEditor.h
index 1def1ca82..d84126c82 100644
--- a/Source/Processors/Editors/ChannelMappingEditor.h
+++ b/Source/Processors/Editors/ChannelMappingEditor.h
@@ -83,6 +83,8 @@ private:
     ScopedPointer<ElectrodeEditorButton> selectAllButton;
     ScopedPointer<ElectrodeEditorButton> modifyButton;
     ScopedPointer<ElectrodeEditorButton> resetButton;
+    ScopedPointer<TriangleButton> upButton;
+    ScopedPointer<TriangleButton> downButton;
 
     Array<int> channelArray;
     Array<int> referenceArray;
diff --git a/Source/Processors/FileReader.cpp b/Source/Processors/FileReader.cpp
index d99534cc2..b4c239f9b 100644
--- a/Source/Processors/FileReader.cpp
+++ b/Source/Processors/FileReader.cpp
@@ -73,7 +73,7 @@ float FileReader::getDefaultSampleRate()
 
 int FileReader::getDefaultNumOutputs()
 {
-    return 128;
+    return 16;
 }
 
 float FileReader::getDefaultBitVolts()
-- 
GitLab