#include "dcpomatic_button.h"
#include "wx_util.h"
+#include "lib/scope_guard.h"
#include <dcp/warnings.h>
LIBDCP_DISABLE_WARNINGS
#include <wx/listctrl.h>
};
+enum class EditableListTitle
+{
+ VISIBLE,
+ INVISIBLE
+};
+
+
/** @param T type of things being edited.
* @param S dialog to edit a thing.
* @param get Function to get a std::vector of the things being edited.
std::function<std::vector<T> ()> get,
std::function<void (std::vector<T>)> set,
std::function<std::string (T, int)> column,
- bool title,
+ EditableListTitle title,
int buttons
)
: wxPanel (parent)
SetSizer (_sizer);
long style = wxLC_REPORT | wxLC_SINGLE_SEL;
- if (!title) {
+ if (title == EditableListTitle::INVISIBLE) {
style |= wxLC_NO_HEADER;
}
void add_clicked ()
{
S* dialog = new S (this);
+ ScopeGuard sg = [dialog]() { dialog->Destroy(); };
if (dialog->ShowModal() == wxID_OK) {
auto const v = dialog->get ();
_set (all);
}
}
-
- dialog->Destroy ();
}
void edit_clicked ()
DCPOMATIC_ASSERT (item >= 0 && item < int (all.size ()));
S* dialog = new S (this);
+ ScopeGuard sg = [dialog]() { dialog->Destroy(); };
dialog->set (all[item]);
if (dialog->ShowModal() == wxID_OK) {
auto const v = dialog->get ();
all[item] = v.get ();
}
- dialog->Destroy ();
for (size_t i = 0; i < _columns.size(); ++i) {
_list->SetItem (item, i, std_to_wx (_column (all[item], i)));