stupid hack to fix issues with OS X Carbon headers
[ardour.git] / gtk2_ardour / route_time_axis.cc
index 3836f4cf6cdd1f86b44f48d60b0b2a2e4e42dbc1..581e3eb23855ff8dece60b6c9574feb5cd3cda8d 100644 (file)
@@ -62,6 +62,7 @@
 #include "evoral/Parameter.hpp"
 
 #include "ardour_ui.h"
+#include "ardour_button.h"
 #include "debug.h"
 #include "global_signals.h"
 #include "route_time_axis.h"
@@ -93,6 +94,7 @@ using namespace Gtkmm2ext;
 using namespace Gtk;
 using namespace Editing;
 using namespace std;
+using std::list;
 
 Glib::RefPtr<Gdk::Pixbuf> RouteTimeAxisView::slider;
 
@@ -110,6 +112,7 @@ RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session* sess, Canvas& c
        , TimeAxisView(sess,ed,(TimeAxisView*) 0, canvas)
        , _view (0)
        , parent_canvas (canvas)
+       , no_redraw (false)
        , button_table (3, 3)
        , route_group_button (_("g"))
        , playlist_button (_("p"))
@@ -156,34 +159,27 @@ RouteTimeAxisView::set_route (boost::shared_ptr<Route> rt)
 
        ignore_toggle = false;
 
-       route_group_button.set_name ("TrackGroupButton");
-       playlist_button.set_name ("TrackPlaylistButton");
-       automation_button.set_name ("TrackAutomationButton");
-
-       route_group_button.unset_flags (Gtk::CAN_FOCUS);
-       playlist_button.unset_flags (Gtk::CAN_FOCUS);
-       automation_button.unset_flags (Gtk::CAN_FOCUS);
+       route_group_button.set_name ("route button");
+       playlist_button.set_name ("route button");
+       automation_button.set_name ("route button");
 
        route_group_button.signal_button_release_event().connect (sigc::mem_fun(*this, &RouteTimeAxisView::route_group_click), false);
-       playlist_button.signal_clicked().connect (sigc::mem_fun(*this, &RouteTimeAxisView::playlist_click));
-       automation_button.signal_clicked().connect (sigc::mem_fun(*this, &RouteTimeAxisView::automation_click));
+       playlist_button.signal_clicked.connect (sigc::mem_fun(*this, &RouteTimeAxisView::playlist_click));
+       automation_button.signal_clicked.connect (sigc::mem_fun(*this, &RouteTimeAxisView::automation_click));
 
        if (is_track()) {
 
                /* use icon */
-
-               rec_enable_button->remove ();
-
+               
                switch (track()->mode()) {
                case ARDOUR::Normal:
                case ARDOUR::NonLayered:
-                       rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_normal_red"))))));
+                       rec_enable_button->set_image (::get_icon (X_("record_normal_red")));
                        break;
                case ARDOUR::Destructive:
-                       rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_tape_red"))))));
+                       rec_enable_button->set_image (::get_icon (X_("record_tape_red")));
                        break;
                }
-               rec_enable_button->show_all ();
 
                controls_table.attach (*rec_enable_button, 5, 6, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
 
@@ -258,6 +254,8 @@ RouteTimeAxisView::set_route (boost::shared_ptr<Route> rt)
        gm.get_gain_slider().signal_scroll_event().connect(sigc::mem_fun(*this, &RouteTimeAxisView::controls_ebox_scroll), false);
        gm.get_gain_slider().set_name ("TrackGainFader");
 
+       gm.get_level_meter().signal_scroll_event().connect (sigc::mem_fun (*this, &RouteTimeAxisView::controls_ebox_scroll), false);
+
        show_name_entry ();
        hide_name_label ();
 }
@@ -470,6 +468,7 @@ RouteTimeAxisView::build_display_menu ()
                                ++overlaid;
                                break;
                        case Stacked:
+                       case Expanded:
                                ++stacked;
                                break;
                        }
@@ -750,10 +749,12 @@ RouteTimeAxisView::set_track_mode (TrackMode mode, bool apply_to_selection)
                switch (mode) {
                case ARDOUR::NonLayered:
                case ARDOUR::Normal:
-                       rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_normal_red"))))));
+                       rec_enable_button->set_image (::get_icon (X_("record_normal_red")));
+                       rec_enable_button->set_text (string());
                        break;
                case ARDOUR::Destructive:
-                       rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_tape_red"))))));
+                       rec_enable_button->set_image (::get_icon (X_("record_tape_red")));
+                       rec_enable_button->set_text (string());
                        break;
                }
 
@@ -911,12 +912,10 @@ RouteTimeAxisView::set_height (uint32_t h)
 }
 
 void
-RouteTimeAxisView::set_color (Gdk::Color const & c)
+RouteTimeAxisView::route_color_changed ()
 {
-       RouteUI::set_color (c);
-
        if (_view) {
-               _view->apply_color (_color, StreamView::RegionColor);
+               _view->apply_color (color(), StreamView::RegionColor);
        }
 }
 
