Mercurial > hg > touchkeys
comparison Source/Display/KeyboardDisplay.h @ 27:eef567a60146
Changed how OpenGL updates are handled so the canvas is only re-rendered when something changes. This should reduce CPU usage in certain circumstances.
author | Andrew McPherson <andrewm@eecs.qmul.ac.uk> |
---|---|
date | Sun, 02 Mar 2014 19:25:50 +0000 |
parents | 73d2ec21de9a |
children | 73576f49ad1c |
comparison
equal
deleted
inserted
replaced
26:90069a503079 | 27:eef567a60146 |
---|---|
93 } Point; | 93 } Point; |
94 | 94 |
95 public: | 95 public: |
96 KeyboardDisplay(); | 96 KeyboardDisplay(); |
97 virtual ~KeyboardDisplay() {} | 97 virtual ~KeyboardDisplay() {} |
98 | |
99 // Set canvas for triggering rendering; | |
100 void setCanvas(OpenGLJuceCanvas *canvas) { canvas_ = canvas; } | |
101 void tellCanvasToRepaint(); | |
98 | 102 |
99 // Setup methods for display size and keyboard range | 103 // Setup methods for display size and keyboard range |
100 void setKeyboardRange(int lowest, int highest); | 104 void setKeyboardRange(int lowest, int highest); |
101 float keyboardAspectRatio() { return totalDisplayWidth_ / totalDisplayHeight_; } | 105 float keyboardAspectRatio() { return totalDisplayWidth_ / totalDisplayHeight_; } |
102 virtual void setDisplaySize(float width, float height); | 106 virtual void setDisplaySize(float width, float height); |
103 | 107 |
104 // Drawing methods | 108 // Drawing methods |
105 virtual bool needsRender() { return needsUpdate_; } | |
106 virtual void render(); | 109 virtual void render(); |
107 | 110 |
108 // Interaction methods | 111 // Interaction methods |
109 virtual void mouseDown(float x, float y); | 112 virtual void mouseDown(float x, float y); |
110 virtual void mouseDragged(float x, float y); | 113 virtual void mouseDragged(float x, float y); |
157 | 160 |
158 // Figure out which key (if any) the current point corresponds to | 161 // Figure out which key (if any) the current point corresponds to |
159 int keyForLocation(Point& internalPoint); | 162 int keyForLocation(Point& internalPoint); |
160 | 163 |
161 protected: | 164 protected: |
162 | 165 OpenGLJuceCanvas *canvas_; // Reference to object which handles rendering |
166 | |
163 int lowestMidiNote_, highestMidiNote_; // Which keys should be displayed (use MIDI note numbers) | 167 int lowestMidiNote_, highestMidiNote_; // Which keys should be displayed (use MIDI note numbers) |
164 float totalDisplayWidth_, totalDisplayHeight_; // Size of the internal view (centered around origin) | 168 float totalDisplayWidth_, totalDisplayHeight_; // Size of the internal view (centered around origin) |
165 float displayPixelWidth_, displayPixelHeight_; // Pixel resolution of the surrounding window | 169 float displayPixelWidth_, displayPixelHeight_; // Pixel resolution of the surrounding window |
166 bool needsUpdate_; // Whether the keyboard should be redrawn | |
167 int currentHighlightedKey_; // What key is being clicked on at the moment | 170 int currentHighlightedKey_; // What key is being clicked on at the moment |
168 bool touchSensingEnabled_; // Whether touch-sensitive keys are being used | 171 bool touchSensingEnabled_; // Whether touch-sensitive keys are being used |
169 bool touchSensingPresentOnKey_[128]; // Whether the key with this MIDI note has a touch sensor | 172 bool touchSensingPresentOnKey_[128]; // Whether the key with this MIDI note has a touch sensor |
170 | 173 |
171 bool analogSensorsPresent_; // Whether the given device has analog sensors at all | 174 bool analogSensorsPresent_; // Whether the given device has analog sensors at all |