Debian Codegraph @

plugins/dragonfly-hall-reverb/AbstractUI.cpp

raw
1 /*
2 * Dragonfly Reverb, copyright (c) 2020 Michael Willis, Rob van den Berg
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 3 of
7 * the License, or any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * For a full copy of the GNU General Public License see the LICENSE file.
15 */
16
17 #include "AbstractUI.hpp"
18 #include "Bitstream_Vera_Sans_Regular.hpp"
19
20 DragonflyReverbAbstractUI::DragonflyReverbAbstractUI(
21 uint width, uint height, const Param* params,
22 const char* knobData, uint knobWidth, uint knobHeight,
23 const char* questionData, uint questionWidth, uint questionHeight)
24 : UI (width, height) {
25 setGeometryConstraints(width, height, true, true, true);
26 NanoVG::FontId font = nanoText.createFontFromMemory(
27 "bitstream vera sans",
28 font_bitstream_vera::bitstream_vera_sans_ttf,
29 font_bitstream_vera::bitstream_vera_sans_ttf_size,
30 false);
31 nanoText.fontFaceId(font);
32 this->params = params;
33 this->knobImage = Image(knobData, knobWidth, knobHeight);
34
35 displayAbout = false;
36 aboutButton = new ImageButton(this, Image (questionData, questionWidth, questionHeight, kImageFormatBGRA));
37 aboutButton->setCallback(this);
38
39 }
40
41 LabelledKnob * DragonflyReverbAbstractUI::createLabelledKnob(const Param *param, const char * numberFormat, int x, int y) {
42 return new LabelledKnob(this, this, &knobImage, &nanoText, param, numberFormat, x, y);
43 }
44
45 void DragonflyReverbAbstractUI::imageButtonClicked(ImageButton* imageButton, int button)
46 {
47 if (imageButton == aboutButton && button == 1) {
48 aboutButton->setVisible(false);
49 displayAbout = true;
50 repaint();
51 }
52 }
53
54 bool DragonflyReverbAbstractUI::onMouse(const MouseEvent& ev) {
55 if (ev.press && displayAbout) {
56 aboutButton->setVisible(true);
57 displayAbout = false;
58 repaint();
59 }
60
61 return UI::onMouse(ev);
62 }