#include "lib/film.h"
#include "lib/image_content.h"
#include "lib/playlist.h"
+#include "lib/scope_guard.h"
#include "lib/text_content.h"
#include "lib/timer.h"
#include "lib/video_content.h"
{
wxPaintDC dc (_labels_canvas);
+ auto film = _film.lock();
+ if (film->content().empty()) {
+ return;
+ }
+
auto gc = wxGraphicsContext::Create (dc);
if (!gc) {
return;
}
+ ScopeGuard sg = [gc]() { delete gc; };
+
int vsx, vsy;
_labels_canvas->GetViewStart (&vsx, &vsy);
gc->Translate (-vsx * _x_scroll_rate, -vsy * _y_scroll_rate + tracks_y_offset());
_labels_view->paint (gc, {});
-
- delete gc;
}
Timeline::paint_main ()
{
wxPaintDC dc (_main_canvas);
+
+ auto film = _film.lock();
+ if (film->content().empty()) {
+ return;
+ }
+
_main_canvas->DoPrepareDC (dc);
auto gc = wxGraphicsContext::Create (dc);
return;
}
+ ScopeGuard sg = [gc]() { delete gc; };
+
int vsx, vsy;
_main_canvas->GetViewStart (&vsx, &vsy);
gc->Translate (-vsx * _x_scroll_rate, -vsy * _y_scroll_rate);
path.MoveToPoint (ph, 0);
path.AddLineToPoint (ph, pixels_per_track() * _tracks + 32);
gc->StrokePath (path);
-
- delete gc;
}
int t = base;
auto content = cv->content();
- DCPTimePeriod const content_period (content->position(), content->end(film));
+ DCPTimePeriod const content_period = content->period(film);
while (true) {
auto j = views.begin();
auto test_content = test->content();
if (
test->track() && test->track().get() == t &&
- content_period.overlap(DCPTimePeriod(test_content->position(), test_content->end(film)))) {
+ content_period.overlap(test_content->period(film))
+ ) {
/* we have an overlap on track `t' */
++t;
break;
_down_view_position = content_view->content()->position ();
}
+ if (dynamic_pointer_cast<TimelineTimeAxisView>(view)) {
+ int vsx, vsy;
+ _main_canvas->GetViewStart(&vsx, &vsy);
+ _viewer.seek(DCPTime::from_seconds((ev.GetPosition().x + vsx * _x_scroll_rate) / _pixels_per_second.get_value_or(1)), true);
+ }
+
for (auto i: _views) {
auto cv = dynamic_pointer_cast<TimelineContentView>(i);
if (!cv) {
_labels_canvas->Scroll (0, 0);
Refresh ();
}
+
+
+void
+Timeline::keypress(wxKeyEvent const& event)
+{
+ if (event.GetKeyCode() == WXK_DELETE) {
+ auto film = _film.lock();
+ film->remove_content(selected_content());
+ }
+}
+