3 #include "edlsession.h"
4 #include "localsession.h"
5 #include "maincursor.h"
7 #include "mwindowgui.h"
8 #include "trackcanvas.h"
11 MainCursor::MainCursor(MWindow *mwindow, MWindowGUI *gui)
13 this->mwindow = mwindow;
20 MainCursor::~MainCursor()
24 void MainCursor::create_objects()
29 void MainCursor::focus_in_event()
33 void MainCursor::focus_out_event()
39 void MainCursor::activate()
41 //printf("MainCursor::activate 1 %d\n", BC_WindowBase::get_resources()->blink_rate);
45 gui->set_repeat(BC_WindowBase::get_resources()->blink_rate);
49 void MainCursor::deactivate()
54 gui->unset_repeat(BC_WindowBase::get_resources()->blink_rate);
60 int MainCursor::repeat_event(int64_t duration)
62 if(!active || !gui->get_has_focus()) return 0;
63 if(duration != BC_WindowBase::get_resources()->blink_rate) return 0;
65 // Only flash a single sample selection
66 if(selectionstart == selectionend)
68 if(!playing_back || (playing_back && !visible))
77 void MainCursor::draw()
81 selectionstart = mwindow->edl->local_session->get_selectionstart(1);
82 selectionend = mwindow->edl->local_session->get_selectionend(1);
83 view_start = mwindow->edl->local_session->view_start;
84 zoom_sample = mwindow->edl->local_session->zoom_sample;
86 pixel1 = Units::to_int64((selectionstart *
87 mwindow->edl->session->sample_rate /
90 pixel2 = Units::to_int64((selectionend *
91 mwindow->edl->session->sample_rate /
94 if(pixel1 < -10) pixel1 = -10;
95 if(pixel2 > gui->canvas->get_w() + 10) pixel2 = gui->canvas->get_w() + 10;
96 if(pixel2 < pixel1) pixel2 = pixel1;
97 //printf("MainCursor::draw 2\n");
100 gui->canvas->set_color(WHITE);
101 gui->canvas->set_inverse();
102 gui->canvas->draw_box(pixel1, 0, pixel2 - pixel1 + 1, gui->canvas->get_h());
103 gui->canvas->set_opaque();
107 // Draw the cursor in a new location
108 void MainCursor::update()
120 void MainCursor::flash()
122 gui->canvas->flash(pixel1, 0, pixel2 - pixel1 + 1, gui->canvas->get_h());
126 void MainCursor::hide()
131 void MainCursor::show()
136 // Constitutively redraw the cursor after it is overwritten by a draw
137 void MainCursor::restore()