Eliminate some uses of std::bind

This commit is contained in:
Thomas Goyne 2014-03-26 10:36:34 -07:00
parent e5e3bff7f8
commit e477005ecd
7 changed files with 27 additions and 46 deletions

View File

@ -45,8 +45,6 @@
#include <wx/bitmap.h>
#include <wx/dcmemory.h>
using std::placeholders::_1;
AudioRendererBitmapCacheBitmapFactory::AudioRendererBitmapCacheBitmapFactory(AudioRenderer *renderer)
: renderer(renderer)
{

View File

@ -56,8 +56,6 @@
#include <wx/msgdlg.h>
#include <wx/sizer.h>
using std::placeholders::_1;
DialogAutomation::DialogAutomation(agi::Context *c)
: wxDialog(c->parent, -1, _("Automation Manager"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
, context(c)
@ -221,22 +219,6 @@ void DialogAutomation::OnReload(wxCommandEvent &)
local_manager->Reload(ei.script);
}
static wxString fac_to_str(std::unique_ptr<Automation4::ScriptFactory> const& f) {
return wxString::Format("- %s (%s)", to_wx(f->GetEngineName()), to_wx(f->GetFilenamePattern()));
}
static wxString cmd_to_str(const cmd::Command *f, agi::Context *c) {
return wxString::Format(_(" Macro: %s (%s)"), f->StrDisplay(c), to_wx(f->name()));
}
static wxString filt_to_str(const Automation4::ExportFilter* f) {
return wxString::Format(_(" Export filter: %s"), to_wx(f->GetName()));
}
static wxString form_to_str(const SubtitleFormat* f) {
return wxString::Format(_(" Subtitle format handler: %s"), to_wx(f->GetName()));
}
void DialogAutomation::OnInfo(wxCommandEvent &)
{
int i = list->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
@ -252,7 +234,10 @@ void DialogAutomation::OnInfo(wxCommandEvent &)
(int)local_manager->GetScripts().size()));
info.push_back(_("Scripting engines installed:"));
boost::transform(Automation4::ScriptFactory::GetFactories(), append_info, fac_to_str);
boost::transform(Automation4::ScriptFactory::GetFactories(), append_info,
[](std::unique_ptr<Automation4::ScriptFactory> const& f) {
return wxString::Format("- %s (%s)", to_wx(f->GetEngineName()), to_wx(f->GetFilenamePattern()));
});
if (ei) {
info.push_back(wxString::Format(_("\nScript info:\nName: %s\nDescription: %s\nAuthor: %s\nVersion: %s\nFull path: %s\nState: %s\n\nFeatures provided by script:"),
@ -263,9 +248,15 @@ void DialogAutomation::OnInfo(wxCommandEvent &)
ei->script->GetFilename().wstring(),
ei->script->GetLoadedState() ? _("Correctly loaded") : _("Failed to load")));
boost::transform(ei->script->GetMacros(), append_info, std::bind(cmd_to_str, _1, context));
boost::transform(ei->script->GetFilters(), append_info, filt_to_str);
boost::transform(ei->script->GetFormats(), append_info, form_to_str);
boost::transform(ei->script->GetMacros(), append_info, [=](const cmd::Command *f) {
return wxString::Format(_(" Macro: %s (%s)"), f->StrDisplay(context), to_wx(f->name()));
});
boost::transform(ei->script->GetFilters(), append_info, [](const Automation4::ExportFilter* f) {
return wxString::Format(_(" Export filter: %s"), to_wx(f->GetName()));
});
boost::transform(ei->script->GetFormats(), append_info, [](const SubtitleFormat* f) {
return wxString::Format(_(" Subtitle format handler: %s"), to_wx(f->GetName()));
});
}
wxMessageBox(wxJoin(info, '\n', 0), _("Automation Script Info"));

View File

@ -70,8 +70,6 @@
#include <wx/textdlg.h>
#include <wx/choicdlg.h> // Keep this last so wxUSE_CHOICEDLG is set.
using std::placeholders::_1;
namespace {
wxBitmapButton *add_bitmap_button(wxWindow *parent, wxSizer *sizer, wxBitmap const& img, wxString const& tooltip) {
@ -485,7 +483,7 @@ void DialogStyleManager::PasteToCurrent() {
void DialogStyleManager::PasteToStorage() {
add_styles(
std::bind(&AssStyleStorage::GetStyle, &Store, _1),
[=](std::string const& str) { return Store.GetStyle(str); },
[=](AssStyle *s) { Store.push_back(std::unique_ptr<AssStyle>(s)); });
UpdateStorage();
@ -516,8 +514,8 @@ void DialogStyleManager::OnStorageCopy() {
int sel = get_single_sel(StorageList);
if (sel == -1) return;
ShowStorageEditor(Store[sel],
unique_name(std::bind(&AssStyleStorage::GetStyle, &Store, _1), Store[sel]->name));
ShowStorageEditor(Store[sel], unique_name(
[=](std::string const& str) { return Store.GetStyle(str); }, Store[sel]->name));
}
void DialogStyleManager::OnStorageDelete() {

View File

@ -70,13 +70,6 @@
using namespace boost::adaptors;
namespace {
using std::placeholders::_1;
void set_ctrl_state(wxCommandEvent &evt, wxCheckBox *cb, wxTextCtrl *tc) {
tc->Enable(cb->IsChecked());
evt.Skip();
}
wxTextCtrl *make_ctrl(wxWindow *parent, wxSizer *sizer, wxString const& desc, int *value, wxCheckBox *cb, wxString const& tooltip) {
wxIntegerValidator<int> validator(value);
validator.SetMin(0);
@ -87,7 +80,10 @@ wxTextCtrl *make_ctrl(wxWindow *parent, wxSizer *sizer, wxString const& desc, in
sizer->Add(ctrl, wxSizerFlags().Expand().Border(wxRIGHT));
ctrl->Enable(cb->IsChecked());
cb->Bind(wxEVT_CHECKBOX, bind(set_ctrl_state, _1, cb, ctrl));
cb->Bind(wxEVT_CHECKBOX, [=](wxCommandEvent& evt) {
ctrl->Enable(cb->IsChecked());
evt.Skip();
});
return ctrl;
}

View File

@ -34,8 +34,6 @@
#include <unicode/uchar.h>
#include <wx/intl.h>
using namespace std::placeholders;
namespace {
wxString format_missing(wxString const& str) {
wxString printable;
@ -193,7 +191,7 @@ std::vector<agi::fs::path> FontCollector::GetFontPaths(const AssFile *file) {
ProcessDialogueLine(&diag, ++index);
status_callback(_("Searching for font files\n"), 0);
for_each(used_styles.begin(), used_styles.end(), bind(&FontCollector::ProcessChunk, this, _1));
for (auto const& style : used_styles) ProcessChunk(style);
status_callback(_("Done\n\n"), 0);
std::vector<agi::fs::path> paths;

View File

@ -63,8 +63,6 @@
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/replace.hpp>
using namespace std::placeholders;
namespace {
std::vector<std::unique_ptr<SubtitleFormat>> formats;
}
@ -299,12 +297,16 @@ SubtitleFormat *find_or_throw(Cont &container, Pred pred) {
const SubtitleFormat *SubtitleFormat::GetReader(agi::fs::path const& filename, std::string const& encoding) {
LoadFormats();
return find_or_throw(formats, std::bind(&SubtitleFormat::CanReadFile, _1, filename, encoding));
return find_or_throw(formats, [&](std::unique_ptr<SubtitleFormat> const& f) {
return f->CanReadFile(filename, encoding);
});
}
const SubtitleFormat *SubtitleFormat::GetWriter(agi::fs::path const& filename) {
LoadFormats();
return find_or_throw(formats, std::bind(&SubtitleFormat::CanWriteFile, _1, filename));
return find_or_throw(formats, [&](std::unique_ptr<SubtitleFormat> const& f) {
return f->CanWriteFile(filename);
});
}
std::string SubtitleFormat::GetWildcards(int mode) {

View File

@ -42,8 +42,6 @@
#include <algorithm>
#include <boost/format.hpp>
using std::placeholders::_1;
const wxColour VisualToolBase::colour[] = {
wxColour(106,32,19),
wxColour(255,169,40),