X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Ftimeline_content_view.cc;h=926ca3258c0b3947bdafdc4cf1644d149a0b3dfd;hb=313319ba2d8544bc25524e02e634804a503b54f1;hp=8258a81f97a5bfd6dd37e8485a3a5b2cef29ba71;hpb=a5d004b0773f633401528392fc28e66d70e13ac8;p=dcpomatic.git diff --git a/src/wx/timeline_content_view.cc b/src/wx/timeline_content_view.cc index 8258a81f9..926ca3258 100644 --- a/src/wx/timeline_content_view.cc +++ b/src/wx/timeline_content_view.cc @@ -18,12 +18,14 @@ */ -#include "timeline_content_view.h" + #include "timeline.h" +#include "timeline_content_view.h" #include "wx_util.h" #include "lib/content.h" #include + using std::list; using std::shared_ptr; using namespace dcpomatic; @@ -31,23 +33,24 @@ using namespace dcpomatic; using namespace boost::placeholders; #endif + TimelineContentView::TimelineContentView (Timeline& tl, shared_ptr c) : TimelineView (tl) , _content (c) - , _selected (false) { _content_connection = c->Change.connect (bind (&TimelineContentView::content_change, this, _1, _3)); } + dcpomatic::Rect TimelineContentView::bbox () const { DCPOMATIC_ASSERT (_track); - shared_ptr film = _timeline.film (); - shared_ptr content = _content.lock (); + auto film = _timeline.film (); + auto content = _content.lock (); if (!film || !content) { - return dcpomatic::Rect (); + return {}; } return dcpomatic::Rect ( @@ -58,6 +61,7 @@ TimelineContentView::bbox () const ); } + void TimelineContentView::set_selected (bool s) { @@ -65,49 +69,55 @@ TimelineContentView::set_selected (bool s) force_redraw (); } + bool TimelineContentView::selected () const { return _selected; } + shared_ptr TimelineContentView::content () const { return _content.lock (); } + void TimelineContentView::set_track (int t) { _track = t; } + void TimelineContentView::unset_track () { - _track = boost::optional (); + _track = boost::optional(); } + boost::optional TimelineContentView::track () const { return _track; } + void -TimelineContentView::do_paint (wxGraphicsContext* gc, list > overlaps) +TimelineContentView::do_paint (wxGraphicsContext* gc, list> overlaps) { DCPOMATIC_ASSERT (_track); - shared_ptr film = _timeline.film (); - shared_ptr cont = content (); + auto film = _timeline.film (); + auto cont = content (); if (!film || !cont) { return; } - DCPTime const position = cont->position (); - DCPTime const len = cont->length_after_trim (film); + auto const position = cont->position (); + auto const len = cont->length_after_trim (film); wxColour selected (background_colour().Red() / 2, background_colour().Green() / 2, background_colour().Blue() / 2); @@ -119,7 +129,7 @@ TimelineContentView::do_paint (wxGraphicsContext* gc, list } /* Outline */ - wxGraphicsPath path = gc->CreatePath (); + auto path = gc->CreatePath (); path.MoveToPoint (time_x (position) + 2, y_pos (_track.get()) + 4); path.AddLineToPoint (time_x (position + len) - 1, y_pos (_track.get()) + 4); path.AddLineToPoint (time_x (position + len) - 1, y_pos (_track.get() + 1) - 4); @@ -139,12 +149,12 @@ TimelineContentView::do_paint (wxGraphicsContext* gc, list /* Overlaps */ gc->SetBrush (*wxTheBrushList->FindOrCreateBrush (foreground_colour(), wxBRUSHSTYLE_CROSSDIAG_HATCH)); - for (list >::const_iterator i = overlaps.begin(); i != overlaps.end(); ++i) { - gc->DrawRectangle (i->x, i->y + 4, i->width, i->height - 8); + for (auto const& i: overlaps) { + gc->DrawRectangle (i.x, i.y + 4, i.width, i.height - 8); } /* Label text */ - wxString lab = label (); + auto lab = label (); wxDouble lab_width; wxDouble lab_height; wxDouble lab_descent; @@ -157,16 +167,18 @@ TimelineContentView::do_paint (wxGraphicsContext* gc, list gc->PopState (); } + int TimelineContentView::y_pos (int t) const { return t * _timeline.pixels_per_track() + _timeline.tracks_y_offset(); } + void TimelineContentView::content_change (ChangeType type, int p) { - if (type != CHANGE_TYPE_DONE) { + if (type != ChangeType::DONE) { return; } @@ -177,6 +189,7 @@ TimelineContentView::content_change (ChangeType type, int p) } } + wxString TimelineContentView::label () const {