From: Carl Hetherington Date: Fri, 9 Jan 2015 21:53:38 +0000 (+0000) Subject: Hand-apply d7329603f8698f5302d11acfc233ca67695e654d from master; timecode labelling. X-Git-Tag: v2.0.48~330 X-Git-Url: https://git.carlh.net/gitweb/?a=commitdiff_plain;h=772c2476431ebf42ac83b371cd7edbc9717248f9;p=dcpomatic.git Hand-apply d7329603f8698f5302d11acfc233ca67695e654d from master; timecode labelling. --- diff --git a/TO_PORT b/TO_PORT index f7662f18a..e69de29bb 100644 --- a/TO_PORT +++ b/TO_PORT @@ -1 +0,0 @@ -8a1014523dea0253efa30f3831c086bf367e8e67 diff --git a/src/wx/timecode.cc b/src/wx/timecode.cc index bd0a182c2..fe6819cd0 100644 --- a/src/wx/timecode.cc +++ b/src/wx/timecode.cc @@ -29,10 +29,8 @@ using boost::lexical_cast; TimecodeBase::TimecodeBase (wxWindow* parent) : wxPanel (parent) { - wxClientDC dc (parent); - wxSize size = dc.GetTextExtent (wxT ("9999")); - size.SetHeight (-1); - + wxSize const s = TimecodeBase::size (parent); + wxTextValidator validator (wxFILTER_INCLUDE_CHAR_LIST); wxArrayString list; @@ -47,19 +45,19 @@ TimecodeBase::TimecodeBase (wxWindow* parent) _editable = new wxPanel (this); wxSizer* editable_sizer = new wxBoxSizer (wxHORIZONTAL); - _hours = new wxTextCtrl (_editable, wxID_ANY, wxT(""), wxDefaultPosition, size, 0, validator); + _hours = new wxTextCtrl (_editable, wxID_ANY, wxT(""), wxDefaultPosition, s, 0, validator); _hours->SetMaxLength (2); editable_sizer->Add (_hours); add_label_to_sizer (editable_sizer, _editable, wxT (":"), false); - _minutes = new wxTextCtrl (_editable, wxID_ANY, wxT(""), wxDefaultPosition, size, 0, validator); + _minutes = new wxTextCtrl (_editable, wxID_ANY, wxT(""), wxDefaultPosition, s, 0, validator); _minutes->SetMaxLength (2); editable_sizer->Add (_minutes); add_label_to_sizer (editable_sizer, _editable, wxT (":"), false); - _seconds = new wxTextCtrl (_editable, wxID_ANY, wxT(""), wxDefaultPosition, size, 0, validator); + _seconds = new wxTextCtrl (_editable, wxID_ANY, wxT(""), wxDefaultPosition, s, 0, validator); _seconds->SetMaxLength (2); editable_sizer->Add (_seconds); add_label_to_sizer (editable_sizer, _editable, wxT (":"), false); - _frames = new wxTextCtrl (_editable, wxID_ANY, wxT(""), wxDefaultPosition, size, 0, validator); + _frames = new wxTextCtrl (_editable, wxID_ANY, wxT(""), wxDefaultPosition, s, 0, validator); _frames->SetMaxLength (2); editable_sizer->Add (_frames); _set_button = new wxButton (_editable, wxID_ANY, _("Set")); @@ -112,3 +110,14 @@ TimecodeBase::set_editable (bool e) _fixed->Show (!e); _sizer->Layout (); } + +wxSize +TimecodeBase::size (wxWindow* parent) +{ + wxClientDC dc (parent); + wxSize size = dc.GetTextExtent (wxT ("9999")); + size.SetHeight (-1); + return size; +} + + diff --git a/src/wx/timecode.h b/src/wx/timecode.h index 1d1d6a7f5..1e66b8d94 100644 --- a/src/wx/timecode.h +++ b/src/wx/timecode.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2014 Carl Hetherington + Copyright (C) 2013-2015 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -37,6 +37,8 @@ public: boost::signals2::signal Changed; + static wxSize size (wxWindow* parent); + protected: void changed (); void set_clicked (); diff --git a/src/wx/timing_panel.cc b/src/wx/timing_panel.cc index 716a27b66..ab98a5094 100644 --- a/src/wx/timing_panel.cc +++ b/src/wx/timing_panel.cc @@ -40,6 +40,40 @@ TimingPanel::TimingPanel (ContentPanel* p) wxFlexGridSizer* grid = new wxFlexGridSizer (2, 4, 4); _sizer->Add (grid, 0, wxALL, 8); + wxSize size = TimecodeBase::size (this); + + wxSizer* labels = new wxBoxSizer (wxHORIZONTAL); + //// TRANSLATORS: this is an abbreviation for "hours" + wxStaticText* t = new wxStaticText (this, wxID_ANY, _("h"), wxDefaultPosition, size, wxALIGN_CENTRE_HORIZONTAL); +#ifdef DCPOMATIC_LINUX + /* Hack to work around failure to centre text on GTK */ + gtk_label_set_line_wrap (GTK_LABEL (t->GetHandle()), FALSE); +#endif + labels->Add (t, 1, wxEXPAND); + add_label_to_sizer (labels, this, wxT (":"), false); + //// TRANSLATORS: this is an abbreviation for "minutes" + t = new wxStaticText (this, wxID_ANY, _("m"), wxDefaultPosition, size, wxALIGN_CENTRE_HORIZONTAL); +#ifdef DCPOMATIC_LINUX + gtk_label_set_line_wrap (GTK_LABEL (t->GetHandle()), FALSE); +#endif + labels->Add (t, 1, wxEXPAND); + add_label_to_sizer (labels, this, wxT (":"), false); + //// TRANSLATORS: this is an abbreviation for "seconds" + t = new wxStaticText (this, wxID_ANY, _("s"), wxDefaultPosition, size, wxALIGN_CENTRE_HORIZONTAL); +#ifdef DCPOMATIC_LINUX + gtk_label_set_line_wrap (GTK_LABEL (t->GetHandle()), FALSE); +#endif + labels->Add (t, 1, wxEXPAND); + add_label_to_sizer (labels, this, wxT (":"), false); + //// TRANSLATORS: this is an abbreviation for "frames" + t = new wxStaticText (this, wxID_ANY, _("f"), wxDefaultPosition, size, wxALIGN_CENTRE_HORIZONTAL); +#ifdef DCPOMATIC_LINUX + gtk_label_set_line_wrap (GTK_LABEL (t->GetHandle()), FALSE); +#endif + labels->Add (t, 1, wxEXPAND); + grid->Add (new wxStaticText (this, wxID_ANY, wxT (""))); + grid->Add (labels); + add_label_to_sizer (grid, this, _("Position"), true); _position = new Timecode (this); grid->Add (_position);