summaryrefslogtreecommitdiff
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
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.
-rw-r--r--src/wx/dcpomatic_spin_ctrl.cc38
-rw-r--r--src/wx/dcpomatic_spin_ctrl.h41
-rw-r--r--src/wx/text_panel.cc79
-rw-r--r--src/wx/text_panel.h17
-rw-r--r--src/wx/wscript23
5 files changed, 154 insertions, 44 deletions
diff --git a/src/wx/dcpomatic_spin_ctrl.cc b/src/wx/dcpomatic_spin_ctrl.cc
new file mode 100644
index 000000000..e8f2fdbc7
--- /dev/null
+++ b/src/wx/dcpomatic_spin_ctrl.cc
@@ -0,0 +1,38 @@
+/*
+ Copyright (C) 2021 Carl Hetherington <cth@carlh.net>
+
+ This file is part of DCP-o-matic.
+
+ DCP-o-matic is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ DCP-o-matic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#include "dcpomatic_spin_ctrl.h"
+#include <boost/bind.hpp>
+#include <wx/wx.h>
+#if BOOST_VERSION >= 106100
+using namespace boost::placeholders;
+#endif
+
+
+SpinCtrl::SpinCtrl (wxWindow* parent, int width)
+ : wxSpinCtrl (parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(width, -1), wxSP_ARROW_KEYS | wxTE_PROCESS_ENTER)
+{
+ auto enter = [](wxCommandEvent& ev) {
+ dynamic_cast<wxWindow*>(ev.GetEventObject())->Navigate();
+ };
+ Bind (wxEVT_TEXT_ENTER, boost::bind<void>(enter, _1));
+}
+
diff --git a/src/wx/dcpomatic_spin_ctrl.h b/src/wx/dcpomatic_spin_ctrl.h
new file mode 100644
index 000000000..556cf6347
--- /dev/null
+++ b/src/wx/dcpomatic_spin_ctrl.h
@@ -0,0 +1,41 @@
+/*
+ Copyright (C) 2021 Carl Hetherington <cth@carlh.net>
+
+ This file is part of DCP-o-matic.
+
+ DCP-o-matic is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ DCP-o-matic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#ifndef DCPOMATIC_SPIN_CTRL_H
+#define DCPOMATIC_SPIN_CTRL_H
+
+
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
+#include <wx/spinctrl.h>
+#include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
+
+
+class SpinCtrl : public wxSpinCtrl
+{
+public:
+ SpinCtrl (wxWindow* parent, int width);
+};
+
+
+#endif
+
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 ()
{
diff --git a/src/wx/text_panel.h b/src/wx/text_panel.h
index f35f39cbe..7f38ff42b 100644
--- a/src/wx/text_panel.h
+++ b/src/wx/text_panel.h
@@ -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,14 +18,17 @@
*/
+
#include "content_sub_panel.h"
+
class wxCheckBox;
-class wxSpinCtrl;
class TextView;
class FontsDialog;
+class SpinCtrl;
class SubtitleAnalysis;
+
class TextPanel : public ContentSubPanel
{
public:
@@ -75,18 +78,18 @@ private:
wxStaticText* _x_offset_pc_label;
wxStaticText* _y_offset_label;
wxStaticText* _y_offset_pc_label;
- wxSpinCtrl* _x_offset;
- wxSpinCtrl* _y_offset;
+ SpinCtrl* _x_offset;
+ SpinCtrl* _y_offset;
wxStaticText* _scale_label;
wxStaticText* _x_scale_label;
wxStaticText* _x_scale_pc_label;
wxStaticText* _y_scale_label;
wxStaticText* _y_scale_pc_label;
- wxSpinCtrl* _x_scale;
- wxSpinCtrl* _y_scale;
+ SpinCtrl* _x_scale;
+ SpinCtrl* _y_scale;
wxStaticText* _line_spacing_label;
wxStaticText* _line_spacing_pc_label;
- wxSpinCtrl* _line_spacing;
+ SpinCtrl* _line_spacing;
wxStaticText* _dcp_track_label;
wxChoice* _dcp_track;
wxStaticText* _stream_label;
diff --git a/src/wx/wscript b/src/wx/wscript
index f70d2921c..76eea3fa5 100644
--- a/src/wx/wscript
+++ b/src/wx/wscript
@@ -36,6 +36,7 @@ sources = """
check_box.cc
christie_certificate_panel.cc
cinema_dialog.cc
+ closed_captions_dialog.cc
colour_conversion_editor.cc
config_dialog.cc
config_move_dialog.cc
@@ -49,24 +50,21 @@ sources = """
content_version_dialog.cc
content_view.cc
controls.cc
- closed_captions_dialog.cc
credentials_download_certificate_panel.cc
custom_scale_dialog.cc
dcp_panel.cc
- dcpomatic_button.cc
- disk_warning_dialog.cc
- dkdm_output_panel.cc
- drive_wipe_warning_dialog.cc
- email_dialog.cc
- full_language_tag_dialog.cc
- image_sequence_dialog.cc
- isdcf_metadata_dialog.cc
dcp_text_track_dialog.cc
+ dcpomatic_button.cc
+ dcpomatic_spin_ctrl.cc
dir_picker_ctrl.cc
+ disk_warning_dialog.cc
dkdm_dialog.cc
+ dkdm_output_panel.cc
dolby_doremi_certificate_panel.cc
download_certificate_dialog.cc
download_certificate_panel.cc
+ drive_wipe_warning_dialog.cc
+ email_dialog.cc
export_subtitles_dialog.cc
export_video_file_dialog.cc
file_picker_ctrl.cc
@@ -77,17 +75,20 @@ sources = """
focus_manager.cc
fonts_dialog.cc
full_config_dialog.cc
+ full_language_tag_dialog.cc
gain_calculator_dialog.cc
gdc_certificate_panel.cc
gl_video_view.cc
hints_dialog.cc
html_dialog.cc
+ i18n_hook.cc
+ image_sequence_dialog.cc
instant_i18n_dialog.cc
interop_metadata_dialog.cc
- i18n_hook.cc
+ isdcf_metadata_dialog.cc
+ job_manager_view.cc
job_view.cc
job_view_dialog.cc
- job_manager_view.cc
kdm_advanced_dialog.cc
kdm_cpl_panel.cc
kdm_dialog.cc