}
}
- o->padding = format()->dcp_padding (this);
- o->ratio = format()->ratio_as_float (this);
+ o->padding = format()->dcp_padding (shared_from_this ());
+ o->ratio = format()->ratio_as_float (shared_from_this ());
o->decode_subtitles = with_subtitles ();
shared_ptr<Job> r;
#include "format.h"
#include "film.h"
-using namespace std;
+using std::string;
+using std::setprecision;
+using std::stringstream;
+using std::vector;
+using boost::shared_ptr;
vector<Format const *> Format::_formats;
}
int
-Format::dcp_padding (Film const * f) const
+Format::dcp_padding (shared_ptr<const Film> f) const
{
int p = rint ((_dcp_size.width - (_dcp_size.height * ratio_as_integer(f) / 100.0)) / 2.0);
}
int
-VariableFormat::ratio_as_integer (Film const * f) const
+VariableFormat::ratio_as_integer (shared_ptr<const Film> f) const
{
return rint (ratio_as_float (f) * 100);
}
float
-VariableFormat::ratio_as_float (Film const * f) const
+VariableFormat::ratio_as_float (shared_ptr<const Film> f) const
{
return float (f->size().width) / f->size().height;
}
/** @return the aspect ratio multiplied by 100
* (e.g. 239 for Cinemascope 2.39:1)
*/
- virtual int ratio_as_integer (Film const * f) const = 0;
+ virtual int ratio_as_integer (boost::shared_ptr<const Film> f) const = 0;
/** @return the ratio as a floating point number */
- virtual float ratio_as_float (Film const * f) const = 0;
+ virtual float ratio_as_float (boost::shared_ptr<const Film> f) const = 0;
- int dcp_padding (Film const * f) const;
+ int dcp_padding (boost::shared_ptr<const Film> f) const;
/** @return size in pixels of the images that we should
* put in a DCP for this ratio. This size will not correspond
public:
FixedFormat (int, Size, std::string, std::string, std::string);
- int ratio_as_integer (Film const *) const {
+ int ratio_as_integer (boost::shared_ptr<const Film>) const {
return _ratio;
}
- float ratio_as_float (Film const *) const {
+ float ratio_as_float (boost::shared_ptr<const Film>) const {
return _ratio / 100.0;
}
public:
VariableFormat (Size, std::string, std::string, std::string);
- int ratio_as_integer (Film const * f) const;
- float ratio_as_float (Film const * f) const;
+ int ratio_as_integer (boost::shared_ptr<const Film> f) const;
+ float ratio_as_float (boost::shared_ptr<const Film> f) const;
std::string name () const;
};
#include "job_manager.h"
#include "job.h"
#include "cross.h"
+#include "ui_signaller.h"
using std::string;
using std::list;
JobManager* JobManager::_instance = 0;
JobManager::JobManager ()
+ : _last_active_jobs (false)
{
boost::thread (boost::bind (&JobManager::scheduler, this));
}
return false;
}
-
void
JobManager::scheduler ()
{
while (1) {
+
+ bool active_jobs = false;
+
{
boost::mutex::scoped_lock lm (_mutex);
for (list<shared_ptr<Job> >::iterator i = _jobs.begin(); i != _jobs.end(); ++i) {
break;
}
}
+
+ if (!(*i)->finished ()) {
+ active_jobs = true;
+ }
}
}
+ if (active_jobs != _last_active_jobs) {
+ _last_active_jobs = active_jobs;
+ ui_signaller->emit (boost::bind (boost::ref (ActiveJobsChanged), active_jobs));
+ }
+
dvdomatic_sleep (1);
}
}
#include <list>
#include <boost/thread/mutex.hpp>
+#include <boost/signals2.hpp>
class Job;
bool work_to_do () const;
bool errors () const;
+ boost::signals2::signal<void (bool)> ActiveJobsChanged;
+
static JobManager* instance ();
private:
mutable boost::mutex _mutex;
std::list<boost::shared_ptr<Job> > _jobs;
+ bool _last_active_jobs;
+
static JobManager* _instance;
};
#include "lib/version.h"
#include "lib/ui_signaller.h"
-using namespace std;
-using namespace boost;
+using std::string;
+using std::stringstream;
+using std::map;
+using std::make_pair;
+using boost::shared_ptr;
static FilmEditor* film_editor = 0;
static FilmViewer* film_viewer = 0;
-static Film* film = 0;
+static shared_ptr<Film> film;
static void set_menu_sensitivity ();
}
}
- delete film;
- film = 0;
+ film.reset ();
}
enum Sensitivity {
if (r == wxID_OK) {
maybe_save_then_delete_film ();
- film = new Film (d->get_path (), false);
+ film.reset (new Film (d->get_path (), false));
#if BOOST_FILESYSTEM_VERSION == 3
- film->set_name (filesystem::path (d->get_path()).filename().generic_string());
+ film->set_name (boost::filesystem::path (d->get_path()).filename().generic_string());
#else
- film->set_name (filesystem::path (d->get_path()).filename());
+ film->set_name (boost::filesystem::path (d->get_path()).filename());
#endif
set_film ();
}
if (r == wxID_OK) {
maybe_save_then_delete_film ();
- film = new Film (wx_to_std (c->GetPath ()));
+ film.reset (new Film (wx_to_std (c->GetPath ())));
set_film ();
}
}
dvdomatic_setup ();
if (argc == 2 && boost::filesystem::is_directory (wx_to_std (argv[1]))) {
- film = new Film (wx_to_std (argv[1]));
+ film.reset (new Film (wx_to_std (argv[1])));
}
Frame* f = new Frame (_("DVD-o-matic"));
#include "wx_util.h"
#include "film.h"
-DCINameDialog::DCINameDialog (wxWindow* parent, Film* film)
+using boost::shared_ptr;
+
+DCINameDialog::DCINameDialog (wxWindow* parent, shared_ptr<Film> film)
: wxDialog (parent, wxID_ANY, _("DCI name"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
, _film (film)
{
#include <wx/dialog.h>
#include <wx/textctrl.h>
+#include <boost/shared_ptr.hpp>
class Film;
class DCINameDialog : public wxDialog
{
public:
- DCINameDialog (wxWindow *, Film *);
+ DCINameDialog (wxWindow *, boost::shared_ptr<Film>);
private:
void audio_language_changed (wxCommandEvent &);
wxTextCtrl* _facility;
wxTextCtrl* _package_type;
- Film* _film;
+ boost::shared_ptr<Film> _film;
};
#include "dcp_range_dialog.h"
#include "wx_util.h"
-DCPRangeDialog::DCPRangeDialog (wxWindow* p, Film* f)
+using boost::shared_ptr;
+
+DCPRangeDialog::DCPRangeDialog (wxWindow* p, shared_ptr<Film> f)
: wxDialog (p, wxID_ANY, wxString (_("DCP Range")))
, _film (f)
{
class DCPRangeDialog : public wxDialog
{
public:
- DCPRangeDialog (wxWindow *, Film *);
+ DCPRangeDialog (wxWindow *, boost::shared_ptr<Film>);
boost::signals2::signal<void (int, TrimAction)> Changed;
void set_sensitivity ();
void emit_changed ();
- Film* _film;
+ boost::shared_ptr<Film> _film;
wxRadioButton* _whole;
wxRadioButton* _first;
wxSpinCtrl* _n_frames;
#include "dci_name_dialog.h"
#include "scaler.h"
-using namespace std;
-using namespace boost;
+using std::string;
+using std::stringstream;
+using std::pair;
+using std::fixed;
+using std::setprecision;
+using std::list;
+using std::vector;
+using boost::shared_ptr;
/** @param f Film to edit */
-FilmEditor::FilmEditor (Film* f, wxWindow* parent)
+FilmEditor::FilmEditor (shared_ptr<Film> f, wxWindow* parent)
: wxPanel (parent)
, _ignore_changes (Film::NONE)
, _film (f)
_scaler->Append (std_to_wx ((*i)->name()));
}
+ JobManager::instance()->ActiveJobsChanged.connect (
+ bind (&FilmEditor::active_jobs_changed, this, _1)
+ );
+
/* And set their values from the Film */
set_film (f);
/** Sets the Film that we are editing */
void
-FilmEditor::set_film (Film* f)
+FilmEditor::set_film (shared_ptr<Film> f)
{
_film = f;
_audio->SetLabel (std_to_wx (s.str ()));
}
}
+
+void
+FilmEditor::active_jobs_changed (bool a)
+{
+ set_things_sensitive (!a);
+}
class FilmEditor : public wxPanel
{
public:
- FilmEditor (Film *, wxWindow *);
+ FilmEditor (boost::shared_ptr<Film>, wxWindow *);
- void set_film (Film *);
+ void set_film (boost::shared_ptr<Film>);
void setup_visibility ();
boost::signals2::signal<void (std::string)> FileChanged;
wxControl* video_control (wxControl *);
wxControl* still_control (wxControl *);
+ void active_jobs_changed (bool);
+
Film::Property _ignore_changes;
/** The film we are editing */
- Film* _film;
+ boost::shared_ptr<Film> _film;
/** The Film's name */
wxTextCtrl* _name;
wxStaticText* _dcp_name;
class ThumbPanel : public wxPanel
{
public:
- ThumbPanel (wxPanel* parent, Film* film)
+ ThumbPanel (wxPanel* parent, shared_ptr<Film> film)
: wxPanel (parent)
, _film (film)
, _frame_rebuild_needed (false)
Refresh ();
}
- void set_film (Film* f)
+ void set_film (shared_ptr<Film> f)
{
_film = f;
if (!_film) {
}
}
- Film* _film;
+ shared_ptr<Film> _film;
shared_ptr<wxImage> _image;
wxImage _transformed_image;
/** currently-displayed thumbnail index */
EVT_SIZE (ThumbPanel::size_event)
END_EVENT_TABLE ()
-FilmViewer::FilmViewer (Film* f, wxWindow* p)
+FilmViewer::FilmViewer (shared_ptr<Film> f, wxWindow* p)
: wxPanel (p)
- , _film (0)
{
_sizer = new wxBoxSizer (wxVERTICAL);
SetSizer (_sizer);
}
void
-FilmViewer::set_film (Film* f)
+FilmViewer::set_film (shared_ptr<Film> f)
{
if (_film == f) {
return;
class FilmViewer : public wxPanel
{
public:
- FilmViewer (Film *, wxWindow *);
+ FilmViewer (boost::shared_ptr<Film>, wxWindow *);
- void set_film (Film *);
+ void set_film (boost::shared_ptr<Film>);
void setup_visibility ();
private:
void set_thumbnail (int);
void film_changed (Film::Property);
- Film* _film;
+ boost::shared_ptr<Film> _film;
wxBoxSizer* _sizer;
ThumbPanel* _thumb_panel;
wxSlider* _slider;
#include "job_wrapper.h"
#include "wx_util.h"
-using namespace std;
+using boost::shared_ptr;
void
-JobWrapper::make_dcp (wxWindow* parent, Film* film, bool transcode)
+JobWrapper::make_dcp (wxWindow* parent, shared_ptr<Film> film, bool transcode)
{
if (!film) {
return;
namespace JobWrapper
{
-void make_dcp (wxWindow *, Film *, bool);
+void make_dcp (wxWindow *, boost::shared_ptr<Film>, bool);
}
#include "properties_dialog.h"
#include "wx_util.h"
-using namespace std;
-using namespace boost;
+using std::string;
+using std::stringstream;
+using std::fixed;
+using std::setprecision;
+using boost::shared_ptr;
+using boost::lexical_cast;
-PropertiesDialog::PropertiesDialog (wxWindow* parent, Film* film)
+PropertiesDialog::PropertiesDialog (wxWindow* parent, shared_ptr<Film> film)
: wxDialog (parent, wxID_ANY, _("Film Properties"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE)
, _film (film)
{
stringstream u;
try {
u << _film->encoded_frames ();
- } catch (thread_interrupted &) {
+ } catch (boost::thread_interrupted &) {
return "";
}
class PropertiesDialog : public wxDialog
{
public:
- PropertiesDialog (wxWindow *, Film *);
+ PropertiesDialog (wxWindow *, boost::shared_ptr<Film>);
private:
std::string frames_already_encoded () const;
- Film* _film;
+ boost::shared_ptr<Film> _film;
wxStaticText* _frames;
wxStaticText* _disk_for_frames;
wxStaticText* _total_disk;
Format const * f = Format::from_nickname ("Flat");
BOOST_CHECK (f);
- BOOST_CHECK_EQUAL (f->ratio_as_integer(0), 185);
+ BOOST_CHECK_EQUAL (f->ratio_as_integer(shared_ptr<const Film> ()), 185);
f = Format::from_nickname ("Scope");
BOOST_CHECK (f);
- BOOST_CHECK_EQUAL (f->ratio_as_integer(0), 239);
+ BOOST_CHECK_EQUAL (f->ratio_as_integer(shared_ptr<const Film> ()), 239);
}
BOOST_AUTO_TEST_CASE (util_test)