1 /* B.Angr 2 * Dynamic distorted bandpass filter plugin 3 * 4 * Copyright (C) 2021 by Sven Jähnichen 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 3, or (at your option) 9 * any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software Foundation, 18 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 */ 20 21 #ifndef BANGRGUI_HPP_ 22 #define BANGRGUI_HPP_ 23 24 #include <array> 25 #include <lv2/lv2plug.in/ns/extensions/ui/ui.h> 26 #include <lv2/lv2plug.in/ns/ext/atom/atom.h> 27 #include <lv2/lv2plug.in/ns/ext/atom/forge.h> 28 #include "BWidgets/Widget.hpp" 29 #include "BWidgets/Window.hpp" 30 #include "BWidgets/Label.hpp" 31 #include "BWidgets/PopupListBox.hpp" 32 #include "BWidgets/HSliderValue.hpp" 33 #include "Dial.hpp" 34 #include "DialRange.hpp" 35 #include "Dot.hpp" 36 #include "HaloButton.hpp" 37 #include "LightButton.hpp" 38 #include "Definitions.hpp" 39 #include "Ports.hpp" 40 #include "Urids.hpp" 41 42 #ifdef LOCALEFILE 43 #include LOCALEFILE 44 #else 45 #include "Locale_EN.hpp" 46 #endif 47 48 #ifdef SKINFILE 49 #include SKINFILE 50 #else 51 #include "Skin_Default.hpp" 52 #endif 53 54 #ifndef LIMIT 55 #define LIMIT(g , max) ((g) > (max) ? (max) : (g)) 56 #endif 57 58 #ifndef WWW_BROWSER_CMD 59 #define WWW_BROWSER_CMD "x-www-browser" 60 #endif 61 62 #define XREGION_URL "http://www.airwindows.com/xregion/" 63 #define HELP_URL "https://github.com/sjaehn/BAngr/blob/master/README.md" 64 #define YT_URL "https://www.youtube.com/watch?v=-kWy_1UYazo" 65 #define RESIZE(widget, x, y, w, h, sz) (widget).moveTo ((x) * (sz), (y) * (sz)); (widget).resize ((w) * (sz), (h) * (sz)); 66 67 class BAngrGUI : public BWidgets::Window 68 { 69 public: 70 BAngrGUI (const char *bundle_path, const LV2_Feature *const *features, PuglNativeView parentWindow); 71 ~BAngrGUI (); 72 void portEvent (uint32_t port_index, uint32_t buffer_size, uint32_t format, const void *buffer); 73 void sendCursor (); 74 void sendXCursor (); 75 void sendYCursor (); 76 void sendCursorOn (); 77 void sendCursorOff (); 78 virtual void onConfigureRequest (BEvents::ExposeEvent* event) override; 79 void applyTheme (BStyles::Theme& theme) override; 80 81 LV2UI_Controller controller; 82 LV2UI_Write_Function write_function; 83 84 85 private: 86 void resizeGUI (); 87 static void valueChangedCallback (BEvents::Event* event); 88 static void cursorDraggedCallback (BEvents::Event* event); 89 static void cursorReleasedCallback (BEvents::Event* event); 90 static void xregionClickedCallback (BEvents::Event* event); 91 static void helpButtonClickedCallback (BEvents::Event* event); 92 static void ytButtonClickedCallback (BEvents::Event* event); 93 94 std::string pluginPath; 95 double sz; 96 cairo_surface_t* bgImageSurface; 97 98 LV2_Atom_Forge forge; 99 BAngrURIs urids; 100 LV2_URID_Map* map; 101 // LV2_URID_Unmap* unmap; 102 103 // Widgets 104 BWidgets::Widget mContainer; 105 Dot cursor; 106 BWidgets::Label poweredLabel; 107 HaloButton helpButton; 108 HaloButton ytButton; 109 LightButton bypassButton; 110 BWidgets::Label bypassLabel; 111 Dial drywetDial; 112 BWidgets::Label drywetLabel; 113 DialRange speedDial; 114 BWidgets::Label speedLabel; 115 DialRange spinDial; 116 BWidgets::Label spinLabel; 117 BWidgets::Widget speedScreen; 118 BWidgets::Label speedFlexLabel; 119 BWidgets::PopupListBox speedTypeListbox; 120 BWidgets::HSliderValue speedAmountSlider; 121 BWidgets::Widget spinScreen; 122 BWidgets::Label spinFlexLabel; 123 BWidgets::PopupListBox spinTypeListbox; 124 BWidgets::HSliderValue spinAmountSlider; 125 126 struct Fx 127 { 128 BWidgets::Widget container; 129 std::array<Dial, NR_PARAMS> paramDials; 130 std::array<BWidgets::Label, NR_PARAMS> paramLabels; 131 }; 132 std::array<Fx, NR_FX> fx; 133 134 // Controllers 135 std::array<BWidgets::ValueWidget*, NR_CONTROLLERS> controllerWidgets; 136 137 // Definition of styles 138 BColors::ColorSet fgColors = BANGR_FG_COLORS; 139 BColors::ColorSet txColors = BANGR_TX_COLORS; 140 BColors::ColorSet bgColors = BANGR_BG_COLORS; 141 BColors::ColorSet noColors = BANGR_NO_COLORS; 142 143 BStyles::Border menuBorder = {{*noColors.getColor (BColors::NORMAL), 1.0}, 0.0, 0.0, 0.0}; 144 BStyles::Border menuBorder2 = {{*bgColors.getColor (BColors::NORMAL), 1.0}, 0.0, 0.0, 0.0}; 145 BStyles::Border labelBorder = {BStyles::noLine, 4.0, 0.0, 0.0}; 146 BStyles::Fill widgetBg = BStyles::noFill; 147 BStyles::Fill screenBg = BStyles::Fill (BColors::Color (BANGR_SCREEN_BG_COLORS)); 148 BStyles::Font defaultFont = BStyles::Font 149 ( 150 "Sans", 151 CAIRO_FONT_SLANT_NORMAL, 152 CAIRO_FONT_WEIGHT_NORMAL, 153 12.0, 154 BStyles::TEXT_ALIGN_CENTER, 155 BStyles::TEXT_VALIGN_MIDDLE 156 ); 157 158 BStyles::Font rFont = BStyles::Font 159 ( 160 "Sans", 161 CAIRO_FONT_SLANT_NORMAL, 162 CAIRO_FONT_WEIGHT_NORMAL, 163 12.0, 164 BStyles::TEXT_ALIGN_RIGHT, 165 BStyles::TEXT_VALIGN_MIDDLE 166 ); 167 168 BStyles::Font lFont = BStyles::Font 169 ( 170 "Sans", 171 CAIRO_FONT_SLANT_NORMAL, 172 CAIRO_FONT_WEIGHT_NORMAL, 173 12.0, 174 BStyles::TEXT_ALIGN_LEFT, 175 BStyles::TEXT_VALIGN_MIDDLE 176 ); 177 178 BStyles::StyleSet defaultStyles = {"default", {{"background", STYLEPTR (&BStyles::noFill)}, {"border", STYLEPTR (&BStyles::noBorder)}}}; 179 BStyles::StyleSet labelStyles = {"labels", {{"background", STYLEPTR (&BStyles::noFill)}, 180 {"border", STYLEPTR (&BStyles::noBorder)}, 181 {"textcolors", STYLEPTR (&txColors)}, 182 {"font", STYLEPTR (&defaultFont)}}}; 183 184 BStyles::StyleSet focusStyles = {"labels", {{"background", STYLEPTR (&screenBg)}, 185 {"border", STYLEPTR (&BStyles::noBorder)}, 186 {"textcolors", STYLEPTR (&txColors)}, 187 {"font", STYLEPTR (&defaultFont)}}}; 188 189 BStyles::Theme theme = BStyles::Theme 190 ({ 191 defaultStyles, 192 {"B.Angr", {{"background", STYLEPTR (&BStyles::blackFill)}, 193 {"border", STYLEPTR (&BStyles::noBorder)}}}, 194 {"main", {{"background", STYLEPTR (&widgetBg)}, 195 {"border", STYLEPTR (&BStyles::noBorder)}}}, 196 {"widget", {{"uses", STYLEPTR (&defaultStyles)}}}, 197 {"widget/focus",{{"uses", STYLEPTR (&focusStyles)}}}, 198 {"screen", {{"uses", STYLEPTR (&defaultStyles)}, 199 {"background", STYLEPTR (&screenBg)}}}, 200 {"dial", {{"uses", STYLEPTR (&defaultStyles)}, 201 {"fgcolors", STYLEPTR (&fgColors)}, 202 {"bgcolors", STYLEPTR (&bgColors)}, 203 {"textcolors", STYLEPTR (&txColors)}, 204 {"font", STYLEPTR (&defaultFont)}}}, 205 {"dial/focus", {{"uses", STYLEPTR (&focusStyles)}}}, 206 {"slider", {{"uses", STYLEPTR (&defaultStyles)}, 207 {"fgcolors", STYLEPTR (&fgColors)}, 208 {"bgcolors", STYLEPTR (&bgColors)}, 209 {"textcolors", STYLEPTR (&txColors)}, 210 {"font", STYLEPTR (&defaultFont)}}}, 211 {"slider/focus",{{"uses", STYLEPTR (&focusStyles)}}}, 212 {"label", {{"uses", STYLEPTR (&labelStyles)}}}, 213 {"rlabel", {{"uses", STYLEPTR (&labelStyles)}, 214 {"font", STYLEPTR (&rFont)}}}, 215 {"dot", {{"uses", STYLEPTR (&defaultStyles)}, 216 {"fgcolors", STYLEPTR (&txColors)}}}, 217 {"menu", {{"border", STYLEPTR (&menuBorder)}, 218 {"background", STYLEPTR (&screenBg)}}}, 219 {"menu/item", {{"uses", STYLEPTR (&defaultStyles)}, 220 {"border", STYLEPTR (&labelBorder)}, 221 {"textcolors", STYLEPTR (&BColors::whites)}, 222 {"font", STYLEPTR (&lFont)}}}, 223 {"menu/button", {{"border", STYLEPTR (&menuBorder)}, 224 {"background", STYLEPTR (&screenBg)}, 225 {"bgcolors", STYLEPTR (&txColors)}}}, 226 {"menu/listbox",{{"border", STYLEPTR (&menuBorder2)}, 227 {"background", STYLEPTR (&screenBg)}}}, 228 {"menu/listbox/item", {{"uses", STYLEPTR (&defaultStyles)}, 229 {"border", STYLEPTR (&labelBorder)}, 230 {"textcolors", STYLEPTR (&BColors::whites)}, 231 {"font", STYLEPTR (&lFont)}}}, 232 {"menu/listbox/button", {{"border", STYLEPTR (&menuBorder)}, 233 {"background", STYLEPTR (&screenBg)}, 234 {"bgcolors", STYLEPTR (&noColors)}}} 235 }); 236 }; 237 238 #endif /* BANGRGUI_HPP_ */