2 Copyright (C) 2015-2021 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
23 #include <wx/graphics.h>
25 #include "timeline_reels_view.h"
31 using namespace dcpomatic;
34 TimelineReelsView::TimelineReelsView (Timeline& tl, int y)
43 TimelineReelsView::bbox () const
45 return dcpomatic::Rect<int> (0, _y - 4, _timeline.width(), 24);
50 TimelineReelsView::set_y (int y)
58 TimelineReelsView::do_paint (wxGraphicsContext* gc, list<dcpomatic::Rect<int>>)
60 if (!_timeline.pixels_per_second()) {
64 double const pps = _timeline.pixels_per_second().get ();
66 gc->SetPen (*wxThePenList->FindOrCreatePen (wxColour (0, 0, 255), 1, wxPENSTYLE_SOLID));
68 auto path = gc->CreatePath ();
69 path.MoveToPoint (time_x (DCPTime (0)), _y);
70 path.AddLineToPoint (time_x (_timeline.film()->length()), _y);
71 gc->StrokePath (path);
73 gc->SetFont (gc->CreateFont (*wxNORMAL_FONT, wxColour (0, 0, 255)));
76 for (auto i: _timeline.film()->reels()) {
77 int const size = min (8.0, i.duration().seconds() * pps / 2);
79 auto path = gc->CreatePath ();
80 path.MoveToPoint (time_x (i.from) + size, _y + size / 2);
81 path.AddLineToPoint (time_x (i.from), _y);
82 path.AddLineToPoint (time_x (i.from) + size, _y - size / 2);
83 gc->StrokePath (path);
85 path = gc->CreatePath ();
86 path.MoveToPoint (time_x (i.to) - size, _y + size / 2);
87 path.AddLineToPoint (time_x (i.to), _y);
88 path.AddLineToPoint (time_x (i.to) - size, _y - size / 2);
89 gc->StrokePath (path);
91 auto str = wxString::Format (_("Reel %d"), reel++);
96 gc->GetTextExtent (str, &str_width, &str_height, &str_descent, &str_leading);
98 int const available_width = time_x(DCPTime(i.to.get())) - time_x(DCPTime(i.from.get()));
100 if (available_width > str_width) {
101 gc->DrawText (str, time_x(DCPTime(i.from.get())) + (available_width - str_width) / 2, _y + 4);