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.

134 lines
3.6KB

  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_SliderX.H"
  19. #include <FL/Fl.H>
  20. #include <FL/fl_draw.H>
  21. void
  22. Fl_SliderX::draw ( int X, int Y, int W, int H)
  23. {
  24. int act = active_r();
  25. if (damage()&FL_DAMAGE_ALL) draw_box();
  26. double val;
  27. if (minimum() == maximum())
  28. val = 0.5;
  29. else {
  30. val = (value()-minimum())/(maximum()-minimum());
  31. if (val > 1.0) val = 1.0;
  32. else if (val < 0.0) val = 0.0;
  33. }
  34. int ww = (horizontal() ? W : H);
  35. int hh = (horizontal() ? H : W);
  36. int xx, S;
  37. /* S = int(val*ww+.5); */
  38. /* if (minimum()>maximum()) {S = ww-S; xx = ww-S;} */
  39. /* else xx = 0; */
  40. {
  41. //S = //int(ww+.5);
  42. S = hh;
  43. int T = (horizontal() ? H : W)/2+1;
  44. // if (type()==FL_VERT_NICE_SLIDER || type()==FL_HOR_NICE_SLIDER) T += 4;
  45. if (S < T) S = T;
  46. xx = int(val*(ww-S)+.5);
  47. }
  48. int xsl, ysl, wsl, hsl;
  49. if (horizontal()) {
  50. xsl = X+xx;
  51. wsl = S;
  52. ysl = Y + hh/2;
  53. hsl = hh/4;
  54. } else {
  55. ysl = Y+xx;
  56. hsl = S;
  57. xsl = X + hh/2;
  58. wsl = hh/4;
  59. }
  60. {
  61. fl_push_clip(X, Y, W, H);
  62. draw_box();
  63. fl_pop_clip();
  64. }
  65. //draw_bg(X, Y, W, H);
  66. fl_line_style( FL_SOLID, hh/6 );
  67. Fl_Color c = fl_darker(color());
  68. if ( !act )
  69. c = fl_inactive(c);
  70. fl_color(c);
  71. if ( horizontal() )
  72. fl_line ( X + S/2, Y + hh/2, X + W - S/2, Y + hh/2 );
  73. else
  74. fl_line ( X + hh/2, Y + S/2, X + hh/2, Y + H - S/2 );
  75. c = selection_color();
  76. if ( !act )
  77. c = fl_inactive(c);
  78. fl_color( c );
  79. if ( horizontal() )
  80. fl_line ( X + S/2, ysl, xsl + S/2, ysl );
  81. else
  82. fl_line ( X + S/2, Y + H - S/2, xsl, ysl + (S/2) );
  83. fl_line_style( FL_SOLID, 0 );
  84. if ( act )
  85. {
  86. fl_push_matrix();
  87. if ( horizontal() )
  88. fl_translate( xsl + (hh/2), ysl);
  89. else
  90. fl_translate( xsl, ysl + (hh/2) );
  91. fl_color( fl_color_add_alpha( FL_WHITE, 127 ));
  92. fl_begin_polygon(); fl_circle(0.0,0.0, hh/3); fl_end_polygon();
  93. fl_color( FL_WHITE );
  94. fl_begin_polygon(); fl_circle(0.0,0.0, hh/6); fl_end_polygon();
  95. fl_pop_matrix();
  96. }
  97. draw_label(xsl, ysl, wsl, hsl);
  98. if (Fl::focus() == this) {
  99. draw_focus();
  100. }
  101. /* draw(x()+Fl::box_dx(box()), */
  102. /* y()+Fl::box_dy(box()), */
  103. /* w()-Fl::box_dw(box()), */
  104. /* h()-Fl::box_dh(box())); */
  105. }