4 * Copyright (C) 1997-2014 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "edlsession.h"
24 #include "localsession.h"
25 #include "maincursor.h"
27 #include "mwindowgui.h"
29 #include "mainsession.h"
31 #include "timelinepane.h"
32 #include "trackcanvas.h"
34 #include "trackscroll.h"
36 TrackScroll::TrackScroll(MWindow *mwindow,
49 this->mwindow = mwindow;
55 TrackScroll::TrackScroll(MWindow *mwindow,
68 this->mwindow = mwindow;
69 this->gui = mwindow->gui;
74 TrackScroll::~TrackScroll()
78 long TrackScroll::get_distance()
80 return get_value() - old_position;
83 int TrackScroll::update()
88 int TrackScroll::resize_event()
90 reposition_window(mwindow->theme->mvscroll_x,
91 mwindow->theme->mvscroll_y,
92 mwindow->theme->mvscroll_h);
97 int TrackScroll::resize_event(int x, int y, int h)
106 int TrackScroll::flip_vertical(int top, int bottom)
111 void TrackScroll::set_position()
113 int64_t max_pos = mwindow->edl->get_tracks_height(mwindow->theme) - pane->view_h;
114 if( max_pos < 0 ) max_pos = 0;
115 if( mwindow->edl->local_session->track_start[pane->number] > max_pos )
116 mwindow->edl->local_session->track_start[pane->number] = max_pos;
117 if( pane->number == TOP_RIGHT_PANE ) {
118 if( mwindow->edl->local_session->track_start[TOP_LEFT_PANE] > max_pos )
119 mwindow->edl->local_session->track_start[TOP_LEFT_PANE] = max_pos;
121 else if( pane->number == BOTTOM_RIGHT_PANE ) {
122 if( mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] > max_pos )
123 mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] = max_pos;
126 mwindow->edl->get_tracks_height(mwindow->theme),
127 mwindow->edl->local_session->track_start[pane->number],
132 int TrackScroll::handle_event()
134 int64_t distance = get_value() -
135 mwindow->edl->local_session->track_start[pane->number];
136 mwindow->trackmovement(distance, pane->number);
137 // mwindow->edl->local_session->track_start[pane->number] = get_value();
138 // if(pane->number == TOP_RIGHT_PANE)
139 // mwindow->edl->local_session->track_start[TOP_LEFT_PANE] =
140 // mwindow->edl->local_session->track_start[pane->number];
142 // if(pane->number == BOTTOM_RIGHT_PANE)
143 // mwindow->edl->local_session->track_start[BOTTOM_LEFT_PANE] =
144 // mwindow->edl->local_session->track_start[pane->number];
146 // mwindow->edl->tracks->update_y_pixels(mwindow->theme);
147 // mwindow->gui->draw_canvas(0, 0);
148 // mwindow->gui->draw_cursor(1);
149 // mwindow->gui->update_patchbay();
150 // mwindow->gui->flash_canvas(1);
151 // Scrollbar must be active to trap button release events
152 // mwindow->gui->canvas->activate();
153 old_position = get_value();