Tidy up; make viewer respond with with subtitles button.
authorCarl Hetherington <cth@carlh.net>
Thu, 11 Oct 2012 00:28:17 +0000 (01:28 +0100)
committerCarl Hetherington <cth@carlh.net>
Thu, 11 Oct 2012 00:28:17 +0000 (01:28 +0100)
src/wx/film_editor.cc
src/wx/film_viewer.cc

index bc7414c41325603babaa2c72f9cd462ff68e177c..97a98e54d36bfef2dd45ff7facc718832e938083 100644 (file)
@@ -219,6 +219,7 @@ FilmEditor::FilmEditor (Film* f, wxWindow* parent)
        _audio_delay->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::audio_delay_changed), 0, this);
        _still_duration->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::still_duration_changed), 0, this);
        _change_dcp_range_button->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::change_dcp_range_clicked), 0, this);
+       _with_subtitles->Connect (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler (FilmEditor::with_subtitles_toggled), 0, this);
 
        setup_visibility ();
        setup_formats ();
index e49532cdbcc7a40939f1e45e6f903b90147e1202..6a992f0db9e305c7ab11840636f875c42509afc8 100644 (file)
@@ -54,7 +54,6 @@ public:
 
                        _subtitles.clear ();
 
-                       cout << "=== SUBS for " << _film->thumb_frame (_pending_index) << "\n";
                        list<pair<Position, string> > s = _film->thumb_subtitles (_pending_index);
                        for (list<pair<Position, string> >::iterator i = s.begin(); i != s.end(); ++i) {
                                _subtitles.push_back (SubtitleView (i->first, std_to_wx (i->second)));
@@ -70,13 +69,13 @@ public:
 
                wxPaintDC dc (this);
                if (_bitmap) {
-                       cout << "frame bm " << _bitmap->GetWidth() << " " << _bitmap->GetHeight() << "\n";
                        dc.DrawBitmap (*_bitmap, 0, 0, false);
                }
 
-               for (list<SubtitleView>::iterator i = _subtitles.begin(); i != _subtitles.end(); ++i) {
-                       dc.DrawBitmap (*i->bitmap, i->position.x, i->position.y, true);
-                       cout << "\tsub bm at " << i->position.x << " " << i->position.y << " size " << i->bitmap->GetWidth() << " by " << i->bitmap->GetHeight() << "\n";
+               if (_film->with_subtitles ()) {
+                       for (list<SubtitleView>::iterator i = _subtitles.begin(); i != _subtitles.end(); ++i) {
+                               dc.DrawBitmap (*i->bitmap, i->position.x, i->position.y, true);
+                       }
                }
        }
 
@@ -178,9 +177,6 @@ private:
                        Rectangle sub_rect (i->position.x, i->position.y, i->image.GetWidth(), i->image.GetHeight());
                        Rectangle cropped_sub_rect = sub_rect.intersection (cropped);
 
-                       cout << "sub " << sub_rect.x << " " << sub_rect.y << " " << sub_rect.w << " " << sub_rect.h << "\n";
-                       cout << "cropped " << cropped_sub_rect.x << " " << cropped_sub_rect.y << " " << cropped_sub_rect.w << " " << cropped_sub_rect.h << "\n";
-
                        i->cropped_image = i->image.GetSubImage (
                                wxRect (
                                        cropped_sub_rect.x - sub_rect.x,
@@ -197,9 +193,6 @@ private:
                                cropped_sub_rect.y * y_scale
                                );
 
-                       cout << "scales are " << x_scale << " " << y_scale << "\n";
-                       cout << "scaled to " << (cropped_sub_rect.w * x_scale) << " " << (cropped_sub_rect.h * y_scale) << "\n";
-
                        i->bitmap.reset (new wxBitmap (i->cropped_image));
                }
        }
@@ -274,9 +267,11 @@ FilmViewer::slider_changed (wxCommandEvent &)
 void
 FilmViewer::film_changed (Film::Property p)
 {
-       if (p == Film::CROP) {
+       switch (p) {
+       case Film::CROP:
                _thumb_panel->set_crop (_film->crop ());
-       } else if (p == Film::THUMBS) {
+               break;
+       case Film::THUMBS:
                if (_film && _film->num_thumbs() > 1) {
                        _slider->SetRange (0, _film->num_thumbs () - 1);
                } else {
@@ -286,12 +281,20 @@ FilmViewer::film_changed (Film::Property p)
                
                _slider->SetValue (0);
                set_thumbnail (0);
-       } else if (p == Film::FORMAT) {
+               break;
+       case Film::FORMAT:
                _thumb_panel->refresh ();
-       } else if (p == Film::CONTENT) {
+               break;
+       case Film::CONTENT:
                setup_visibility ();
                _film->examine_content ();
                update_thumbs ();
+               break;
+       case Film::WITH_SUBTITLES:
+               _thumb_panel->Refresh ();
+               break;
+       default:
+               break;
        }
 }