#include "util.h"
using std::string;
+using std::set;
using boost::shared_ptr;
using boost::lexical_cast;
Content::Content (shared_ptr<const Film> f, Time s)
: _film (f)
, _start (s)
+ , _change_signals_frequent (false)
{
}
: _film (f)
, _file (p)
, _start (0)
+ , _change_signals_frequent (false)
{
}
Content::Content (shared_ptr<const Film> f, shared_ptr<const cxml::Node> node)
: _film (f)
+ , _change_signals_frequent (false)
{
_file = node->string_child ("File");
_digest = node->string_child ("Digest");
, _file (o._file)
, _digest (o._digest)
, _start (o._start)
+ , _change_signals_frequent (o._change_signals_frequent)
{
}
void
Content::signal_changed (int p)
{
- Changed (shared_from_this (), p);
+ Changed (shared_from_this (), p, _change_signals_frequent);
}
void
#ifndef DCPOMATIC_CONTENT_H
#define DCPOMATIC_CONTENT_H
+#include <set>
#include <boost/filesystem.hpp>
#include <boost/signals2.hpp>
#include <boost/thread/mutex.hpp>
return start() + length();
}
- boost::signals2::signal<void (boost::weak_ptr<Content>, int)> Changed;
+ void set_change_signals_frequent (bool f) {
+ _change_signals_frequent = f;
+ }
+
+ boost::signals2::signal<void (boost::weak_ptr<Content>, int, bool)> Changed;
protected:
void signal_changed (int);
boost::filesystem::path _file;
std::string _digest;
Time _start;
+ bool _change_signals_frequent;
};
#endif
, _audio_buffers (f->dcp_audio_channels(), 0)
{
_playlist->Changed.connect (bind (&Player::playlist_changed, this));
- _playlist->ContentChanged.connect (bind (&Player::content_changed, this, _1, _2));
+ _playlist->ContentChanged.connect (bind (&Player::content_changed, this, _1, _2, _3));
_film->Changed.connect (bind (&Player::film_changed, this, _1));
set_video_container_size (_film->container()->size (_film->full_frame ()));
}
}
void
-Player::content_changed (weak_ptr<Content> w, int p)
+Player::content_changed (weak_ptr<Content> w, int property, bool frequent)
{
shared_ptr<Content> c = w.lock ();
if (!c) {
}
if (
- p == ContentProperty::START || p == ContentProperty::LENGTH ||
- p == VideoContentProperty::VIDEO_CROP || p == VideoContentProperty::VIDEO_RATIO
+ property == ContentProperty::START || property == ContentProperty::LENGTH ||
+ property == VideoContentProperty::VIDEO_CROP || property == VideoContentProperty::VIDEO_RATIO
) {
_have_valid_pieces = false;
- Changed ();
+ Changed (frequent);
- } else if (p == SubtitleContentProperty::SUBTITLE_OFFSET || p == SubtitleContentProperty::SUBTITLE_SCALE) {
+ } else if (property == SubtitleContentProperty::SUBTITLE_OFFSET || property == SubtitleContentProperty::SUBTITLE_SCALE) {
update_subtitle ();
- Changed ();
+ Changed (frequent);
}
}
Player::playlist_changed ()
{
_have_valid_pieces = false;
- Changed ();
+ Changed (false);
}
void
*/
if (p == Film::SCALER || p == Film::WITH_SUBTITLES || p == Film::CONTAINER) {
- Changed ();
+ Changed (false);
}
}
/** Emitted when something has changed such that if we went back and emitted
* the last frame again it would look different. This is not emitted after
* a seek.
+ *
+ * The parameter is true if these signals are currently likely to be frequent.
*/
- boost::signals2::signal<void ()> Changed;
+ boost::signals2::signal<void (bool)> Changed;
private:
friend class PlayerWrapper;
void process_subtitle (boost::weak_ptr<Piece>, boost::shared_ptr<Image>, dcpomatic::Rect<double>, Time, Time);
void setup_pieces ();
void playlist_changed ();
- void content_changed (boost::weak_ptr<Content>, int);
+ void content_changed (boost::weak_ptr<Content>, int, bool);
void do_seek (Time, bool);
void flush ();
void emit_black ();
}
void
-Playlist::content_changed (weak_ptr<Content> c, int p)
+Playlist::content_changed (weak_ptr<Content> content, int property, bool frequent)
{
- if (p == ContentProperty::LENGTH) {
+ if (property == ContentProperty::LENGTH) {
maybe_sequence_video ();
}
- ContentChanged (c, p);
+ ContentChanged (content, property, frequent);
}
_content_connections.clear ();
for (ContentList::iterator i = _content.begin(); i != _content.end(); ++i) {
- _content_connections.push_back ((*i)->Changed.connect (bind (&Playlist::content_changed, this, _1, _2)));
+ _content_connections.push_back ((*i)->Changed.connect (bind (&Playlist::content_changed, this, _1, _2, _3)));
}
}
void maybe_sequence_video ();
mutable boost::signals2::signal<void ()> Changed;
- mutable boost::signals2::signal<void (boost::weak_ptr<Content>, int)> ContentChanged;
+ /** Third parameter is true if signals are currently being emitted frequently */
+ mutable boost::signals2::signal<void (boost::weak_ptr<Content>, int, bool)> ContentChanged;
private:
- void content_changed (boost::weak_ptr<Content>, int);
+ void content_changed (boost::weak_ptr<Content>, int, bool);
void reconnect ();
ContentList _content;
_player = f->player ();
_player->disable_audio ();
_player->Video.connect (boost::bind (&FilmViewer::process_video, this, _1, _3));
- _player->Changed.connect (boost::bind (&FilmViewer::player_changed, this));
+ _player->Changed.connect (boost::bind (&FilmViewer::player_changed, this, _1));
calculate_sizes ();
fetch_current_frame_again ();
}
void
-FilmViewer::player_changed ()
+FilmViewer::player_changed (bool frequent)
{
+ if (frequent) {
+ return;
+ }
+
calculate_sizes ();
fetch_current_frame_again ();
}
void active_jobs_changed (bool);
void back_clicked (wxCommandEvent &);
void forward_clicked (wxCommandEvent &);
- void player_changed ();
+ void player_changed (bool);
boost::shared_ptr<Film> _film;
boost::shared_ptr<Player> _player;
_left_down = true;
_down_point = ev.GetPosition ();
_first_move = false;
+
+ if (_down_view) {
+ shared_ptr<Content> c = _down_view->content().lock ();
+ if (c) {
+ c->set_change_signals_frequent (true);
+ }
+ }
}
void
-Timeline::left_up (wxMouseEvent &)
+Timeline::left_up (wxMouseEvent& ev)
{
_left_down = false;
+
+ if (_down_view) {
+ shared_ptr<Content> c = _down_view->content().lock ();
+ if (c) {
+ c->set_change_signals_frequent (false);
+ }
+ }
+
+ set_start_from_event (ev);
}
void
return;
}
+ set_start_from_event (ev);
+}
+
+void
+Timeline::set_start_from_event (wxMouseEvent& ev)
+{
wxPoint const p = ev.GetPosition();
if (!_first_move) {
void setup_pixels_per_time_unit ();
void resized (wxSizeEvent &);
void assign_tracks ();
+ void set_start_from_event (wxMouseEvent &);
FilmEditor* _film_editor;
boost::weak_ptr<Film> _film;