r956: README.BUILD - add more library recommendations
[cinelerra_cv/ct.git] / cinelerra / cursor.C
blob2cf9a72099ffcfea52cf9f1dd5340e388b16130b
1 #include "cursor.h"
3 Cursor_::Cursor_(BC_SubWindow *canvas)
5         this->canvas = canvas;
6         selectionstart = selectionend = zoom_sample = viewstart = 0;
9 Cursor_::~Cursor_()
13 int Cursor_::show(int flash, long selectionstart, long selectionend, long zoom_sample, long viewstart, int vertical)
15 return 0;
16         this->selectionstart = selectionstart;
17         this->selectionend = selectionend;
18         this->viewstart = viewstart;
19         this->zoom_sample = zoom_sample;
20         this->vertical = vertical;
21         draw(flash, selectionstart, selectionend, zoom_sample, viewstart, vertical);
24 int Cursor_::hide(int flash)
26 return 0;
27         draw(flash, selectionstart, selectionend, zoom_sample, viewstart, vertical);
30 int Cursor_::draw(int flash, long selectionstart, long selectionend, long zoom_sample, long viewstart, int vertical)
32 return 0;
33         if(canvas->get_h() * canvas->get_w() == 0) return 1; 
34         if(zoom_sample == 0) return 1;       // no canvas
36         long start = viewstart;
37         long end = start + (long)(vertical ? canvas->get_h() : canvas->get_w()) * zoom_sample;
38         int pixel1, pixel2;
40         if((selectionstart >= start && selectionstart <= end) ||
41                  (selectionend >= start && selectionend <= end) ||
42                  (start >= selectionstart && end <= selectionend))
43         {
44                 if(selectionstart < start)
45                 {
46                         pixel1 = 0;
47                 }
48                 else
49                 {
50                         pixel1 = (selectionstart - start) / zoom_sample;
51                 }
52                 
53                 if(selectionend > end)
54                 {
55                         pixel2 = (vertical ? canvas->get_h() : canvas->get_w());
56                 }
57                 else
58                 {
59                         pixel2 = (selectionend - start) / zoom_sample;
60                 }
61                 pixel2++;
63                 canvas->set_inverse();
64                 canvas->set_color(WHITE);
65                 
66                 if(vertical)
67                 canvas->draw_box(0, pixel1, canvas->get_w(), pixel2 - pixel1);
68                 else
69                 canvas->draw_box(pixel1, 0, pixel2 - pixel1, canvas->get_h());
70                 
71                 
72                 canvas->set_opaque();
73         }
74         if(flash) canvas->flash();
77 int Cursor_::resize(int w, int h)