Open Ephys GUI
 All Classes Functions Variables Pages
ProcessorList.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 __PROCESSORLIST_H_C3A661E9__
25 #define __PROCESSORLIST_H_C3A661E9__
26 
27 #include "../../JuceLibraryCode/JuceHeader.h"
28 #include "../Processors/Visualization/OpenGLCanvas.h"
29 #include "../AccessClass.h"
30 
31 /**
32 
33  Holds a list of processors that can be used to build the signal
34  chain.
35 
36  Must be manually updated every time a new processor is created,
37  and the names must match those recognized by the ProcessorGraph.
38 
39  @see ProcessorViewport, ProcessorGraph
40 
41 */
42 
43 class ProcessorListItem;
44 class UIComponent;
45 
46 class ProcessorList : public OpenGLCanvas,
47  public DragAndDropContainer,
48  public AccessClass,
49  public ChangeListener
50 
51 {
52 public:
53 
54  ProcessorList();
55  ~ProcessorList();
56  void newOpenGLContextCreated();
57  void renderOpenGL();
58 
59  //void setUIComponent(UIComponent* ui) {UI = ui;}
60  void toggleState();
61 
62  void changeListenerCallback(ChangeBroadcaster* source);
63 
64  bool isOpen();
65 
66 private:
67 
68  void drawItems();
69  void drawItem(ProcessorListItem*);
70  void drawItemName(ProcessorListItem*);
71  void drawButton(bool isOpen);
72 
73  ProcessorListItem* getListItemForYPos(int y);
74 
75  void setViewport(bool);
76 
77 
78  enum {
79  PROCESSOR_COLOR = 801,
80  FILTER_COLOR = 802,
81  SINK_COLOR = 803,
82  SOURCE_COLOR = 804,
83  UTILITY_COLOR = 805,
84  };
85 
86  int currentColor;
87 
88  int getTotalHeight();
89  void clearSelectionState();
90 
91  bool isDragging;
92  int totalHeight, itemHeight, subItemHeight;
93  int xBuffer, yBuffer;
94 
95  String category;
96 
97  void mouseDownInCanvas(const MouseEvent& e);
98  void mouseDragInCanvas(const MouseEvent& e);
99 
100  ProcessorListItem* baseItem;
101 
102  JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ProcessorList);
103 
104 };
105 
106 class ProcessorListItem : public Component
107 {
108 public:
109  ProcessorListItem(const String& name);
111 
112  int getNumSubItems();
113  ProcessorListItem* getSubItem (int index);
114 
115  void clearSubItems();
116  void addSubItem (ProcessorListItem* newItem);
117  void removeSubItem (int index);
118  bool hasSubItems();
119 
120  bool isOpen();
121  void setOpen(bool);
122  bool isSelected() {return selected;}
123  void setSelected(bool b) {selected = b;}
124 
125  void reverseOpenState() {open = !open;}
126 
127  const String& getName();
128  const String& getParentName();
129  void setParentName(const String& name);
130 
131  //Colour color;
132  int colorId;
133 
134 private:
135 
136  bool selected;
137  bool open;
138  const String name;
139  String parentName;
140  OwnedArray<ProcessorListItem> subItems;
141 
142 };
143 
144 
145 #endif // __PROCESSORLIST_H_C3A661E9__