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 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. void Fl_Vert_Progress::draw()
  10. {
  11. int progress; // Size of progress bar...
  12. int bx, by, bw, bh; // Box areas...
  13. int tx, ty, tw, th; // Temporary X + width
  14. float min_ = minimum();
  15. float max_ = maximum();
  16. float val_ = value();
  17. // Get the box borders...
  18. bx = Fl::box_dx(box());
  19. by = Fl::box_dy(box());
  20. bw = Fl::box_dw(box());
  21. bh = Fl::box_dh(box());
  22. tx = x() + bx;
  23. ty = y() + by;
  24. tw = w() - bw;
  25. th = h() - bh;
  26. // Draw the progress bar...
  27. if (max_ > min_)
  28. progress = (int)( th * (val_ - min_) / (max_ - min_) );
  29. else
  30. progress = 0;
  31. // Draw the box and label...
  32. if (progress > 0)
  33. {
  34. Fl_Color c = labelcolor();
  35. labelcolor(fl_contrast(labelcolor(), selection_color()));
  36. // draw the progress area
  37. //fl_push_clip(x(), y() + h() - progress, w(), progress);
  38. fl_push_clip(tx,ty + th - progress, tw, progress );
  39. draw_box(box(), x(), y(), w(), h(), active_r() ? selection_color() : fl_inactive(selection_color()));
  40. draw_label(tx, y() + by, tw, h() - bh);
  41. fl_pop_clip();
  42. labelcolor(c);
  43. if (progress<w())
  44. {
  45. // draw the non-progress area
  46. //fl_push_clip(x(), y(), w(), h() - progress );
  47. fl_push_clip(tx,ty,tw,th-progress );
  48. draw_box(box(), x(), y(), w(), h(), active_r() ? color() : fl_inactive(color()));
  49. draw_label(tx, y() + by, tw, h() - bh);
  50. fl_pop_clip();
  51. }
  52. }
  53. else
  54. {
  55. draw_box(box(), x(), y(), w(), h(), active_r() ? color() : fl_inactive(color()));
  56. draw_label(tx, y() + by, tw, h() - bh);
  57. }
  58. //fl_draw_box(FL_FLAT_BOX,x(),y(),w(),h(), FL_RED);
  59. //fl_draw_box(FL_FLAT_BOX,tx,ty,tw,th, FL_GREEN);
  60. //fl_draw_box(FL_FLAT_BOX,tx,ty,tw,th-progress, FL_BLACK); // non-prog
  61. //fl_draw_box(FL_FLAT_BOX,tx,ty + th - progress,tw,progress,FL_BLUE); // prog
  62. }