Mouse press event. This UI will de/activate blocks when you click them and reports it as a parameter change to the plugin. */
| 181 | This UI will de/activate blocks when you click them and reports it as a parameter change to the plugin. |
| 182 | */ |
| 183 | bool onMouse(const MouseEvent& ev) override |
| 184 | { |
| 185 | // Test for left-clicked + pressed first. |
| 186 | if (ev.button != 1 || ! ev.press) |
| 187 | return false; |
| 188 | |
| 189 | const uint width = getWidth(); |
| 190 | const uint height = getHeight(); |
| 191 | const uint minwh = std::min(width, height); |
| 192 | |
| 193 | Rectangle<double> r; |
| 194 | |
| 195 | r.setWidth(minwh/3 - 6); |
| 196 | r.setHeight(minwh/3 - 6); |
| 197 | |
| 198 | // handle left, center and right columns |
| 199 | for (int i=0; i<3; ++i) |
| 200 | { |
| 201 | r.setX(3 + i*minwh/3); |
| 202 | |
| 203 | // top |
| 204 | r.setY(3); |
| 205 | |
| 206 | if (r.contains(ev.pos)) |
| 207 | { |
| 208 | // parameter index that this block applies to |
| 209 | const uint32_t index = 0+i; |
| 210 | |
| 211 | // invert block state |
| 212 | fParamGrid[index] = !fParamGrid[index]; |
| 213 | |
| 214 | // report change to host (and thus plugin) |
| 215 | editParameter(index, true); |
| 216 | setParameterValue(index, fParamGrid[index] ? 1.0f : 0.0f); |
| 217 | editParameter(index, false); |
| 218 | |
| 219 | // trigger repaint |
| 220 | repaint(); |
| 221 | break; |
| 222 | } |
| 223 | |
| 224 | // middle |
| 225 | r.setY(3 + minwh/3); |
| 226 | |
| 227 | if (r.contains(ev.pos)) |
| 228 | { |
| 229 | // same as before |
| 230 | const uint32_t index = 3+i; |
| 231 | fParamGrid[index] = !fParamGrid[index]; |
| 232 | editParameter(index, true); |
| 233 | setParameterValue(index, fParamGrid[index] ? 1.0f : 0.0f); |
| 234 | editParameter(index, false); |
| 235 | repaint(); |
| 236 | break; |
| 237 | } |
| 238 | |
| 239 | // bottom |
| 240 | r.setY(3 + minwh*2/3); |
nothing calls this directly
no test coverage detected