X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Fwx%2Ftimeline_content_view.cc;h=5d039d0d3f0a2e82d252da234f63519b8eb4864e;hp=13575b28004787b340481522b13d401fe80dbec1;hb=4d8f96e15edb4807cc9773cc7f9eb6aa56ac2dc8;hpb=4e617f7dee7b4b78555ca3e80e77d26d4fa8f884 diff --git a/src/wx/timeline_content_view.cc b/src/wx/timeline_content_view.cc index 13575b280..5d039d0d3 100644 --- a/src/wx/timeline_content_view.cc +++ b/src/wx/timeline_content_view.cc @@ -1,57 +1,70 @@ /* - Copyright (C) 2013-2015 Carl Hetherington + Copyright (C) 2013-2016 Carl Hetherington - This program is free software; you can redistribute it and/or modify + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - This program is distributed in the hope that it will be useful, + DCP-o-matic is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with DCP-o-matic. If not, see . */ -#include "timeline_content_view.h" + #include "timeline.h" +#include "timeline_content_view.h" #include "wx_util.h" #include "lib/content.h" +#include +LIBDCP_DISABLE_WARNINGS #include +LIBDCP_ENABLE_WARNINGS + + +using std::list; +using std::shared_ptr; +using namespace dcpomatic; +#if BOOST_VERSION >= 106100 +using namespace boost::placeholders; +#endif -using boost::shared_ptr; TimelineContentView::TimelineContentView (Timeline& tl, shared_ptr c) : TimelineView (tl) , _content (c) - , _selected (false) { - _content_connection = c->Changed.connect (bind (&TimelineContentView::content_changed, this, _2, _3)); + _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 ( time_x (content->position ()), y_pos (_track.get()), - content->length_after_trim().seconds() * _timeline.pixels_per_second().get_value_or(0), - _timeline.track_height() + content->length_after_trim(film).seconds() * _timeline.pixels_per_second().get_value_or(0), + _timeline.pixels_per_track() ); } + void TimelineContentView::set_selected (bool s) { @@ -59,49 +72,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) +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 (); + 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); @@ -112,44 +131,63 @@ TimelineContentView::do_paint (wxGraphicsContext* gc) gc->SetBrush (*wxTheBrushList->FindOrCreateBrush (background_colour(), wxBRUSHSTYLE_SOLID)); } - wxGraphicsPath path = gc->CreatePath (); - path.MoveToPoint (time_x (position) + 1, y_pos (_track.get()) + 4); + /* Outline */ + 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); - path.AddLineToPoint (time_x (position) + 1, y_pos (_track.get() + 1) - 4); - path.AddLineToPoint (time_x (position) + 1, y_pos (_track.get()) + 4); + path.AddLineToPoint (time_x (position) + 2, y_pos (_track.get() + 1) - 4); + path.AddLineToPoint (time_x (position) + 2, y_pos (_track.get()) + 4); gc->StrokePath (path); gc->FillPath (path); - wxString name = std_to_wx (cont->summary()); - wxDouble name_width; - wxDouble name_height; - wxDouble name_descent; - wxDouble name_leading; + /* Reel split points */ + gc->SetPen (*wxThePenList->FindOrCreatePen (foreground_colour(), 1, wxPENSTYLE_DOT)); + for (auto i: cont->reel_split_points(film)) { + path = gc->CreatePath (); + path.MoveToPoint (time_x (i), y_pos (_track.get()) + 4); + path.AddLineToPoint (time_x (i), y_pos (_track.get() + 1) - 4); + gc->StrokePath (path); + } + + /* Overlaps */ + gc->SetBrush (*wxTheBrushList->FindOrCreateBrush (foreground_colour(), wxBRUSHSTYLE_CROSSDIAG_HATCH)); + for (auto const& i: overlaps) { + gc->DrawRectangle (i.x, i.y + 4, i.width, i.height - 8); + } + + /* Label text */ + auto lab = label (); + wxDouble lab_width; + wxDouble lab_height; + wxDouble lab_descent; + wxDouble lab_leading; gc->SetFont (gc->CreateFont (*wxNORMAL_FONT, foreground_colour ())); - gc->GetTextExtent (name, &name_width, &name_height, &name_descent, &name_leading); - gc->Clip (wxRegion (time_x (position), y_pos (_track.get()), len.seconds() * _timeline.pixels_per_second().get_value_or(0), _timeline.track_height())); - gc->DrawText (name, time_x (position) + 12, y_pos (_track.get() + 1) - name_height - 4); - gc->ResetClip (); + gc->GetTextExtent (lab, &lab_width, &lab_height, &lab_descent, &lab_leading); + gc->PushState (); + gc->Clip (wxRegion (time_x (position), y_pos (_track.get()), len.seconds() * _timeline.pixels_per_second().get_value_or(0), _timeline.pixels_per_track())); + gc->DrawText (lab, time_x (position) + 12, y_pos (_track.get() + 1) - lab_height - 4); + gc->PopState (); } -int -TimelineContentView::y_pos (int t) const -{ - return _timeline.tracks_position().y + t * _timeline.track_height(); -} void -TimelineContentView::content_changed (int p, bool frequent) +TimelineContentView::content_change (ChangeType type, int p) { + if (type != ChangeType::DONE) { + return; + } + ensure_ui_thread (); if (p == ContentProperty::POSITION || p == ContentProperty::LENGTH) { force_redraw (); } +} - if (!frequent) { - _timeline.setup_pixels_per_second (); - _timeline.Refresh (); - } + +wxString +TimelineContentView::label () const +{ + return std_to_wx(content()->summary()); }