X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Fwx%2Ftimeline_dialog.cc;h=261177e36815e55b2a8d7ad52f812892ffbed585;hp=ba0e1b15e419800f192dd6e250c59f93504e32aa;hb=c04fec82d25127fafa73c3daff87bece9aa8c8e8;hpb=2227cbabb7e135276f56391ed1c460ee5cf76b40 diff --git a/src/wx/timeline_dialog.cc b/src/wx/timeline_dialog.cc index ba0e1b15e..261177e36 100644 --- a/src/wx/timeline_dialog.cc +++ b/src/wx/timeline_dialog.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2018 Carl Hetherington + Copyright (C) 2013-2019 Carl Hetherington This file is part of DCP-o-matic. @@ -33,10 +33,14 @@ using std::list; using std::cout; using std::string; using boost::shared_ptr; +using boost::weak_ptr; +#if BOOST_VERSION >= 106100 +using namespace boost::placeholders; +#endif -TimelineDialog::TimelineDialog (ContentPanel* cp, shared_ptr film) +TimelineDialog::TimelineDialog (ContentPanel* cp, shared_ptr film, weak_ptr viewer) : wxDialog ( - cp->panel(), + cp->window(), wxID_ANY, _("Timeline"), wxDefaultPosition, @@ -51,7 +55,7 @@ TimelineDialog::TimelineDialog (ContentPanel* cp, shared_ptr film) #endif ) , _film (film) - , _timeline (this, cp, film) + , _timeline (this, cp, film, viewer) { wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL); @@ -61,12 +65,14 @@ TimelineDialog::TimelineDialog (ContentPanel* cp, shared_ptr film) wxBitmap snap (bitmap_path("snap"), wxBITMAP_TYPE_PNG); wxBitmap sequence (bitmap_path("sequence"), wxBITMAP_TYPE_PNG); - _toolbar = new wxToolBar (this, wxID_ANY); + _toolbar = new wxToolBar (this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTB_HORIZONTAL); + _toolbar->SetMargins (4, 4); _toolbar->AddRadioTool ((int) Timeline::SELECT, _("Select"), select, wxNullBitmap, _("Select and move content")); _toolbar->AddRadioTool ((int) Timeline::ZOOM, _("Zoom"), zoom, wxNullBitmap, _("Zoom in / out")); _toolbar->AddTool ((int) Timeline::ZOOM_ALL, _("Zoom all"), zoom_all, _("Zoom out to whole film")); _toolbar->AddCheckTool ((int) Timeline::SNAP, _("Snap"), snap, wxNullBitmap, _("Snap")); _toolbar->AddCheckTool ((int) Timeline::SEQUENCE, _("Sequence"), sequence, wxNullBitmap, _("Keep video and subtitles in sequence")); + _toolbar->Realize (); _toolbar->Bind (wxEVT_TOOL, bind (&TimelineDialog::tool_clicked, this, _1)); @@ -85,22 +91,18 @@ TimelineDialog::TimelineDialog (ContentPanel* cp, shared_ptr film) sizer->SetSizeHints (this); _toolbar->ToggleTool ((int) Timeline::SNAP, _timeline.snap ()); - film_changed (Film::SEQUENCE); - - _film_changed_connection = film->Changed.connect (bind (&TimelineDialog::film_changed, this, _1)); -} + film_change (CHANGE_TYPE_DONE, Film::SEQUENCE); -wxString -TimelineDialog::bitmap_path (string name) -{ - boost::filesystem::path p = shared_path() / String::compose("%1.png", name); - cout << "Loading " << p.string() << "\n"; - return std_to_wx (p.string()); + _film_changed_connection = film->Change.connect (bind (&TimelineDialog::film_change, this, _1, _2)); } void -TimelineDialog::film_changed (Film::Property p) +TimelineDialog::film_change (ChangeType type, Film::Property p) { + if (type != CHANGE_TYPE_DONE) { + return; + } + shared_ptr film = _film.lock (); if (!film) { return; @@ -123,11 +125,11 @@ TimelineDialog::tool_clicked (wxCommandEvent& ev) Timeline::Tool t = (Timeline::Tool) ev.GetId(); _timeline.tool_clicked (t); if (t == Timeline::SNAP) { - _timeline.set_snap (_snap->IsToggled()); + _timeline.set_snap (_toolbar->GetToolState ((int) t)); } else if (t == Timeline::SEQUENCE) { shared_ptr film = _film.lock (); if (film) { - film->set_sequence (_sequence->IsToggled()); + film->set_sequence (_toolbar->GetToolState ((int) t)); } } }