Third set of 50 GPL attribution for CV-Contributors added +
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / panedividers.C
1 /*
2  * CINELERRA
3  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
4  * 
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  * 
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  * 
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  * 
19  */
20
21 #include "bcsignals.h"
22 #include "cursors.h"
23 #include "mwindow.h"
24 #include "mwindowgui.h"
25 #include "panedividers.h"
26 #include "theme.h"
27
28
29 PaneDivider::PaneDivider(MWindow *mwindow, int x, int y, int length, int is_x)
30  : BC_SubWindow(x,
31         y,
32         is_x ? mwindow->theme->pane_w : length,
33         is_x ? length : mwindow->theme->pane_h,
34         mwindow->theme->pane_color)
35 {
36         this->mwindow = mwindow;
37         this->is_x = is_x;
38         button_down = 0;
39         is_dragging = 0;
40         images[0] = images[1]= images[2] = 0;
41         status = BUTTON_UP;
42 }
43
44 PaneDivider::~PaneDivider()
45 {
46         delete images[0];
47         delete images[1];
48         delete images[2];
49 }
50
51 void PaneDivider::create_objects()
52 {
53         VFrame **image_src;
54         if(is_x)
55         {
56                 set_cursor(HSEPARATE_CURSOR, 0, 0);
57                 image_src = mwindow->theme->get_image_set("xpane");
58         }
59         else
60         {
61                 set_cursor(VSEPARATE_CURSOR, 0, 0);
62                 image_src = mwindow->theme->get_image_set("ypane");
63         }
64
65         for(int i = 0; i < 3; i++)
66         {
67                 images[i] = new BC_Pixmap(this, image_src[i], PIXMAP_ALPHA);
68         }
69
70         draw(0);
71 }
72
73 void PaneDivider::draw(int flush)
74 {
75         if(is_x)
76         {
77                 draw_3segmentv(0,
78                         0,
79                         get_h(),
80                         images[status]);
81         }
82         else
83         {
84                 draw_3segmenth(0,
85                         0,
86                         get_w(),
87                         images[status]);
88         }
89         this->flash(flush);
90 }
91
92 void PaneDivider::reposition_window(int x, int y, int length)
93 {
94         BC_SubWindow::reposition_window(x,
95                 y,
96                 is_x ? mwindow->theme->pane_w : length,
97
98                 is_x ? length : mwindow->theme->pane_h);
99 }
100
101 int PaneDivider::button_press_event()
102 {
103         if(is_event_win())
104         {
105                 origin_x = get_cursor_x();
106                 origin_y = get_cursor_y();
107                 button_down = 1;
108                 status = BUTTON_DOWNHI;
109                 draw(1);
110                 return 0;
111         }
112         return 0;
113 }
114
115 int PaneDivider::button_release_event()
116 {
117         if(button_down)
118         {
119                 button_down = 0;
120
121                 if(is_dragging)
122                 {
123                         is_dragging = 0;
124 // might be deleted in here
125                         mwindow->gui->stop_pane_drag();
126                         status = BUTTON_UPHI;
127                         draw(1);
128                 }
129
130                 return 1;
131         }
132         return 0;
133 }
134
135 int PaneDivider::cursor_motion_event()
136 {
137         if(button_down)
138         {
139                 if(!is_dragging)
140                 {
141                         if(is_x && abs(get_cursor_x() - origin_x) > 5)
142                         {
143                                 is_dragging = 1;
144                                 mwindow->gui->start_x_pane_drag();
145                         }
146                         else
147                         if(!is_x && abs(get_cursor_y() - origin_y) > 5)
148                         {
149                                 is_dragging = 1;
150                                 mwindow->gui->start_y_pane_drag();
151                         }
152                 }
153                 else
154                 {
155                         mwindow->gui->handle_pane_drag();
156                 }
157                 return 1;
158         }
159         return 0;
160 }
161
162
163 int PaneDivider::cursor_enter_event()
164 {
165         if(is_event_win())
166         {
167                 if(get_button_down())
168                 {
169                         status = BUTTON_DOWNHI;
170                 }
171                 else
172                 if(status == BUTTON_UP)
173                 {
174                         status = BUTTON_UPHI;
175                 }
176
177                 draw(1);
178         }
179         return 0;
180 }
181
182 int PaneDivider::cursor_leave_event()
183 {
184         if(status == BUTTON_UPHI)
185         {
186                 status = BUTTON_UP;
187
188                 draw(1);
189
190
191         }
192         return 0;
193 }
194
195
196
197
198
199
200
201
202
203