/*
- Copyright (C) 2002 Paul Davis
+ Copyright (C) 2002-2006 Paul Davis
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include <gtkmm2ext/gtk_ui.h>
#include <gtkmm2ext/stop_signal.h>
#include <gtkmm2ext/choice.h>
-#include <gtkmm2ext/bindable_button.h>
#include <gtkmm2ext/doi.h>
+#include <gtkmm2ext/bindable_button.h>
#include <ardour/route_group.h>
#include <ardour/route.h>
#include <ardour/audio_track.h>
-#include <ardour/diskstream.h>
+#include <ardour/audio_diskstream.h>
#include "i18n.h"
using namespace sigc;
using namespace Gtk;
using namespace Gtkmm2ext;
using namespace ARDOUR;
+using namespace PBD;
RouteUI::RouteUI (ARDOUR::Route& rt, ARDOUR::Session& sess, const char* m_name,
xml_node = 0;
mute_menu = 0;
solo_menu = 0;
+ remote_control_menu = 0;
ignore_toggle = false;
wait_for_release = false;
route_active_menu_item = 0;
_route.GoingAway.connect (mem_fun (*this, &RouteUI::route_removed));
_route.active_changed.connect (mem_fun (*this, &RouteUI::route_active_changed));
- mute_button = manage (new BindableToggleButton (& _route.midi_mute_control(), m_name ));
- mute_button->set_bind_button_state (2, GDK_CONTROL_MASK);
- solo_button = manage (new BindableToggleButton (& _route.midi_solo_control(), s_name ));
- solo_button->set_bind_button_state (2, GDK_CONTROL_MASK);
-
+ mute_button = manage (new BindableToggleButton (_route.mute_control(), m_name ));
+ solo_button = manage (new BindableToggleButton (_route.solo_control(), s_name ));
+
if (is_audio_track()) {
AudioTrack* at = dynamic_cast<AudioTrack*>(&_route);
get_diskstream()->record_enable_changed.connect (mem_fun (*this, &RouteUI::route_rec_enable_changed));
- _session.RecordEnabled.connect (mem_fun (*this, &RouteUI::session_rec_enable_changed));
- _session.RecordDisabled.connect (mem_fun (*this, &RouteUI::session_rec_enable_changed));
+ _session.RecordStateChanged.connect (mem_fun (*this, &RouteUI::session_rec_enable_changed));
- rec_enable_button = manage (new BindableToggleButton (& at->midi_rec_enable_control(), r_name ));
- rec_enable_button->set_bind_button_state (2, GDK_CONTROL_MASK);
+ rec_enable_button = manage (new BindableToggleButton (at->rec_enable_control(), r_name ));
- } else {
- rec_enable_button = manage (new BindableToggleButton (0, r_name ));
- }
+ rec_enable_button->unset_flags (Gtk::CAN_FOCUS);
+
+ update_rec_display ();
+ }
mute_button->unset_flags (Gtk::CAN_FOCUS);
solo_button->unset_flags (Gtk::CAN_FOCUS);
- rec_enable_button->unset_flags (Gtk::CAN_FOCUS);
/* map the current state */
- update_rec_display ();
map_frozen ();
}
}
- return stop_signal (*mute_button, "button-press-event");
+ return true;
}
gint
// undo the last op
// because the press was the last undoable thing we did
_session.undo (1U);
- stop_signal (*mute_button, "button-release-event");
}
}
- return TRUE;
+ return true;
}
gint
}
}
- return stop_signal (*solo_button, "button-press-event");
+ return true;
}
gint
RouteUI::solo_release(GdkEventButton* ev)
{
- if(!ignore_toggle){
- if (wait_for_release){
+ if (!ignore_toggle) {
+ if (wait_for_release) {
wait_for_release = false;
// undo the last op
// because the press was the last undoable thing we did
_session.undo (1U);
-
- stop_signal (*solo_button, "button-release-event");
}
}
- return TRUE;
+
+ return true;
}
gint
RouteUI::rec_enable_press(GdkEventButton* ev)
{
- if (!ignore_toggle && is_audio_track()) {
+ if (!ignore_toggle && is_audio_track() && rec_enable_button) {
if (ev->button == 2 && Keyboard::modifier_state_equals (ev->state, Keyboard::Control)) {
// do nothing on midi bind event
}
}
+void
+RouteUI::build_remote_control_menu ()
+{
+ remote_control_menu = manage (new Menu);
+ refresh_remote_control_menu ();
+}
+
+void
+RouteUI::refresh_remote_control_menu ()
+{
+ using namespace Menu_Helpers;
+
+ RadioMenuItem::Group rc_group;
+ CheckMenuItem* rc_active;
+ uint32_t limit = _session.ntracks();
+ char buf[32];
+
+ MenuList& rc_items = remote_control_menu->items();
+ rc_items.clear ();
+
+ /* note that this menu list starts at zero, not 1, because zero
+ is a valid, if useless, ID.
+ */
+
+ limit += 4; /* leave some breathing room */
+
+ rc_items.push_back (RadioMenuElem (rc_group, _("None")));
+ if (_route.remote_control_id() == 0) {
+ rc_active = dynamic_cast<CheckMenuItem*> (&rc_items.back());
+ rc_active->set_active ();
+ }
+
+ for (uint32_t i = 1; i < limit; ++i) {
+ snprintf (buf, sizeof (buf), "%u", i);
+ rc_items.push_back (RadioMenuElem (rc_group, buf));
+ rc_active = dynamic_cast<RadioMenuItem*>(&rc_items.back());
+ if (_route.remote_control_id() == i) {
+ rc_active = dynamic_cast<CheckMenuItem*> (&rc_items.back());
+ rc_active->set_active ();
+ }
+ rc_active->signal_activate().connect (bind (mem_fun (*this, &RouteUI::set_remote_control_id), i, rc_active));
+ }
+}
+
+void
+RouteUI::set_remote_control_id (uint32_t id, CheckMenuItem* item)
+{
+ /* this is called when the radio menu item is toggled, and so
+ is actually invoked twice per menu selection. we only
+ care about the invocation for the item that was being
+ marked active.
+ */
+
+ if (item->get_active()) {
+ _route.set_remote_control_id (id);
+ }
+}
+
void
RouteUI::build_solo_menu (void)
{
check->show_all();
items.push_back (SeparatorElem());
- items.push_back (MenuElem (_("MIDI Bind"), mem_fun (*mute_button, &BindableToggleButton::midi_learn)));
+ // items.push_back (MenuElem (_("MIDI Bind"), mem_fun (*mute_button, &BindableToggleButton::midi_learn)));
}
check->show_all();
items.push_back (SeparatorElem());
- items.push_back (MenuElem (_("MIDI Bind"), mem_fun (*mute_button, &BindableToggleButton::midi_learn)));
+ // items.push_back (MenuElem (_("MIDI Bind"), mem_fun (*mute_button, &BindableToggleButton::midi_learn)));
}
void
{
bool picked;
Gdk::Color color;
- Gdk::Color current;
-
- current.set_red ( _color.get_red() / 65535.0);
- current.set_green (_color.get_green() / 65535.0);
- current.set_blue (_color.get_blue() / 65535.0);
- //current[3] = 1.0;
- color = Gtkmm2ext::UI::instance()->get_color (_("ardour: color selection"), picked, ¤t);
+ color = Gtkmm2ext::UI::instance()->get_color (_("ardour: color selection"), picked, &_color);
if (picked) {
set_color (color);
}
void
-RouteUI::set_color (Gdk::Color c)
+RouteUI::set_color (const Gdk::Color & c)
{
char buf[64];
}
XMLNode*
-RouteUI::get_child_xml_node (string childname)
+RouteUI::get_child_xml_node (const string & childname)
{
XMLNode* child;
string prompt;
if (is_audio_track()) {
- prompt = string_compose (_("Do you really want to remove track \"%1\" ?\nYou may also lose the playlist used by this track.\n(cannot be undone)"), _route.name());
+ prompt = string_compose (_("Do you really want to remove track \"%1\" ?\n\nYou may also lose the playlist used by this track.\n(cannot be undone)"), _route.name());
} else {
prompt = string_compose (_("Do you really want to remove bus \"%1\" ?\n(cannot be undone)"), _route.name());
}
- choices.push_back (_("Yes, remove it."));
choices.push_back (_("No, do nothing."));
+ choices.push_back (_("Yes, remove it."));
Choice prompter (prompt, choices);
- prompter.chosen.connect (Gtk::Main::quit.slot());
- prompter.show_all ();
-
- Gtk::Main::run ();
-
- if (prompter.get_choice() == 0) {
- Glib::signal_idle().connect (bind (sigc::ptr_fun (&RouteUI::idle_remove_this_route), this));
+ if (prompter.run () == 1) {
+ Glib::signal_idle().connect (bind (sigc::ptr_fun (&RouteUI::idle_remove_this_route), this));
}
}
{
ArdourPrompter name_prompter (true);
string result;
- name_prompter.set_prompt (_("new name: "));
+ name_prompter.set_prompt (_("New Name: "));
name_prompter.set_initial_text (_route.name());
+ name_prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
+ name_prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
name_prompter.show_all ();
switch (name_prompter.run ()) {
- case GTK_RESPONSE_ACCEPT:
- name_prompter.get_result (result);
- if (result.length()) {
- strip_whitespace_edges (result);
+ case Gtk::RESPONSE_ACCEPT:
+ name_prompter.get_result (result);
+ if (result.length()) {
_route.set_name (result, this);
}
break;
RouteUI::name_changed (void *src)
{
ENSURE_GUI_THREAD(bind (mem_fun (*this, &RouteUI::name_changed), src));
-
+
name_label.set_text (_route.name());
}
}
}
+void
+RouteUI::toggle_polarity ()
+{
+ if (polarity_menu_item) {
+
+ bool x;
+
+ ENSURE_GUI_THREAD(mem_fun (*this, &RouteUI::toggle_polarity));
+
+ if ((x = polarity_menu_item->get_active()) != _route.phase_invert()) {
+ _route.set_phase_invert (x, this);
+ if (x) {
+ name_label.set_text (X_("Ø ") + name_label.get_text());
+ } else {
+ name_label.set_text (_route.name());
+ }
+ }
+ }
+}
+
+void
+RouteUI::polarity_changed ()
+{
+ /* no signal for this yet */
+}
+
void
RouteUI::solo_safe_toggle(void* src, Gtk::CheckMenuItem* check)
{
return dynamic_cast<AudioTrack*>(&_route) != 0;
}
-DiskStream*
+AudioDiskstream*
RouteUI::get_diskstream () const
{
AudioTrack *at;