Open Ephys GUI
 All Classes Functions Variables Pages
GenericEditor.h
1 /*
2  ------------------------------------------------------------------
3 
4  This file is part of the Open Ephys GUI
5  Copyright (C) 2012 Open Ephys
6 
7  ------------------------------------------------------------------
8 
9  This program is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program. If not, see <http://www.gnu.org/licenses/>.
21 
22 */
23 
24 #ifndef __GENERICEDITOR_H_DD406E71__
25 #define __GENERICEDITOR_H_DD406E71__
26 
27 #include "../../../JuceLibraryCode/JuceHeader.h"
28 #include "../GenericProcessor.h"
29 #include "../../AccessClass.h"
30 #include <stdio.h>
31 
32 /**
33 
34  Base class for creating processor editors.
35 
36  If a processor doesn't havesign an editor defined, a GenericEditor will be used.
37 
38  Classes derived from this class must place their controls as child components.
39  They shouldn't try to re-draw any aspects of their background.
40 
41  @see GenericProcessor, EditorViewport
42 
43 */
44 
45 class GenericProcessor;
46 class DrawerButton;
47 class TriangleButton;
48 class UtilityButton;
49 class ParameterEditor;
50 class ChannelSelector;
51 
52 class GenericEditor : public AudioProcessorEditor,
53  public Timer,
54  public AccessClass,
55  public Button::Listener,
56  public Slider::Listener
57 
58 {
59 public:
61  virtual ~GenericEditor();
62 
63  void paint (Graphics& g);
64 
65  bool keyPressed (const KeyPress& key);
66 
67  void switchSelectedState();
68  void select();
69  void highlight();
70  void deselect();
71  bool getSelectionState();
72 
73  void enable();
74  void disable();
75  bool getEnabledState();
76  void setEnabledState(bool);
77 
78  String getName() {return name;}
79 
80  int desiredWidth;
81  int nodeId;
82 
83  virtual void tabNumber(int t) {tNum = t;}
84  int tabNumber() {return tNum;}
85 
86  virtual void switchSource(int) { } // needed for MergerEditor
87  virtual void switchSource() { }; // needed for MergerEditor
88 
89  GenericProcessor* getProcessor() const {return (GenericProcessor*) getAudioProcessor();}
90 
91  void fadeIn();
92 
93  bool isFading;
94 
95  float accumulator;
96 
97  virtual void switchDest() { }
98  virtual void switchIO(int) { }
99 
100  virtual void buttonClicked(Button* button);
101  virtual void buttonEvent(Button* button) {}
102  virtual void sliderValueChanged(Slider* slider);
103  virtual void sliderEvent(Slider* slider) {}
104  virtual void editorWasClicked() {}
105 
106  bool checkDrawerButton(Button* button);
107 // bool checkParameterButtons(Button* button);
108 
109  bool getRecordStatus(int chan);
110  bool getAudioStatus(int chan);
111 
112  void selectChannels(Array<int>);
113 
114  void refreshColors();
115 
116  virtual void update();
117  virtual void updateSettings() {}
118  virtual void updateVisualizer() {}
119 
120  virtual void channelChanged(int chan) {}
121 
122  Array<int> getActiveChannels();
123 
124  Font titleFont;
125 
126  int getStartChannel();
127 
128 protected:
129  DrawerButton* drawerButton;
130  int drawerWidth;
131 
132  virtual void addParameterEditors();
133 
134  ChannelSelector* channelSelector;
135 
136 private:
137 
138  virtual void timerCallback();
139 
140  virtual void resized();
141 
142  Colour backgroundColor;
143  ColourGradient backgroundGradient;
144 
145  bool isSelected;
146  bool isEnabled;
147 
148  int tNum;
149 
150  String name;
151 
152  JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (GenericEditor);
153 
154 };
155 
156 
157 class DrawerButton : public Button
158 {
159 public:
160  DrawerButton(const String& name);
161  ~DrawerButton() {}
162 private:
163  void paintButton(Graphics& g, bool isMouseOver, bool isButtonDown);
164 
165 };
166 
167 
168 class TriangleButton : public Button
169 {
170 public:
171  TriangleButton(int direction_) : Button("Arrow")
172  {direction = direction_;}
173  ~TriangleButton() {}
174 private:
175  void paintButton(Graphics& g, bool isMouseOver, bool isButtonDown);
176 
177  int direction;
178 };
179 
180 class UtilityButton : public Button
181 {
182 public:
183  UtilityButton(const String& label_, Font font_);
184  ~UtilityButton() {}
185 
186  void setCorners(bool UL, bool UR, bool LL, bool LR);
187  void setRadius(float r);
188 
189  void setEnabledState(bool);
190  bool getEnabledState() {return isEnabled;}
191 
192 private:
193  void paintButton(Graphics& g, bool isMouseOver, bool isButtonDown);
194 
195  const String label;
196  Font font;
197  bool roundUL, roundUR, roundLL, roundLR;
198  float radius;
199  ColourGradient selectedGrad, selectedOverGrad, neutralGrad, neutralOverGrad;
200  Colour fontColor;
201  Path outlinePath;
202 
203  bool isEnabled;
204 
205  void resized();
206 
207 };
208 
209 
210 #endif // __GENERICEDITOR_H_DD406E71__