summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2012-07-25 16:24:36 +0100
committerCarl Hetherington <cth@carlh.net>2012-07-25 16:24:36 +0100
commitb0f5d569ccf740d5524e06ff59a17638221dc9d7 (patch)
tree9dd8c27f890244555b927e7e90256687c16409be /src
parent489e6a92b9aa940de64a886a1f9b5a420b50c7fc (diff)
Various hacks.
Diffstat (limited to 'src')
-rw-r--r--src/tools/dvdomatic.cc410
-rw-r--r--src/wx/film_editor.cc22
-rw-r--r--src/wx/film_editor.h2
-rw-r--r--src/wx/film_viewer.cc109
-rw-r--r--src/wx/film_viewer.h12
-rw-r--r--src/wx/wx_util.cc12
-rw-r--r--src/wx/wx_util.h2
7 files changed, 251 insertions, 318 deletions
diff --git a/src/tools/dvdomatic.cc b/src/tools/dvdomatic.cc
index 81da111e7..68fa1bab6 100644
--- a/src/tools/dvdomatic.cc
+++ b/src/tools/dvdomatic.cc
@@ -29,7 +29,7 @@
//#include "gtk/gpl.h"
//#include "gtk/job_wrapper.h"
//#include "gtk/dvd_title_dialog.h"
-//#include "gtk/gtk_util.h"
+#include "wx/wx_util.h"
#include "lib/film.h"
#include "lib/format.h"
#include "lib/config.h"
@@ -41,12 +41,10 @@
using namespace std;
using namespace boost;
+static wxFrame* frame = 0;
static FilmEditor* film_editor = 0;
static FilmViewer* film_viewer = 0;
-#if 0
-
-static Gtk::Window* window = 0;
#ifndef DVDOMATIC_DISABLE_PLAYER
static FilmPlayer* film_player = 0;
#endif
@@ -54,252 +52,129 @@ static Film* film = 0;
static void set_menu_sensitivity ();
-class FilmChangedDialog : public Gtk::MessageDialog
+class FilmChangedDialog
{
public:
FilmChangedDialog ()
- : Gtk::MessageDialog ("", false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_NONE)
{
stringstream s;
s << "Save changes to film \"" << film->name() << "\" before closing?";
- set_message (s.str ());
- add_button ("Close _without saving", Gtk::RESPONSE_NO);
- add_button ("_Cancel", Gtk::RESPONSE_CANCEL);
- add_button ("_Save", Gtk::RESPONSE_YES);
+ _dialog = new wxMessageDialog (frame, std_to_wx (s.str()), wxT ("Film changed"), wxYES_DEFAULT | wxICON_QUESTION);
+ }
+
+ ~FilmChangedDialog ()
+ {
+ _dialog->Destroy ();
+ }
+
+ int run ()
+ {
+ return _dialog->ShowModal ();
}
+
+private:
+ wxMessageDialog* _dialog;
};
-bool
+void
maybe_save_then_delete_film ()
{
if (!film) {
- return false;
+ return;
}
if (film->dirty ()) {
FilmChangedDialog d;
switch (d.run ()) {
- case Gtk::RESPONSE_CANCEL:
- return true;
- case Gtk::RESPONSE_YES:
+ case wxID_NO:
+ break;
+ case wxID_YES:
film->write_metadata ();
break;
- case Gtk::RESPONSE_NO:
- return false;
}
}
delete film;
film = 0;
- return false;
-}
-
-void
-file_new ()
-{
- Gtk::FileChooserDialog c (*window, "New Film", Gtk::FILE_CHOOSER_ACTION_CREATE_FOLDER);
-#ifdef DVDOMATIC_WINDOWS
- c.set_current_folder (g_get_user_data_dir ());
-#endif
- c.add_button ("_Cancel", Gtk::RESPONSE_CANCEL);
- c.add_button ("C_reate", Gtk::RESPONSE_ACCEPT);
-
- int const r = c.run ();
- if (r == Gtk::RESPONSE_ACCEPT) {
- if (maybe_save_then_delete_film ()) {
- return;
- }
- film = new Film (c.get_filename ());
-#if BOOST_FILESYSTEM_VERSION == 3
- film->set_name (filesystem::path (c.get_filename().c_str()).filename().generic_string());
-#else
- film->set_name (filesystem::path (c.get_filename().c_str()).filename());
-#endif
- film_viewer->set_film (film);
- film_editor->set_film (film);
- set_menu_sensitivity ();
- }
-}
-
-void
-file_open ()
-{
- Gtk::FileChooserDialog c (*window, "Open Film", Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER);
-#ifdef DVDOMATIC_WINDOWS
- c.set_current_folder (g_get_user_data_dir ());
-#endif
- c.add_button ("_Cancel", Gtk::RESPONSE_CANCEL);
- c.add_button ("_Open", Gtk::RESPONSE_ACCEPT);
-
- int const r = c.run ();
- if (r == Gtk::RESPONSE_ACCEPT) {
- if (maybe_save_then_delete_film ()) {
- return;
- }
- film = new Film (c.get_filename ());
- film_viewer->set_film (film);
- film_editor->set_film (film);
- set_menu_sensitivity ();
- }
-}
-
-void
-file_save ()
-{
- film->write_metadata ();
-}
-
-void
-file_quit ()
-{
- if (maybe_save_then_delete_film ()) {
- return;
- }
-
- Gtk::Main::quit ();
-}
-
-void
-edit_preferences ()
-{
- ConfigDialog d;
- d.run ();
- Config::instance()->write ();
-}
-
-void
-jobs_make_dcp ()
-{
- JobWrapper::make_dcp (film, true);
-}
-
-void
-jobs_make_dcp_from_existing_transcode ()
-{
- JobWrapper::make_dcp (film, false);
-}
-
-void
-jobs_copy_from_dvd ()
-{
- try {
- DVDTitleDialog d;
- if (d.run () != Gtk::RESPONSE_OK) {
- return;
- }
- film->copy_from_dvd ();
- } catch (DVDError& e) {
- error_dialog (e.what ());
- }
-}
-
-void
-jobs_send_dcp_to_tms ()
-{
- film->send_dcp_to_tms ();
-}
-
-void
-jobs_examine_content ()
-{
- film->examine_content ();
}
-void
-help_about ()
-{
- Gtk::AboutDialog d;
- d.set_name ("DVD-o-matic");
- d.set_version (DVDOMATIC_VERSION);
- stringstream s;
- s << "DCP generation from arbitrary formats\n\n"
- << "Using " << dependency_version_summary() << "\n";
- d.set_comments (s.str ());
-
- vector<string> authors;
- authors.push_back ("Carl Hetherington");
- authors.push_back ("Terrence Meiczinger");
- authors.push_back ("Paul Davis");
- d.set_authors (authors);
-
- d.set_website ("http://carlh.net/software/dvdomatic");
- d.set_license (gpl);
-
- d.run ();
-}
enum Sensitivity {
ALWAYS,
NEEDS_FILM
};
-map<Gtk::MenuItem *, Sensitivity> menu_items;
+map<wxMenuItem*, Sensitivity> menu_items;
void
-add_item (Gtk::Menu_Helpers::MenuList& items, string text, sigc::slot0<void> handler, Sensitivity sens)
+add_item (wxMenu* menu, std::string text, int id, Sensitivity sens)
{
- items.push_back (Gtk::Menu_Helpers::MenuElem (text, handler));
- menu_items.insert (make_pair (&items.back(), sens));
+ wxMenuItem* item = menu->Append (id, std_to_wx (text));
+ menu_items.insert (make_pair (item, sens));
}
void
set_menu_sensitivity ()
{
- for (map<Gtk::MenuItem *, Sensitivity>::iterator i = menu_items.begin(); i != menu_items.end(); ++i) {
+ for (map<wxMenuItem*, Sensitivity>::iterator i = menu_items.begin(); i != menu_items.end(); ++i) {
if (i->second == NEEDS_FILM) {
- i->first->set_sensitive (film != 0);
+ i->first->Enable (film != 0);
} else {
- i->first->set_sensitive (true);
+ i->first->Enable (true);
}
}
}
+enum {
+ ID_file_new = 1,
+ ID_file_open,
+ ID_file_save,
+ ID_file_quit,
+ ID_edit_preferences,
+ ID_jobs_make_dcp,
+ ID_jobs_send_dcp_to_tms,
+ ID_jobs_copy_from_dvd,
+ ID_jobs_examine_content,
+ ID_jobs_make_dcp_from_existing_transcode,
+ ID_help_about
+};
+
void
-setup_menu (Gtk::MenuBar& m)
+setup_menu (wxMenuBar* m)
{
- using namespace Gtk::Menu_Helpers;
-
- Gtk::Menu* file = manage (new Gtk::Menu);
- MenuList& file_items (file->items ());
- add_item (file_items, "New...", sigc::ptr_fun (file_new), ALWAYS);
- add_item (file_items, "_Open...", sigc::ptr_fun (file_open), ALWAYS);
- file_items.push_back (SeparatorElem ());
- add_item (file_items, "_Save", sigc::ptr_fun (file_save), NEEDS_FILM);
- file_items.push_back (SeparatorElem ());
- add_item (file_items, "_Quit", sigc::ptr_fun (file_quit), ALWAYS);
-
- Gtk::Menu* edit = manage (new Gtk::Menu);
- MenuList& edit_items (edit->items ());
- add_item (edit_items, "_Preferences...", sigc::ptr_fun (edit_preferences), ALWAYS);
-
- Gtk::Menu* jobs = manage (new Gtk::Menu);
- MenuList& jobs_items (jobs->items ());
- add_item (jobs_items, "_Make DCP", sigc::ptr_fun (jobs_make_dcp), NEEDS_FILM);
- add_item (jobs_items, "_Send DCP to TMS", sigc::ptr_fun (jobs_send_dcp_to_tms), NEEDS_FILM);
- add_item (jobs_items, "Copy from _DVD...", sigc::ptr_fun (jobs_copy_from_dvd), NEEDS_FILM);
- jobs_items.push_back (SeparatorElem ());
- add_item (jobs_items, "_Examine content", sigc::ptr_fun (jobs_examine_content), NEEDS_FILM);
- add_item (jobs_items, "Make DCP from _existing transcode", sigc::ptr_fun (jobs_make_dcp_from_existing_transcode), NEEDS_FILM);
-
- Gtk::Menu* help = manage (new Gtk::Menu);
- MenuList& help_items (help->items ());
- add_item (help_items, "About", sigc::ptr_fun (help_about), ALWAYS);
-
- MenuList& items (m.items ());
- items.push_back (MenuElem ("_File", *file));
- items.push_back (MenuElem ("_Edit", *edit));
- items.push_back (MenuElem ("_Jobs", *jobs));
- items.push_back (MenuElem ("_Help", *help));
+ wxMenu* file = new wxMenu;
+ add_item (file, "New...", ID_file_new, ALWAYS);
+ add_item (file, "&Open...", ID_file_open, ALWAYS);
+ file->AppendSeparator ();
+ add_item (file, "&Save", ID_file_save, NEEDS_FILM);
+ file->AppendSeparator ();
+ add_item (file, "&Quit", ID_file_quit, ALWAYS);
+
+ wxMenu* edit = new wxMenu;
+ add_item (edit, "&Preferences...", ID_edit_preferences, ALWAYS);
+
+ wxMenu* jobs = new wxMenu;
+ add_item (jobs, "&Make DCP", ID_jobs_make_dcp, NEEDS_FILM);
+ add_item (jobs, "&Send DCP to TMS", ID_jobs_send_dcp_to_tms, NEEDS_FILM);
+ add_item (jobs, "Copy from &DVD...", ID_jobs_copy_from_dvd, NEEDS_FILM);
+ jobs->AppendSeparator ();
+ add_item (jobs, "&Examine content", ID_jobs_examine_content, NEEDS_FILM);
+ add_item (jobs, "Make DCP from existing &transcode", ID_jobs_make_dcp_from_existing_transcode, NEEDS_FILM);
+
+ wxMenu* help = new wxMenu;
+ add_item (help, "About", ID_help_about, ALWAYS);
+
+ m->Append (file, _("&File"));
+ m->Append (edit, _("&Edit"));
+ m->Append (jobs, _("&Jobs"));
+ m->Append (help, _("&Help"));
}
bool
-window_closed (GdkEventAny *)
+window_closed (wxCommandEvent &)
{
- if (maybe_save_then_delete_film ()) {
- return true;
- }
-
+ maybe_save_then_delete_film ();
return false;
}
@@ -312,16 +187,9 @@ file_changed (string f)
s << " — " << f;
}
- window->set_title (s.str ());
+ frame->SetTitle (std_to_wx (s.str()));
}
-#endif
-
-
-enum {
- ID_Quit = 1,
-};
-
class Frame : public wxFrame
{
public:
@@ -329,23 +197,118 @@ public:
: wxFrame (NULL, -1, title)
{
wxMenuBar* bar = new wxMenuBar;
- bar->Show (true);
+ setup_menu (bar);
+ SetMenuBar (bar);
+ }
+
+ void file_new (wxCommandEvent &)
+ {
+ wxDirDialog* c = new wxDirDialog (frame, wxT ("New Film"));
+ int const r = c->ShowModal ();
+ c->Destroy ();
+
+ if (r == wxID_OK) {
+ maybe_save_then_delete_film ();
+ film = new Film (wx_to_std (c->GetPath ()));
+#if BOOST_FILESYSTEM_VERSION == 3
+ film->set_name (filesystem::path (wx_to_std (c->GetPath())).filename().generic_string());
+#else
+ film->set_name (filesystem::path (wx_to_std (c->GetPath())).filename());
+#endif
+ film_viewer->set_film (film);
+ film_editor->set_film (film);
+ set_menu_sensitivity ();
+ }
+ }
+
+ void file_open (wxCommandEvent &)
+ {
+ wxDirDialog* c = new wxDirDialog (frame, wxT ("Open Film"), wxT (""), wxDD_DIR_MUST_EXIST);
+ int const r = c->ShowModal ();
+ c->Destroy ();
- wxMenu *menu_file = new wxMenu;
- menu_file->Append (ID_Quit, _("&Quit"));
+ if (r == wxID_OK) {
+ maybe_save_then_delete_film ();
+ film = new Film (wx_to_std (c->GetPath ()));
+ film_viewer->set_film (film);
+ film_editor->set_film (film);
+ set_menu_sensitivity ();
+ }
+ }
- bar->Append (menu_file, _("&File"));
+ void file_save (wxCommandEvent &)
+ {
+ film->write_metadata ();
+ }
+
+ void file_quit (wxCommandEvent &)
+ {
+ maybe_save_then_delete_film ();
+ frame->Close (true);
+ }
- SetMenuBar (bar);
+ void edit_preferences (wxCommandEvent &)
+ {
+// ConfigDialog d;
+// d.run ();
+// Config::instance()->write ();
+ }
- CreateStatusBar ();
- SetStatusText (_("Welcome to DVD-o-matic!"));
+ void jobs_make_dcp (wxCommandEvent &)
+ {
+// JobWrapper::make_dcp (film, true);
}
- void quit (wxCommandEvent& event)
+ void jobs_make_dcp_from_existing_transcode (wxCommandEvent &)
{
- Close (true);
+// JobWrapper::make_dcp (film, false);
}
+
+ void jobs_copy_from_dvd (wxCommandEvent &)
+ {
+// try {
+// DVDTitleDialog d;
+// if (d.run () != Gtk::RESPONSE_OK) {
+// return;
+// }
+// film->copy_from_dvd ();
+// } catch (DVDError& e) {
+// error_dialog (e.what ());
+// }
+ }
+
+ void jobs_send_dcp_to_tms (wxCommandEvent &)
+ {
+ film->send_dcp_to_tms ();
+ }
+
+ void jobs_examine_content (wxCommandEvent &)
+ {
+ film->examine_content ();
+ }
+
+ void help_about (wxCommandEvent &)
+ {
+// Gtk::AboutDialog d;
+// d.set_name ("DVD-o-matic");
+// d.set_version (DVDOMATIC_VERSION);
+
+// stringstream s;
+// s << "DCP generation from arbitrary formats\n\n"
+// << "Using " << dependency_version_summary() << "\n";
+// d.set_comments (s.str ());
+
+// vector<string> authors;
+// authors.push_back ("Carl Hetherington");
+// authors.push_back ("Terrence Meiczinger");
+// authors.push_back ("Paul Davis");
+// d.set_authors (authors);
+
+// d.set_website ("http://carlh.net/software/dvdomatic");
+// d.set_license (gpl);
+
+// d.run ();
+}
};
class App : public wxApp
@@ -364,15 +327,22 @@ class App : public wxApp
// film = new Film (argv[1]);
// }
- Film* film = new Film ("/home/carl/DCP/BitHarvest");
+ film = new Film ("/home/carl/DCP/BitHarvest");
- Frame* frame = new Frame (_("DVD-o-matic"));
+ frame = new Frame (_("DVD-o-matic"));
frame->Show (true);
- frame->Connect (
- ID_Quit, wxEVT_COMMAND_MENU_SELECTED,
- (wxObjectEventFunction) &Frame::quit
- );
+ frame->Connect (ID_file_new, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::file_new));
+ frame->Connect (ID_file_open, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::file_open));
+ frame->Connect (ID_file_save, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::file_save));
+ frame->Connect (ID_file_quit, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::file_quit));
+ frame->Connect (ID_edit_preferences, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::edit_preferences));
+ frame->Connect (ID_jobs_make_dcp, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::jobs_make_dcp));
+ frame->Connect (ID_jobs_send_dcp_to_tms, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::jobs_send_dcp_to_tms));
+ frame->Connect (ID_jobs_copy_from_dvd, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::jobs_copy_from_dvd));
+ frame->Connect (ID_jobs_examine_content, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::jobs_examine_content));
+ frame->Connect (ID_jobs_make_dcp_from_existing_transcode, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::jobs_make_dcp_from_existing_transcode));
+ frame->Connect (ID_help_about, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::help_about));
film_editor = new FilmEditor (film, frame);
film_editor->Show (true);
diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc
index 395b855da..42d6fcff5 100644
--- a/src/wx/film_editor.cc
+++ b/src/wx/film_editor.cc
@@ -96,7 +96,7 @@ FilmEditor::FilmEditor (Film* f, wxWindow* parent)
vector<Format const *> fmt = Format::all ();
for (vector<Format const *>::iterator i = fmt.begin(); i != fmt.end(); ++i) {
- _format->Append (wxString ((*i)->name().c_str(), wxConvUTF8));
+ _format->Append (std_to_wx ((*i)->name ()));
}
//XXX _frames_per_second.set_increments (1, 5);
@@ -105,12 +105,12 @@ FilmEditor::FilmEditor (Film* f, wxWindow* parent)
vector<DCPContentType const *> const ct = DCPContentType::all ();
for (vector<DCPContentType const *>::const_iterator i = ct.begin(); i != ct.end(); ++i) {
- _dcp_content_type->Append (wxString ((*i)->pretty_name().c_str(), wxConvUTF8));
+ _dcp_content_type->Append (std_to_wx ((*i)->pretty_name ()));
}
vector<Scaler const *> const sc = Scaler::all ();
for (vector<Scaler const *>::const_iterator i = sc.begin(); i != sc.end(); ++i) {
- _scaler->Append (wxString ((*i)->name().c_str(), wxConvUTF8));
+ _scaler->Append (std_to_wx ((*i)->name()));
}
//XXX _original_size.set_alignment (0, 0.5);
@@ -340,11 +340,11 @@ FilmEditor::film_changed (Film::Property p)
{
pair<string, string> p = Filter::ffmpeg_strings (_film->filters ());
string const b = p.first + " " + p.second;
- _filters->SetLabel (wxString (b.c_str(), wxConvUTF8));
+ _filters->SetLabel (std_to_wx (b));
break;
}
case Film::NAME:
- _name->SetValue (wxString (_film->name().c_str(), wxConvUTF8));
+ _name->SetValue (std_to_wx (_film->name ()));
break;
case Film::FRAMES_PER_SECOND:
_frames_per_second->SetValue (_film->frames_per_second ());
@@ -355,7 +355,7 @@ FilmEditor::film_changed (Film::Property p)
_audio->SetLabel (wxT (""));
} else {
s << _film->audio_channels () << " channels, " << _film->audio_sample_rate() << "Hz";
- _audio->SetLabel (wxString (s.str().c_str(), wxConvUTF8));
+ _audio->SetLabel (std_to_wx (s.str ()));
}
break;
case Film::SIZE:
@@ -363,7 +363,7 @@ FilmEditor::film_changed (Film::Property p)
_original_size->SetLabel (wxT (""));
} else {
s << _film->size().width << " x " << _film->size().height;
- _original_size->SetLabel (wxString (s.str().c_str(), wxConvUTF8));
+ _original_size->SetLabel (std_to_wx (s.str ()));
}
break;
case Film::LENGTH:
@@ -372,7 +372,7 @@ FilmEditor::film_changed (Film::Property p)
} else if (_film->length() > 0) {
s << _film->length() << " frames";
}
- _length->SetLabel (wxString (s.str().c_str(), wxConvUTF8));
+ _length->SetLabel (std_to_wx (s.str ()));
break;
case Film::DCP_CONTENT_TYPE:
_dcp_content_type->SetSelection (DCPContentType::as_index (_film->dcp_content_type ()));
@@ -385,7 +385,7 @@ FilmEditor::film_changed (Film::Property p)
} else {
stringstream s;
s << "First " << _film->dcp_frames() << " frames";
- _dcp_range->SetLabel (wxString (s.str().c_str(), wxConvUTF8));
+ _dcp_range->SetLabel (std_to_wx (s.str ()));
}
break;
case Film::DCP_TRIM_ACTION:
@@ -449,9 +449,9 @@ FilmEditor::set_film (Film* f)
}
if (_film) {
-// FileChanged (_film->directory ());
+ FileChanged (_film->directory ());
} else {
-// FileChanged ("");
+ FileChanged ("");
}
film_changed (Film::NAME);
diff --git a/src/wx/film_editor.h b/src/wx/film_editor.h
index c0e4ec3b4..23fd3352a 100644
--- a/src/wx/film_editor.h
+++ b/src/wx/film_editor.h
@@ -39,7 +39,7 @@ public:
void set_film (Film *);
void setup_visibility ();
-//XXX sigc::signal1<void, std::string> FileChanged;
+ sigc::signal1<void, std::string> FileChanged;
private:
/* Handle changes to the view */
diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc
index c9a72f225..6f5625293 100644
--- a/src/wx/film_viewer.cc
+++ b/src/wx/film_viewer.cc
@@ -43,6 +43,10 @@ public:
, _film (film)
, _image (0)
, _bitmap (0)
+ , _left_crop (0)
+ , _right_crop (0)
+ , _top_crop (0)
+ , _bottom_crop (0)
{
}
@@ -72,15 +76,21 @@ public:
float const target = _film->format()->ratio_as_float ();
- delete _bitmap;
+ _cropped_image = _image->GetSubImage (
+ wxRect (_left_crop, _top_crop, _image->GetWidth() - (_left_crop + _right_crop), _image->GetHeight() - (_top_crop + _bottom_crop))
+ );
+
if ((float (vw) / vh) > target) {
/* view is longer (horizontally) than the ratio; fit height */
- _bitmap = new wxBitmap (_image->Scale (vh * target, vh));
+ _cropped_image.Rescale (vh * target, vh);
} else {
/* view is shorter (horizontally) than the ratio; fit width */
- _bitmap = new wxBitmap (_image->Scale (vw, vw / target));
+ _cropped_image.Rescale (vw, vw / target);
}
+ delete _bitmap;
+ _bitmap = new wxBitmap (_cropped_image);
+
Refresh ();
}
@@ -91,6 +101,15 @@ public:
resize ();
}
+ void set_crop (int l, int r, int t, int b)
+ {
+ _left_crop = l;
+ _right_crop = r;
+ _top_crop = t;
+ _bottom_crop = b;
+ resize ();
+ }
+
void clear ()
{
delete _bitmap;
@@ -104,7 +123,12 @@ public:
private:
Film* _film;
wxImage* _image;
+ wxImage _cropped_image;
wxBitmap* _bitmap;
+ int _left_crop;
+ int _right_crop;
+ int _top_crop;
+ int _bottom_crop;
};
BEGIN_EVENT_TABLE (ThumbPanel, wxPanel)
@@ -122,7 +146,7 @@ FilmViewer::FilmViewer (Film* f, wxWindow* p)
_thumb_panel = new ThumbPanel (this, f);
_sizer->Add (_thumb_panel, 1, wxEXPAND);
- int const max = f ? f->num_thumbs() : 0;
+ int const max = f ? f->num_thumbs() - 1 : 0;
_slider = new wxSlider (this, wxID_ANY, 0, 0, max);
_sizer->Add (_slider, 0, wxEXPAND | wxLEFT | wxRIGHT);
load_thumbnail (0);
@@ -139,11 +163,6 @@ FilmViewer::load_thumbnail (int n)
return;
}
- int const left = _film->left_crop ();
- int const right = _film->right_crop ();
- int const top = _film->top_crop ();
- int const bottom = _film->bottom_crop ();
-
_thumb_panel->load (_film->thumb_file(n));
}
@@ -159,38 +178,20 @@ FilmViewer::slider_changed (wxCommandEvent &)
reload_current_thumbnail ();
}
-string
-FilmViewer::format_position_slider_value (double v) const
-{
-#if 0
- stringstream s;
-
- if (_film && int (v) < _film->num_thumbs ()) {
- int const f = _film->thumb_frame (int (v));
- s << f << " " << seconds_to_hms (f / _film->frames_per_second ());
- } else {
- s << "-";
- }
-
- return s.str ();
-#endif
-}
-
void
FilmViewer::film_changed (Film::Property p)
{
-#if 0
if (p == Film::LEFT_CROP || p == Film::RIGHT_CROP || p == Film::TOP_CROP || p == Film::BOTTOM_CROP) {
- reload_current_thumbnail ();
+ _thumb_panel->set_crop (_film->left_crop(), _film->right_crop(), _film->top_crop(), _film->bottom_crop ());
} else if (p == Film::THUMBS) {
if (_film && _film->num_thumbs() > 1) {
- _position_slider.set_range (0, _film->num_thumbs () - 1);
+ _slider->SetRange (0, _film->num_thumbs () - 1);
} else {
- _image.clear ();
- _position_slider.set_range (0, 1);
+ _thumb_panel->clear ();
+ _slider->SetRange (0, 1);
}
- _position_slider.set_value (0);
+ _slider->SetValue (0);
reload_current_thumbnail ();
} else if (p == Film::FORMAT) {
reload_current_thumbnail ();
@@ -199,7 +200,6 @@ FilmViewer::film_changed (Film::Property p)
_film->examine_content ();
update_thumbs ();
}
-#endif
}
void
@@ -212,50 +212,14 @@ FilmViewer::set_film (Film* f)
return;
}
-// _film->Changed.connect (sigc::mem_fun (*this, &FilmViewer::film_changed));
+ _film->Changed.connect (sigc::mem_fun (*this, &FilmViewer::film_changed));
film_changed (Film::THUMBS);
}
-pair<int, int>
-FilmViewer::scaled_pixbuf_size () const
-{
-#if 0
- if (_film == 0) {
- return make_pair (0, 0);
- }
-
- int const cw = _film->size().width - _film->left_crop() - _film->right_crop();
- int const ch = _film->size().height - _film->top_crop() - _film->bottom_crop();
-
- float ratio = 1;
- if (_film->format()) {
- ratio = _film->format()->ratio_as_float() * ch / cw;
- }
-
- Gtk::Allocation const a = _scroller.get_allocation ();
- float const zoom = min (float (a.get_width()) / (cw * ratio), float (a.get_height()) / cw);
- return make_pair (cw * zoom * ratio, ch * zoom);
-#endif
-}
-
-void
-FilmViewer::update_scaled_pixbuf ()
-{
-#if 0
- pair<int, int> const s = scaled_pixbuf_size ();
-
- if (s.first > 0 && s.second > 0 && _cropped_pixbuf) {
- _scaled_pixbuf = _cropped_pixbuf->scale_simple (s.first, s.second, Gdk::INTERP_HYPER);
- _image.set (_scaled_pixbuf);
- }
-#endif
-}
-
void
FilmViewer::update_thumbs ()
{
-#if 0
if (!_film) {
return;
}
@@ -272,18 +236,15 @@ FilmViewer::update_thumbs ()
shared_ptr<Job> j (new ThumbsJob (s, o, _film->log ()));
j->Finished.connect (sigc::mem_fun (_film, &Film::update_thumbs_post_gui));
JobManager::instance()->add (j);
-#endif
}
void
FilmViewer::setup_visibility ()
{
-#if 0
if (!_film) {
return;
}
ContentType const c = _film->content_type ();
- _position_slider.property_visible() = (c == VIDEO);
-#endif
+ _slider->Show (c == VIDEO);
}
diff --git a/src/wx/film_viewer.h b/src/wx/film_viewer.h
index f1213e023..8a1a0c908 100644
--- a/src/wx/film_viewer.h
+++ b/src/wx/film_viewer.h
@@ -40,24 +40,12 @@ public:
private:
void slider_changed (wxCommandEvent &);
void update_thumbs ();
- std::string format_position_slider_value (double) const;
void load_thumbnail (int);
void film_changed (Film::Property);
void reload_current_thumbnail ();
- void update_scaled_pixbuf ();
- std::pair<int, int> scaled_pixbuf_size () const;
-// void scroller_size_allocate (Gtk::Allocation);
Film* _film;
wxBoxSizer* _sizer;
ThumbPanel* _thumb_panel;
wxSlider* _slider;
-// Gtk::VBox _vbox;
-// Gtk::ScrolledWindow _scroller;
-// Gtk::Image _image;
-// Glib::RefPtr<Gdk::Pixbuf> _pixbuf;
-// Glib::RefPtr<Gdk::Pixbuf> _cropped_pixbuf;
-// Glib::RefPtr<Gdk::Pixbuf> _scaled_pixbuf;
-// Gtk::HScale _position_slider;
-// Gtk::Allocation _last_scroller_allocation;
};
diff --git a/src/wx/wx_util.cc b/src/wx/wx_util.cc
index 409ab361c..bb268ea68 100644
--- a/src/wx/wx_util.cc
+++ b/src/wx/wx_util.cc
@@ -43,3 +43,15 @@ error_dialog (string m)
d.run ();
}
#endif
+
+string
+wx_to_std (wxString s)
+{
+ return string (s.mb_str ());
+}
+
+wxString
+std_to_wx (string s)
+{
+ return wxString (s.c_str(), wxConvUTF8);
+}
diff --git a/src/wx/wx_util.h b/src/wx/wx_util.h
index 8a84b1323..6f83e3df0 100644
--- a/src/wx/wx_util.h
+++ b/src/wx/wx_util.h
@@ -26,3 +26,5 @@
extern void error_dialog (std::string);
extern wxStaticText* add_label_to_sizer (wxSizer *, wxWindow *, std::list<wxControl*>&, std::string);
+extern std::string wx_to_std (wxString);
+extern wxString std_to_wx (std::string);