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.

121 lines
3.5KB

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