MCPcopy Create free account
hub / github.com/DISTRHO/DPF / onMouse

Function onMouse

tests/widgets/ExampleRectanglesWidget.hpp:107–157  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105 }
106
107 bool onMouse(const Widget::MouseEvent& ev) override
108 {
109 if (ev.button != 1 || ! ev.press)
110 return false;
111
112 const uint width = BaseWidget::getWidth();
113 const uint height = BaseWidget::getHeight();
114
115 Rectangle<double> r;
116
117 r.setWidth(width/3 - 6);
118 r.setHeight(height/3 - 6);
119
120 // draw a 3x3 grid
121 for (int i=0; i<3; ++i)
122 {
123 r.setX(3 + i*width/3);
124
125 // 1st
126 r.setY(3);
127
128 if (r.contains(ev.pos))
129 {
130 clicked[0+i] = !clicked[0+i];
131 BaseWidget::repaint();
132 break;
133 }
134
135 // 2nd
136 r.setY(3 + height/3);
137
138 if (r.contains(ev.pos))
139 {
140 clicked[3+i] = !clicked[3+i];
141 BaseWidget::repaint();
142 break;
143 }
144
145 // 3rd
146 r.setY(3 + height*2/3);
147
148 if (r.contains(ev.pos))
149 {
150 clicked[6+i] = !clicked[6+i];
151 BaseWidget::repaint();
152 break;
153 }
154 }
155
156 return true;
157 }
158};
159
160// SubWidget

Callers

nothing calls this directly

Calls 8

setXMethod · 0.80
setYMethod · 0.80
getWidthFunction · 0.50
getHeightFunction · 0.50
repaintFunction · 0.50
setWidthMethod · 0.45
setHeightMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected