Make nudge buttons nudge further with modifiers (shift/control/shift+control).
authorCarl Hetherington <cth@carlh.net>
Thu, 30 Jun 2016 22:15:31 +0000 (23:15 +0100)
committerCarl Hetherington <cth@carlh.net>
Thu, 30 Jun 2016 22:15:31 +0000 (23:15 +0100)
src/wx/film_viewer.cc
src/wx/film_viewer.h

index 42ce7cd1841fe27b5440e7324e4936b533c74c61..da980dafccda4500d12ffae24bf87f6a804182c5 100644 (file)
@@ -122,8 +122,8 @@ FilmViewer::FilmViewer (wxWindow* p)
        _slider->Bind         (wxEVT_SCROLL_PAGEDOWN,              boost::bind (&FilmViewer::slider_moved,    this));
        _play_button->Bind    (wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, boost::bind (&FilmViewer::play_clicked,    this));
        _timer.Bind           (wxEVT_TIMER,                        boost::bind (&FilmViewer::timer,           this));
-       _back_button->Bind    (wxEVT_COMMAND_BUTTON_CLICKED,       boost::bind (&FilmViewer::back_clicked,    this));
-       _forward_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED,       boost::bind (&FilmViewer::forward_clicked, 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));
 
        set_film (shared_ptr<Film> ());
 
@@ -448,10 +448,26 @@ FilmViewer::active_jobs_changed (optional<string> j)
        _play_button->Enable (a);
 }
 
+DCPTime
+FilmViewer::nudge_amount (wxMouseEvent& ev)
+{
+       DCPTime amount = DCPTime::from_frames (1, _film->video_frame_rate ());
+
+       if (ev.ShiftDown() && !ev.ControlDown()) {
+               amount = DCPTime::from_seconds (1);
+       } else if (!ev.ShiftDown() && ev.ControlDown()) {
+               amount = DCPTime::from_seconds (10);
+       } else if (ev.ShiftDown() && ev.ControlDown()) {
+               amount = DCPTime::from_seconds (60);
+       }
+
+       return amount;
+}
+
 void
-FilmViewer::back_clicked ()
+FilmViewer::back_clicked (wxMouseEvent& ev)
 {
-       DCPTime p = _position - DCPTime::from_frames (1, _film->video_frame_rate ());
+       DCPTime p = _position - nudge_amount (ev);
        if (p < DCPTime ()) {
                p = DCPTime ();
        }
@@ -459,12 +475,14 @@ FilmViewer::back_clicked ()
        get (p, true);
        update_position_label ();
        update_position_slider ();
+
+       ev.Skip ();
 }
 
 void
-FilmViewer::forward_clicked ()
+FilmViewer::forward_clicked (wxMouseEvent& ev)
 {
-       DCPTime p = _position + DCPTime::from_frames (1, _film->video_frame_rate ());
+       DCPTime p = _position + nudge_amount (ev);
        if (p >= _film->length ()) {
                p = _position;
        }
@@ -472,6 +490,8 @@ FilmViewer::forward_clicked ()
        get (p, true);
        update_position_label ();
        update_position_slider ();
+
+       ev.Skip ();
 }
 
 void
index 0bb22d4227548de40af590d1a1f445cb12647e77..c9f25fa65dab2f67a397491fdf6072897376f955 100644 (file)
@@ -61,8 +61,8 @@ private:
        void calculate_sizes ();
        void check_play_state ();
        void active_jobs_changed (boost::optional<std::string>);
-       void back_clicked ();
-       void forward_clicked ();
+       void back_clicked (wxMouseEvent &);
+       void forward_clicked (wxMouseEvent &);
        void player_changed (bool);
        void update_position_label ();
        void update_position_slider ();
@@ -70,6 +70,7 @@ private:
        void refresh_panel ();
        void setup_sensitivity ();
        void film_changed (Film::Property);
+       DCPTime nudge_amount (wxMouseEvent &);
 
        boost::shared_ptr<Film> _film;
        boost::shared_ptr<Player> _player;