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(int do_plugintoggles)
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;
85 //printf("MainCursor::draw %f %f\n", selectionstart, selectionend);
87 pixel1 = Units::to_int64((selectionstart *
88 mwindow->edl->session->sample_rate /
91 pixel2 = Units::to_int64((selectionend *
92 mwindow->edl->session->sample_rate /
95 if(pixel1 < -10) pixel1 = -10;
96 if(pixel2 > gui->canvas->get_w() + 10) pixel2 = gui->canvas->get_w() + 10;
97 if(pixel2 < pixel1) pixel2 = pixel1;
98 //printf("MainCursor::draw 2\n");
101 gui->canvas->set_color(WHITE);
102 gui->canvas->set_inverse();
103 gui->canvas->draw_box(pixel1, 0, pixel2 - pixel1 + 1, gui->canvas->get_h());
104 gui->canvas->set_opaque();
105 if(do_plugintoggles) gui->canvas->refresh_plugintoggles();
109 // Draw the cursor in a new location
110 void MainCursor::update()
112 int64_t old_pixel1 = pixel1;
113 int64_t old_pixel2 = pixel2;
121 if(old_pixel1 != pixel1 || old_pixel2 != pixel2)
122 gui->canvas->flash(old_pixel1,
124 old_pixel2 - old_pixel1 + 1,
125 gui->canvas->get_h());
130 void MainCursor::flash()
132 gui->canvas->flash(pixel1, 0, pixel2 - pixel1 + 1, gui->canvas->get_h());
135 void MainCursor::hide(int do_plugintoggles)
137 if(visible) draw(do_plugintoggles);
140 void MainCursor::show(int do_plugintoggles)
142 if(!visible) draw(do_plugintoggles);
145 // Constitutively redraw the cursor after it is overwritten by a draw
146 void MainCursor::restore(int do_plugintoggles)
150 draw(do_plugintoggles);