splashgui text clr, faders/speed keyframe popup slider rework, reticle rework
[goodguy/history.git] / cinelerra-5.1 / cinelerra / cursor.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 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 "cursor.h"
23
24 Cursor_::Cursor_(BC_SubWindow *canvas)
25 {
26         this->canvas = canvas;
27         selectionstart = selectionend = zoom_sample = viewstart = 0;
28 }
29
30 Cursor_::~Cursor_()
31 {
32 }
33
34 int Cursor_::show(int flash, long selectionstart, long selectionend, long zoom_sample, long viewstart, int vertical)
35 {
36 return 0;
37         this->selectionstart = selectionstart;
38         this->selectionend = selectionend;
39         this->viewstart = viewstart;
40         this->zoom_sample = zoom_sample;
41         this->vertical = vertical;
42         draw(flash, selectionstart, selectionend, zoom_sample, viewstart, vertical);
43 }
44
45 int Cursor_::hide(int flash)
46 {
47 return 0;
48         draw(flash, selectionstart, selectionend, zoom_sample, viewstart, vertical);
49 }
50
51 int Cursor_::draw(int flash, long selectionstart, long selectionend, long zoom_sample, long viewstart, int vertical)
52 {
53 return 0;
54         if(canvas->get_h() * canvas->get_w() == 0) return 1;
55         if(zoom_sample == 0) return 1;       // no canvas
56
57         long start = viewstart;
58         long end = start + (long)(vertical ? canvas->get_h() : canvas->get_w()) * zoom_sample;
59         int pixel1, pixel2;
60
61         if((selectionstart >= start && selectionstart <= end) ||
62                  (selectionend >= start && selectionend <= end) ||
63                  (start >= selectionstart && end <= selectionend))
64         {
65                 if(selectionstart < start)
66                 {
67                         pixel1 = 0;
68                 }
69                 else
70                 {
71                         pixel1 = (selectionstart - start) / zoom_sample;
72                 }
73
74                 if(selectionend > end)
75                 {
76                         pixel2 = (vertical ? canvas->get_h() : canvas->get_w());
77                 }
78                 else
79                 {
80                         pixel2 = (selectionend - start) / zoom_sample;
81                 }
82                 pixel2++;
83
84                 canvas->set_inverse();
85                 canvas->set_color(WHITE);
86
87                 if(vertical)
88                 canvas->draw_box(0, pixel1, canvas->get_w(), pixel2 - pixel1);
89                 else
90                 canvas->draw_box(pixel1, 0, pixel2 - pixel1, canvas->get_h());
91
92
93                 canvas->set_opaque();
94         }
95         if(flash) canvas->flash();
96 }
97
98 int Cursor_::resize(int w, int h)
99 {
100         return 0;
101 }