summaryrefslogtreecommitdiff
path: root/src/wx/text_panel.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2021-03-29 22:27:35 +0200
committerCarl Hetherington <cth@carlh.net>2021-03-29 22:38:28 +0200
commit5baecb091f5f3f956be002668ce74291c7826b95 (patch)
treeb9583297ce05ddf133ed441dac946b439b8d0fb2 /src/wx/text_panel.cc
parent25142b529304096d22baf885c45ba41bce480b72 (diff)
Fix strange problems with spin entries on macOS (#1944).
SetRange() with minimum > 0 seems to stop entry of numbers by selecting the existing one and typing new. Also we can make Enter work properly by adding a handler.
Diffstat (limited to 'src/wx/text_panel.cc')
-rw-r--r--src/wx/text_panel.cc79
1 files changed, 53 insertions, 26 deletions
diff --git a/src/wx/text_panel.cc b/src/wx/text_panel.cc
index ec4904afd..3b617a031 100644
--- a/src/wx/text_panel.cc
+++ b/src/wx/text_panel.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2012-2020 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
@@ -18,32 +18,35 @@
*/
-#include "text_panel.h"
-#include "film_editor.h"
-#include "wx_util.h"
-#include "text_view.h"
+
+#include "check_box.h"
#include "content_panel.h"
-#include "fonts_dialog.h"
#include "dcp_text_track_dialog.h"
-#include "subtitle_appearance_dialog.h"
-#include "static_text.h"
-#include "check_box.h"
#include "dcpomatic_button.h"
+#include "dcpomatic_spin_ctrl.h"
+#include "film_editor.h"
#include "film_viewer.h"
-#include "lib/job_manager.h"
-#include "lib/ffmpeg_content.h"
-#include "lib/string_text_file_content.h"
-#include "lib/ffmpeg_subtitle_stream.h"
+#include "fonts_dialog.h"
+#include "static_text.h"
+#include "subtitle_appearance_dialog.h"
+#include "text_panel.h"
+#include "text_view.h"
+#include "wx_util.h"
+#include "lib/analyse_subtitles_job.h"
+#include "lib/dcp_content.h"
#include "lib/dcp_subtitle_content.h"
-#include "lib/string_text_file_decoder.h"
#include "lib/dcp_subtitle_decoder.h"
-#include "lib/dcp_content.h"
-#include "lib/text_content.h"
#include "lib/decoder_factory.h"
-#include "lib/analyse_subtitles_job.h"
+#include "lib/ffmpeg_content.h"
+#include "lib/ffmpeg_subtitle_stream.h"
+#include "lib/job_manager.h"
+#include "lib/string_text_file_content.h"
+#include "lib/string_text_file_decoder.h"
#include "lib/subtitle_analysis.h"
+#include "lib/text_content.h"
#include <wx/spinctrl.h>
+
using std::vector;
using std::string;
using std::list;
@@ -53,6 +56,7 @@ using boost::optional;
using std::dynamic_pointer_cast;
using boost::bind;
+
/** @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)))
@@ -92,22 +96,22 @@ TextPanel::TextPanel (ContentPanel* p, TextType t)
_offset_label = create_label (this, _("Offset"), true);
_x_offset_label = create_label (this, _("X"), true);
- _x_offset = new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(spin_width, -1));
+ _x_offset = new SpinCtrl (this, spin_width);
_x_offset_pc_label = new StaticText (this, _("%"));
_y_offset_label = create_label (this, _("Y"), true);
- _y_offset = new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(spin_width, -1));
+ _y_offset = new SpinCtrl (this, spin_width);
_y_offset_pc_label = new StaticText (this, _("%"));
_scale_label = create_label (this, _("Scale"), true);
_x_scale_label = create_label (this, _("X"), true);
- _x_scale = new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(spin_width, -1));
+ _x_scale = new SpinCtrl (this, spin_width);
_x_scale_pc_label = new StaticText (this, _("%"));
_y_scale_label = create_label (this, S_("Coord|Y"), true);
- _y_scale = new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(spin_width, -1));
+ _y_scale = new SpinCtrl (this, spin_width);
_y_scale_pc_label = new StaticText (this, _("%"));
_line_spacing_label = create_label (this, _("Line spacing"), true);
- _line_spacing = new wxSpinCtrl (this);
+ _line_spacing = new SpinCtrl (this, spin_width);
_line_spacing_pc_label = new StaticText (this, _("%"));
_stream_label = create_label (this, _("Stream"), true);
@@ -119,9 +123,9 @@ TextPanel::TextPanel (ContentPanel* p, TextType t)
_x_offset->SetRange (-100, 100);
_y_offset->SetRange (-100, 100);
- _x_scale->SetRange (10, 1000);
- _y_scale->SetRange (10, 1000);
- _line_spacing->SetRange (10, 1000);
+ _x_scale->SetRange (0, 1000);
+ _y_scale->SetRange (0, 1000);
+ _line_spacing->SetRange (0, 1000);
_reference->Bind (wxEVT_CHECKBOX, boost::bind (&TextPanel::reference_clicked, this));
_use->Bind (wxEVT_CHECKBOX, boost::bind (&TextPanel::use_toggled, this));
@@ -141,6 +145,7 @@ TextPanel::TextPanel (ContentPanel* p, TextType t)
content_selection_changed ();
}
+
void
TextPanel::setup_visibility ()
{
@@ -152,7 +157,7 @@ TextPanel::setup_visibility ()
}
if (_dcp_track) {
_dcp_track->Destroy ();
- _dcp_track = 0;
+ _dcp_track = nullptr;
}
if (!_outline_subtitles) {
_outline_subtitles = new CheckBox (this, _("Show subtitle area"));
@@ -186,6 +191,7 @@ TextPanel::setup_visibility ()
_grid->Layout ();
}
+
void
TextPanel::add_to_grid ()
{
@@ -271,6 +277,7 @@ TextPanel::add_to_grid ()
setup_visibility ();
}
+
void
TextPanel::update_dcp_track_selection ()
{
@@ -303,6 +310,7 @@ TextPanel::update_dcp_track_selection ()
}
}
+
void
TextPanel::update_dcp_tracks ()
{
@@ -325,6 +333,7 @@ TextPanel::update_dcp_tracks ()
update_dcp_track_selection ();
}
+
void
TextPanel::dcp_track_changed ()
{
@@ -357,6 +366,7 @@ TextPanel::dcp_track_changed ()
update_dcp_tracks ();
}
+
void
TextPanel::film_changed (Film::Property property)
{
@@ -365,6 +375,7 @@ TextPanel::film_changed (Film::Property property)
}
}
+
void
TextPanel::film_content_changed (int property)
{
@@ -459,6 +470,7 @@ TextPanel::film_content_changed (int property)
}
}
+
void
TextPanel::use_toggled ()
{
@@ -467,6 +479,7 @@ TextPanel::use_toggled ()
}
}
+
/** @return the text type that is currently selected in the drop-down */
TextType
TextPanel::current_type () const
@@ -481,6 +494,7 @@ TextPanel::current_type () const
return TextType::UNKNOWN;
}
+
void
TextPanel::type_changed ()
{
@@ -491,6 +505,7 @@ TextPanel::type_changed ()
setup_visibility ();
}
+
void
TextPanel::burn_toggled ()
{
@@ -499,6 +514,7 @@ TextPanel::burn_toggled ()
}
}
+
void
TextPanel::setup_sensitivity ()
{
@@ -589,6 +605,7 @@ TextPanel::setup_sensitivity ()
_appearance_dialog_button->Enable (!reference && any_subs > 0 && use && type == TextType::OPEN_SUBTITLE);
}
+
void
TextPanel::stream_changed ()
{
@@ -611,6 +628,7 @@ TextPanel::stream_changed ()
}
}
+
void
TextPanel::x_offset_changed ()
{
@@ -619,6 +637,7 @@ TextPanel::x_offset_changed ()
}
}
+
void
TextPanel::y_offset_changed ()
{
@@ -627,6 +646,7 @@ TextPanel::y_offset_changed ()
}
}
+
void
TextPanel::x_scale_changed ()
{
@@ -635,6 +655,7 @@ TextPanel::x_scale_changed ()
}
}
+
void
TextPanel::y_scale_changed ()
{
@@ -643,6 +664,7 @@ TextPanel::y_scale_changed ()
}
}
+
void
TextPanel::line_spacing_changed ()
{
@@ -651,6 +673,7 @@ TextPanel::line_spacing_changed ()
}
}
+
void
TextPanel::content_selection_changed ()
{
@@ -668,6 +691,7 @@ TextPanel::content_selection_changed ()
film_content_changed (DCPContentProperty::REFERENCE_TEXT);
}
+
void
TextPanel::text_view_clicked ()
{
@@ -687,6 +711,7 @@ TextPanel::text_view_clicked ()
}
}
+
void
TextPanel::fonts_dialog_clicked ()
{
@@ -702,6 +727,7 @@ TextPanel::fonts_dialog_clicked ()
_fonts_dialog->Show ();
}
+
void
TextPanel::reference_clicked ()
{
@@ -718,6 +744,7 @@ TextPanel::reference_clicked ()
d->set_reference_text (_original_type, _reference->GetValue ());
}
+
void
TextPanel::appearance_dialog_clicked ()
{