Assists music production by grouping standalone programs into sessions. Community version of "Non Session Manager".
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.

396 lines
12KB

  1. /*******************************************************************************/
  2. /* Copyright (C) 2008 Jonathan Moore Liles */
  3. /* */
  4. /* This program is free software; you can redistribute it and/or modify it */
  5. /* under the terms of the GNU General Public License as published by the */
  6. /* Free Software Foundation; either version 2 of the License, or (at your */
  7. /* option) any later version. */
  8. /* */
  9. /* This program is distributed in the hope that it will be useful, but WITHOUT */
  10. /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
  11. /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */
  12. /* more details. */
  13. /* */
  14. /* You should have received a copy of the GNU General Public License along */
  15. /* with This program; see the file COPYING. If not,write to the Free Software */
  16. /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  17. /*******************************************************************************/
  18. #pragma GCC diagnostic ignored "-Wchar-subscripts"
  19. #include <FL/fl_draw.H>
  20. #include <string.h>
  21. #include "FL/Fl_Theme.H"
  22. /* Crystal boxes, base (obviously) on the FLTK1 'plastic' boxes, but
  23. * without the rude color blending and with a slightly enhanced
  24. * appearance. */
  25. extern uchar *fl_gray_ramp();
  26. inline Fl_Color
  27. shade_color ( uchar gc, Fl_Color bc )
  28. {
  29. return fl_color_average( ( Fl_Color ) gc, bc, 0.25f );
  30. }
  31. static void
  32. frame_rect ( int x, int y, int w, int h, const char *c, Fl_Color bc )
  33. {
  34. uchar *g = fl_gray_ramp();
  35. int b = strlen( c ) / 4 + 1;
  36. for ( x += b, y += b, w -= 2 * b, h -= 2 * b; b > 1; b-- )
  37. {
  38. // Draw lines around the perimeter of the button, 4 colors per
  39. // circuit.
  40. fl_color( shade_color( g[*c++], bc ) );
  41. fl_line( x, y + h + b, x + w - 1, y + h + b, x + w + b - 1, y + h );
  42. fl_color( shade_color( g[*c++], bc ) );
  43. fl_line( x + w + b - 1, y + h, x + w + b - 1, y, x + w - 1, y - b );
  44. fl_color( shade_color( g[*c++], bc ) );
  45. fl_line( x + w - 1, y - b, x, y - b, x - b, y );
  46. fl_color( shade_color( g[*c++], bc ) );
  47. fl_line( x - b, y, x - b, y + h, x, y + h + b );
  48. }
  49. }
  50. static void
  51. frame_round ( int x, int y, int w, int h, const char *c, Fl_Color bc )
  52. {
  53. uchar *g = fl_gray_ramp();
  54. int b = strlen( c ) / 4 + 1;
  55. if ( ! Fl::draw_box_active() )
  56. bc = fl_inactive( bc );
  57. if ( w == h )
  58. {
  59. for ( ; b > 1; b--, x++, y++, w -= 2, h -= 2 )
  60. {
  61. fl_color( shade_color( g[*c++], bc ) );
  62. fl_arc( x, y, w, h, 45.0, 135.0 );
  63. fl_color( shade_color( g[*c++], bc ) );
  64. fl_arc( x, y, w, h, 315.0, 405.0 );
  65. fl_color( shade_color( g[*c++], bc ) );
  66. fl_arc( x, y, w, h, 225.0, 315.0 );
  67. fl_color( shade_color( g[*c++], bc ) );
  68. fl_arc( x, y, w, h, 135.0, 225.0 );
  69. }
  70. }
  71. else if ( w > h )
  72. {
  73. int d = h / 2;
  74. for ( ; b > 1; d--, b--, x++, y++, w -= 2, h -= 2 )
  75. {
  76. fl_color( shade_color( g[*c++], bc ) );
  77. fl_arc( x, y, h, h, 90.0, 135.0 );
  78. fl_xyline( x + d, y, x + w - d );
  79. fl_arc( x + w - h, y, h, h, 45.0, 90.0 );
  80. fl_color( shade_color( g[*c++], bc ) );
  81. fl_arc( x + w - h, y, h, h, 315.0, 405.0 );
  82. fl_color( shade_color( g[*c++], bc ) );
  83. fl_arc( x + w - h, y, h, h, 270.0, 315.0 );
  84. fl_xyline( x + d, y + h - 1, x + w - d );
  85. fl_arc( x, y, h, h, 225.0, 270.0 );
  86. fl_color( shade_color( g[*c++], bc ) );
  87. fl_arc( x, y, h, h, 135.0, 225.0 );
  88. }
  89. }
  90. else if ( w < h )
  91. {
  92. int d = w / 2;
  93. for ( ; b > 1; d--, b--, x++, y++, w -= 2, h -= 2 )
  94. {
  95. fl_color( shade_color( g[*c++], bc ) );
  96. fl_arc( x, y, w, w, 45.0, 135.0 );
  97. fl_color( shade_color( g[*c++], bc ) );
  98. fl_arc( x, y, w, w, 0.0, 45.0 );
  99. fl_yxline( x + w - 1, y + d, y + h - d );
  100. fl_arc( x, y + h - w, w, w, 315.0, 360.0 );
  101. fl_color( shade_color( g[*c++], bc ) );
  102. fl_arc( x, y + h - w, w, w, 225.0, 315.0 );
  103. fl_color( shade_color( g[*c++], bc ) );
  104. fl_arc( x, y + h - w, w, w, 180.0, 225.0 );
  105. fl_yxline( x, y + d, y + h - d );
  106. fl_arc( x, y, w, w, 135.0, 180.0 );
  107. }
  108. }
  109. }
  110. static void
  111. shade_rect ( int x, int y, int w, int h, const char *c, Fl_Color bc )
  112. {
  113. uchar *g = fl_gray_ramp();
  114. int i, j;
  115. int clen = strlen( c ) - 1;
  116. int chalf = clen / 2;
  117. int cstep = 1;
  118. if ( ! Fl::draw_box_active() )
  119. bc = fl_inactive( bc );
  120. if ( h < ( w * 2 ) )
  121. {
  122. // Horizontal shading...
  123. if ( clen >= h )
  124. cstep = 2;
  125. for ( i = 0, j = 0; j < chalf; i++, j += cstep )
  126. {
  127. // Draw the top line and points...
  128. fl_color( shade_color( g[c[i]], bc ) );
  129. fl_xyline( x + 1, y + i, x + w - 2 );
  130. fl_color( shade_color( g[c[i] - 2], bc ) );
  131. fl_point( x, y + i + 1 );
  132. fl_point( x + w - 1, y + i + 1 );
  133. // Draw the bottom line and points...
  134. fl_color( shade_color( g[c[clen - i]], bc ) );
  135. fl_xyline( x + 1, y + h - i, x + w - 2 );
  136. fl_color( shade_color( g[c[clen - i] - 2], bc ) );
  137. fl_point( x, y + h - i );
  138. fl_point( x + w - 1, y + h - i );
  139. }
  140. // Draw the interior and sides...
  141. i = chalf / cstep;
  142. // fl_color( shade_color( g[c[chalf]], bc ) );
  143. fl_color( bc );
  144. fl_rectf( x + 1, y + i, w - 2, h - 2 * i + 1 );
  145. fl_color( shade_color( g[c[chalf] - 2], bc ) );
  146. fl_yxline( x, y + i, y + h - i );
  147. fl_yxline( x + w - 1, y + i, y + h - i );
  148. }
  149. else
  150. {
  151. // Vertical shading...
  152. if ( clen >= w )
  153. cstep = 2;
  154. for ( i = 0, j = 0; j < chalf; i++, j += cstep )
  155. {
  156. // Draw the left line and points...
  157. fl_color( shade_color( g[c[i]], bc ) );
  158. fl_yxline( x + i, y + 1, y + h - 1 );
  159. fl_color( shade_color( g[c[i] - 2], bc ) );
  160. fl_point( x + i + 1, y );
  161. fl_point( x + i + 1, y + h );
  162. // Draw the right line and points...
  163. fl_color( shade_color( g[c[clen - i]], bc ) );
  164. fl_yxline( x + w - 1 - i, y + 1, y + h - 1 );
  165. fl_color( shade_color( g[c[clen - i] - 2], bc ) );
  166. fl_point( x + w - 2 - i, y );
  167. fl_point( x + w - 2 - i, y + h );
  168. }
  169. // Draw the interior, top, and bottom...
  170. i = chalf / cstep;
  171. fl_color( shade_color( g[c[chalf]], bc ) );
  172. fl_rectf( x + i, y + 1, w - 2 * i, h - 1 );
  173. fl_color( shade_color( g[c[chalf] - 2], bc ) );
  174. fl_xyline( x + i, y, x + w - i );
  175. fl_xyline( x + i, y + h, x + w - i );
  176. }
  177. }
  178. static void
  179. shade_round ( int x, int y, int w, int h, const char *c, Fl_Color bc )
  180. {
  181. uchar *g = fl_gray_ramp();
  182. int i;
  183. int clen = strlen( c ) - 1;
  184. int chalf = clen / 2;
  185. if ( w > h )
  186. {
  187. int d = h / 2;
  188. const int na = 8;
  189. for ( i = 0; i < chalf; i++, d--, x++, y++, w -= 2, h -= 2 )
  190. {
  191. fl_color( shade_color( g[c[i]], bc ) );
  192. fl_pie( x, y, h, h, 90.0, 135.0 + i * na );
  193. fl_xyline( x + d, y, x + w - d );
  194. fl_pie( x + w - h, y, h, h, 45.0 + i * na, 90.0 );
  195. fl_color( shade_color( g[c[i] - 2], bc ) );
  196. fl_pie( x + w - h, y, h, h, 315.0 + i * na, 405.0 + i * na );
  197. fl_color( shade_color( g[c[clen - i]], bc ) );
  198. fl_pie( x + w - h, y, h, h, 270.0, 315.0 + i * na );
  199. fl_xyline( x + d, y + h - 1, x + w - d );
  200. fl_pie( x, y, h, h, 225.0 + i * na, 270.0 );
  201. fl_color( shade_color( g[c[clen - i] - 2], bc ) );
  202. fl_pie( x, y, h, h, 135.0 + i * na, 225.0 + i * na );
  203. }
  204. // fl_color( shade_color( g[c[chalf]], bc ) );
  205. fl_color( bc );
  206. fl_rectf( x + d, y, w - h + 1, h + 1 );
  207. fl_pie( x, y, h, h, 90.0, 270.0 );
  208. fl_pie( x + w - h, y, h, h, 270.0, 90.0 );
  209. }
  210. else
  211. {
  212. int d = w / 2;
  213. const int na = 8;
  214. for ( i = 0; i < chalf; i++, d--, x++, y++, w -= 2, h -= 2 )
  215. {
  216. fl_color( shade_color( g[c[i]], bc ) );
  217. fl_pie( x, y, w, w, 45.0 + i * na, 135.0 + i * na );
  218. fl_color( shade_color( g[c[i] - 2], bc ) );
  219. fl_pie( x, y, w, w, 0.0, 45.0 + i * na );
  220. fl_yxline( x + w - 1, y + d, y + h - d );
  221. fl_pie( x, y + h - w, w, w, 315.0 + i * na, 360.0 );
  222. fl_color( shade_color( g[c[clen - i]], bc ) );
  223. fl_pie( x, y + h - w, w, w, 225.0 + i * na, 315.0 + i * na );
  224. fl_color( shade_color( g[c[clen - i] - 2], bc ) );
  225. fl_pie( x, y + h - w, w, w, 180.0, 225.0 + i * na );
  226. fl_yxline( x, y + d, y + h - d );
  227. fl_pie( x, y, w, w, 135.0 + i * na, 180.0 );
  228. }
  229. // fl_color( shade_color( g[c[chalf]], bc ) );
  230. fl_color( bc );
  231. fl_rectf( x, y + d, w + 1, h - w + 1 );
  232. fl_pie( x, y, w, w, 0.0, 180.0 );
  233. fl_pie( x, y + h - w, w, w, 180.0, 360.0 );
  234. }
  235. }
  236. static void
  237. up_frame ( int x, int y, int w, int h, Fl_Color c )
  238. {
  239. frame_rect( x, y, w, h - 1, "KLDIIJLM", c );
  240. }
  241. static void
  242. narrow_thin_box ( int x, int y, int w, int h, Fl_Color c )
  243. {
  244. if ( h <= 0 || w <= 0 )
  245. return;
  246. uchar *g = fl_gray_ramp();
  247. fl_color( shade_color( g['R'], c ) );
  248. fl_rectf( x + 1, y + 1, w - 2, h - 2 );
  249. fl_color( shade_color( g['I'], c ) );
  250. if ( w > 1 )
  251. {
  252. fl_xyline( x + 1, y, x + w - 2 );
  253. fl_xyline( x + 1, y + h - 1, x + w - 2 );
  254. }
  255. if ( h > 1 )
  256. {
  257. fl_yxline( x, y + 1, y + h - 2 );
  258. fl_yxline( x + w - 1, y + 1, y + h - 2 );
  259. }
  260. }
  261. static void
  262. thin_up_box ( int x, int y, int w, int h, Fl_Color c )
  263. {
  264. if ( w > 4 && h > 4 )
  265. {
  266. shade_rect( x + 1, y + 1, w - 2, h - 3, "RQOQSUWQ", c );
  267. frame_rect( x, y, w, h - 1, "IJLM", c );
  268. }
  269. else
  270. narrow_thin_box( x, y, w, h, c );
  271. }
  272. static void
  273. up_box ( int x, int y, int w, int h, Fl_Color c )
  274. {
  275. if ( w > 8 && h > 8 )
  276. {
  277. shade_rect( x + 1, y + 1, w - 2, h - 3, "RVQNOPQRSTUVWVQ", c );
  278. // shade_rect( x + 1, y + 1, w - 2, h - 3, "STUVWVQRWXVUVVQ", c );
  279. // shade_rect( x + 1, y + 1, w - 2, h - 3, "FISPPQQRSSTTUPJ", c );
  280. frame_rect( x, y, w, h - 1, "IJLM", c );
  281. }
  282. else
  283. thin_up_box( x, y, w, h, c );
  284. }
  285. static void
  286. up_round ( int x, int y, int w, int h, Fl_Color c )
  287. {
  288. shade_round( x, y, w, h, "RVQNOPQRSTUVWVQ", c );
  289. frame_round( x, y, w, h, "IJLM", c );
  290. }
  291. static void
  292. down_frame ( int x, int y, int w, int h, Fl_Color c )
  293. {
  294. frame_rect( x, y, w, h - 1, "LLLLTTRR", c );
  295. }
  296. static void
  297. down_box ( int x, int y, int w, int h, Fl_Color c )
  298. {
  299. if ( w > 6 && h > 6 )
  300. {
  301. // shade_rect( x + 2, y + 2, w - 4, h - 5, "STUVWWWVT", c );
  302. fl_rectf( x + 2, y + 2, w - 4, h - 5 , fl_darker( c ) );
  303. down_frame( x, y, w, h, c );
  304. }
  305. else
  306. {
  307. narrow_thin_box( x, y, w, h, c );
  308. }
  309. }
  310. static void
  311. down_round ( int x, int y, int w, int h, Fl_Color c )
  312. {
  313. shade_round( x, y, w, h, "STUVWWWVT", c );
  314. frame_round( x, y, w, h, "IJLM", c );
  315. }
  316. static void
  317. init_theme ( void )
  318. {
  319. printf( "Initializing crystal boxtypes" );
  320. /* replace the plastic boxes... (is there a better way?) */
  321. Fl::set_boxtype( FL_UP_BOX, up_box, 4,4,8,8 );
  322. Fl::set_boxtype( FL_DOWN_BOX, down_box, 2,2,4,4 );
  323. Fl::set_boxtype( FL_UP_FRAME, up_frame, 2,2,4,4 );
  324. Fl::set_boxtype( FL_DOWN_FRAME, down_frame, 2,2,4,4 );
  325. Fl::set_boxtype( FL_THIN_UP_BOX, thin_up_box, 1,1,2,2 );
  326. Fl::set_boxtype( FL_THIN_DOWN_BOX, down_box, 1,1,2,2 );
  327. Fl::set_boxtype( FL_ROUND_UP_BOX, up_round, 1,1,2,2 );
  328. Fl::set_boxtype( FL_ROUND_DOWN_BOX, down_round, 1,1,2,2 );
  329. }
  330. void
  331. init_crystal_theme ( void )
  332. {
  333. Fl_Theme *t = new Fl_Theme( "Crystal", "", "", init_theme );
  334. Fl_Theme::add( t );
  335. }