@@ -1299,33 +1298,27 @@ RouteTimeAxisView::playlist () const
 void
 RouteTimeAxisView::name_entry_changed ()
 {
-       string x;
-
-       x = name_entry.get_text ();
+       string x = name_entry.get_text ();
 
        if (x == _route->name()) {
                return;
        }
 
-       strip_whitespace_edges(x);
+       strip_whitespace_edges (x);
 
        if (x.length() == 0) {
                name_entry.set_text (_route->name());
                return;
        }
 
-       if (!_session->route_name_unique (x)) {
-               ARDOUR_UI::instance()->popup_error (_("A track already exists with that name"));
-               name_entry.set_text (_route->name());
-       } else if (_session->route_name_internal (x)) {
+       if (_session->route_name_internal (x)) {
                ARDOUR_UI::instance()->popup_error (string_compose (_("You cannot create a track with that name as it is reserved for %1"),
-                                                                    PROGRAM_NAME));
-               name_entry.set_text (_route->name());
+                                                                   PROGRAM_NAME));
+               name_entry.grab_focus ();
+       } else if (RouteUI::verify_new_route_name (x)) {
+               _route->set_name (x);
        } else {
-
-               if (RouteUI::verify_new_route_name (x)) {
-                       _route->set_name (x);
-               }
+               name_entry.grab_focus ();
        }
 }
 
@@ -1473,18 +1466,10 @@ RouteTimeAxisView::build_playlist_menu ()
        playlist_action_menu->set_name ("ArdourContextMenu");
        playlist_items.clear();
 
-        vector<boost::shared_ptr<Playlist> > playlists, playlists_tr;
-       boost::shared_ptr<Track> tr = track();
        RadioMenuItem::Group playlist_group;
+       boost::shared_ptr<Track> tr = track ();
 
-       _session->playlists->get (playlists);
-
-        /* find the playlists for this diskstream */
-        for (vector<boost::shared_ptr<Playlist> >::iterator i = playlists.begin(); i != playlists.end(); ++i) {
-                if (((*i)->get_orig_diskstream_id() == tr->diskstream_id()) || (tr->playlist()->id() == (*i)->id())) {
-                        playlists_tr.push_back(*i);
-                }
-        }
+        vector<boost::shared_ptr<Playlist> > playlists_tr = _session->playlists->playlists_for_track (tr);
 
         /* sort the playlists */
         PlaylistSorter cmp;
@@ -1889,7 +1874,7 @@ RouteTimeAxisView::add_processor_automation_curve (boost::shared_ptr<Processor>
 }
 
 void
-RouteTimeAxisView::processor_automation_track_hidden (RouteTimeAxisView::ProcessorAutomationNode* pan, boost::shared_ptr<Processor> i)
+RouteTimeAxisView::processor_automation_track_hidden (RouteTimeAxisView::ProcessorAutomationNode* pan, boost::shared_ptr<Processor>)
 {
        if (!_hidden) {
                pan->menu_item->set_active (false);
@@ -2295,7 +2280,7 @@ RouteTimeAxisView::set_underlay_state()
 }
 
 void
-RouteTimeAxisView::add_underlay (StreamView* v, bool update_xml)
+RouteTimeAxisView::add_underlay (StreamView* v, bool /*update_xml*/)
 {
        if (!v) {
                return;
@@ -2360,25 +2345,29 @@ RouteTimeAxisView::remove_underlay (StreamView* v)
 void
 RouteTimeAxisView::set_button_names ()
 {
-       rec_enable_button_label.set_text (_("r"));
-
         if (_route && _route->solo_safe()) {
-                solo_button_label.set_text (X_("!"));
+               solo_button->remove ();
+               if (solo_safe_pixbuf == 0) {
+                       solo_safe_pixbuf = ::get_icon("solo-safe-icon");
+               }
+               solo_button->set_image (solo_safe_pixbuf);
+               solo_button->set_text (string());
         } else {
+               solo_button->set_image (Glib::RefPtr<Gdk::Pixbuf>());
                 if (Config->get_solo_control_is_listen_control()) {
                         switch (Config->get_listen_position()) {
                         case AfterFaderListen:
-                                solo_button_label.set_text (_("A"));
+                                solo_button->set_text (_("A"));
                                 break;
                         case PreFaderListen:
-                                solo_button_label.set_text (_("P"));
+                                solo_button->set_text (_("P"));
                                 break;
                         }
                 } else {
-                        solo_button_label.set_text (_("s"));
+                        solo_button->set_text (_("s"));
                 }
         }
-       mute_button_label.set_text (_("m"));
+       mute_button->set_text (_("m"));
 }
 
 Gtk::CheckMenuItem*
@@ -2495,3 +2484,20 @@ RouteTimeAxisView::state_id() const
 {
        return string_compose ("rtav %1", _route->id().to_s());
 }
+
+
+void
+RouteTimeAxisView::remove_child (boost::shared_ptr<TimeAxisView> c)
+{
+       TimeAxisView::remove_child (c);
+       
+       boost::shared_ptr<AutomationTimeAxisView> a = boost::dynamic_pointer_cast<AutomationTimeAxisView> (c);
+       if (a) {
+               for (AutomationTracks::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
+                       if (i->second == a) {
+                               _automation_tracks.erase (i);
+                               return;
+                       }
+               }
+       }
+}