Programmable real-time audio signal processing application
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.

Fl_Vert_Progress.cpp 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #include <FL/Fl.H>
  2. #include <FL/fl_draw.H>
  3. #include <Fl/Fl_Progress.H>
  4. #include "Fl_Vert_Progress.h"
  5. Fl_Vert_Progress::Fl_Vert_Progress(int x, int y, int w, int h, const char* l)
  6. : Fl_Progress(x,y,w,h)
  7. {
  8. }
  9. // This member function is a slight variation on a verbatim
  10. // copy of Fl_Progress.cxx from the FLTK source library.
  11. void Fl_Vert_Progress::draw()
  12. {
  13. int progress; // Size of progress bar...
  14. int bx, by, bw, bh; // Box areas...
  15. int tx, tw; // Temporary X + width
  16. // Get the box borders...
  17. bx = Fl::box_dx(box());
  18. by = Fl::box_dy(box());
  19. bw = Fl::box_dw(box());
  20. bh = Fl::box_dh(box());
  21. tx = x() + bx;
  22. tw = w() - bw;
  23. // Draw the progress bar...
  24. if (maximum() > minimum())
  25. progress = (int)(h() * (value() - minimum()) / (maximum() - minimum()) + 0.5f);
  26. else
  27. progress = 0;
  28. // Draw the box and label...
  29. if (progress > 0)
  30. {
  31. Fl_Color c = labelcolor();
  32. labelcolor(fl_contrast(labelcolor(), selection_color()));
  33. fl_push_clip(x(), y() + h() - (progress + by), w(), progress + by);
  34. draw_box(box(), x(), y(), w(), h(), active_r() ? selection_color() : fl_inactive(selection_color()));
  35. draw_label(tx, y() + by, tw, h() - bh);
  36. fl_pop_clip();
  37. labelcolor(c);
  38. if (progress<h())
  39. {
  40. fl_push_clip(x(), y(), w(), h()-progress);
  41. draw_box(box(), x(), y(), w(), h(), active_r() ? color() : fl_inactive(color()));
  42. draw_label(tx, y() + by, tw, h() - bh);
  43. fl_pop_clip();
  44. }
  45. }
  46. else
  47. {
  48. draw_box(box(), x(), y(), w(), h(), active_r() ? color() : fl_inactive(color()));
  49. draw_label(tx, y() + by, tw, h() - bh);
  50. }
  51. }