Open Ephys GUI
 All Classes Functions Variables Pages
OpenGLCanvas.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 __OPENGLCANVAS_H_98F0C13D__
25 #define __OPENGLCANVAS_H_98F0C13D__
26 
27 #include "../../../JuceLibraryCode/JuceHeader.h"
28 
29 #include "../../OpenGL.h"
30 
31 class OpenGLCanvas : public OpenGLComponent, Timer
32 
33 {
34 public:
35  OpenGLCanvas();
36  ~OpenGLCanvas();
37 
38  void setUp2DCanvas();
39  void activateAntiAliasing();
40 
41  virtual void refreshState() {};
42 
43 
44 
45  void resized();
46  virtual void canvasWasResized() { }
47 
48  void mouseDown(const MouseEvent& e);
49  void mouseDrag(const MouseEvent& e);
50  void mouseMove(const MouseEvent& e);
51  void mouseUp(const MouseEvent& e);
52  void mouseWheelMove(const MouseEvent&, float, float);
53 
54  virtual void mouseDownInCanvas(const MouseEvent& e) {}
55  virtual void mouseDragInCanvas(const MouseEvent& e) {}
56  virtual void mouseMoveInCanvas(const MouseEvent& e) {}
57  virtual void mouseUpInCanvas(const MouseEvent& e) {}
58  virtual void mouseWheelMoveInCanvas(const MouseEvent&,
59  float,
60  float) {}
61 
62  void startCallbacks();
63  void stopCallbacks();
64 
65  int getScrollAmount() {return scrollPix;};
66  int getScrollBarWidth() {return scrollBarWidth;}
67  void drawScrollBars();
68 
69  void drawRoundedRect(float x, float y, float w, float h, float r, int n);
70 
71  FTGLPixmapFont* getFont(String fontName);
72 
73 protected:
74 
75  virtual int getTotalHeight() = 0;
76  int scrollPix;
77  void showScrollBars();
78 
79  bool animationIsActive;
80 
81 private:
82 
83 
84 
85  int refreshMs;
86 
87  void loadFonts();
88 
89  void drawScrollBar(float y1, float y2, float alpha);
90 
91 
92  int scrollBarWidth, scrollDiff, originalScrollPix;
93  int scrollTime;
94  bool showScrollTrack;
95 
96  Time* timer;
97  void timerCallback();
98 
99  float scrollBarTop, scrollBarBottom;
100 
101  OwnedArray<FTGLPixmapFont> fontList;
102 
103  const float PI;
104 
105  JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OpenGLCanvas);
106 
107 };
108 
109 
110 #endif // __OPENGLCANVAS_H_98F0C13D__