Merged with trunk R846
[ardour.git] / gtk2_ardour / route_time_axis.cc
index cb9883b8e6acf9f8835ac5e8272927510eafd6a2..e7a6df2f273c2ec0f8da018f91845e4e9f9bacec 100644 (file)
@@ -29,6 +29,7 @@
 #include <pbd/error.h>
 #include <pbd/stl_delete.h>
 #include <pbd/whitespace.h>
+#include <pbd/memento_command.h>
 
 #include <gtkmm/menu.h>
 #include <gtkmm/menuitem.h>
@@ -60,8 +61,6 @@
 #include "gui_thread.h"
 #include "keyboard.h"
 #include "playlist_selector.h"
-#include "plugin_selector.h"
-#include "plugin_ui.h"
 #include "point_selection.h"
 #include "prompter.h"
 #include "public_editor.h"
@@ -575,46 +574,88 @@ RouteTimeAxisView::set_height (TrackHeight h)
        switch (height_style) {
        case Largest:
                xml_node->add_property ("track_height", "largest");
-               show_name_entry ();
-               hide_name_label ();
-               controls_table.show_all();
                break;
+
        case Large:
                xml_node->add_property ("track_height", "large");
-               show_name_entry ();
-               hide_name_label ();
-               controls_table.show_all();
                break;
+
        case Larger:
                xml_node->add_property ("track_height", "larger");
-               show_name_entry ();
-               hide_name_label ();
-               controls_table.show_all();
                break;
+
        case Normal:
                xml_node->add_property ("track_height", "normal");
+               break;
+
+       case Smaller:
+               xml_node->add_property ("track_height", "smaller");
+               break;
+
+       case Small:
+               xml_node->add_property ("track_height", "small");
+               break;
+       }
+
+       switch (height_style) {
+       case Largest:
+       case Large:
+       case Larger:
+       case Normal:
                show_name_entry ();
                hide_name_label ();
-               controls_table.show_all();
+
+               mute_button->show_all();
+               solo_button->show_all();
+               if (rec_enable_button)
+                       rec_enable_button->show_all();
+
+               edit_group_button.show_all();
+               hide_button.show_all();
+               visual_button.show_all();
+               size_button.show_all();
+               automation_button.show_all();
+               
+               if (is_track() && track()->mode() == ARDOUR::Normal) {
+                       playlist_button.show_all();
+               }
                break;
+
        case Smaller:
-               xml_node->add_property ("track_height", "smaller");
-               controls_table.show_all ();
                show_name_entry ();
                hide_name_label ();
+
+               mute_button->show_all();
+               solo_button->show_all();
+               if (rec_enable_button)
+                       rec_enable_button->show_all();
+
                edit_group_button.hide ();
                hide_button.hide ();
                visual_button.hide ();
                size_button.hide ();
                automation_button.hide ();
-               playlist_button.hide ();
+               
+               if (is_track() && track()->mode() == ARDOUR::Normal) {
+                       playlist_button.hide ();
+               }
                break;
+
        case Small:
-               xml_node->add_property ("track_height", "small");
-               controls_table.hide_all ();
-               controls_table.show ();
                hide_name_entry ();
                show_name_label ();
+
+               mute_button->hide();
+               solo_button->hide();
+               if (rec_enable_button)
+                       rec_enable_button->hide();
+
+               edit_group_button.hide ();
+               hide_button.hide ();
+               visual_button.hide ();
+               size_button.hide ();
+               automation_button.hide ();
+               playlist_button.hide ();
                name_label.set_text (_route->name());
                break;
        }
@@ -687,7 +728,7 @@ RouteTimeAxisView::rename_current_playlist ()
        ArdourPrompter prompter (true);
        string name;
 
-       Diskstream *const ds = get_diskstream();
+       boost::shared_ptr<Diskstream> ds = get_diskstream();
        if (!ds || ds->destructive())
                return;
 
@@ -718,7 +759,7 @@ RouteTimeAxisView::use_copy_playlist (bool prompt)
 {
        string name;
        
-       Diskstream *const ds = get_diskstream();
+       boost::shared_ptr<Diskstream> ds = get_diskstream();
        if (!ds || ds->destructive())
                return;
 
@@ -759,7 +800,7 @@ RouteTimeAxisView::use_new_playlist (bool prompt)
 {
        string name;
        
-       Diskstream *const ds = get_diskstream();
+       boost::shared_ptr<Diskstream> ds = get_diskstream();
        if (!ds || ds->destructive())
                return;
 
@@ -797,7 +838,7 @@ RouteTimeAxisView::use_new_playlist (bool prompt)
 void
 RouteTimeAxisView::clear_playlist ()
 {
-       Diskstream *const ds = get_diskstream();
+       boost::shared_ptr<Diskstream> ds = get_diskstream();
        if (!ds || ds->destructive())
                return;
 
@@ -837,8 +878,7 @@ RouteTimeAxisView::selection_click (GdkEventButton* ev)
 
        switch (Keyboard::selection_type (ev->state)) {
        case Selection::Toggle:
-               /* XXX this is not right */
-               editor.get_selection().add (*tracks);
+               editor.get_selection().toggle (*tracks);
                break;
                
        case Selection::Set:
@@ -923,7 +963,7 @@ RouteTimeAxisView::name() const
 Playlist *
 RouteTimeAxisView::playlist () const 
 {
-       Diskstream *ds;
+       boost::shared_ptr<Diskstream> ds;
 
        if ((ds = get_diskstream()) != 0) {
                return ds->playlist(); 
@@ -973,7 +1013,7 @@ RouteTimeAxisView::hide_click ()
 Region*
 RouteTimeAxisView::find_next_region (jack_nframes_t pos, RegionPoint point, int32_t dir)
 {
-       Diskstream *stream;
+       boost::shared_ptr<Diskstream> stream;
        Playlist *playlist;
 
        if ((stream = get_diskstream()) != 0 && (playlist = stream->playlist()) != 0) {
@@ -987,7 +1027,7 @@ bool
 RouteTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
 {
        Playlist* what_we_got;
-       Diskstream* ds = get_diskstream();
+       boost::shared_ptr<Diskstream> ds = get_diskstream();
        Playlist* playlist;
        bool ret = false;
 
@@ -1008,12 +1048,12 @@ RouteTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
                }
        }
        
+       XMLNode &before = playlist->get_state();
        switch (op) {
        case Cut:
-               _session.add_undo (playlist->get_memento());
                if ((what_we_got = playlist->cut (time)) != 0) {
                        editor.get_cut_buffer().add (what_we_got);
-                       _session.add_redo_no_execute (playlist->get_memento());
+                       _session.add_command( new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
                        ret = true;
                }
                break;
@@ -1024,9 +1064,8 @@ RouteTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
                break;
 
        case Clear:
-               _session.add_undo (playlist->get_memento());
                if ((what_we_got = playlist->cut (time)) != 0) {
-                       _session.add_redo_no_execute (playlist->get_memento());
+                       _session.add_command( new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
                        what_we_got->unref ();
                        ret = true;
                }
@@ -1055,9 +1094,9 @@ RouteTimeAxisView::paste (jack_nframes_t pos, float times, Selection& selection,
        if (get_diskstream()->speed() != 1.0f)
                pos = session_frame_to_track_frame(pos, get_diskstream()->speed() );
        
-       _session.add_undo (playlist->get_memento());
+       XMLNode &before = playlist->get_state();
        playlist->paste (**p, pos, times);
-       _session.add_redo_no_execute (playlist->get_memento());
+       _session.add_command( new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
 
        return true;
 }