Only show user-presets in favorite sidebar
[ardour.git] / tools / bb / gui.cc
1 #include "bb.h"
2 #include "gui.h"
3
4 BBGUI::BBGUI (int* argc, char** argv[], jack_client_t* j, BeatBox* bb)
5         : jack (j)
6         , bbox (bb)
7         , main (argc, argv)
8         , quantize_off (quantize_group, "None")
9         , quantize_32nd (quantize_group, "ThirtySecond")
10         , quantize_16th (quantize_group, "Sixteenth")
11         , quantize_8th (quantize_group, "Eighth")
12         , quantize_quarter (quantize_group, "Quarter")
13         , quantize_half (quantize_group, "Half")
14         , quantize_whole (quantize_group, "Whole")
15         , play_button ("Run")
16         , clear_button ("Clear")
17         , tempo_adjustment (bb->tempo(), 1, 300, 1, 10)
18         , tempo_spinner (tempo_adjustment)
19 {
20         quantize_off.signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &BBGUI::set_quantize), 0));
21         quantize_32nd.signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &BBGUI::set_quantize), 32));
22         quantize_16th.signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &BBGUI::set_quantize), 16));
23         quantize_8th.signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &BBGUI::set_quantize), 8));
24         quantize_quarter.signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &BBGUI::set_quantize), 4));
25         quantize_half.signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &BBGUI::set_quantize), 2));
26         quantize_whole.signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &BBGUI::set_quantize), 1));
27
28         quantize_button_box.pack_start (quantize_off);
29         quantize_button_box.pack_start (quantize_32nd);
30         quantize_button_box.pack_start (quantize_16th);
31         quantize_button_box.pack_start (quantize_8th);
32         quantize_button_box.pack_start (quantize_quarter);
33         quantize_button_box.pack_start (quantize_half);
34         quantize_button_box.pack_start (quantize_whole);
35
36         play_button.signal_toggled().connect (sigc::mem_fun (*this, &BBGUI::toggle_play));
37         clear_button.signal_clicked().connect (sigc::mem_fun (*this, &BBGUI::clear));
38
39         misc_button_box.pack_start (play_button);
40         misc_button_box.pack_start (clear_button);
41
42         tempo_adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &BBGUI::tempo_changed));
43
44         misc_button_box.pack_start (tempo_spinner);
45
46         global_vbox.pack_start (misc_button_box);
47         global_vbox.pack_start (quantize_button_box, true, true);
48         window.add (global_vbox);
49         window.show_all ();
50 }
51
52 BBGUI::~BBGUI ()
53 {
54 }
55
56 void
57 BBGUI::run ()
58 {
59         window.show ();
60         main.run ();
61 }
62
63 void
64 BBGUI::tempo_changed ()
65 {
66         float t = tempo_adjustment.get_value();
67         bbox->set_tempo (t);
68 }
69
70 void
71 BBGUI::set_quantize (int divisor)
72 {
73         bbox->set_quantize (divisor);
74 }
75
76 void
77 BBGUI::clear ()
78 {
79         bbox->clear ();
80 }
81
82 void
83 BBGUI::toggle_play ()
84 {
85         if (bbox->running()) {
86                 bbox->stop ();
87         } else {
88                 bbox->start ();
89         }
90 }