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

Class CairoExampleUI

examples/CairoUI/CairoExampleUI.cpp:35–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33using DGL_NAMESPACE::DemoWidgetBanner;
34
35class CairoExampleUI : public UI,
36 public CairoImageKnob::Callback,
37 public CairoImageSwitch::Callback,
38 public DemoWidgetClickable::Callback
39{
40 ScopedPointer<CairoImageKnob> fKnob;
41 ScopedPointer<CairoImageSwitch> fButton;
42 ScopedPointer<DemoWidgetBanner> fWidgetBanner;
43 ScopedPointer<DemoWidgetClickable> fWidgetClickable;
44
45public:
46 CairoExampleUI()
47 {
48 CairoImage knobSkin;
49 knobSkin.loadFromPNG(Artwork::knobData, Artwork::knobDataSize);
50
51 fWidgetBanner = new DemoWidgetBanner(this);
52 fWidgetBanner->setAbsolutePos(10, 10);
53 fWidgetBanner->setSize(180, 80);
54
55 fWidgetClickable = new DemoWidgetClickable(this);
56 fWidgetClickable->setAbsolutePos(100, 100);
57 fWidgetClickable->setSize(50, 50);
58 fWidgetClickable->setCallback(this);
59 fWidgetClickable->setId(kParameterTriState);
60
61 fKnob = new CairoImageKnob(this, knobSkin);
62 fKnob->setAbsolutePos(10, 100);
63 fKnob->setSize(80, 80);
64 fKnob->setCallback(this);
65 fKnob->setId(kParameterKnob);
66
67 CairoImage buttonOn, buttonOff;
68 buttonOn.loadFromPNG(Artwork::buttonOnData, Artwork::buttonOnDataSize);
69 buttonOff.loadFromPNG(Artwork::buttonOffData, Artwork::buttonOffDataSize);
70
71 fButton = new CairoImageSwitch(this, buttonOff, buttonOn);
72 fButton->setAbsolutePos(100, 160);
73 fButton->setSize(60, 35);
74 fButton->setCallback(this);
75 fButton->setId(kParameterButton);
76
77 setGeometryConstraints(DISTRHO_UI_DEFAULT_WIDTH, DISTRHO_UI_DEFAULT_HEIGHT, true, true);
78 }
79
80protected:
81 void onCairoDisplay(const CairoGraphicsContext& context) override
82 {
83 cairo_t* const cr = context.handle;
84 cairo_set_source_rgb(cr, 1.0, 0.8, 0.5);
85 cairo_paint(cr);
86 }
87
88#if 0
89 // we can use this if/when our resources are scalable, for now they are PNGs
90 void onResize(const ResizeEvent& ev) override
91 {
92 UI::onResize(ev);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected