Non reinvents the DAW. Powerful enough to form a complete studio, fast and light enough to run on low-end hardware like the eeePC or Raspberry Pi, and so reliable that it can be used live https://non.tuxfamily.org/
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.

125 lines
3.4KB

  1. /*******************************************************************************/
  2. /* Copyright (C) 2013 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. #include "Fl_DialX.H"
  19. #include <FL/Fl.H>
  20. #include <FL/fl_draw.H>
  21. void
  22. Fl_DialX::draw ( void )
  23. {
  24. int X,Y,S;
  25. int act = active_r();
  26. {
  27. int ox, oy, ww, hh, side;
  28. ox = x();
  29. oy = y();
  30. ww = w();
  31. hh = h();
  32. if (ww > hh)
  33. {
  34. side = hh;
  35. ox = ox + (ww - side) / 2;
  36. }
  37. else
  38. {
  39. side = ww;
  40. oy = oy + (hh - side) / 2;
  41. }
  42. side = w() > h() ? hh : ww;
  43. X = ox;
  44. Y = oy;
  45. S = side;
  46. }
  47. draw_box();
  48. draw_label();
  49. double angle = ( angle2() - angle1() ) * ( value() - minimum()) / ( maximum() - minimum() ) + angle1();
  50. fl_draw_box( box(), X, Y, S, S, color() );
  51. /* shrink a bit */
  52. int OX = x();
  53. int OY = y();
  54. X += S / 8;
  55. Y += S / 8;
  56. int OS = S;
  57. S -= S / 4;
  58. fl_line_style( FL_SOLID, S / 12 );
  59. /* background arc */
  60. Fl_Color c = fl_darker( color() );
  61. if ( !act )
  62. c = fl_inactive( c );
  63. fl_color( c );
  64. fl_arc( X, Y, S, S, 270 - angle1(), 270 - angle2() );
  65. /* foreground arc */
  66. c = selection_color();
  67. if ( !act )
  68. c = fl_inactive( c );
  69. fl_color(c);
  70. fl_arc( X, Y, S, S, 270 - angle1(), 270 - angle );
  71. fl_line_style( FL_SOLID, 0 );
  72. if ( act )
  73. {
  74. int W = OS;
  75. int H = OS;
  76. fl_push_matrix();
  77. fl_translate(OX+W/2, OY+H/2);
  78. fl_scale(W, H);
  79. fl_rotate(310+angle);
  80. fl_color( fl_color_add_alpha( FL_WHITE, 127 ));
  81. fl_begin_polygon(); fl_circle(-0.26, 0.26, 0.12); fl_end_polygon();
  82. fl_color( FL_WHITE );
  83. fl_begin_polygon(); fl_circle(-0.26, 0.26, 0.06); fl_end_polygon();
  84. fl_pop_matrix();
  85. }
  86. fl_color( fl_contrast( labelcolor(), color() ) );
  87. if ( Fl::belowmouse() == this )
  88. {
  89. char s[128];
  90. fl_font( FL_HELVETICA, 9 );
  91. char buf[128];
  92. format(buf);
  93. snprintf( s, sizeof( s ), buf, value() );
  94. fl_color( FL_FOREGROUND_COLOR );
  95. fl_draw( s, X, Y, S, S, FL_ALIGN_CENTER );
  96. }
  97. }