2 Copyright (C) 2015 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include "timeline_reels_view.h"
23 #include <wx/graphics.h>
24 #include <boost/foreach.hpp>
28 TimelineReelsView::TimelineReelsView (Timeline& tl, int y)
36 TimelineReelsView::bbox () const
38 return dcpomatic::Rect<int> (0, _y - 4, _timeline.width(), 24);
42 TimelineReelsView::set_y (int y)
49 TimelineReelsView::do_paint (wxGraphicsContext* gc)
51 if (!_timeline.pixels_per_second()) {
55 double const pps = _timeline.pixels_per_second().get ();
57 gc->SetPen (*wxThePenList->FindOrCreatePen (wxColour (0, 0, 255), 1, wxPENSTYLE_SOLID));
59 wxGraphicsPath path = gc->CreatePath ();
60 path.MoveToPoint (time_x (DCPTime (0)), _y);
61 path.AddLineToPoint (time_x (_timeline.film()->length()), _y);
62 gc->StrokePath (path);
64 gc->SetFont (gc->CreateFont (*wxNORMAL_FONT, wxColour (0, 0, 255)));
67 BOOST_FOREACH (DCPTimePeriod i, _timeline.film()->reels()) {
68 int const size = min (8.0, i.duration().seconds() * pps / 2);
70 wxGraphicsPath path = gc->CreatePath ();
71 path.MoveToPoint (time_x (i.from) + size, _y + size / 2);
72 path.AddLineToPoint (time_x (i.from), _y);
73 path.AddLineToPoint (time_x (i.from) + size, _y - size / 2);
74 gc->StrokePath (path);
76 path = gc->CreatePath ();
77 path.MoveToPoint (time_x (i.to) - size, _y + size / 2);
78 path.AddLineToPoint (time_x (i.to), _y);
79 path.AddLineToPoint (time_x (i.to) - size, _y - size / 2);
80 gc->StrokePath (path);
82 wxString str = wxString::Format (_("Reel %d"), reel++);
87 gc->GetTextExtent (str, &str_width, &str_height, &str_descent, &str_leading);
89 int const tx = time_x (DCPTime((i.from.get() + i.to.get()) / 2));
90 gc->DrawText (str, tx - str_width / 2, _y + 4);