diff options
| author | Carl Hetherington <cth@carlh.net> | 2023-12-20 23:41:49 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2024-03-12 23:41:00 +0100 |
| commit | 63b1442519ce5032a7fd85d9585aa203de639f27 (patch) | |
| tree | eeafe8fb0e5ca2255208241d261b8f093256dc94 | |
| parent | 9936ec84cb2a5e5f8f4fe77bcd5742f06bdb2d6c (diff) | |
Add validity check to Timecode.
| -rw-r--r-- | src/wx/timecode.cc | 2 | ||||
| -rw-r--r-- | src/wx/timecode.h | 13 |
2 files changed, 14 insertions, 1 deletions
diff --git a/src/wx/timecode.cc b/src/wx/timecode.cc index 1e6a1930d..64fe87190 100644 --- a/src/wx/timecode.cc +++ b/src/wx/timecode.cc @@ -114,7 +114,7 @@ void TimecodeBase::changed () { if (_set_button && !_ignore_changed) { - _set_button->Enable (true); + _set_button->Enable(valid()); } } diff --git a/src/wx/timecode.h b/src/wx/timecode.h index 6c5d8ae23..22899ddc9 100644 --- a/src/wx/timecode.h +++ b/src/wx/timecode.h @@ -50,6 +50,7 @@ public: protected: void changed (); void set_clicked (); + virtual bool valid() const = 0; wxSizer* _sizer; wxPanel* _editable; @@ -96,6 +97,11 @@ public: _frames->SetHint (std_to_wx(dcp::raw_convert<std::string>(hmsf.f))); } + void set_maximum(dcpomatic::HMSF maximum) + { + _maximum = std::move(maximum); + } + dcpomatic::HMSF get () const { auto value_or_hint = [](wxTextCtrl const * t) { @@ -116,6 +122,13 @@ public: { return T(get(), fps); } + +private: + bool valid() const override { + return !_maximum || get() <= *_maximum; + } + + boost::optional<dcpomatic::HMSF> _maximum; }; #endif |
