projects
/
dcpomatic.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Rename subtitle appearance dialogue.
[dcpomatic.git]
/
src
/
wx
/
content_widget.h
diff --git
a/src/wx/content_widget.h
b/src/wx/content_widget.h
index 6f406dadbc926e92c094b74d53366327b6d08093..e162aca4950718ac7fd709a21d59d2bca114b52b 100644
(file)
--- a/
src/wx/content_widget.h
+++ b/
src/wx/content_widget.h
@@
-1,19
+1,20
@@
/*
/*
- Copyright (C) 2013-201
4
Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-201
6
Carl Hetherington <cth@carlh.net>
- This program is free software; you can redistribute it and/or modify
+ 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.
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.
-
This program
is distributed in the hope that it will be useful,
+
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
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 this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
*/
*/
@@
-21,21
+22,22
@@
* @brief ContentWidget class.
*/
* @brief ContentWidget class.
*/
-#ifndef DCPOMATIC_
MULTIPLE
_WIDGET_H
-#define DCPOMATIC_
MULTIPLE
_WIDGET_H
+#ifndef DCPOMATIC_
CONTENT
_WIDGET_H
+#define DCPOMATIC_
CONTENT
_WIDGET_H
-#include <vector>
+#include "wx_util.h"
+#include "lib/content.h"
#include <wx/wx.h>
#include <wx/gbsizer.h>
#include <wx/spinctrl.h>
#include <boost/function.hpp>
#include <wx/wx.h>
#include <wx/gbsizer.h>
#include <wx/spinctrl.h>
#include <boost/function.hpp>
-#include
"wx_util.h"
+#include
<vector>
/** @class ContentWidget
* @brief A widget which represents some Content state and which can be used
* when multiple pieces of content are selected.
*
/** @class ContentWidget
* @brief A widget which represents some Content state and which can be used
* when multiple pieces of content are selected.
*
- * @param S Type
containing the content being represen
ted (e.g. VideoContent)
+ * @param S Type
of ContentPart being manipula
ted (e.g. VideoContent)
* @param T Type of the widget (e.g. wxSpinCtrl)
* @param U Data type of state as used by the model.
* @param V Data type of state as used by the view.
* @param T Type of the widget (e.g. wxSpinCtrl)
* @param U Data type of state as used by the model.
* @param V Data type of state as used by the view.
@@
-47,13
+49,17
@@
public:
/** @param parent Parent window.
* @param wrapped Control widget that we are wrapping.
* @param property ContentProperty that the widget is handling.
/** @param parent Parent window.
* @param wrapped Control widget that we are wrapping.
* @param property ContentProperty that the widget is handling.
+ * @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 model_getter Function on the Content to get the value.
* @param model_setter Function on the Content to set the value.
+ * @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.
*/
ContentWidget (
wxWindow* parent,
T* wrapped,
int property,
*/
ContentWidget (
wxWindow* parent,
T* wrapped,
int property,
+ boost::function<boost::shared_ptr<S> (Content*)> part,
boost::function<U (S*)> model_getter,
boost::function<void (S*, U)> model_setter,
boost::function<U (V)> view_to_model,
boost::function<U (S*)> model_getter,
boost::function<void (S*, U)> model_setter,
boost::function<U (V)> view_to_model,
@@
-63,6
+69,7
@@
public:
, _sizer (0)
, _button (new wxButton (parent, wxID_ANY, _("Multiple values")))
, _property (property)
, _sizer (0)
, _button (new wxButton (parent, wxID_ANY, _("Multiple values")))
, _property (property)
+ , _part (part)
, _model_getter (model_getter)
, _model_setter (model_setter)
, _view_to_model (view_to_model)
, _model_getter (model_getter)
, _model_setter (model_setter)
, _view_to_model (view_to_model)
@@
-80,7
+87,7
@@
public:
return _wrapped;
}
return _wrapped;
}
- typedef std::vector<boost::shared_ptr<
S
> > List;
+ typedef std::vector<boost::shared_ptr<
Content
> > List;
/** Set the content that this control is working on (i.e. the selected content) */
void set_content (List content)
/** Set the content that this control is working on (i.e. the selected content) */
void set_content (List content)
@@
-90,7
+97,7
@@
public:
}
_connections.clear ();
}
_connections.clear ();
-
+
_content = content;
_wrapped->Enable (!_content.empty ());
_content = content;
_wrapped->Enable (!_content.empty ());
@@
-120,8
+127,8
@@
public:
}
typename List::iterator i = _content.begin ();
}
typename List::iterator i = _content.begin ();
- U const v = boost::bind (_model_getter, _
content.front(
).get())();
- while (i != _content.end() && boost::bind (_model_getter,
i->
get())() == v) {
+ U const v = boost::bind (_model_getter, _
part(_content.front().get()
).get())();
+ while (i != _content.end() && boost::bind (_model_getter,
_part(i->get()).
get())() == v) {
++i;
}
++i;
}
@@
-137,13
+144,13
@@
public:
{
_ignore_model_changes = true;
for (size_t i = 0; i < _content.size(); ++i) {
{
_ignore_model_changes = true;
for (size_t i = 0; i < _content.size(); ++i) {
- boost::bind (_model_setter, _
content[i]
.get(), _view_to_model (wx_get (_wrapped))) ();
+ boost::bind (_model_setter, _
part (_content[i].get())
.get(), _view_to_model (wx_get (_wrapped))) ();
}
_ignore_model_changes = false;
}
}
_ignore_model_changes = false;
}
-
+
private:
private:
-
+
void set_single ()
{
if (_wrapped->IsShown ()) {
void set_single ()
{
if (_wrapped->IsShown ()) {
@@
-162,7
+169,7
@@
private:
if (_button->IsShown ()) {
return;
}
if (_button->IsShown ()) {
return;
}
-
+
_wrapped->Hide ();
_sizer->Detach (_wrapped);
_button->Show ();
_wrapped->Hide ();
_sizer->Detach (_wrapped);
_button->Show ();
@@
-172,9
+179,9
@@
private:
void button_clicked ()
{
void button_clicked ()
{
- U const v = boost::bind (_model_getter, _
content.front(
).get())();
+ U const v = boost::bind (_model_getter, _
part(_content.front().get()
).get())();
for (typename List::iterator i = _content.begin (); i != _content.end(); ++i) {
for (typename List::iterator i = _content.begin (); i != _content.end(); ++i) {
- boost::bind (_model_setter,
i->
get(), v) ();
+ boost::bind (_model_setter,
_part(i->get()).
get(), v) ();
}
}
}
}
@@
-184,7
+191,7
@@
private:
update_from_model ();
}
}
update_from_model ();
}
}
-
+
T* _wrapped;
wxGridBagSizer* _sizer;
wxGBPosition _position;
T* _wrapped;
wxGridBagSizer* _sizer;
wxGBPosition _position;
@@
-192,6
+199,7
@@
private:
wxButton* _button;
List _content;
int _property;
wxButton* _button;
List _content;
int _property;
+ boost::function<boost::shared_ptr<S> (Content *)> _part;
boost::function<U (S*)> _model_getter;
boost::function<void (S*, U)> _model_setter;
boost::function<U (V)> _view_to_model;
boost::function<U (S*)> _model_getter;
boost::function<void (S*, U)> _model_setter;
boost::function<U (V)> _view_to_model;
@@
-214,6
+222,7
@@
public:
wxWindow* parent,
wxSpinCtrl* wrapped,
int property,
wxWindow* parent,
wxSpinCtrl* wrapped,
int property,
+ boost::function<boost::shared_ptr<S> (Content *)> part,
boost::function<int (S*)> getter,
boost::function<void (S*, int)> setter
)
boost::function<int (S*)> getter,
boost::function<void (S*, int)> setter
)
@@
-221,6
+230,7
@@
public:
parent,
wrapped,
property,
parent,
wrapped,
property,
+ part,
getter, setter,
&caster<int, int>,
&caster<int, int>
getter, setter,
&caster<int, int>,
&caster<int, int>
@@
-238,6
+248,7
@@
public:
wxWindow* parent,
wxSpinCtrlDouble* wrapped,
int property,
wxWindow* parent,
wxSpinCtrlDouble* wrapped,
int property,
+ boost::function<boost::shared_ptr<S> (Content *)> part,
boost::function<double (S*)> getter,
boost::function<void (S*, double)> setter
)
boost::function<double (S*)> getter,
boost::function<void (S*, double)> setter
)
@@
-245,6
+256,7
@@
public:
parent,
wrapped,
property,
parent,
wrapped,
property,
+ part,
getter, setter,
&caster<double, double>,
&caster<double, double>
getter, setter,
&caster<double, double>,
&caster<double, double>
@@
-262,6
+274,7
@@
public:
wxWindow* parent,
wxChoice* wrapped,
int property,
wxWindow* parent,
wxChoice* wrapped,
int property,
+ boost::function<boost::shared_ptr<S> (Content *)> part,
boost::function<U (S*)> getter,
boost::function<void (S*, U)> setter,
boost::function<U (int)> view_to_model,
boost::function<U (S*)> getter,
boost::function<void (S*, U)> setter,
boost::function<U (int)> view_to_model,
@@
-271,6
+284,7
@@
public:
parent,
wrapped,
property,
parent,
wrapped,
property,
+ part,
getter,
setter,
view_to_model,
getter,
setter,
view_to_model,