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

Function onDisplay

examples/States/ExampleUIStates.cpp:150–221  ·  view source on GitHub ↗

The OpenGL drawing function. This UI will draw a 3x3 grid, with on/off states according to plugin state. */

Source from the content-addressed store, hash-verified

148 This UI will draw a 3x3 grid, with on/off states according to plugin state.
149 */
150 void onDisplay() override
151 {
152 const GraphicsContext& context(getGraphicsContext());
153
154 const uint width = getWidth();
155 const uint height = getHeight();
156 const uint minwh = std::min(width, height);
157 const uint bgColor = getBackgroundColor();
158
159 Rectangle<double> r;
160
161 // if host doesn't respect aspect-ratio but supports ui background, draw out-of-bounds color from it
162 if (width != height && bgColor != 0)
163 {
164 const int red = (bgColor >> 24) & 0xff;
165 const int green = (bgColor >> 16) & 0xff;
166 const int blue = (bgColor >> 8) & 0xff;
167 Color(red, green, blue).setFor(context);
168
169 if (width > height)
170 {
171 r.setPos(height, 0);
172 r.setSize(width-height, height);
173 }
174 else
175 {
176 r.setPos(0, width);
177 r.setSize(width, height-width);
178 }
179
180 r.draw(context);
181 }
182
183 r.setWidth(minwh/3 - 6);
184 r.setHeight(minwh/3 - 6);
185
186 // draw left, center and right columns
187 for (int i=0; i<3; ++i)
188 {
189 r.setX(3 + i*minwh/3);
190
191 // top
192 r.setY(3);
193
194 if (fParamGrid[0+i])
195 Color(0.8f, 0.5f, 0.3f).setFor(context);
196 else
197 Color(0.3f, 0.5f, 0.8f).setFor(context);
198
199 r.draw(context);
200
201 // middle
202 r.setY(3 + minwh/3);
203
204 if (fParamGrid[3+i])
205 Color(0.8f, 0.5f, 0.3f).setFor(context);
206 else
207 Color(0.3f, 0.5f, 0.8f).setFor(context);

Callers

nothing calls this directly

Calls 11

getBackgroundColorFunction · 0.85
setPosMethod · 0.80
setXMethod · 0.80
setYMethod · 0.80
getWidthFunction · 0.50
getHeightFunction · 0.50
setForMethod · 0.45
setSizeMethod · 0.45
drawMethod · 0.45
setWidthMethod · 0.45
setHeightMethod · 0.45

Tested by

no test coverage detected