summaryrefslogtreecommitdiff
path: root/gtk2_ardour/editor_hscroller.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2005-12-12 20:54:55 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2005-12-12 20:54:55 +0000
commit3733c995c5269756ca5941a9db50c6a965787508 (patch)
treee2152d49f8bd6daadf616d7b68aed2c8350d105a /gtk2_ardour/editor_hscroller.cc
parent088a5289dc41b9066e9f518b94af546f80601d56 (diff)
editor window layout changes, and lots more
git-svn-id: svn://localhost/trunk/ardour2@187 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/editor_hscroller.cc')
-rw-r--r--gtk2_ardour/editor_hscroller.cc238
1 files changed, 13 insertions, 225 deletions
diff --git a/gtk2_ardour/editor_hscroller.cc b/gtk2_ardour/editor_hscroller.cc
index d918983f94..049f19b85f 100644
--- a/gtk2_ardour/editor_hscroller.cc
+++ b/gtk2_ardour/editor_hscroller.cc
@@ -26,244 +26,32 @@ using namespace std;
using namespace ARDOUR;
void
-Editor::hscroll_slider_allocate (Gtk::Allocation &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;
+ horizontal_adjustment.set_upper (session->current_end_frame() / frames_per_unit);
}
- /* 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;
- edit_hscroll_slider.add_modal_grab();
- }
-
- 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;
- edit_hscroll_slider.remove_modal_grab();
- }
-
- return TRUE;
+ return true;
}
-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;
- }
-
- 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 (edit_hscroll_dragging) {
+ // lets do a tempo redisplay only on button release, because it is dog slow
+ tempo_map_changed (Change (0));
+ edit_hscroll_dragging = false;
}
}
- if (new_frame != leftmost_frame) {
- reposition_x_origin (new_frame);
- }
-
- edit_hscroll_drag_last = x;
-
- return TRUE;
-}
-
-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)
-{
- 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;
+ 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;
-}