Basic retained-mode-style canvas for timeline; allow selection.
[dcpomatic.git] / src / wx / film_editor.cc
index c50782452ce0af3393e6e3dd9a7cf1e0280a572e..ca43ffb8a2a8b1c57ab6685be2b976812a71b052 100644 (file)
@@ -73,6 +73,7 @@ FilmEditor::FilmEditor (shared_ptr<Film> f, wxWindow* parent)
        : wxPanel (parent)
        , _generally_sensitive (true)
        , _audio_dialog (0)
+       , _timeline_dialog (0)
 {
        wxBoxSizer* s = new wxBoxSizer (wxVERTICAL);
        _notebook = new wxNotebook (this, wxID_ANY);
@@ -213,10 +214,10 @@ FilmEditor::connect_to_widgets ()
        _content->Connect                (wxID_ANY, wxEVT_COMMAND_LIST_ITEM_ACTIVATED,  wxListEventHandler    (FilmEditor::content_activated), 0, this);
        _content_add->Connect            (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED,       wxCommandEventHandler (FilmEditor::content_add_clicked), 0, this);
        _content_remove->Connect         (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED,       wxCommandEventHandler (FilmEditor::content_remove_clicked), 0, this);
-       _content_edit->Connect           (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED,       wxCommandEventHandler (FilmEditor::content_edit_clicked), 0, this);
+       _content_properties->Connect     (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED,       wxCommandEventHandler (FilmEditor::content_properties_clicked), 0, this);
        _content_earlier->Connect        (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED,       wxCommandEventHandler (FilmEditor::content_earlier_clicked), 0, this);
        _content_later->Connect          (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED,       wxCommandEventHandler (FilmEditor::content_later_clicked), 0, this);
-       _timeline_button->Connect        (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED,       wxCommandEventHandler (FilmEditor::timeline_clicked), 0, this);
+       _content_timeline->Connect       (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED,       wxCommandEventHandler (FilmEditor::content_timeline_clicked), 0, this);
        _loop_content->Connect           (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED,     wxCommandEventHandler (FilmEditor::loop_content_toggled), 0, this);
        _loop_count->Connect             (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED,     wxCommandEventHandler (FilmEditor::loop_count_changed), 0, this);
        _left_crop->Connect              (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED,     wxCommandEventHandler (FilmEditor::left_crop_changed), 0, this);
@@ -360,12 +361,14 @@ FilmEditor::make_content_panel ()
                 b->Add (_content_add);
                 _content_remove = new wxButton (_content_panel, wxID_ANY, _("Remove"));
                 b->Add (_content_remove);
-                _content_edit = new wxButton (_content_panel, wxID_ANY, _("Edit..."));
-                b->Add (_content_edit);
+                _content_properties = new wxButton (_content_panel, wxID_ANY, _("Properties..."));
+                b->Add (_content_properties);
                 _content_earlier = new wxButton (_content_panel, wxID_ANY, _("Earlier"));
                 b->Add (_content_earlier);
                 _content_later = new wxButton (_content_panel, wxID_ANY, _("Later"));
                 b->Add (_content_later);
+               _content_timeline = new wxButton (_content_panel, wxID_ANY, _("Timeline..."));
+               b->Add (_content_timeline);
 
                 s->Add (b, 0, wxALL, 4);
 
@@ -383,16 +386,6 @@ FilmEditor::make_content_panel ()
        add_label_to_sizer (h, _content_panel, _("times"));
        _content_sizer->Add (h, 0, wxALL, 6);
 
-       _playlist_description = new wxStaticText (_content_panel, wxID_ANY, wxT ("\n \n \n \n "));
-       _content_sizer->Add (_playlist_description, 0.25, wxEXPAND | wxALL, 6);
-       wxFont font = _playlist_description->GetFont();
-       font.SetStyle(wxFONTSTYLE_ITALIC);
-       font.SetPointSize(font.GetPointSize() - 1);
-       _playlist_description->SetFont(font);
-
-       _timeline_button = new wxButton (_content_panel, wxID_ANY, _("Timeline..."));
-       _content_sizer->Add (_timeline_button, 0, wxALL, 6);
-
        _loop_count->SetRange (2, 1024);
 }
 
@@ -1102,7 +1095,7 @@ FilmEditor::setup_subtitle_control_sensitivity ()
 {
        bool h = false;
        if (_generally_sensitive && _film) {
-               h = !_film->has_subtitles ();
+               h = _film->has_subtitles ();
        }
        
        _with_subtitles->Enable (h);
@@ -1211,7 +1204,7 @@ FilmEditor::setup_content ()
                _content->SetItemState (0, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
        }
 
-       setup_playlist_description ();
+       setup_content_information ();
 }
 
 void
@@ -1256,22 +1249,22 @@ FilmEditor::content_activated (wxListEvent& ev)
        ContentList c = _film->content ();
        assert (ev.GetIndex() >= 0 && size_t (ev.GetIndex()) < c.size ());
 
-       edit_content (c[ev.GetIndex()]);
+       content_properties (c[ev.GetIndex()]);
 }
 
 void
-FilmEditor::content_edit_clicked (wxCommandEvent &)
+FilmEditor::content_properties_clicked (wxCommandEvent &)
 {
        shared_ptr<Content> c = selected_content ();
        if (!c) {
                return;
        }
 
-       edit_content (c);
+       content_properties (c);
 }
 
 void
-FilmEditor::edit_content (shared_ptr<Content> c)
+FilmEditor::content_properties (shared_ptr<Content> c)
 {
        shared_ptr<ImageMagickContent> im = dynamic_pointer_cast<ImageMagickContent> (c);
        if (im) {
@@ -1332,7 +1325,7 @@ FilmEditor::setup_content_button_sensitivity ()
 
        shared_ptr<Content> selection = selected_content ();
 
-        _content_edit->Enable (
+        _content_properties->Enable (
                selection && _generally_sensitive &&
                (dynamic_pointer_cast<ImageMagickContent> (selection) || dynamic_pointer_cast<FFmpegContent> (selection))
                );
@@ -1340,6 +1333,7 @@ FilmEditor::setup_content_button_sensitivity ()
         _content_remove->Enable (selection && _generally_sensitive);
         _content_earlier->Enable (selection && _generally_sensitive);
         _content_later->Enable (selection && _generally_sensitive);
+       _content_timeline->Enable (_generally_sensitive);
 }
 
 shared_ptr<Content>
@@ -1445,20 +1439,13 @@ FilmEditor::setup_loop_sensitivity ()
 }
 
 void
-FilmEditor::setup_playlist_description ()
+FilmEditor::content_timeline_clicked (wxCommandEvent &)
 {
-       if (!_film) {
-               _playlist_description->SetLabel (wxT (""));
-               return;
+       if (_timeline_dialog) {
+               _timeline_dialog->Destroy ();
+               _timeline_dialog = 0;
        }
-
-       _playlist_description->SetLabel (std_to_wx (_film->playlist_description ()));
-}
-
-void
-FilmEditor::timeline_clicked (wxCommandEvent &)
-{
-       TimelineDialog* d = new TimelineDialog (this, _film->playlist ());
-       d->ShowModal ();
-       d->Destroy ();
+       
+       _timeline_dialog = new TimelineDialog (this, _film->playlist ());
+       _timeline_dialog->Show ();
 }