Fix incorrect subtitle outline rectangle display when subtitles
[dcpomatic.git] / src / wx / text_panel.cc
index ebeb518ddb2e1f2d15e2e9483aad74fcab2aae39..a9a3f142dd60ce3773f5f2d0f8acb7965052f415 100644 (file)
@@ -18,6 +18,7 @@
 
 */
 
+
 #include "check_box.h"
 #include "content_panel.h"
 #include "dcp_text_track_dialog.h"
 #include "lib/string_text_file_decoder.h"
 #include "lib/subtitle_analysis.h"
 #include "lib/text_content.h"
+#include <dcp/warnings.h>
+LIBDCP_DISABLE_WARNINGS
 #include <wx/spinctrl.h>
+LIBDCP_ENABLE_WARNINGS
 
 
-using std::vector;
-using std::string;
-using std::list;
 using std::cout;
-using std::shared_ptr;
-using boost::optional;
 using std::dynamic_pointer_cast;
+using std::list;
+using std::shared_ptr;
+using std::string;
+using std::vector;
 using boost::bind;
+using boost::optional;
 
 
 /** @param t Original text type of the content, if known */
 TextPanel::TextPanel (ContentPanel* p, TextType t)
        : ContentSubPanel (p, std_to_wx(text_type_to_name(t)))
        , _original_type (t)
+{
+
+}
+
+
+void
+TextPanel::create ()
 {
        wxString refer = _("Use this DCP's subtitle as OV and make VF");
-       if (t == TextType::CLOSED_CAPTION) {
+       if (_original_type == TextType::CLOSED_CAPTION) {
                refer = _("Use this DCP's closed caption as OV and make VF");
        }
 
@@ -131,6 +142,8 @@ TextPanel::TextPanel (ContentPanel* p, TextType t)
 
        add_to_grid();
        content_selection_changed ();
+
+       _sizer->Layout ();
 }
 
 
@@ -165,7 +178,7 @@ TextPanel::setup_visibility ()
                        _language_type->Append (_("Main"));
                        _language_type->Append (_("Additional"));
                        _language_type->Bind (wxEVT_CHOICE, boost::bind(&TextPanel::language_is_additional_changed, this));
-                       _language_sizer->Add (_language_type, 0);
+                       _language_sizer->Add (_language_type, 0, wxALIGN_CENTER_VERTICAL | wxTOP, DCPOMATIC_CHOICE_TOP_PAD);
                        _grid->Add (_language_sizer, wxGBPosition(_ccap_track_or_language_row, 1), wxGBSpan(1, 2));
                        film_content_changed (TextContentProperty::LANGUAGE);
                        film_content_changed (TextContentProperty::LANGUAGE_IS_ADDITIONAL);
@@ -860,12 +873,12 @@ TextPanel::update_outline_subtitles_in_viewer ()
                if (rect) {
                        auto content = _analysis_content.lock ();
                        DCPOMATIC_ASSERT (content);
-                       rect->x += content->text.front()->x_offset();
-                       rect->y += content->text.front()->y_offset();
+                       rect->x += content->text.front()->x_offset() - _analysis->analysis_x_offset();
+                       rect->y += content->text.front()->y_offset() - _analysis->analysis_y_offset();
                }
                fv->set_outline_subtitles (rect);
        } else {
-               fv->set_outline_subtitles (optional<dcpomatic::Rect<double> >());
+               fv->set_outline_subtitles ({});
        }
 }