Basics of custom DCP filename components.
[dcpomatic.git] / src / wx / name_format_editor.h
index ab4787f64a5349021ca10ef43286c55ab9a1e794..1ca4c0b719864b0ae9adcb934f30fbed18130f8d 100644 (file)
@@ -21,8 +21,8 @@
 #ifndef DCPOMATIC_NAME_FORMAT_EDITOR_H
 #define DCPOMATIC_NAME_FORMAT_EDITOR_H
 
-#include "lib/name_format.h"
 #include "lib/compose.hpp"
+#include <dcp/name_format.h>
 #include <wx/wx.h>
 #include <boost/foreach.hpp>
 
@@ -41,7 +41,7 @@ public:
                _sizer->Add (_example, 0, wxBOTTOM, DCPOMATIC_SIZER_Y_GAP);
                _panel->SetSizer (_sizer);
 
-               BOOST_FOREACH (NameFormat::Component c, name.components ()) {
+               BOOST_FOREACH (dcp::NameFormat::Component c, name.components ()) {
                        wxStaticText* t = new wxStaticText (_panel, wxID_ANY, std_to_wx (String::compose ("%%%1 %2", c.placeholder, c.title)));
                        _sizer->Add (t);
                        wxFont font = t->GetFont();
@@ -52,7 +52,7 @@ public:
                }
 
                _specification->SetValue (std_to_wx (_name.specification ()));
-               _specification->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&NameFormatEditor::update_example, this));
+               _specification->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&NameFormatEditor::changed, this));
 
                update_example ();
        }
@@ -62,7 +62,7 @@ public:
                return _panel;
        }
 
-       void set_example (NameFormat::Map v) {
+       void set_example (dcp::NameFormat::Map v) {
                _example_values = v;
                update_example ();
        }
@@ -71,8 +71,16 @@ public:
                return _name;
        }
 
+       boost::signals2::signal<void ()> Changed;
+
 private:
 
+       void changed ()
+       {
+               update_example ();
+               Changed ();
+       }
+
        virtual void update_example ()
        {
                _name.set_specification (wx_to_std (_specification->GetValue ()));
@@ -95,7 +103,7 @@ private:
        wxTextCtrl* _specification;
 
        T _name;
-       NameFormat::Map _example_values;
+       dcp::NameFormat::Map _example_values;
 };
 
 #endif