forked from mia/Aegisub
Replace field_setter with a lambda
This commit is contained in:
parent
621b665885
commit
1b6f122d12
2 changed files with 5 additions and 13 deletions
|
@ -67,14 +67,6 @@
|
|||
#include <libaegisub/of_type_adaptor.h>
|
||||
|
||||
namespace {
|
||||
template<class T>
|
||||
struct field_setter : public std::binary_function<AssDialogue*, T, void> {
|
||||
T AssDialogue::*field;
|
||||
field_setter(T AssDialogue::*field) : field(field) { }
|
||||
void operator()(AssDialogue* obj, T const& value) {
|
||||
obj->*field = value;
|
||||
}
|
||||
};
|
||||
|
||||
/// Work around wxGTK's fondness for generating events from ChangeValue
|
||||
void change_value(wxTextCtrl *ctrl, wxString const& value) {
|
||||
|
@ -386,7 +378,7 @@ void SubsEditBox::OnUndoTimer(wxTimerEvent&) {
|
|||
}
|
||||
|
||||
template<class T, class setter>
|
||||
void SubsEditBox::SetSelectedRows(setter set, T value, wxString desc, int type, bool amend) {
|
||||
void SubsEditBox::SetSelectedRows(setter set, T value, wxString const& desc, int type, bool amend) {
|
||||
for_each(sel.begin(), sel.end(), bind(set, std::placeholders::_1, value));
|
||||
|
||||
file_changed_slot.Block();
|
||||
|
@ -399,8 +391,8 @@ void SubsEditBox::SetSelectedRows(setter set, T value, wxString desc, int type,
|
|||
}
|
||||
|
||||
template<class T>
|
||||
void SubsEditBox::SetSelectedRows(T AssDialogue::*field, T value, wxString desc, int type, bool amend) {
|
||||
SetSelectedRows(field_setter<T>(field), value, desc, type, amend);
|
||||
void SubsEditBox::SetSelectedRows(T AssDialogue::*field, T value, wxString const& desc, int type, bool amend) {
|
||||
SetSelectedRows([=](AssDialogue *d, T const& v) { d->*field = v; }, value, desc, type, amend);
|
||||
}
|
||||
|
||||
void SubsEditBox::CommitText(wxString const& desc) {
|
||||
|
|
|
@ -173,7 +173,7 @@ class SubsEditBox : public wxPanel {
|
|||
/// @param type Commit type to use
|
||||
/// @param amend Coalesce sequences of commits of the same type
|
||||
template<class T, class setter>
|
||||
void SetSelectedRows(setter set, T value, wxString desc, int type, bool amend = false);
|
||||
void SetSelectedRows(setter set, T value, wxString const& desc, int type, bool amend = false);
|
||||
|
||||
/// @brief Set a field in each selected line to a specified value
|
||||
/// @param field Field to set
|
||||
|
@ -182,7 +182,7 @@ class SubsEditBox : public wxPanel {
|
|||
/// @param type Commit type to use
|
||||
/// @param amend Coalesce sequences of commits of the same type
|
||||
template<class T>
|
||||
void SetSelectedRows(T AssDialogue::*field, T value, wxString desc, int type, bool amend = false);
|
||||
void SetSelectedRows(T AssDialogue::*field, T value, wxString const& desc, int type, bool amend = false);
|
||||
|
||||
/// @brief Reload the current line from the file
|
||||
/// @param type AssFile::CommitType
|
||||
|
|
Loading…
Reference in a new issue