From 3e9048fffaa3e8c52bbc5f25b91dd6c84c57a580 Mon Sep 17 00:00:00 2001 From: Krzysztof Foltman Date: Sat, 26 Oct 2013 13:14:32 +0100 Subject: [PATCH] Add an option to disable the VU meters in the JACK host window. --- calf-gui.xml | 26 +++++++++++++++++++- src/calf/gtk_main_win.h | 3 ++- src/calf/gui_config.h | 1 + src/gtk_main_win.cpp | 65 +++++++++++++++++++++++++++++++++++-------------- src/gui_config.cpp | 3 +++ 5 files changed, 78 insertions(+), 20 deletions(-) diff --git a/calf-gui.xml b/calf-gui.xml index 4c8ac00..7b5707e 100644 --- a/calf-gui.xml +++ b/calf-gui.xml @@ -105,7 +105,7 @@ True - 3 + 4 2 10 @@ -172,6 +172,30 @@ 3 + + + True + Show volume meters + + + 3 + 4 + + + + + True + True + False + True + + + 1 + 2 + 3 + 4 + + 1 diff --git a/src/calf/gtk_main_win.h b/src/calf/gtk_main_win.h index a3b5771..8f29630 100644 --- a/src/calf/gtk_main_win.h +++ b/src/calf/gtk_main_win.h @@ -35,7 +35,7 @@ namespace calf_plugins { gtk_main_window *main_win; plugin_ctl_iface *plugin; plugin_gui_window *gui_win; - GtkWidget *strip_table, *name, *button, *midi_in, *extra, *leftBox, *rightBox; + GtkWidget *strip_table, *name, *button, *midi_in, *extra, *leftBox, *rightBox, *inBox, *outBox; std::vector audio_in, audio_out; }; @@ -93,6 +93,7 @@ namespace calf_plugins { bool save_file_as(); void save_file_from_sighandler(); void show_rack_ears(bool show); + void show_vu_meters(bool show); /// Implementation of progress_report_iface function virtual void report_progress(float percentage, const std::string &message); /// Mark condition as true diff --git a/src/calf/gui_config.h b/src/calf/gui_config.h index 2006c28..6e781a8 100644 --- a/src/calf/gui_config.h +++ b/src/calf/gui_config.h @@ -80,6 +80,7 @@ struct gui_config { int rack_float, float_size; bool rack_ears; + bool vu_meters; gui_config(); ~gui_config(); diff --git a/src/gtk_main_win.cpp b/src/gtk_main_win.cpp index d3add7c..12e463e 100644 --- a/src/gtk_main_win.cpp +++ b/src/gtk_main_win.cpp @@ -108,12 +108,14 @@ void gtk_main_window::on_preferences_action(GtkWidget *widget, gtk_main_window * gtk_spin_button_set_increments(GTK_SPIN_BUTTON(gtk_builder_get_object(prefs_builder, "float-size")), 1, 1); gtk_spin_button_set_value(GTK_SPIN_BUTTON(gtk_builder_get_object(prefs_builder, "rack-float")), main->get_config()->rack_float); gtk_spin_button_set_value(GTK_SPIN_BUTTON(gtk_builder_get_object(prefs_builder, "float-size")), main->get_config()->float_size); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gtk_builder_get_object(prefs_builder, "show-vu-meters")), main->get_config()->vu_meters); int response = gtk_dialog_run(GTK_DIALOG(preferences_dlg)); if (response == GTK_RESPONSE_OK) { main->get_config()->rack_ears = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gtk_builder_get_object(prefs_builder, "show-rack-ears"))); main->get_config()->rack_float = gtk_spin_button_get_value(GTK_SPIN_BUTTON(gtk_builder_get_object(prefs_builder, "rack-float"))); main->get_config()->float_size = gtk_spin_button_get_value(GTK_SPIN_BUTTON(gtk_builder_get_object(prefs_builder, "float-size"))); + main->get_config()->vu_meters = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gtk_builder_get_object(prefs_builder, "show-vu-meters"))); main->get_config()->save(main->get_config_db()); } gtk_widget_destroy(preferences_dlg); @@ -209,7 +211,7 @@ extra_button_pressed(GtkWidget *button, gtk_main_window::plugin_strip *strip) void gtk_main_window::show_rack_ears(bool show) { - for (std::map::iterator i = plugins.begin(); i != plugins.end(); i++) + for (std::map::iterator i = plugins.begin(); i != plugins.end(); ++i) { if (show) { @@ -224,6 +226,27 @@ void gtk_main_window::show_rack_ears(bool show) } } +void gtk_main_window::show_vu_meters(bool show) +{ + for (std::map::iterator i = plugins.begin(); i != plugins.end(); ++i) + { + if (show) + { + if (i->second->inBox) + gtk_widget_show(i->second->inBox); + if (i->second->outBox) + gtk_widget_show(i->second->outBox); + } + else + { + if (i->second->inBox) + gtk_widget_hide(i->second->inBox); + if (i->second->outBox) + gtk_widget_hide(i->second->outBox); + } + } +} + gtk_main_window::plugin_strip *gtk_main_window::create_strip(plugin_ctl_iface *plugin) { plugin_strip *strip = new plugin_strip; @@ -337,15 +360,16 @@ gtk_main_window::plugin_strip *gtk_main_window::create_strip(plugin_ctl_iface *p } strip->midi_in = label; - + strip->inBox = NULL; + strip->outBox = NULL; strip->audio_in.clear(); strip->audio_out.clear(); if (metadata->get_input_count() >= 1) { - GtkWidget *inBox = gtk_vbox_new(FALSE, 1); + strip->inBox = gtk_vbox_new(FALSE, 1); - gtk_box_pack_start(GTK_BOX(inBox), gtk_label_new("audio in"),TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(strip->inBox), gtk_label_new("audio in"),TRUE, TRUE, 0); for (int i = 0; i < metadata->get_input_count(); i++) { @@ -355,21 +379,21 @@ gtk_main_window::plugin_strip *gtk_main_window::create_strip(plugin_ctl_iface *p calf_vumeter_set_width(CALF_VUMETER(label), 120); calf_vumeter_set_height(CALF_VUMETER(label), 12); calf_vumeter_set_position(CALF_VUMETER(label), 2); - gtk_box_pack_start(GTK_BOX(inBox), label,FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(strip->inBox), label,FALSE, FALSE, 0); strip->audio_in.push_back(label); } - gtk_widget_show_all(inBox); - gtk_table_attach(GTK_TABLE(strip->strip_table), inBox, 3, 4, row, row + 1, GTK_FILL, GTK_SHRINK, 5, 3); + gtk_widget_show_all(strip->inBox); + gtk_table_attach(GTK_TABLE(strip->strip_table), strip->inBox, 3, 4, row, row + 1, GTK_FILL, GTK_SHRINK, 5, 3); - gtk_widget_set_size_request(GTK_WIDGET(inBox), 160, -1); + gtk_widget_set_size_request(GTK_WIDGET(strip->inBox), 160, -1); } if (metadata->get_output_count() >= 1) { - GtkWidget *outBox = gtk_vbox_new(FALSE, 1); + strip->outBox = gtk_vbox_new(FALSE, 1); - gtk_box_pack_start(GTK_BOX(outBox), gtk_label_new("audio out"),TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(strip->outBox), gtk_label_new("audio out"),TRUE, TRUE, 0); for (int i = 0; i < metadata->get_output_count(); i++) { @@ -379,14 +403,14 @@ gtk_main_window::plugin_strip *gtk_main_window::create_strip(plugin_ctl_iface *p calf_vumeter_set_width(CALF_VUMETER(label), 120); calf_vumeter_set_height(CALF_VUMETER(label), 12); calf_vumeter_set_position(CALF_VUMETER(label), 2); - gtk_box_pack_start(GTK_BOX(outBox), label,FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(strip->outBox), label,FALSE, FALSE, 0); strip->audio_out.push_back(label); } - gtk_widget_show_all(outBox); - gtk_table_attach(GTK_TABLE(strip->strip_table), outBox, 4, 5, row, row + 1, GTK_FILL, GTK_SHRINK, 5, 3); + gtk_widget_show_all(strip->outBox); + gtk_table_attach(GTK_TABLE(strip->strip_table), strip->outBox, 4, 5, row, row + 1, GTK_FILL, GTK_SHRINK, 5, 3); - gtk_widget_set_size_request(GTK_WIDGET(outBox), 160, -1); + gtk_widget_set_size_request(GTK_WIDGET(strip->outBox), 160, -1); } // other stuff bottom right @@ -570,6 +594,7 @@ void gtk_main_window::on_config_change() { get_config()->load(get_config_db()); show_rack_ears(get_config()->rack_ears); + show_vu_meters(get_config()->vu_meters); sort_strips(); } @@ -616,11 +641,15 @@ gboolean gtk_main_window::on_idle(void *data) plugin_ctl_iface *plugin = i->first; plugin_strip *strip = i->second; int idx = 0; - for (int i = 0; i < (int)strip->audio_in.size(); i++) { - calf_vumeter_set_value(CALF_VUMETER(strip->audio_in[i]), LVL(plugin->get_level(idx++))); + if (strip->inBox && gtk_widget_is_drawable (strip->inBox)) { + for (int i = 0; i < (int)strip->audio_in.size(); i++) { + calf_vumeter_set_value(CALF_VUMETER(strip->audio_in[i]), LVL(plugin->get_level(idx++))); + } } - for (int i = 0; i < (int)strip->audio_out.size(); i++) { - calf_vumeter_set_value(CALF_VUMETER(strip->audio_out[i]), LVL(plugin->get_level(idx++))); + if (strip->outBox && gtk_widget_is_drawable (strip->outBox)) { + for (int i = 0; i < (int)strip->audio_out.size(); i++) { + calf_vumeter_set_value(CALF_VUMETER(strip->audio_out[i]), LVL(plugin->get_level(idx++))); + } } if (plugin->get_metadata_iface()->get_midi()) { calf_led_set_value (CALF_LED (strip->midi_in), plugin->get_level(idx++)); diff --git a/src/gui_config.cpp b/src/gui_config.cpp index a22d9d8..fc51ab8 100644 --- a/src/gui_config.cpp +++ b/src/gui_config.cpp @@ -10,6 +10,7 @@ gui_config::gui_config() rack_float = 0; float_size = 1; rack_ears = true; + vu_meters = true; } gui_config::~gui_config() @@ -21,6 +22,7 @@ void gui_config::load(config_db_iface *db) rack_float = db->get_int("rack-float", gui_config().rack_float); float_size = db->get_int("float-size", gui_config().float_size); rack_ears = db->get_bool("show-rack-ears", gui_config().rack_ears); + vu_meters = db->get_bool("show-vu-meters", gui_config().vu_meters); } void gui_config::save(config_db_iface *db) @@ -28,6 +30,7 @@ void gui_config::save(config_db_iface *db) db->set_int("rack-float", rack_float); db->set_int("float-size", float_size); db->set_bool("show-rack-ears", rack_ears); + db->set_bool("show-vu-meters", vu_meters); db->save(); } -- 2.11.4.GIT