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.

138 lines
3.9KB

  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. #include "Fl_Arc_Dial.H"
  19. #include <FL/fl_draw.H>
  20. #include <FL/Fl.H>
  21. #include <string.h>
  22. #include <stdio.h>
  23. #include <math.h>
  24. int
  25. Fl_Arc_Dial::handle ( int m )
  26. {
  27. /* Fl_Dial and friends should really handle mousewheel, but they don't in FTLK1 */
  28. switch ( m )
  29. {
  30. case FL_MOUSEWHEEL:
  31. {
  32. if ( this != Fl::belowmouse() )
  33. return 0;
  34. int steps = 16;
  35. if ( Fl::event_ctrl() )
  36. steps = 128;
  37. float step = fabs( maximum() - minimum() ) / (float)steps;
  38. float d = ((float)Fl::event_dy()) * step;
  39. double v = value() + d;
  40. if ( maximum() > minimum() )
  41. {
  42. if ( v < minimum() )
  43. v = minimum();
  44. else if ( v > maximum() )
  45. v = maximum();
  46. }
  47. else
  48. {
  49. if ( v > minimum() )
  50. v = minimum();
  51. else if ( v < maximum() )
  52. v = maximum();
  53. }
  54. value( v );
  55. do_callback();
  56. return 1;
  57. }
  58. }
  59. return Fl_Dial::handle( m );
  60. }
  61. void
  62. Fl_Arc_Dial::draw ( void )
  63. {
  64. int X = x();
  65. int Y = y();
  66. int W = w();
  67. int H = h();
  68. draw_box();
  69. draw_label();
  70. X += Fl::box_dx(box());
  71. Y += Fl::box_dy(box());
  72. W -= Fl::box_dw(box());
  73. H -= Fl::box_dh(box());
  74. double angle = ( angle2() - angle1() ) * ( value() - minimum()) / ( maximum() - minimum() ) + angle1();
  75. fl_line_style( FL_SOLID, W / 6 );
  76. X += W / 8;
  77. Y += H / 8;
  78. W -= W / 4;
  79. H -= H / 4;
  80. if ( box() == FL_NO_BOX )
  81. {
  82. /* draw backgrond arc */
  83. fl_color( fl_color_average( FL_BLACK, selection_color(), 0.80f ) );
  84. fl_arc( X, Y, W, H, 270 - angle1(), 270 - angle2() );
  85. }
  86. fl_color( selection_color() );
  87. // fl_color( fl_color_average( FL_RED, selection_color(), ( value() - minimum() ) / ( maximum() - minimum() ) ) );
  88. if ( type() == FL_FILL_DIAL )
  89. fl_arc( X, Y, W, H, 270 - angle1(), 270 - angle );
  90. else
  91. {
  92. const int d = 6;
  93. /* account for edge conditions */
  94. angle = angle < angle1() + d ? angle1() + d : angle;
  95. angle = angle > angle2() - d ? angle2() - d : angle;
  96. fl_arc( X, Y, W, H, 270 - (angle - d), 270 - (angle + d) );
  97. }
  98. fl_line_style( FL_SOLID, 0 );
  99. fl_color( labelcolor() );
  100. char s[10];
  101. fl_font( FL_HELVETICA, 8 );
  102. snprintf( s, sizeof( s ), "%.1f", value() );
  103. fl_draw( s, X, Y, W, H, FL_ALIGN_BOTTOM );
  104. }