Programmable real-time audio signal processing application
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

Fl_Vert_Progress.cpp 1.8KB

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