add bluray dv, misc fixes
[goodguy/history.git] / cinelerra-5.1 / cinelerra / panedividers.C
1 #include "bcsignals.h"
2 #include "cursors.h"
3 #include "mwindow.h"
4 #include "mwindowgui.h"
5 #include "panedividers.h"
6 #include "theme.h"
7
8
9 PaneDivider::PaneDivider(MWindow *mwindow, int x, int y, int length, int is_x)
10  : BC_SubWindow(x,
11         y,
12         is_x ? mwindow->theme->pane_w : length,
13         is_x ? length : mwindow->theme->pane_h,
14         mwindow->theme->pane_color)
15 {
16         this->mwindow = mwindow;
17         this->is_x = is_x;
18         button_down = 0;
19         is_dragging = 0;
20         images[0] = images[1]= images[2] = 0;
21         status = BUTTON_UP;
22 }
23
24 PaneDivider::~PaneDivider()
25 {
26         delete images[0];
27         delete images[1];
28         delete images[2];
29 }
30
31 void PaneDivider::create_objects()
32 {
33         VFrame **image_src;
34         if(is_x)
35         {
36                 set_cursor(HSEPARATE_CURSOR, 0, 0);
37                 image_src = mwindow->theme->get_image_set("xpane");
38         }
39         else
40         {
41                 set_cursor(VSEPARATE_CURSOR, 0, 0);
42                 image_src = mwindow->theme->get_image_set("ypane");
43         }
44
45         for(int i = 0; i < 3; i++)
46         {
47                 images[i] = new BC_Pixmap(this, image_src[i], PIXMAP_ALPHA);
48         }
49
50         draw(0);
51 }
52
53 void PaneDivider::draw(int flush)
54 {
55         if(is_x)
56         {
57                 draw_3segmentv(0,
58                         0,
59                         get_h(),
60                         images[status]);
61         }
62         else
63         {
64                 draw_3segmenth(0,
65                         0,
66                         get_w(),
67                         images[status]);
68         }
69         this->flash(flush);
70 }
71
72 void PaneDivider::reposition_window(int x, int y, int length)
73 {
74         BC_SubWindow::reposition_window(x,
75                 y,
76                 is_x ? mwindow->theme->pane_w : length,
77
78                 is_x ? length : mwindow->theme->pane_h);
79 }
80
81 int PaneDivider::button_press_event()
82 {
83         if(is_event_win())
84         {
85                 origin_x = get_cursor_x();
86                 origin_y = get_cursor_y();
87                 button_down = 1;
88                 status = BUTTON_DOWNHI;
89                 draw(1);
90                 return 0;
91         }
92         return 0;
93 }
94
95 int PaneDivider::button_release_event()
96 {
97         if(button_down)
98         {
99                 button_down = 0;
100
101                 if(is_dragging)
102                 {
103                         is_dragging = 0;
104 // might be deleted in here
105                         mwindow->gui->stop_pane_drag();
106                         status = BUTTON_UPHI;
107                         draw(1);
108                 }
109
110                 return 1;
111         }
112         return 0;
113 }
114
115 int PaneDivider::cursor_motion_event()
116 {
117         if(button_down)
118         {
119                 if(!is_dragging)
120                 {
121                         if(is_x && abs(get_cursor_x() - origin_x) > 5)
122                         {
123                                 is_dragging = 1;
124                                 mwindow->gui->start_x_pane_drag();
125                         }
126                         else
127                         if(!is_x && abs(get_cursor_y() - origin_y) > 5)
128                         {
129                                 is_dragging = 1;
130                                 mwindow->gui->start_y_pane_drag();
131                         }
132                 }
133                 else
134                 {
135                         mwindow->gui->handle_pane_drag();
136                 }
137                 return 1;
138         }
139         return 0;
140 }
141
142
143 int PaneDivider::cursor_enter_event()
144 {
145         if(is_event_win())
146         {
147                 if(get_button_down())
148                 {
149                         status = BUTTON_DOWNHI;
150                 }
151                 else
152                 if(status == BUTTON_UP)
153                 {
154                         status = BUTTON_UPHI;
155                 }
156
157                 draw(1);
158         }
159         return 0;
160 }
161
162 int PaneDivider::cursor_leave_event()
163 {
164         if(status == BUTTON_UPHI)
165         {
166                 status = BUTTON_UP;
167
168                 draw(1);
169
170
171         }
172         return 0;
173 }
174
175
176
177
178
179
180
181
182
183