2 #include "edlsession.h"
3 #include "localsession.h"
4 #include "maincursor.h"
6 #include "mwindowgui.h"
7 #include "trackcanvas.h"
10 MainCursor::MainCursor(MWindow *mwindow, MWindowGUI *gui)
12 this->mwindow = mwindow;
19 MainCursor::~MainCursor()
23 void MainCursor::create_objects()
28 void MainCursor::activate()
30 //printf("MainCursor::activate 1 %d\n", BC_WindowBase::get_resources()->blink_rate);
34 gui->set_repeat(BC_WindowBase::get_resources()->blink_rate);
38 void MainCursor::deactivate()
43 gui->unset_repeat(BC_WindowBase::get_resources()->blink_rate);
49 int MainCursor::repeat_event(int64_t duration)
52 //printf("MainCursor::repeat_event 1 %d\n", duration);
53 if(duration != BC_WindowBase::get_resources()->blink_rate) return 0;
55 // Only flash a single sample selection
56 if(selectionstart == selectionend)
58 if(!playing_back || (playing_back && !visible))
64 //printf("MainCursor::repeat_event 2 %d\n", duration);
68 void MainCursor::draw()
72 //printf("MainCursor::draw 1\n");
73 selectionstart = mwindow->edl->local_session->selectionstart;
74 selectionend = mwindow->edl->local_session->selectionend;
75 view_start = mwindow->edl->local_session->view_start;
76 zoom_sample = mwindow->edl->local_session->zoom_sample;
78 pixel1 = Units::to_int64((selectionstart *
79 mwindow->edl->session->sample_rate /
82 pixel2 = Units::to_int64((selectionend *
83 mwindow->edl->session->sample_rate /
86 if(pixel1 < -10) pixel1 = -10;
87 if(pixel2 > gui->canvas->get_w() + 10) pixel2 = gui->canvas->get_w() + 10;
88 if(pixel2 < pixel1) pixel2 = pixel1;
89 //printf("MainCursor::draw 2\n");
92 gui->canvas->set_color(WHITE);
93 gui->canvas->set_inverse();
94 gui->canvas->draw_box(pixel1, 0, pixel2 - pixel1 + 1, gui->canvas->get_h());
95 gui->canvas->set_opaque();
99 // Draw the cursor in a new location
100 void MainCursor::update()
112 void MainCursor::flash()
114 gui->canvas->flash(pixel1, 0, pixel2 - pixel1 + 1, gui->canvas->get_h());
117 void MainCursor::hide()
122 void MainCursor::show()
124 //printf("MainCursor::show 1 %d\n", visible);
128 // Constitutively redraw the cursor after it is overwritten by a draw
129 void MainCursor::restore()