GObject canvas changes
[ardour.git] / gtk2_ardour / audio_time_axis.cc
index f8a460f778348fafa77c4743c81d62da37b24449..1c25863e23203ed5cdba33249076bd8e2d0aebb3 100644 (file)
@@ -51,7 +51,7 @@
 #include "public_editor.h"
 #include "audio_time_axis.h"
 #include "streamview.h"
-#include "canvas-simplerect.h"
+#include "simplerect.h"
 #include "playlist_selector.h"
 #include "plugin_selector.h"
 #include "plugin_ui.h"
@@ -72,6 +72,7 @@
 #include "prompter.h"
 #include "crossfade_view.h"
 #include "gui_thread.h"
+#include "canvas_impl.h"
 
 #include <ardour/audio_track.h>
 
@@ -99,7 +100,7 @@ static const gchar * small_x_xpm[] = {
 "           ",
 "           "};
 
-AudioTimeAxisView::AudioTimeAxisView (PublicEditor& ed, Session& sess, Route& rt, Widget *canvas)
+AudioTimeAxisView::AudioTimeAxisView (PublicEditor& ed, Session& sess, Route& rt, Canvas& canvas)
        : AxisView(sess),
          RouteUI(rt, sess, _("m"), _("s"), _("r")), // mute, solo, and record
          TimeAxisView(sess,ed,(TimeAxisView*) 0, canvas),
@@ -168,7 +169,6 @@ AudioTimeAxisView::AudioTimeAxisView (PublicEditor& ed, Session& sess, Route& rt
        hide_button.signal_clicked().connect (mem_fun(*this, &AudioTimeAxisView::hide_click));
 
        name_entry.signal_activate().connect (mem_fun(*this, &AudioTimeAxisView::name_entry_activated));
-       name_entry.signal_focus_out_event().connect (mem_fun(*this, &AudioTimeAxisView::name_entry_focus_out_handler));
        name_entry.signal_button_press_event().connect (mem_fun(*this, &AudioTimeAxisView::name_entry_button_press_handler));
        name_entry.signal_button_release_event().connect (mem_fun(*this, &AudioTimeAxisView::name_entry_button_release_handler));
        name_entry.signal_key_release_event().connect (mem_fun(*this, &AudioTimeAxisView::name_entry_key_release_handler));
@@ -484,20 +484,18 @@ AudioTimeAxisView::show_timestretch (jack_nframes_t start, jack_nframes_t end)
 #endif
 
        if (timestretch_rect == 0) {
-               timestretch_rect = gnome_canvas_item_new (GNOME_CANVAS_GROUP(canvas_display),
-                                                       gnome_canvas_simplerect_get_type(),
-                                                       "x1", 0.0,
-                                                       "y1", 0.0,
-                                                       "x2", 0.0,
-                                                       "y2", 0.0,
-                                                       "fill_color_rgba", color_map[cTimeStretchFill],
-                                                       "outline_color_rgba" , color_map[cTimeStretchOutline],
-                                                       NULL);
-       }
-
-       gnome_canvas_item_show (timestretch_rect);
-       gnome_canvas_item_raise_to_top (timestretch_rect);
-       
+               timestretch_rect = new SimpleRect (*canvas_display);
+               timestretch_rect->property_x1() =  0.0;
+               timestretch_rect->property_y1() =  0.0;
+               timestretch_rect->property_x2() =  0.0;
+               timestretch_rect->property_y2() =  0.0;
+               timestretch_rect->property_fill_color_rgba() =  color_map[cTimeStretchFill];
+               timestretch_rect->property_outline_color_rgba() = color_map[cTimeStretchOutline];
+       }
+
+       timestretch_rect->show ();
+       timestretch_rect->raise_to_top ();
+
        x1 = start / editor.get_current_zoom();
        x2 = (end - 1) / editor.get_current_zoom();
        y2 = height - 2;
@@ -516,7 +514,7 @@ AudioTimeAxisView::hide_timestretch ()
        TimeAxisView::hide_timestretch ();
 
        if (timestretch_rect) {
-               gnome_canvas_item_hide (timestretch_rect);
+               timestretch_rect->hide ();
        }
 }
 
@@ -1038,9 +1036,9 @@ AudioTimeAxisView::get_selectables (jack_nframes_t start, jack_nframes_t end, do
                speed = get_diskstream()->speed();
        }
        
-       jack_nframes_t start_adjusted = (jack_nframes_t) (start * speed);
-       jack_nframes_t end_adjusted = (jack_nframes_t) (end * speed);
-       
+       jack_nframes_t start_adjusted = session_frame_to_track_frame(start, speed);
+       jack_nframes_t end_adjusted   = session_frame_to_track_frame(end, speed);
+
        if (view && touched (top, bot)) {
                view->get_selectables (start_adjusted, end_adjusted, results);
        }
@@ -1109,13 +1107,6 @@ AudioTimeAxisView::name_entry_button_release_handler (GdkEventButton *ev)
        return FALSE;
 }
 
