4 #include <fltk/Widget.h>
5 #include <fltk/events.h>
12 Metronome::Metronome(int x
, int y
, int w
, int h
, const char* label
= 0) : fltk::Widget(x
, y
, w
, h
, label
) {
24 int Metronome::handle(int event
){
28 void Metronome::draw(){
31 //setcolor(fltk::color(r,g,b));
32 //fillrect(2,2,w()-4,h()-4);
34 setcolor(fltk::WHITE
);
35 int X
= last_beat
%N
*(w()-4)/N
+2;
38 fillrect(X
,2,W
,h()-4);
42 //setcolor(fltk::color(r,g,b));
43 //fillrect(X+W/2-W2/2,h()/2-H2/2,W2,H2);
45 //setcolor(fltk::BLACK);
46 //int C = (getascent()-getdescent())/2;
47 //drawtext(label(),X+W/2-getwidth(label())/2,h()/2+C);
51 //div N is the greatest divisor of N less than or equal to sqrt(N)
54 for(int i
=1; i
<=sqrt(N
); i
++){
65 void Metronome::update(int tick
){
66 int now_beat
= tick
/128;
68 if(now_beat
!= last_beat
){
69 int step
= last_beat
- now_beat
;
73 snprintf(buf
,16,"%d",now_beat
%N
+ plus
);
79 else if(now_beat
%n
== 0){
90 void Metronome::set_N(int zN
){