+2015-06-14 Carl Hetherington <cth@carlh.net>
+
+ * Add buttons to set trim from current `playhead'
+ position (#372).
+
2015-06-13 Carl Hetherington <cth@carlh.net>
* Version 2.1.2 released.
*/
wxPanel* overall_panel = new wxPanel (this, wxID_ANY);
- _film_editor = new FilmEditor (overall_panel);
_film_viewer = new FilmViewer (overall_panel);
+ _film_editor = new FilmEditor (overall_panel, _film_viewer);
JobManagerView* job_manager_view = new JobManagerView (overall_panel);
wxBoxSizer* right_sizer = new wxBoxSizer (wxVERTICAL);
using boost::weak_ptr;
using boost::dynamic_pointer_cast;
-ContentPanel::ContentPanel (wxNotebook* n, boost::shared_ptr<Film> f)
+ContentPanel::ContentPanel (wxNotebook* n, boost::shared_ptr<Film> f, FilmViewer* viewer)
: _timeline_dialog (0)
, _film (f)
, _generally_sensitive (true)
_panels.push_back (_audio_panel);
_subtitle_panel = new SubtitlePanel (this);
_panels.push_back (_subtitle_panel);
- _timing_panel = new TimingPanel (this);
+ _timing_panel = new TimingPanel (this, viewer);
_panels.push_back (_timing_panel);
_content->Bind (wxEVT_COMMAND_LIST_ITEM_SELECTED, boost::bind (&ContentPanel::selection_changed, this));
/*
- Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
class FilmEditor;
class ContentSubPanel;
class Film;
+class FilmViewer;
class ContentPanel : public boost::noncopyable
{
public:
- ContentPanel (wxNotebook *, boost::shared_ptr<Film>);
+ ContentPanel (wxNotebook *, boost::shared_ptr<Film>, FilmViewer* viewer);
boost::shared_ptr<Film> film () const {
return _film;
*/
-/** @file src/film_editor.cc
- * @brief A wx widget to edit a film's metadata, and perform various functions.
+/** @file src/wx/film_editor.cc
+ * @brief FilmEditor class.
*/
#include "lib/film.h"
using boost::shared_ptr;
/** @param f Film to edit */
-FilmEditor::FilmEditor (wxWindow* parent)
+FilmEditor::FilmEditor (wxWindow* parent, FilmViewer* viewer)
: wxPanel (parent)
{
wxBoxSizer* s = new wxBoxSizer (wxVERTICAL);
_main_notebook = new wxNotebook (this, wxID_ANY);
s->Add (_main_notebook, 1);
- _content_panel = new ContentPanel (_main_notebook, _film);
+ _content_panel = new ContentPanel (_main_notebook, _film, viewer);
_main_notebook->AddPage (_content_panel->panel (), _("Content"), true);
_dcp_panel = new DCPPanel (_main_notebook, _film);
_main_notebook->AddPage (_dcp_panel->panel (), _("DCP"), false);
/*
- Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
*/
-/** @file src/film_editor.h
- * @brief A wx widget to edit a film's metadata, and perform various functions.
+/** @file src/wx/film_editor.h
+ * @brief FilmEditor class.
*/
+#include "lib/film.h"
#include <wx/wx.h>
#include <boost/signals2.hpp>
-#include "lib/film.h"
-class wxSpinCtrl;
class wxNotebook;
class Film;
-class Ratio;
class ContentPanel;
class DCPPanel;
+class FilmViewer;
/** @class FilmEditor
* @brief A wx widget to edit a film's metadata, and perform various functions.
class FilmEditor : public wxPanel
{
public:
- FilmEditor (wxWindow *);
+ FilmEditor (wxWindow *, FilmViewer* viewer);
void set_film (boost::shared_ptr<Film>);
/*
- Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
_frame.reset ();
- _slider->SetValue (0);
- set_position_text ();
+ update_position ();
if (!_film) {
return;
_position = p;
}
- set_position_text ();
+ update_position ();
refresh_panel ();
_last_get_accurate = accurate;
FilmViewer::timer ()
{
get (_position + DCPTime::from_frames (1, _film->video_frame_rate ()), true);
-
- DCPTime const len = _film->length ();
-
- if (len.get ()) {
- int const new_slider_position = 4096 * _position.get() / len.get();
- if (new_slider_position != _slider->GetValue()) {
- _slider->SetValue (new_slider_position);
- }
- }
}
-
void
FilmViewer::paint_panel ()
{
}
void
-FilmViewer::set_position_text ()
+FilmViewer::update_position ()
{
if (!_film) {
+ _slider->SetValue (0);
_frame_number->SetLabel ("0");
_timecode->SetLabel ("0:0:0.0");
return;
}
+
+ DCPTime const len = _film->length ();
+
+ if (len.get ()) {
+ int const new_slider_position = 4096 * _position.get() / len.get();
+ if (new_slider_position != _slider->GetValue()) {
+ _slider->SetValue (new_slider_position);
+ }
+ }
double const fps = _film->video_frame_rate ();
/* Count frame number from 1 ... not sure if this is the best idea */
void set_film (boost::shared_ptr<Film>);
+ DCPTime position () const {
+ return _position;
+ }
+
private:
void paint_panel ();
void panel_sized (wxSizeEvent &);
void back_clicked ();
void forward_clicked ();
void player_changed (bool);
- void set_position_text ();
+ void update_position ();
void get (DCPTime, bool);
void refresh_panel ();
void setup_sensitivity ();
#include "lib/raw_convert.h"
#include "timing_panel.h"
#include "wx_util.h"
+#include "film_viewer.h"
#include "timecode.h"
#include "content_panel.h"
+#include <boost/foreach.hpp>
#include <set>
using std::cout;
using boost::shared_ptr;
using boost::dynamic_pointer_cast;
-TimingPanel::TimingPanel (ContentPanel* p)
+TimingPanel::TimingPanel (ContentPanel* p, FilmViewer* viewer)
/* horrid hack for apparent lack of context support with wxWidgets i18n code */
: ContentSubPanel (p, S_("Timing|Timing"))
+ , _viewer (viewer)
{
wxFlexGridSizer* grid = new wxFlexGridSizer (2, 4, 4);
_sizer->Add (grid, 0, wxALL, 8);
add_label_to_sizer (grid, this, _("Trim from start"), true);
_trim_start = new Timecode<DCPTime> (this);
grid->Add (_trim_start);
+ _trim_start_to_playhead = new wxButton (this, wxID_ANY, _("Trim up to current position"));
+ grid->AddSpacer (0);
+ grid->Add (_trim_start_to_playhead);
add_label_to_sizer (grid, this, _("Trim from end"), true);
_trim_end = new Timecode<DCPTime> (this);
grid->Add (_trim_end);
+ _trim_end_to_playhead = new wxButton (this, wxID_ANY, _("Trim after current position"));
+ grid->AddSpacer (0);
+ grid->Add (_trim_end_to_playhead);
add_label_to_sizer (grid, this, _("Play length"), true);
_play_length = new Timecode<DCPTime> (this);
grid->Add (_play_length);
_position->Changed.connect (boost::bind (&TimingPanel::position_changed, this));
_full_length->Changed.connect (boost::bind (&TimingPanel::full_length_changed, this));
_trim_start->Changed.connect (boost::bind (&TimingPanel::trim_start_changed, this));
+ _trim_start_to_playhead->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&TimingPanel::trim_start_to_playhead_clicked, this));
_trim_end->Changed.connect (boost::bind (&TimingPanel::trim_end_changed, this));
+ _trim_end_to_playhead->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&TimingPanel::trim_end_to_playhead_clicked, this));
_play_length->Changed.connect (boost::bind (&TimingPanel::play_length_changed, this));
_video_frame_rate->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&TimingPanel::video_frame_rate_changed, this));
_set_video_frame_rate->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&TimingPanel::set_video_frame_rate, this));
update_play_length ();
}
}
+
+void
+TimingPanel::trim_start_to_playhead_clicked ()
+{
+ DCPTime const ph = _viewer->position ();
+ BOOST_FOREACH (shared_ptr<Content> i, _parent->selected ()) {
+ if (i->position() < ph && ph < i->end ()) {
+ i->set_trim_start (i->trim_start() + ph - i->position ());
+ }
+ }
+}
+
+void
+TimingPanel::trim_end_to_playhead_clicked ()
+{
+ DCPTime const ph = _viewer->position ();
+ BOOST_FOREACH (shared_ptr<Content> i, _parent->selected ()) {
+ if (i->position() < ph && ph < i->end ()) {
+ i->set_trim_end (i->position() + i->full_length() - i->trim_start() - ph);
+ }
+
+ }
+}
/*
- Copyright (C) 2012-2013 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include "content_sub_panel.h"
#include "timecode.h"
+class FilmViewer;
+
class TimingPanel : public ContentSubPanel
{
public:
- TimingPanel (ContentPanel *);
+ TimingPanel (ContentPanel *, FilmViewer* viewer);
void film_changed (Film::Property);
void film_content_changed (int);
void position_changed ();
void full_length_changed ();
void trim_start_changed ();
+ void trim_start_to_playhead_clicked ();
void trim_end_changed ();
+ void trim_end_to_playhead_clicked ();
void play_length_changed ();
void video_frame_rate_changed ();
void set_video_frame_rate ();
void update_full_length ();
void update_play_length ();
+
+ FilmViewer* _viewer;
Timecode<DCPTime>* _position;
Timecode<DCPTime>* _full_length;
Timecode<DCPTime>* _trim_start;
+ wxButton* _trim_start_to_playhead;
+ wxButton* _trim_end_to_playhead;
Timecode<DCPTime>* _trim_end;
Timecode<DCPTime>* _play_length;
wxTextCtrl* _video_frame_rate;