Mouse press event. This UI will de/activate blocks when you click them and report it as a state change to the plugin. */
| 225 | This UI will de/activate blocks when you click them and report it as a state change to the plugin. |
| 226 | */ |
| 227 | bool onMouse(const MouseEvent& ev) override |
| 228 | { |
| 229 | // Test for left-clicked + pressed first. |
| 230 | if (ev.button != 1 || ! ev.press) |
| 231 | return false; |
| 232 | |
| 233 | const uint width = getWidth(); |
| 234 | const uint height = getHeight(); |
| 235 | |
| 236 | Rectangle<double> r; |
| 237 | |
| 238 | r.setWidth(width/3 - 6); |
| 239 | r.setHeight(height/3 - 6); |
| 240 | |
| 241 | // handle left, center and right columns |
| 242 | for (int i=0; i<3; ++i) |
| 243 | { |
| 244 | r.setX(3 + i*width/3); |
| 245 | |
| 246 | // top |
| 247 | r.setY(3); |
| 248 | |
| 249 | if (r.contains(ev.pos)) |
| 250 | { |
| 251 | // index that this block applies to |
| 252 | const uint32_t index = 0+i; |
| 253 | |
| 254 | // invert block state |
| 255 | fParamGrid[index] = !fParamGrid[index]; |
| 256 | |
| 257 | // report change to host (and thus plugin) |
| 258 | setState(getStateKeyFromIndex(index), fParamGrid[index] ? "true" : "false"); |
| 259 | |
| 260 | // trigger repaint |
| 261 | repaint(); |
| 262 | break; |
| 263 | } |
| 264 | |
| 265 | // middle |
| 266 | r.setY(3 + height/3); |
| 267 | |
| 268 | if (r.contains(ev.pos)) |
| 269 | { |
| 270 | // same as before |
| 271 | const uint32_t index = 3+i; |
| 272 | fParamGrid[index] = !fParamGrid[index]; |
| 273 | setState(getStateKeyFromIndex(index), fParamGrid[index] ? "true" : "false"); |
| 274 | repaint(); |
| 275 | break; |
| 276 | } |
| 277 | |
| 278 | // bottom |
| 279 | r.setY(3 + height*2/3); |
| 280 | |
| 281 | if (r.contains(ev.pos)) |
| 282 | { |
| 283 | // same as before |
| 284 | const uint32_t index = 6+i; |
nothing calls this directly
no test coverage detected