-gint
-AudioTimeAxisView::name_entry_focus_out_handler (GdkEventFocus* ev)
-{
-       name_entry_changed ();
-       return TRUE;
-}
-
 gint
 AudioTimeAxisView::name_entry_key_release_handler (GdkEventKey* ev)
 {
@@ -1145,8 +1136,6 @@ AudioTimeAxisView::name_entry_changed ()
 {
        string x;
 
-       ARDOUR_UI::generic_focus_out_event (0);
-
        x = name_entry.get_text ();
        
        if (x == _route.name()) {
@@ -1199,15 +1188,20 @@ AudioTimeAxisView::add_gain_automation_child ()
        XMLProperty* prop;
        AutomationLine* line;
 
-       gain_track = new GainAutomationTimeAxisView (_session, _route, editor, *this, parent_canvas, _("gain"),
+       gain_track = new GainAutomationTimeAxisView (_session,
+                                                    _route,
+                                                    editor,
+                                                    *this,
+                                                    parent_canvas,
+                                                    _("gain"),
                                                     _route.gain_automation_curve());
        
-       
-       line = new AutomationGainLine ("automation gain", _session, *gain_track,
-                                                  gain_track->canvas_display,
-                                                  _route.gain_automation_curve(),
-                                                  PublicEditor::canvas_control_point_event,
-                                                  PublicEditor::canvas_line_event);
+       line = new AutomationGainLine ("automation gain",
+                                      _session,
+                                      *gain_track,
+                                      *gain_track->canvas_display,
+                                      _route.gain_automation_curve());
+
        line->set_line_color (color_map[cAutomationLine]);
        
 
@@ -1284,10 +1278,8 @@ AudioTimeAxisView::update_pans ()
                AutomationLine* line;
 
                line = new AutomationPanLine ("automation pan", _session, *pan_track,
-                                             pan_track->canvas_display, 
-                                             (*p)->automation(),
-                                             PublicEditor::canvas_control_point_event,
-                                             PublicEditor::canvas_line_event);
+                                             *pan_track->canvas_display, 
+                                             (*p)->automation());
 
                if (p == _route.panner().begin()) {
                        /* first line is a nice orange */
@@ -1310,7 +1302,7 @@ AudioTimeAxisView::toggle_gain_track ()
        if (showit != gain_track->marked_for_display()) {
                if (showit) {
                        gain_track->set_marked_for_display (true);
-                       gnome_canvas_item_show (gain_track->canvas_display);
+                       gain_track->canvas_display->show();
                        gain_track->get_state_node()->add_property ("shown", X_("yes"));
                } else {
                        gain_track->set_marked_for_display (false);
@@ -1346,7 +1338,7 @@ AudioTimeAxisView::toggle_pan_track ()
        if (showit != pan_track->marked_for_display()) {
                if (showit) {
                        pan_track->set_marked_for_display (true);
-                       gnome_canvas_item_show (pan_track->canvas_display);
+                       pan_track->canvas_display->show();
                        pan_track->get_state_node()->add_property ("shown", X_("yes"));
                } else {
                        pan_track->set_marked_for_display (false);
@@ -1467,9 +1459,7 @@ AudioTimeAxisView::add_redirect_automation_curve (Redirect *redirect, uint32_t w
 
        ral = new RedirectAutomationLine (name, 
                                          *redirect, what, _session, *ran->view,
-                                         ran->view->canvas_display, redirect->automation_list (what), 
-                                         PublicEditor::canvas_control_point_event,
-                                         PublicEditor::canvas_line_event);
+                                         *ran->view->canvas_display, redirect->automation_list (what));
        
        ral->set_line_color (color_map[cRedirectAutomationLine]);
        ral->queue_reset ();
@@ -1621,7 +1611,7 @@ AudioTimeAxisView::redirect_menu_item_toggled (AudioTimeAxisView::RedirectAutoma
 
                if (showit) {
                        ran->view->set_marked_for_display (true);
-                       gnome_canvas_item_show (ran->view->canvas_display);
+                       ran->view->canvas_display->show();
                } else {
                        rai->redirect->mark_automation_visible (ran->what, true);
                        ran->view->set_marked_for_display (false);
@@ -1773,8 +1763,8 @@ AudioTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
        float speed = ds->speed();
        if (speed != 1.0f) {
                for (TimeSelection::iterator i = time.begin(); i != time.end(); ++i) {
-                       (*i).start = (jack_nframes_t)floor( (float) (*i).start * speed);
-                       (*i).end   = (jack_nframes_t)floor( (float) (*i).end   * speed);
+                       (*i).start = session_frame_to_track_frame((*i).start, speed);
+                       (*i).end   = session_frame_to_track_frame((*i).end,   speed);
                }
        }
        
@@ -1823,7 +1813,7 @@ AudioTimeAxisView::paste (jack_nframes_t pos, float times, Selection& selection,
        }
 
        if (get_diskstream()->speed() != 1.0f)
-               pos = (jack_nframes_t) floor( (float) pos * get_diskstream()->speed() );
+               pos = session_frame_to_track_frame(pos, get_diskstream()->speed() );
        
        _session.add_undo (playlist->get_memento());
        playlist->paste (**p, pos, times);