From: Carl Hetherington Date: Mon, 11 May 2020 22:10:13 +0000 (+0200) Subject: Add _view_changed callback to ContentWidget. X-Git-Tag: v2.15.72~3^2~3 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=14712fbdb5bd2f6226b9969c581fc32c2e19ecbf;hp=2b870d03ce118f9d9146f53658d3a9a2e2626600 Add _view_changed callback to ContentWidget. --- diff --git a/src/wx/content_widget.h b/src/wx/content_widget.h index c4ae4d591..de7ebedc5 100644 --- a/src/wx/content_widget.h +++ b/src/wx/content_widget.h @@ -52,6 +52,7 @@ public: * @param part Part of Content that the property is in (e.g. &Content::video) * @param model_getter Function on the Content to get the value. * @param model_setter Function on the Content to set the value. + * @param view_changed Function called when the view has changed; useful for linking controls. * @param view_to_model Function to convert a view value to a model value. * @param model_to_view Function to convert a model value to a view value. */ @@ -62,6 +63,7 @@ public: boost::function (Content*)> part, boost::function model_getter, boost::function model_setter, + boost::function view_changed, boost::function view_to_model, boost::function model_to_view ) @@ -72,6 +74,7 @@ public: , _part (part) , _model_getter (model_getter) , _model_setter (model_setter) + , _view_changed (view_changed) , _view_to_model (view_to_model) , _model_to_view (model_to_view) , _ignore_model_changes (false) @@ -146,6 +149,9 @@ public: for (size_t i = 0; i < _content.size(); ++i) { boost::bind (_model_setter, _part (_content[i].get()).get(), _view_to_model (wx_get (_wrapped))) (); } + if (_view_changed) { + _view_changed (); + } _ignore_model_changes = false; } @@ -207,6 +213,7 @@ private: boost::function (Content *)> _part; boost::function _model_getter; boost::function _model_setter; + boost::function _view_changed; boost::function _view_to_model; boost::function _model_to_view; std::list _connections; @@ -229,7 +236,8 @@ public: int property, boost::function (Content *)> part, boost::function getter, - boost::function setter + boost::function setter, + boost::function view_changed = boost::function() ) : ContentWidget ( parent, @@ -237,6 +245,7 @@ public: property, part, getter, setter, + view_changed, &caster, &caster ) @@ -255,7 +264,8 @@ public: int property, boost::function (Content *)> part, boost::function getter, - boost::function setter + boost::function setter, + boost::function view_changed = boost::function() ) : ContentWidget ( parent, @@ -263,6 +273,7 @@ public: property, part, getter, setter, + view_changed, &caster, &caster ) @@ -283,7 +294,8 @@ public: boost::function getter, boost::function setter, boost::function view_to_model, - boost::function model_to_view + boost::function model_to_view, + boost::function view_changed = boost::function() ) : ContentWidget ( parent, @@ -292,6 +304,7 @@ public: part, getter, setter, + view_changed, view_to_model, model_to_view )