From: Nick Mainsbridge Date: Sat, 2 Sep 2006 02:54:04 +0000 (+0000) Subject: make autoscroll a bit easier to use, fix missing measure lines when moving the editor... X-Git-Tag: 2.0beta4~31 X-Git-Url: https://git.carlh.net/gitweb/?a=commitdiff_plain;h=cb17e3cc81c364ed0ea7f4620d745aefe691386a;p=ardour.git make autoscroll a bit easier to use, fix missing measure lines when moving the editor pane, slight optimisation(?) of canvas-simplerect (seems to make a difference to me), fix dirty pixels when moving regions across tracks sometimes. some code cleanup. git-svn-id: svn://localhost/ardour2/trunk@885 d708f5d6-7413-0410-9779-e7cbd77b26cf --- diff --git a/gtk2_ardour/canvas-simplerect.c b/gtk2_ardour/canvas-simplerect.c index abddf5756b..d59096e68b 100644 --- a/gtk2_ardour/canvas-simplerect.c +++ b/gtk2_ardour/canvas-simplerect.c @@ -263,7 +263,7 @@ gnome_canvas_simplerect_reset_bounds (GnomeCanvasItem *item) GnomeCanvasSimpleRect* simplerect; double x1, x2, y1, y2; double old_x1, old_x2, old_y1, old_y2; - double a, b; + double a, b, c, d; old_x1 = item->x1; old_y1 = item->y1; @@ -287,42 +287,24 @@ gnome_canvas_simplerect_reset_bounds (GnomeCanvasItem *item) gnome_canvas_w2c (GNOME_CANVAS(item->canvas), x2, y2, &simplerect->bbox_lrx, &simplerect->bbox_lry); /* now queue redraws for changed areas */ - - if (item->x1 != old_x1) { - - /* left edge changed. redraw the area that altered */ a = MIN(item->x1, old_x1); b = MAX(item->x1, old_x1); - gnome_canvas_request_redraw (item->canvas, a - 1, item->y1, b + 1, item->y2); - } - - if (item->x2 != old_x2) { - - /* right edge changed. redraw the area that altered */ - - a = MIN(item->x2, old_x2); - b = MAX(item->x2, old_x2); - gnome_canvas_request_redraw (item->canvas, a - 1, item->y1, b + 1, item->y2); - } - - if (item->y1 != old_y1) { - - /* top edge changed. redraw the area that altered */ - - a = MIN(item->y1, old_y1); - b = MAX(item->y1, old_y1); - gnome_canvas_request_redraw (item->canvas, item->x1, a - 1, item->x2, b + 1); - } - - if (item->y2 != old_y2) { - - /* lower edge changed. redraw the area that altered */ - - a = MIN(item->y2, old_y2); - b = MAX(item->y2, old_y2); - gnome_canvas_request_redraw (item->canvas, item->x1, a - 1, item->x2, b + 1); - } + + a = MIN(a, item->x2); + a = MIN(a, old_x2); + b = MAX(b, item->x2); + b = MAX(b, old_x2); + + c = MIN(item->y1, old_y1); + d = MAX(item->y1, old_y1); + + c = MIN(c,item->y2); + c = MIN(c, old_y2); + d = MAX(d,item->y2); + d = MAX(d, old_y2); + + gnome_canvas_request_redraw (item->canvas, a, c, b + 0.5, d + 0.5); } /* @@ -494,8 +476,8 @@ gnome_canvas_simplerect_update (GnomeCanvasItem *item, double *affine, ArtSVP *c gnome_canvas_request_redraw (item->canvas, simplerect->bbox_ulx, simplerect->bbox_uly, - simplerect->bbox_lrx+1, - simplerect->bbox_lry+1); + simplerect->bbox_lrx+0.5, + simplerect->bbox_lry+0.5); simplerect->full_draw_on_update = FALSE; } diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index f86b83504e..7a8341dc2f 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -643,7 +643,7 @@ Editor::Editor (AudioEngine& eng) edit_pane.pack1 (edit_packer, true, true); edit_pane.pack2 (the_notebook, false, true); - edit_pane.signal_size_allocate().connect_notify (bind (mem_fun(*this, &Editor::pane_allocation_handler), static_cast (&edit_pane))); + edit_pane.signal_size_allocate().connect (bind (mem_fun(*this, &Editor::pane_allocation_handler), static_cast (&edit_pane))); top_hbox.pack_start (toolbar_frame, true, true); diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 689e7e8ab8..246fa7c608 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -1506,7 +1506,7 @@ class Editor : public PublicEditor jack_nframes_t autoscroll_distance; static gint _autoscroll_canvas (void *); - gint autoscroll_canvas (); + bool autoscroll_canvas (); void start_canvas_autoscroll (int direction); void stop_canvas_autoscroll (); void maybe_autoscroll (GdkEvent*); diff --git a/gtk2_ardour/editor_canvas.cc b/gtk2_ardour/editor_canvas.cc index 51138a5a67..946df13334 100644 --- a/gtk2_ardour/editor_canvas.cc +++ b/gtk2_ardour/editor_canvas.cc @@ -273,7 +273,6 @@ Editor::initialize_canvas () void Editor::track_canvas_allocate (Gtk::Allocation alloc) { - static bool first_time = true; canvas_width = alloc.get_width(); canvas_height = alloc.get_height(); @@ -320,12 +319,9 @@ Editor::track_canvas_allocate (Gtk::Allocation alloc) update_fixed_rulers (); - if (is_visible() && first_time) { + if (is_visible()) { tempo_map_changed (Change (0)); - first_time = false; - } else { - redisplay_tempo (); - } + } Resized (); /* EMIT_SIGNAL */ } @@ -531,7 +527,7 @@ Editor::maybe_autoscroll (GdkEvent* event) } - if (autoscroll_direction != last_autoscroll_direction) { + if ((autoscroll_direction != last_autoscroll_direction) || (leftmost_frame < frame < rightmost_frame)) { stop_canvas_autoscroll (); } @@ -545,14 +541,13 @@ Editor::maybe_autoscroll (GdkEvent* event) gint Editor::_autoscroll_canvas (void *arg) { - return ((Editor *) arg)->autoscroll_canvas (); + return ((Editor *) arg)->autoscroll_canvas (); } -gint +bool Editor::autoscroll_canvas () { jack_nframes_t new_frame; - bool keep_calling = true; jack_nframes_t limit = max_frames - current_page_frames(); GdkEventMotion ev; jack_nframes_t target_frame; @@ -573,10 +568,6 @@ Editor::autoscroll_canvas () target_frame = drag_info.current_pointer_frame + autoscroll_distance; } - if (new_frame != leftmost_frame) { - reposition_x_origin (new_frame); - } - /* now fake a motion event to get the object that is being dragged to move too */ ev.type = GDK_MOTION_NOTIFY; @@ -596,20 +587,26 @@ Editor::autoscroll_canvas () /* connect the timeout so that we get called repeatedly */ - autoscroll_timeout_tag = g_timeout_add (20, _autoscroll_canvas, this); - keep_calling = false; + autoscroll_timeout_tag = g_idle_add ( _autoscroll_canvas, this); + return false; + + } - } else if (autoscroll_cnt == 50) { /* 0.5 seconds */ + if (new_frame != leftmost_frame) { + reposition_x_origin (new_frame); + } + + if (autoscroll_cnt == 50) { /* 0.5 seconds */ /* after about a while, speed up a bit by changing the timeout interval */ - autoscroll_distance = (jack_nframes_t) floor (current_page_frames()/50.0f); + autoscroll_distance = (jack_nframes_t) floor (current_page_frames()/30.0f); - } else if (autoscroll_cnt == 75) { /* 1.0 seconds */ + } else if (autoscroll_cnt == 150) { /* 1.0 seconds */ autoscroll_distance = (jack_nframes_t) floor (current_page_frames()/20.0f); - } else if (autoscroll_cnt == 100) { /* 1.5 seconds */ + } else if (autoscroll_cnt == 300) { /* 1.5 seconds */ /* after about another while, speed up by increasing the shift per callback */ @@ -617,7 +614,7 @@ Editor::autoscroll_canvas () } - return keep_calling; + return true; } void @@ -634,7 +631,7 @@ Editor::start_canvas_autoscroll (int dir) autoscroll_cnt = 0; /* do it right now, which will start the repeated callbacks */ - + autoscroll_canvas (); } diff --git a/gtk2_ardour/route_time_axis.cc b/gtk2_ardour/route_time_axis.cc index 27d1739fd4..c94d3d2e71 100644 --- a/gtk2_ardour/route_time_axis.cc +++ b/gtk2_ardour/route_time_axis.cc @@ -118,6 +118,8 @@ RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session& sess, boost::sh hide_button.add (*(manage (new Image (get_xpm("small_x.xpm"))))); + /* XXX is this incomplete? i don't think its very useful atm + solo_button->signal_button_press_event().connect (mem_fun (*this, &RouteTimeAxisView::select_me), false); mute_button->signal_button_press_event().connect (mem_fun (*this, &RouteTimeAxisView::select_me), false); playlist_button.signal_button_press_event().connect (mem_fun (*this, &RouteTimeAxisView::select_me), false); @@ -125,6 +127,7 @@ RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session& sess, boost::sh size_button.signal_button_press_event().connect (mem_fun (*this, &RouteTimeAxisView::select_me), false); visual_button.signal_button_press_event().connect (mem_fun (*this, &RouteTimeAxisView::select_me), false); hide_button.signal_button_press_event().connect (mem_fun (*this, &RouteTimeAxisView::select_me), false); + */ solo_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::solo_press), false); solo_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::solo_release), false); @@ -140,7 +143,7 @@ RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session& sess, boost::sh if (is_track()) { rec_enable_button->set_active (false); rec_enable_button->set_name ("TrackRecordEnableButton"); - rec_enable_button->signal_button_press_event().connect (mem_fun (*this, &RouteTimeAxisView::select_me), false); + //rec_enable_button->signal_button_press_event().connect (mem_fun (*this, &RouteTimeAxisView::select_me), false); rec_enable_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::rec_enable_press)); controls_table.attach (*rec_enable_button, 5, 6, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0); ARDOUR_UI::instance()->tooltips().set_tip(*rec_enable_button, _("Record")); diff --git a/gtk2_ardour/route_ui.cc b/gtk2_ardour/route_ui.cc index 2b95ff9cfb..67433c33a4 100644 --- a/gtk2_ardour/route_ui.cc +++ b/gtk2_ardour/route_ui.cc @@ -98,7 +98,7 @@ RouteUI::~RouteUI() delete mute_menu; } -gint +bool RouteUI::mute_press(GdkEventButton* ev) { if (!ignore_toggle) { @@ -159,7 +159,7 @@ RouteUI::mute_press(GdkEventButton* ev) return true; } -gint +bool RouteUI::mute_release(GdkEventButton* ev) { if (!ignore_toggle) { @@ -173,7 +173,7 @@ RouteUI::mute_release(GdkEventButton* ev) return true; } -gint +bool RouteUI::solo_press(GdkEventButton* ev) { if (!ignore_toggle) { @@ -253,7 +253,7 @@ RouteUI::solo_press(GdkEventButton* ev) return true; } -gint +bool RouteUI::solo_release(GdkEventButton* ev) { if (!ignore_toggle) { @@ -269,7 +269,7 @@ RouteUI::solo_release(GdkEventButton* ev) return true; } -gint +bool RouteUI::rec_enable_press(GdkEventButton* ev) { if (!ignore_toggle && is_track() && rec_enable_button) { diff --git a/gtk2_ardour/route_ui.h b/gtk2_ardour/route_ui.h index 8a257028e9..ea86041986 100644 --- a/gtk2_ardour/route_ui.h +++ b/gtk2_ardour/route_ui.h @@ -87,11 +87,11 @@ class RouteUI : public virtual AxisView XMLNode* get_child_xml_node (const string & childname); - gint mute_press(GdkEventButton*); - gint mute_release(GdkEventButton*); - gint solo_press(GdkEventButton*); - gint solo_release(GdkEventButton*); - gint rec_enable_press(GdkEventButton*); + bool mute_press(GdkEventButton*); + bool mute_release(GdkEventButton*); + bool solo_press(GdkEventButton*); + bool solo_release(GdkEventButton*); + bool rec_enable_press(GdkEventButton*); void solo_changed(void*); void mute_changed(void*);