Make jump-to-content-start on selection in the content list optional.
authorCarl Hetherington <cth@carlh.net>
Fri, 7 Apr 2017 10:51:39 +0000 (11:51 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 7 Apr 2017 10:51:39 +0000 (11:51 +0100)
This behaviour is annoying in some cases, e.g. trying to move separate
subtitle files around when looking at a particular time in the preview.

ChangeLog
src/lib/config.cc
src/lib/config.h
src/wx/content_panel.cc
src/wx/film_viewer.cc
src/wx/film_viewer.h

index 8465091cfa52ca52c0a37609e3d6ed34afc61bdd..178601665718acd026d66038f16c6f4eabbe9cf6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2017-04-07  Carl Hetherington  <cth@carlh.net>
+
+       * Make jump-to-content-start on selection in the content list
+       optional.
+
 2017-04-03  Carl Hetherington  <cth@carlh.net>
 
        * Confirm overwrite of existing DCPs when making a new one.
index f41d40e0931300ae9a8f648067a18154309a568c..79486c6025966ed67197f7f816f9d0345ef96f1b 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2017 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
@@ -115,6 +115,7 @@ Config::set_defaults ()
        _kdm_filename_format = dcp::NameFormat ("KDM %f %c %s");
        _dcp_metadata_filename_format = dcp::NameFormat ("%t");
        _dcp_asset_filename_format = dcp::NameFormat ("%t");
+       _jump_to_selected = true;
 
        _allowed_dcp_frame_rates.clear ();
        _allowed_dcp_frame_rates.push_back (24);
@@ -307,6 +308,7 @@ try
        _kdm_filename_format = dcp::NameFormat (f.optional_string_child("KDMFilenameFormat").get_value_or ("KDM %f %c %s"));
        _dcp_metadata_filename_format = dcp::NameFormat (f.optional_string_child("DCPMetadataFilenameFormat").get_value_or ("%t"));
        _dcp_asset_filename_format = dcp::NameFormat (f.optional_string_child("DCPAssetFilenameFormat").get_value_or ("%t"));
+       _jump_to_selected = f.optional_bool_child("JumpToSelected").get_value_or (true);
 
        /* Replace any cinemas from config.xml with those from the configured file */
        if (boost::filesystem::exists (_cinemas_file)) {
@@ -474,6 +476,7 @@ Config::write_config () const
        root->add_child("KDMContainerNameFormat")->add_child_text (_kdm_container_name_format.specification ());
        root->add_child("DCPMetadataFilenameFormat")->add_child_text (_dcp_metadata_filename_format.specification ());
        root->add_child("DCPAssetFilenameFormat")->add_child_text (_dcp_asset_filename_format.specification ());
+       root->add_child("JumpToSelected")->add_child_text (_jump_to_selected ? "1" : "0");
 
        try {
                doc.write_to_file_formatted (path("config.xml").string ());
index c02b12eb5456ec68ff66b08df9344b8bc9973fb6..80dfb1dc94d1bfd4da1376b750bf4caa3ce0abd3 100644 (file)
@@ -302,6 +302,10 @@ public:
                return _dcp_asset_filename_format;
        }
 
+       bool jump_to_selected () const {
+               return _jump_to_selected;
+       }
+
        /** @param n New number of local encoding threads */
        void set_num_local_encoding_threads (int n) {
                maybe_set (_num_local_encoding_threads, n);
@@ -540,6 +544,10 @@ public:
 
        void add_to_history (boost::filesystem::path p);
 
+       void set_jump_to_selected (bool j) {
+               maybe_set (_jump_to_selected, j);
+       }
+
        void changed (Property p = OTHER);
        boost::signals2::signal<void (Property)> Changed;
        /** Emitted if ::read() failed on an existing Config file.  There is nothing
@@ -661,6 +669,7 @@ private:
        dcp::NameFormat _kdm_container_name_format;
        dcp::NameFormat _dcp_metadata_filename_format;
        dcp::NameFormat _dcp_asset_filename_format;
+       bool _jump_to_selected;
 
        /** Singleton instance, or 0 */
        static Config* _instance;
index 1aeba63728181478cbe755e28e67413d5795ef53..1d748be5ff2d820becaaf50189f0470199fcd1a1 100644 (file)
@@ -36,6 +36,7 @@
 #include "lib/dcp_content.h"
 #include "lib/case_insensitive_sorter.h"
 #include "lib/playlist.h"
+#include "lib/config.h"
 #include <wx/wx.h>
 #include <wx/notebook.h>
 #include <wx/listctrl.h>
@@ -254,7 +255,7 @@ ContentPanel::selection_changed ()
                }
        }
 
-       if (go_to) {
+       if (go_to && Config::instance()->jump_to_selected ()) {
                _film_viewer->set_position (go_to.get ());
        }
 
index 40155b18c398ed7b5040cdc3095dedb561a623e6..3c6138d465d39a65b2d33cc832a02ac75908d085 100644 (file)
@@ -40,6 +40,7 @@
 #include "lib/video_decoder.h"
 #include "lib/timer.h"
 #include "lib/log.h"
+#include "lib/config.h"
 extern "C" {
 #include <libavutil/pixfmt.h>
 }
@@ -69,6 +70,7 @@ FilmViewer::FilmViewer (wxWindow* p)
        , _outline_content (new wxCheckBox (this, wxID_ANY, _("Outline content")))
        , _left_eye (new wxRadioButton (this, wxID_ANY, _("Left eye"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP))
        , _right_eye (new wxRadioButton (this, wxID_ANY, _("Right eye")))
+       , _jump_to_selected (new wxCheckBox (this, wxID_ANY, _("Jump to selected content")))
        , _slider (new wxSlider (this, wxID_ANY, 0, 0, 4096))
        , _back_button (new wxButton (this, wxID_ANY, wxT("<")))
        , _forward_button (new wxButton (this, wxID_ANY, wxT(">")))
@@ -94,6 +96,7 @@ FilmViewer::FilmViewer (wxWindow* p)
        view_options->Add (_outline_content, 0, wxRIGHT, DCPOMATIC_SIZER_GAP);
        view_options->Add (_left_eye, 0, wxLEFT | wxRIGHT, DCPOMATIC_SIZER_GAP);
        view_options->Add (_right_eye, 0, wxLEFT | wxRIGHT, DCPOMATIC_SIZER_GAP);
+       view_options->Add (_jump_to_selected, 0, wxLEFT | wxRIGHT, DCPOMATIC_SIZER_GAP);
        _v_sizer->Add (view_options, 0, wxALL, DCPOMATIC_SIZER_GAP);
 
        wxBoxSizer* h_sizer = new wxBoxSizer (wxHORIZONTAL);
@@ -114,20 +117,23 @@ FilmViewer::FilmViewer (wxWindow* p)
        _back_button->SetMinSize (wxSize (32, -1));
        _forward_button->SetMinSize (wxSize (32, -1));
 
-       _panel->Bind          (wxEVT_PAINT,             boost::bind (&FilmViewer::paint_panel,     this));
-       _panel->Bind          (wxEVT_SIZE,              boost::bind (&FilmViewer::panel_sized,     this, _1));
-       _outline_content->Bind(wxEVT_CHECKBOX,          boost::bind (&FilmViewer::refresh_panel,   this));
-       _left_eye->Bind       (wxEVT_RADIOBUTTON,       boost::bind (&FilmViewer::refresh,         this));
-       _right_eye->Bind      (wxEVT_RADIOBUTTON,       boost::bind (&FilmViewer::refresh,         this));
-       _slider->Bind         (wxEVT_SCROLL_THUMBTRACK, boost::bind (&FilmViewer::slider_moved,    this));
-       _slider->Bind         (wxEVT_SCROLL_PAGEUP,     boost::bind (&FilmViewer::slider_moved,    this));
-       _slider->Bind         (wxEVT_SCROLL_PAGEDOWN,   boost::bind (&FilmViewer::slider_moved,    this));
-       _play_button->Bind    (wxEVT_TOGGLEBUTTON,      boost::bind (&FilmViewer::play_clicked,    this));
-       _timer.Bind           (wxEVT_TIMER,             boost::bind (&FilmViewer::timer,           this));
-       _back_button->Bind    (wxEVT_LEFT_DOWN,         boost::bind (&FilmViewer::back_clicked,    this, _1));
-       _forward_button->Bind (wxEVT_LEFT_DOWN,         boost::bind (&FilmViewer::forward_clicked, this, _1));
-       _frame_number->Bind   (wxEVT_LEFT_DOWN,         boost::bind (&FilmViewer::frame_number_clicked, this));
-       _timecode->Bind       (wxEVT_LEFT_DOWN,         boost::bind (&FilmViewer::timecode_clicked, this));
+       _panel->Bind            (wxEVT_PAINT,             boost::bind (&FilmViewer::paint_panel,     this));
+       _panel->Bind            (wxEVT_SIZE,              boost::bind (&FilmViewer::panel_sized,     this, _1));
+       _outline_content->Bind  (wxEVT_CHECKBOX,          boost::bind (&FilmViewer::refresh_panel,   this));
+       _left_eye->Bind         (wxEVT_RADIOBUTTON,       boost::bind (&FilmViewer::refresh,         this));
+       _right_eye->Bind        (wxEVT_RADIOBUTTON,       boost::bind (&FilmViewer::refresh,         this));
+       _slider->Bind           (wxEVT_SCROLL_THUMBTRACK, boost::bind (&FilmViewer::slider_moved,    this));
+       _slider->Bind           (wxEVT_SCROLL_PAGEUP,     boost::bind (&FilmViewer::slider_moved,    this));
+       _slider->Bind           (wxEVT_SCROLL_PAGEDOWN,   boost::bind (&FilmViewer::slider_moved,    this));
+       _play_button->Bind      (wxEVT_TOGGLEBUTTON,      boost::bind (&FilmViewer::play_clicked,    this));
+       _timer.Bind             (wxEVT_TIMER,             boost::bind (&FilmViewer::timer,           this));
+       _back_button->Bind      (wxEVT_LEFT_DOWN,         boost::bind (&FilmViewer::back_clicked,    this, _1));
+       _forward_button->Bind   (wxEVT_LEFT_DOWN,         boost::bind (&FilmViewer::forward_clicked, this, _1));
+       _frame_number->Bind     (wxEVT_LEFT_DOWN,         boost::bind (&FilmViewer::frame_number_clicked, this));
+       _timecode->Bind         (wxEVT_LEFT_DOWN,         boost::bind (&FilmViewer::timecode_clicked, this));
+       _jump_to_selected->Bind (wxEVT_CHECKBOX,          boost::bind (&FilmViewer::jump_to_selected_clicked, this));
+
+       _jump_to_selected->SetValue (Config::instance()->jump_to_selected ());
 
        set_film (shared_ptr<Film> ());
 
@@ -590,3 +596,9 @@ FilmViewer::frame_number_clicked ()
        }
        dialog->Destroy ();
 }
+
+void
+FilmViewer::jump_to_selected_clicked ()
+{
+       Config::instance()->set_jump_to_selected (_jump_to_selected->GetValue ());
+}
index aa588b92607d9a3922c1d7a03f70a19a348d603b..0db4bccc55f14cd7e49eb5a9f9485c89810f8d1e 100644 (file)
@@ -75,6 +75,7 @@ private:
        void timecode_clicked ();
        void frame_number_clicked ();
        void go_to (DCPTime t);
+       void jump_to_selected_clicked ();
 
        boost::shared_ptr<Film> _film;
        boost::shared_ptr<Player> _player;
@@ -84,6 +85,7 @@ private:
        wxCheckBox* _outline_content;
        wxRadioButton* _left_eye;
        wxRadioButton* _right_eye;
+       wxCheckBox* _jump_to_selected;
        wxSlider* _slider;
        wxButton* _back_button;
        wxButton* _forward_button;