summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2018-09-11 12:29:13 +0100
committerCarl Hetherington <cth@carlh.net>2018-09-11 13:25:59 +0100
commit7151de6910e6072754bd38d50efa5a36622bb5c6 (patch)
tree532c8ad0ca77e74b0854b5db8b53be762fda674f /src
parentcb82f3c177b53ce99c8443a74da316a94ae829ac (diff)
FilmViewer API tidying.
Diffstat (limited to 'src')
-rw-r--r--src/tools/dcpomatic.cc4
-rw-r--r--src/tools/dcpomatic_player.cc6
-rw-r--r--src/wx/content_panel.cc2
-rw-r--r--src/wx/controls.cc20
-rw-r--r--src/wx/film_viewer.cc46
-rw-r--r--src/wx/film_viewer.h39
-rw-r--r--src/wx/text_view.cc2
-rw-r--r--src/wx/timing_panel.cc6
8 files changed, 52 insertions, 73 deletions
diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc
index 27113eeab..aa6526311 100644
--- a/src/tools/dcpomatic.cc
+++ b/src/tools/dcpomatic.cc
@@ -1301,12 +1301,12 @@ private:
void back_frame ()
{
- _film_viewer->move (-_film_viewer->one_video_frame());
+ _film_viewer->seek_by (-_film_viewer->one_video_frame(), true);
}
void forward_frame ()
{
- _film_viewer->move (_film_viewer->one_video_frame());
+ _film_viewer->seek_by (_film_viewer->one_video_frame(), true);
}
FilmEditor* _film_editor;
diff --git a/src/tools/dcpomatic_player.cc b/src/tools/dcpomatic_player.cc
index d8c3c59fe..a95476fc1 100644
--- a/src/tools/dcpomatic_player.cc
+++ b/src/tools/dcpomatic_player.cc
@@ -217,7 +217,7 @@ public:
}
_viewer->set_film (_film);
- _viewer->set_position (DCPTime ());
+ _viewer->seek (DCPTime(), true);
_info->triggered_update ();
Config::instance()->add_to_player_history (dir);
@@ -579,12 +579,12 @@ private:
void back_frame ()
{
- _viewer->move (-_viewer->one_video_frame());
+ _viewer->seek_by (-_viewer->one_video_frame(), true);
}
void forward_frame ()
{
- _viewer->move (_viewer->one_video_frame());
+ _viewer->seek_by (_viewer->one_video_frame(), true);
}
private:
diff --git a/src/wx/content_panel.cc b/src/wx/content_panel.cc
index 04e35c758..8e6c49294 100644
--- a/src/wx/content_panel.cc
+++ b/src/wx/content_panel.cc
@@ -304,7 +304,7 @@ ContentPanel::check_selection ()
if (go_to && Config::instance()->jump_to_selected() && signal_manager) {
shared_ptr<FilmViewer> fv = _film_viewer.lock ();
DCPOMATIC_ASSERT (fv);
- signal_manager->when_idle(boost::bind(&FilmViewer::set_position, fv.get(), go_to.get().ceil(_film->video_frame_rate())));
+ signal_manager->when_idle(boost::bind(&FilmViewer::seek, fv.get(), go_to.get().ceil(_film->video_frame_rate()), true));
}
if (_timeline_dialog) {
diff --git a/src/wx/controls.cc b/src/wx/controls.cc
index 1bb3c4136..96bd624ac 100644
--- a/src/wx/controls.cc
+++ b/src/wx/controls.cc
@@ -215,7 +215,7 @@ Controls::update_position_slider ()
DCPTime const len = _film->length ();
if (len.get ()) {
- int const new_slider_position = 4096 * _viewer->video_position().get() / len.get();
+ int const new_slider_position = 4096 * _viewer->position().get() / len.get();
if (new_slider_position != _slider->GetValue()) {
_slider->SetValue (new_slider_position);
}
@@ -233,8 +233,8 @@ Controls::update_position_label ()
double const fps = _film->video_frame_rate ();
/* Count frame number from 1 ... not sure if this is the best idea */
- _frame_number->SetLabel (wxString::Format (wxT("%ld"), lrint (_viewer->video_position().seconds() * fps) + 1));
- _timecode->SetLabel (time_to_timecode (_viewer->video_position(), fps));
+ _frame_number->SetLabel (wxString::Format (wxT("%ld"), lrint (_viewer->position().seconds() * fps) + 1));
+ _timecode->SetLabel (time_to_timecode (_viewer->position(), fps));
}
void
@@ -265,32 +265,32 @@ Controls::nudge_amount (wxKeyboardState& ev)
void
Controls::rewind_clicked (wxMouseEvent& ev)
{
- _viewer->go_to (DCPTime());
+ _viewer->seek (DCPTime(), true);
ev.Skip();
}
void
Controls::back_frame ()
{
- _viewer->move (-_viewer->one_video_frame());
+ _viewer->seek_by (-_viewer->one_video_frame(), true);
}
void
Controls::forward_frame ()
{
- _viewer->move (_viewer->one_video_frame());
+ _viewer->seek_by (_viewer->one_video_frame(), true);
}
void
Controls::back_clicked (wxKeyboardState& ev)
{
- _viewer->move (-nudge_amount(ev));
+ _viewer->seek_by (-nudge_amount(ev), true);
}
void
Controls::forward_clicked (wxKeyboardState& ev)
{
- _viewer->move (nudge_amount(ev));
+ _viewer->seek_by (nudge_amount(ev), true);
}
void
@@ -320,7 +320,7 @@ Controls::timecode_clicked ()
{
PlayheadToTimecodeDialog* dialog = new PlayheadToTimecodeDialog (this, _film->video_frame_rate ());
if (dialog->ShowModal() == wxID_OK) {
- _viewer->go_to (dialog->get ());
+ _viewer->seek (dialog->get(), true);
}
dialog->Destroy ();
}
@@ -330,7 +330,7 @@ Controls::frame_number_clicked ()
{
PlayheadToFrameDialog* dialog = new PlayheadToFrameDialog (this, _film->video_frame_rate ());
if (dialog->ShowModal() == wxID_OK) {
- _viewer->go_to (dialog->get ());
+ _viewer->seek (dialog->get(), true);
}
dialog->Destroy ();
}
diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc
index 2d53db9ef..bd83821be 100644
--- a/src/wx/film_viewer.cc
+++ b/src/wx/film_viewer.cc
@@ -434,21 +434,6 @@ FilmViewer::stop ()
}
void
-FilmViewer::go_to (DCPTime t)
-{
- if (t < DCPTime ()) {
- t = DCPTime ();
- }
-
- if (t >= _film->length ()) {
- t = _film->length ();
- }
-
- seek (t, true);
- PositionChanged ();
-}
-
-void
FilmViewer::player_change (ChangeType type, int property, bool frequent)
{
if (type != CHANGE_TYPE_DONE || frequent) {
@@ -515,19 +500,11 @@ FilmViewer::quick_refresh ()
}
void
-FilmViewer::set_position (DCPTime p)
-{
- _video_position = p;
- seek (p, true);
- PositionChanged ();
-}
-
-void
-FilmViewer::set_position (shared_ptr<Content> content, ContentTime t)
+FilmViewer::seek (shared_ptr<Content> content, ContentTime t, bool accurate)
{
optional<DCPTime> dt = _player->content_time_to_dcp (content, t);
if (dt) {
- set_position (*dt);
+ seek (*dt, accurate);
}
}
@@ -551,6 +528,14 @@ FilmViewer::seek (DCPTime t, bool accurate)
return;
}
+ if (t < DCPTime ()) {
+ t = DCPTime ();
+ }
+
+ if (t >= _film->length ()) {
+ t = _film->length ();
+ }
+
bool const was_running = stop ();
_closed_captions_dialog->clear ();
@@ -560,6 +545,8 @@ FilmViewer::seek (DCPTime t, bool accurate)
if (was_running) {
start ();
}
+
+ PositionChanged ();
}
void
@@ -696,6 +683,7 @@ FilmViewer::one_video_frame () const
return DCPTime::from_frames (1, _film->video_frame_rate());
}
+/** Open a dialog box showing our film's closed captions */
void
FilmViewer::show_closed_captions ()
{
@@ -703,11 +691,7 @@ FilmViewer::show_closed_captions ()
}
void
-FilmViewer::move (DCPTime by)
+FilmViewer::seek_by (DCPTime by, bool accurate)
{
- if (!_film) {
- return;
- }
-
- go_to (_video_position + by);
+ seek (_video_position + by, accurate);
}
diff --git a/src/wx/film_viewer.h b/src/wx/film_viewer.h
index 0da656fa9..d7b12703e 100644
--- a/src/wx/film_viewer.h
+++ b/src/wx/film_viewer.h
@@ -19,7 +19,7 @@
*/
/** @file src/film_viewer.h
- * @brief A wx widget to view `thumbnails' of a Film.
+ * @brief FilmViewer class.
*/
#include "lib/film.h"
@@ -38,7 +38,7 @@ class Butler;
class ClosedCaptionsDialog;
/** @class FilmViewer
- * @brief A wx widget to view a preview of a Film.
+ * @brief A wx widget to view a Film.
*/
class FilmViewer
{
@@ -46,25 +46,38 @@ public:
FilmViewer (wxWindow *);
~FilmViewer ();
+ /** @return the panel showing the film's video */
wxPanel* panel () const {
return _panel;
}
+ void show_closed_captions ();
+
void set_film (boost::shared_ptr<Film>);
boost::shared_ptr<Film> film () const {
return _film;
}
+ void seek (DCPTime t, bool accurate);
+ void seek (boost::shared_ptr<Content> content, ContentTime p, bool accurate);
+ void seek_by (DCPTime by, bool accurate);
/** @return our `playhead' position; this may not lie exactly on a frame boundary */
DCPTime position () const {
return _video_position;
}
+ DCPTime one_video_frame () const;
+
+ void start ();
+ bool stop ();
+ bool playing () const {
+ return _playing;
+ }
- void set_position (DCPTime p);
- void set_position (boost::shared_ptr<Content> content, ContentTime p);
void set_coalesce_player_changes (bool c);
void set_dcp_decode_reduction (boost::optional<int> reduction);
boost::optional<int> dcp_decode_reduction () const;
+ void set_outline_content (bool o);
+ void set_eyes (Eyes e);
void slow_refresh ();
bool quick_refresh ();
@@ -73,26 +86,8 @@ public:
return _dropped;
}
- void start ();
- bool stop ();
- bool playing () const {
- return _playing;
- }
-
- void move (DCPTime by);
- DCPTime one_video_frame () const;
- void seek (DCPTime t, bool accurate);
- DCPTime video_position () const {
- return _video_position;
- }
- void go_to (DCPTime t);
- void set_outline_content (bool o);
- void set_eyes (Eyes e);
-
int audio_callback (void* out, unsigned int frames);
- void show_closed_captions ();
-
boost::signals2::signal<void (boost::weak_ptr<PlayerVideo>)> ImageChanged;
boost::signals2::signal<void ()> PositionChanged;
boost::signals2::signal<void ()> Started;
diff --git a/src/wx/text_view.cc b/src/wx/text_view.cc
index 16ec2213f..9b591b191 100644
--- a/src/wx/text_view.cc
+++ b/src/wx/text_view.cc
@@ -140,5 +140,5 @@ TextView::subtitle_selected (wxListEvent& ev)
DCPOMATIC_ASSERT (lc);
shared_ptr<FilmViewer> fv = _film_viewer.lock ();
DCPOMATIC_ASSERT (fv);
- fv->set_position (lc, _start_times[ev.GetIndex()]);
+ fv->seek (lc, _start_times[ev.GetIndex()], true);
}
diff --git a/src/wx/timing_panel.cc b/src/wx/timing_panel.cc
index 4a221c650..b1d13367f 100644
--- a/src/wx/timing_panel.cc
+++ b/src/wx/timing_panel.cc
@@ -421,7 +421,7 @@ TimingPanel::trim_start_changed ()
}
if (ref) {
- fv->set_position (max (DCPTime(), ref_ph.get() + ref->position() - DCPTime (ref->trim_start(), ref_frc.get())));
+ fv->seek (max(DCPTime(), ref_ph.get() + ref->position() - DCPTime(ref->trim_start(), ref_frc.get())), true);
}
fv->set_coalesce_player_changes (false);
@@ -444,7 +444,7 @@ TimingPanel::trim_end_changed ()
/* XXX: maybe playhead-off-the-end-of-the-film should be handled elsewhere */
if (fv->position() >= _parent->film()->length()) {
- fv->set_position (_parent->film()->length() - DCPTime::from_frames (1, _parent->film()->video_frame_rate()));
+ fv->seek (_parent->film()->length() - DCPTime::from_frames(1, _parent->film()->video_frame_rate()), true);
}
fv->set_coalesce_player_changes (true);
@@ -530,7 +530,7 @@ TimingPanel::trim_start_to_playhead_clicked ()
}
if (new_ph) {
- fv->set_position (new_ph.get());
+ fv->seek (new_ph.get(), true);
}
fv->set_coalesce_player_changes (false);