X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Feditor_hscroller.cc;h=f5f94c416372ada64ea1ef53a5a4f932b964dc08;hb=f420fed45db5417b5360c525ae1fcc8e919f3ac9;hp=01fd06107df4b24dfff8db376789e23000157cb7;hpb=2d32c7da360194e33e821badaf2bff89f3ec70a0;p=ardour.git diff --git a/gtk2_ardour/editor_hscroller.cc b/gtk2_ardour/editor_hscroller.cc index 01fd06107d..f5f94c4163 100644 --- a/gtk2_ardour/editor_hscroller.cc +++ b/gtk2_ardour/editor_hscroller.cc @@ -15,7 +15,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id$ */ #include "editor.h" @@ -24,247 +23,35 @@ using namespace std; using namespace ARDOUR; +using namespace PBD; void -Editor::hscroll_slider_allocate (GtkAllocation *alloc) +Editor::hscrollbar_allocate (Gtk::Allocation &alloc) { - //edit_hscroll_slider_width = alloc->width; - //edit_hscroll_slider_height = alloc->height ; - - if (session) { - track_canvas_scroller.get_hadjustment()->set_upper (session->current_end_frame() / frames_per_unit); - } - -} - -gint -Editor::hscroll_slider_expose (GdkEventExpose *ev) -{ - GdkRectangle draw_rect; - GdkRectangle bar_rect; - gint bar_max = edit_hscroll_slider_width - 2; - - bar_rect.y = 1; - bar_rect.height = edit_hscroll_slider_height - 2; - - if (session) { - bar_rect.width = (gint) floor (bar_max * ((canvas_width * frames_per_unit) / session->current_end_frame())); - - if (bar_rect.width > bar_max) { - bar_rect.x = 1; - bar_rect.width = bar_max; - } else { - bar_rect.x = 1 + (gint) floor (bar_max * ((double) leftmost_frame / session->current_end_frame())); - } - - } else { - bar_rect.x = 1; - bar_rect.width = bar_max; - } - - /* make sure we can see the bar at all times, and have enough to do zoom-trim on */ - - bar_rect.width = max ((guint16) (edit_hscroll_edge_width+5), (guint16) bar_rect.width); - - gdk_rectangle_intersect (&ev->area, &bar_rect, &draw_rect); - - gtk_paint_box (edit_hscroll_slider.get_style()->gobj(), - edit_hscroll_slider.get_window()->gobj(), - GTK_STATE_ACTIVE, - GTK_SHADOW_IN, - &ev->area, - GTK_WIDGET(edit_hscroll_slider.gobj()), - "trough", - 0, 0, -1, -1); - - gtk_paint_box (edit_hscroll_slider.get_style()->gobj(), - edit_hscroll_slider.get_window()->gobj(), - GTK_STATE_NORMAL, - GTK_SHADOW_OUT, - &draw_rect, - GTK_WIDGET(edit_hscroll_slider.gobj()), - "hscale", - bar_rect.x, bar_rect.y, bar_rect.width, bar_rect.height); - - - return TRUE; } -gint -Editor::hscroll_slider_button_press (GdkEventButton *ev) +bool +Editor::hscrollbar_button_press (GdkEventButton *ev) { - if (!session) { - return TRUE; - } - - edit_hscroll_dragging = true; - //cerr << "PRESS" << endl; - - return TRUE; - - gint start; - gint width; - gint end; - gint x; - - start = (gint) floor (edit_hscroll_slider_width * ((double) leftmost_frame / session->current_end_frame())); - width = (gint) floor (edit_hscroll_slider_width * ((canvas_width * frames_per_unit) / session->current_end_frame())); - - end = start + width - 1; - x = (gint) max (0.0, ev->x); - - if (x >= start && x <= end) { - - edit_hscroll_drag_last = x; - edit_hscroll_dragging = true; - Gtk::Main::grab_add (edit_hscroll_slider); - } - - return TRUE; -} - -gint -Editor::hscroll_slider_button_release (GdkEventButton *ev) -{ - if (!session) { - return TRUE; - } - - gint start; - gint width; - gint end; - gint x; - gint bar_max = edit_hscroll_slider_width - 2; - jack_nframes_t new_leftmost = 0; - - //cerr << "RELESAE" << endl; - - if (edit_hscroll_dragging) { - // lets do a tempo redisplay now only, because it is dog slow - tempo_map_changed (Change (0)); - edit_hscroll_dragging = false; - } - - return TRUE; - - - start = (gint) floor (bar_max * ((double) leftmost_frame / session->current_end_frame())); - width = (gint) floor (bar_max * ((canvas_width * frames_per_unit) / session->current_end_frame())); - - end = start + width - 1; - x = (gint) max (0.0, ev->x); - - if (!edit_hscroll_dragging) { - - new_leftmost = (jack_nframes_t) floor (((double) x/bar_max) * session->current_end_frame()); - reposition_x_origin (new_leftmost); - } - - if (edit_hscroll_dragging) { - // lets do a tempo redisplay now only, because it is dog slow - tempo_map_changed (Change (0)); - edit_hscroll_dragging = false; - Gtk::Main::grab_remove (edit_hscroll_slider); - } - - return TRUE; + _dragging_hscrollbar = true; + return false; } -gint -Editor::hscroll_slider_motion (GdkEventMotion *ev) +bool +Editor::hscrollbar_button_release (GdkEventButton *ev) { - gint x, y; - Gdk::ModifierType state; - gint bar_max = edit_hscroll_slider_width - 2; - - if (!session || !edit_hscroll_dragging) { - return TRUE; - } + _dragging_hscrollbar = false; - edit_hscroll_slider.get_window()->get_pointer (x, y, state); - - jack_nframes_t new_frame; - jack_nframes_t frames; - double distance; - double fract; - - distance = x - edit_hscroll_drag_last; - fract = fabs (distance) / bar_max; - frames = (jack_nframes_t) floor (session->current_end_frame() * fract); - - if (distance < 0) { - if (leftmost_frame < frames) { - new_frame = 0; - } else { - new_frame = leftmost_frame - frames; - } - } else { - if (leftmost_frame > max_frames - frames) { - new_frame = max_frames; - } else { - new_frame = leftmost_frame + frames; - } - } + if (session) { - if (new_frame != leftmost_frame) { - reposition_x_origin (new_frame); } - edit_hscroll_drag_last = x; - - return TRUE; + return false; } void -Editor::update_hscroller () -{ - //edit_hscroll_slider.queue_draw (); -// if (session) { -// track_canvas_scroller.get_hadjustment()->set_upper (session->current_end_frame() / frames_per_unit); -// track_canvas_scroller.get_hadjustment()->set_value (leftmost_frame/frames_per_unit); -// } -} - -gint -Editor::hscroll_left_arrow_button_press (GdkEventButton *ev) +Editor::reset_hscrollbar_stepping () { - if (!session) { - return FALSE; - } - - start_canvas_autoscroll (-1); - return TRUE; -} - -gint -Editor::hscroll_right_arrow_button_press (GdkEventButton *ev) -{ - if (!session) { - return FALSE; - } - - start_canvas_autoscroll (1); - return TRUE; -} - -gint -Editor::hscroll_left_arrow_button_release (GdkEventButton *ev) -{ - if (!session) { - return FALSE; - } - - stop_canvas_autoscroll (); - return TRUE; -} - -gint -Editor::hscroll_right_arrow_button_release (GdkEventButton *ev) -{ - if (!session) { - return FALSE; - } - - stop_canvas_autoscroll (); - return TRUE; + horizontal_adjustment.set_step_increment ((current_page_frames() / 5)/frames_per_unit); /* 5 clicks to scroll the entire page */ + horizontal_adjustment.set_page_increment (current_page_frames()/frames_per_unit); }