Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

styles.cc 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. // ----------------------------------------------------------------------
  2. //
  3. // Copyright (C) 2010 Fons Adriaensen <fons@linuxaudio.org>
  4. // Modified by falkTX on Jan-Apr 2015 for inclusion in Carla
  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 2 of the License, or
  9. // (at your option) 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
  18. // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. //
  20. // ----------------------------------------------------------------------
  21. #include "styles.h"
  22. #include "png2img.h"
  23. #include "CarlaString.hpp"
  24. #include <dlfcn.h>
  25. namespace REV1 {
  26. XftColor *XftColors [NXFTCOLORS];
  27. XImage *revsect_img;
  28. XImage *eq1sect_img;
  29. XImage *eq2sect_img;
  30. XImage *mixsect_img;
  31. XImage *ambsect_img;
  32. RotaryImg r_delay_img;
  33. RotaryImg r_xover_img;
  34. RotaryImg r_rtlow_img;
  35. RotaryImg r_rtmid_img;
  36. RotaryImg r_fdamp_img;
  37. RotaryImg r_parfr_img;
  38. RotaryImg r_pargn_img;
  39. RotaryImg r_opmix_img;
  40. RotaryImg r_rgxyz_img;
  41. static CarlaString getResourceDir()
  42. {
  43. Dl_info exeInfo;
  44. dladdr((void*)getResourceDir, &exeInfo);
  45. CarlaString filename(exeInfo.dli_fname);
  46. return filename.truncate(filename.rfind("-ui"));
  47. }
  48. void styles_init (X_display *disp, X_resman *xrm)
  49. {
  50. CarlaString resourceDir(getResourceDir());
  51. XftColors [C_MAIN_BG] = disp->alloc_xftcolor (0.25f, 0.25f, 0.25f, 1.0f);
  52. XftColors [C_MAIN_FG] = disp->alloc_xftcolor (1.0f, 1.0f, 1.0f, 1.0f);
  53. revsect_img = png2img (resourceDir+"/revsect.png", disp, XftColors [C_MAIN_BG]);
  54. eq1sect_img = png2img (resourceDir+"/eq1sect.png", disp, XftColors [C_MAIN_BG]);
  55. eq2sect_img = png2img (resourceDir+"/eq2sect.png", disp, XftColors [C_MAIN_BG]);
  56. mixsect_img = png2img (resourceDir+"/mixsect.png", disp, XftColors [C_MAIN_BG]);
  57. ambsect_img = png2img (resourceDir+"/ambsect.png", disp, XftColors [C_MAIN_BG]);
  58. if (!revsect_img || !mixsect_img || !ambsect_img
  59. || !eq1sect_img || !eq2sect_img)
  60. {
  61. fprintf (stderr, "Can't load images from '%s'.\n", resourceDir.buffer());
  62. exit (1);
  63. }
  64. r_delay_img._backg = XftColors [C_MAIN_BG];
  65. r_delay_img._image [0] = revsect_img;
  66. r_delay_img._lncol [0] = 0;
  67. r_delay_img._x0 = 30;
  68. r_delay_img._y0 = 32;
  69. r_delay_img._dx = 23;
  70. r_delay_img._dy = 23;
  71. r_delay_img._xref = 11.5;
  72. r_delay_img._yref = 11.5;
  73. r_delay_img._rad = 11;
  74. r_xover_img._backg = XftColors [C_MAIN_BG];
  75. r_xover_img._image [0] = revsect_img;
  76. r_xover_img._lncol [0] = 0;
  77. r_xover_img._x0 = 92;
  78. r_xover_img._y0 = 17;
  79. r_xover_img._dx = 23;
  80. r_xover_img._dy = 23;
  81. r_xover_img._xref = 11.5;
  82. r_xover_img._yref = 11.5;
  83. r_xover_img._rad = 11;
  84. r_rtlow_img._backg = XftColors [C_MAIN_BG];
  85. r_rtlow_img._image [0] = revsect_img;
  86. r_rtlow_img._lncol [0] = 0;
  87. r_rtlow_img._x0 = 147;
  88. r_rtlow_img._y0 = 17;
  89. r_rtlow_img._dx = 23;
  90. r_rtlow_img._dy = 23;
  91. r_rtlow_img._xref = 11.5;
  92. r_rtlow_img._yref = 11.5;
  93. r_rtlow_img._rad = 11;
  94. r_rtmid_img._backg = XftColors [C_MAIN_BG];
  95. r_rtmid_img._image [0] = revsect_img;
  96. r_rtmid_img._lncol [0] = 0;
  97. r_rtmid_img._x0 = 207;
  98. r_rtmid_img._y0 = 17;
  99. r_rtmid_img._dx = 23;
  100. r_rtmid_img._dy = 23;
  101. r_rtmid_img._xref = 11.5;
  102. r_rtmid_img._yref = 11.5;
  103. r_rtmid_img._rad = 11;
  104. r_fdamp_img._backg = XftColors [C_MAIN_BG];
  105. r_fdamp_img._image [0] = revsect_img;
  106. r_fdamp_img._lncol [0] = 0;
  107. r_fdamp_img._x0 = 267;
  108. r_fdamp_img._y0 = 17;
  109. r_fdamp_img._dx = 23;
  110. r_fdamp_img._dy = 23;
  111. r_fdamp_img._xref = 11.5;
  112. r_fdamp_img._yref = 11.5;
  113. r_fdamp_img._rad = 11;
  114. r_parfr_img._backg = XftColors [C_MAIN_BG];
  115. r_parfr_img._image [0] = eq1sect_img;
  116. r_parfr_img._lncol [0] = 0;
  117. r_parfr_img._x0 = 19;
  118. r_parfr_img._y0 = 32;
  119. r_parfr_img._dx = 23;
  120. r_parfr_img._dy = 23;
  121. r_parfr_img._xref = 11.5;
  122. r_parfr_img._yref = 11.5;
  123. r_parfr_img._rad = 11;
  124. r_pargn_img._backg = XftColors [C_MAIN_BG];
  125. r_pargn_img._image [0] = eq1sect_img;
  126. r_pargn_img._lncol [0] = 1;
  127. r_pargn_img._x0 = 68;
  128. r_pargn_img._y0 = 17;
  129. r_pargn_img._dx = 23;
  130. r_pargn_img._dy = 23;
  131. r_pargn_img._xref = 11.5;
  132. r_pargn_img._yref = 11.5;
  133. r_pargn_img._rad = 11;
  134. r_opmix_img._backg = XftColors [C_MAIN_BG];
  135. r_opmix_img._image [0] = mixsect_img;
  136. r_opmix_img._lncol [0] = 0;
  137. r_opmix_img._x0 = 23;
  138. r_opmix_img._y0 = 32;
  139. r_opmix_img._dx = 23;
  140. r_opmix_img._dy = 23;
  141. r_opmix_img._xref = 11.5;
  142. r_opmix_img._yref = 11.5;
  143. r_opmix_img._rad = 11;
  144. r_rgxyz_img._backg = XftColors [C_MAIN_BG];
  145. r_rgxyz_img._image [0] = ambsect_img;
  146. r_rgxyz_img._lncol [0] = 0;
  147. r_rgxyz_img._x0 = 23;
  148. r_rgxyz_img._y0 = 32;
  149. r_rgxyz_img._dx = 23;
  150. r_rgxyz_img._dy = 23;
  151. r_rgxyz_img._xref = 11.5;
  152. r_rgxyz_img._yref = 11.5;
  153. r_rgxyz_img._rad = 11;
  154. }
  155. void styles_fini (X_display *disp)
  156. {
  157. revsect_img->data = 0;
  158. mixsect_img->data = 0;
  159. ambsect_img->data = 0;
  160. eq1sect_img->data = 0;
  161. eq2sect_img->data = 0;
  162. XDestroyImage (revsect_img);
  163. XDestroyImage (mixsect_img);
  164. XDestroyImage (ambsect_img);
  165. XDestroyImage (eq1sect_img);
  166. XDestroyImage (eq2sect_img);
  167. }
  168. }