version update, docs Features5 msg/txt, shuttle tweaks for build
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / samplescroll.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 "bcsignals.h"
23 #include "edl.h"
24 #include "edlsession.h"
25 #include "samplescroll.h"
26 #include "localsession.h"
27 #include "maincursor.h"
28 #include "mwindow.h"
29 #include "mwindowgui.h"
30 #include "patchbay.h"
31 #include "mainsession.h"
32 #include "mtimebar.h"
33 #include "theme.h"
34 #include "trackcanvas.h"
35 #include "tracks.h"
36
37 SampleScroll::SampleScroll(MWindow *mwindow,
38         MWindowGUI *gui,
39         int x,
40         int y,
41         int w)
42  : BC_ScrollBar(x,
43         y,
44         SCROLL_HORIZ,
45         w,
46         0,
47         0,
48         0)
49 {
50         this->gui = gui;
51         this->pane = 0;
52         this->mwindow = mwindow;
53         oldposition = 0;
54 }
55
56 SampleScroll::SampleScroll(MWindow *mwindow,
57         TimelinePane *pane,
58         int x,
59         int y,
60         int w)
61  : BC_ScrollBar(x,
62         y,
63         SCROLL_HORIZ,
64         w,
65         0,
66         0,
67         0)
68 {
69         this->gui = mwindow->gui;
70         this->pane = pane;
71         this->mwindow = mwindow;
72         oldposition = 0;
73 }
74
75 SampleScroll::~SampleScroll()
76 {
77 }
78
79 int SampleScroll::flip_vertical()
80 {
81         return 0;
82 }
83
84 int SampleScroll::in_use()
85 {
86         return in_use();
87 }
88
89
90 int SampleScroll::resize_event()
91 {
92         reposition_window(mwindow->theme->mhscroll_x,
93                 mwindow->theme->mhscroll_y,
94                 mwindow->theme->mhscroll_w);
95         return 0;
96 }
97
98 int SampleScroll::resize_event(int x, int y, int w)
99 {
100         reposition_window(x,
101                 y,
102                 w);
103         return 0;
104 }
105
106 int SampleScroll::set_position()
107 {
108         if(!pane->canvas) return 0;
109         long length = Units::round(mwindow->edl->tracks->total_length() *
110                 mwindow->edl->session->sample_rate /
111                 mwindow->edl->local_session->zoom_sample);
112         long position = mwindow->edl->local_session->view_start[pane->number];
113         long handle_size = pane->view_w;
114
115         update_length(length,
116                         position,
117                         handle_size,
118                         0);
119
120         oldposition = position;
121         return 0;
122 }
123
124 int SampleScroll::handle_event()
125 {
126 //printf("SampleScroll::handle_event %d %d\n", __LINE__, get_window_lock());
127         mwindow->edl->local_session->view_start[pane->number] = get_value();
128         if(pane->number == TOP_LEFT_PANE ||
129                 pane->number == BOTTOM_LEFT_PANE)
130         {
131                 mwindow->edl->local_session->view_start[TOP_LEFT_PANE] =
132                         mwindow->edl->local_session->view_start[BOTTOM_LEFT_PANE] =
133                         mwindow->edl->local_session->view_start[pane->number];
134         }
135         else
136         {
137                 mwindow->edl->local_session->view_start[TOP_RIGHT_PANE] =
138                         mwindow->edl->local_session->view_start[BOTTOM_RIGHT_PANE] =
139                         mwindow->edl->local_session->view_start[pane->number];
140         }
141
142         mwindow->gui->draw_canvas(0, 1);
143         mwindow->gui->draw_cursor(1);
144         mwindow->gui->update_timebar(0);
145         mwindow->gui->flash_canvas(0);
146
147 //      if(pane->patchbay) pane->patchbay->update();
148
149
150 //printf("SampleScroll::handle_event %d %d\n", __LINE__, get_window_lock());
151
152         return 1;
153 }