remove incorrectly named
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / trackscroll.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 1997-2014 Adam Williams <broadcast at earthling dot net>
5  *
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.
10  *
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.
15  *
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
19  *
20  */
21
22 #include "edl.h"
23 #include "edlsession.h"
24 #include "localsession.h"
25 #include "maincursor.h"
26 #include "mwindow.h"
27 #include "mwindowgui.h"
28 #include "patchbay.h"
29 #include "mainsession.h"
30 #include "theme.h"
31 #include "timelinepane.h"
32 #include "trackcanvas.h"
33 #include "tracks.h"
34 #include "trackscroll.h"
35
36 TrackScroll::TrackScroll(MWindow *mwindow,
37         MWindowGUI *gui,
38         int x,
39         int y,
40         int h)
41  : BC_ScrollBar(x,
42         y,
43         SCROLL_VERT,
44         h,
45         0,
46         0,
47         0)
48 {
49         this->mwindow = mwindow;
50         this->gui = gui;
51         this->pane = 0;
52         old_position = 0;
53 }
54
55 TrackScroll::TrackScroll(MWindow *mwindow,
56         TimelinePane *pane,
57         int x,
58         int y,
59         int h)
60  : BC_ScrollBar(x,
61         y,
62         SCROLL_VERT,
63         h,
64         0,
65         0,
66         0)
67 {
68         this->mwindow = mwindow;
69         this->gui = mwindow->gui;
70         this->pane = pane;
71         old_position = 0;
72 }
73
74 TrackScroll::~TrackScroll()
75 {
76 }
77
78 long TrackScroll::get_distance()
79 {
80         return get_value() - old_position;
81 }
82
83 int TrackScroll::update()
84 {
85         return 0;
86 }
87
88 int TrackScroll::resize_event()
89 {
90         reposition_window(mwindow->theme->mvscroll_x,
91                 mwindow->theme->mvscroll_y,
92                 mwindow->theme->mvscroll_h);
93         update();
94         return 0;
95 }
96
97 int TrackScroll::resize_event(int x, int y, int h)
98 {
99         reposition_window(x,
100                 y,
101                 h);
102         update();
103         return 0;
104 }
105
106 int TrackScroll::flip_vertical(int top, int bottom)
107 {
108         return 0;
109 }
110
111 void TrackScroll::set_position()
112 {
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;
120         }
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;
124         }
125         update_length(
126                 mwindow->edl->get_tracks_height(mwindow->theme),
127                 mwindow->edl->local_session->track_start[pane->number],
128                 pane->view_h,
129                 0);
130 }
131
132 int TrackScroll::handle_event()
133 {
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];
141 //      else
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];
145 //
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();
154         return 1;
155 }