summaryrefslogtreecommitdiff
path: root/tools/bb/gui.cc
diff options
context:
space:
mode:
Diffstat (limited to 'tools/bb/gui.cc')
-rw-r--r--tools/bb/gui.cc77
1 files changed, 77 insertions, 0 deletions
diff --git a/tools/bb/gui.cc b/tools/bb/gui.cc
new file mode 100644
index 0000000000..cdb34eb124
--- /dev/null
+++ b/tools/bb/gui.cc
@@ -0,0 +1,77 @@
+#include "bb.h"
+#include "gui.h"
+
+BBGUI::BBGUI (int* argc, char** argv[], jack_client_t* j, BeatBox* bb)
+ : jack (j)
+ , bbox (bb)
+ , main (argc, argv)
+ , quantize_off (quantize_group, "None")
+ , quantize_32nd (quantize_group, "ThirtySecond")
+ , quantize_16th (quantize_group, "Sixteenth")
+ , quantize_8th (quantize_group, "Eighth")
+ , quantize_quarter (quantize_group, "Quarter")
+ , quantize_half (quantize_group, "Half")
+ , quantize_whole (quantize_group, "Whole")
+ , play_button ("Run")
+ , clear_button ("Clear")
+{
+ quantize_off.signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &BBGUI::set_quantize), 0));
+ quantize_32nd.signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &BBGUI::set_quantize), 32));
+ quantize_16th.signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &BBGUI::set_quantize), 16));
+ quantize_8th.signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &BBGUI::set_quantize), 8));
+ quantize_quarter.signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &BBGUI::set_quantize), 4));
+ quantize_half.signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &BBGUI::set_quantize), 2));
+ quantize_whole.signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &BBGUI::set_quantize), 1));
+
+ quantize_button_box.pack_start (quantize_off);
+ quantize_button_box.pack_start (quantize_32nd);
+ quantize_button_box.pack_start (quantize_16th);
+ quantize_button_box.pack_start (quantize_8th);
+ quantize_button_box.pack_start (quantize_quarter);
+ quantize_button_box.pack_start (quantize_half);
+ quantize_button_box.pack_start (quantize_whole);
+
+ play_button.signal_toggled().connect (sigc::mem_fun (*this, &BBGUI::toggle_play));
+ clear_button.signal_clicked().connect (sigc::mem_fun (*this, &BBGUI::clear));
+
+ misc_button_box.pack_start (play_button);
+ misc_button_box.pack_start (clear_button);
+
+ global_vbox.pack_start (misc_button_box);
+ global_vbox.pack_start (quantize_button_box, true, true);
+ window.add (global_vbox);
+ window.show_all ();
+}
+
+BBGUI::~BBGUI ()
+{
+}
+
+void
+BBGUI::run ()
+{
+ window.show ();
+ main.run ();
+}
+
+void
+BBGUI::set_quantize (int divisor)
+{
+ bbox->set_quantize (divisor);
+}
+
+void
+BBGUI::clear ()
+{
+ bbox->clear ();
+}
+
+void
+BBGUI::toggle_play ()
+{
+ if (bbox->running()) {
+ bbox->stop ();
+ } else {
+ bbox->start ();
+ }
+}