summaryrefslogtreecommitdiff
path: root/src/wx
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-07-19 13:47:34 +0100
committerCarl Hetherington <cth@carlh.net>2013-07-19 13:47:34 +0100
commita6d892268ccdf8e50194c0168491c8a360bbb687 (patch)
tree80d8007be63f7b9f52bdc46e0171d79454a94597 /src/wx
parent91273da19c689e44f3baa368d4b4efbe75cd8fe5 (diff)
parent7370f2b159a539d4a7721a50d0f3dc56ba14c678 (diff)
Merge branch '1.0-alt-loop' into 1.0
Diffstat (limited to 'src/wx')
-rw-r--r--src/wx/film_editor.cc54
-rw-r--r--src/wx/film_editor.h5
-rw-r--r--src/wx/film_viewer.cc4
-rw-r--r--src/wx/properties_dialog.cc8
-rw-r--r--src/wx/repeat_dialog.cc54
-rw-r--r--src/wx/repeat_dialog.h32
-rw-r--r--src/wx/timeline.cc139
-rw-r--r--src/wx/timeline.h9
-rw-r--r--src/wx/wscript1
9 files changed, 225 insertions, 81 deletions
diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc
index 427afb6e8..f087bf84c 100644
--- a/src/wx/film_editor.cc
+++ b/src/wx/film_editor.cc
@@ -214,8 +214,6 @@ FilmEditor::connect_to_widgets ()
_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_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);
_right_crop->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::right_crop_changed), 0, this);
_top_crop->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::top_crop_changed), 0, this);
@@ -336,14 +334,6 @@ FilmEditor::make_content_panel ()
_content_sizer->Add (s, 0.75, wxEXPAND | wxALL, 6);
}
- wxBoxSizer* h = new wxBoxSizer (wxHORIZONTAL);
- _loop_content = new wxCheckBox (_content_panel, wxID_ANY, _("Loop everything"));
- h->Add (_loop_content, 0, wxALL, 6);
- _loop_count = new wxSpinCtrl (_content_panel, wxID_ANY);
- h->Add (_loop_count, 0, wxALL, 6);
- add_label_to_sizer (h, _content_panel, _("times"), false);
- _content_sizer->Add (h, 0, wxALL, 6);
-
_content_notebook = new wxNotebook (_content_panel, wxID_ANY);
_content_sizer->Add (_content_notebook, 1, wxEXPAND | wxTOP, 6);
@@ -355,8 +345,6 @@ FilmEditor::make_content_panel ()
_content_notebook->AddPage (_subtitle_panel, _("Subtitles"), false);
make_timing_panel ();
_content_notebook->AddPage (_timing_panel, _("Timing"), false);
-
- _loop_count->SetRange (2, 1024);
}
void
@@ -622,11 +610,6 @@ FilmEditor::film_changed (Film::Property p)
setup_subtitle_control_sensitivity ();
setup_show_audio_sensitivity ();
break;
- case Film::LOOP:
- checked_set (_loop_content, _film->loop() > 1);
- checked_set (_loop_count, _film->loop());
- setup_loop_sensitivity ();
- break;
case Film::CONTAINER:
setup_container ();
break;
@@ -879,7 +862,6 @@ FilmEditor::set_film (shared_ptr<Film> f)
film_changed (Film::NAME);
film_changed (Film::USE_DCI_NAME);
film_changed (Film::CONTENT);
- film_changed (Film::LOOP);
film_changed (Film::DCP_CONTENT_TYPE);
film_changed (Film::CONTAINER);
film_changed (Film::RESOLUTION);
@@ -890,8 +872,8 @@ FilmEditor::set_film (shared_ptr<Film> f)
film_changed (Film::DCP_VIDEO_FRAME_RATE);
film_changed (Film::DCP_AUDIO_CHANNELS);
- if (!_film->content_without_loop().empty ()) {
- set_selection (_film->content_without_loop().front ());
+ if (!_film->content().empty ()) {
+ set_selection (_film->content().front ());
}
wxListEvent ev;
@@ -926,8 +908,6 @@ FilmEditor::set_things_sensitive (bool s)
_show_audio->Enable (s);
_audio_delay->Enable (s);
_container->Enable (s);
- _loop_content->Enable (s);
- _loop_count->Enable (s);
setup_subtitle_control_sensitivity ();
setup_show_audio_sensitivity ();
@@ -1152,7 +1132,7 @@ FilmEditor::setup_content ()
_content->DeleteAllItems ();
- Playlist::ContentList content = _film->content_without_loop ();
+ Playlist::ContentList content = _film->content ();
for (Playlist::ContentList::iterator i = content.begin(); i != content.end(); ++i) {
int const t = _content->GetItemCount ();
_content->InsertItem (t, std_to_wx ((*i)->summary ()));
@@ -1260,7 +1240,7 @@ FilmEditor::selected_content ()
return shared_ptr<Content> ();
}
- Playlist::ContentList c = _film->content_without_loop ();
+ Playlist::ContentList c = _film->content ();
if (s < 0 || size_t (s) >= c.size ()) {
return shared_ptr<Content> ();
}
@@ -1366,30 +1346,6 @@ FilmEditor::setup_scaling_description ()
}
void
-FilmEditor::loop_content_toggled (wxCommandEvent &)
-{
- if (_loop_content->GetValue ()) {
- _film->set_loop (_loop_count->GetValue ());
- } else {
- _film->set_loop (1);
- }
-
- setup_loop_sensitivity ();
-}
-
-void
-FilmEditor::loop_count_changed (wxCommandEvent &)
-{
- _film->set_loop (_loop_count->GetValue ());
-}
-
-void
-FilmEditor::setup_loop_sensitivity ()
-{
- _loop_count->Enable (_loop_content->GetValue ());
-}
-
-void
FilmEditor::content_timeline_clicked (wxCommandEvent &)
{
if (_timeline_dialog) {
@@ -1510,7 +1466,7 @@ FilmEditor::length_changed ()
void
FilmEditor::set_selection (weak_ptr<Content> wc)
{
- Playlist::ContentList content = _film->content_without_loop ();
+ Playlist::ContentList content = _film->content ();
for (size_t i = 0; i < content.size(); ++i) {
if (content[i] == wc.lock ()) {
_content->SetItemState (i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
diff --git a/src/wx/film_editor.h b/src/wx/film_editor.h
index c965a7aff..a7e8ab197 100644
--- a/src/wx/film_editor.h
+++ b/src/wx/film_editor.h
@@ -87,8 +87,6 @@ private:
void dcp_frame_rate_changed (wxCommandEvent &);
void best_dcp_frame_rate_clicked (wxCommandEvent &);
void edit_filters_clicked (wxCommandEvent &);
- void loop_content_toggled (wxCommandEvent &);
- void loop_count_changed (wxCommandEvent &);
void content_timeline_clicked (wxCommandEvent &);
void audio_stream_changed (wxCommandEvent &);
void subtitle_stream_changed (wxCommandEvent &);
@@ -112,7 +110,6 @@ private:
void setup_content ();
void setup_container ();
void setup_content_sensitivity ();
- void setup_loop_sensitivity ();
void active_jobs_changed (bool);
boost::shared_ptr<Content> selected_content ();
@@ -143,8 +140,6 @@ private:
wxButton* _content_earlier;
wxButton* _content_later;
wxButton* _content_timeline;
- wxCheckBox* _loop_content;
- wxSpinCtrl* _loop_count;
wxButton* _edit_dci_button;
wxChoice* _ratio;
wxStaticText* _ratio_description;
diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc
index d00a582e5..fffb64796 100644
--- a/src/wx/film_viewer.cc
+++ b/src/wx/film_viewer.cc
@@ -164,7 +164,7 @@ FilmViewer::timer (wxTimerEvent &)
fetch_next_frame ();
- Time const len = _film->length_with_loop ();
+ Time const len = _film->length ();
if (len) {
int const new_slider_position = 4096 * _player->video_position() / len;
@@ -213,7 +213,7 @@ void
FilmViewer::slider_moved (wxScrollEvent &)
{
if (_film && _player) {
- _player->seek (_slider->GetValue() * _film->length_with_loop() / 4096, false);
+ _player->seek (_slider->GetValue() * _film->length() / 4096, false);
fetch_next_frame ();
}
}
diff --git a/src/wx/properties_dialog.cc b/src/wx/properties_dialog.cc
index b8d97cb59..d525fe38b 100644
--- a/src/wx/properties_dialog.cc
+++ b/src/wx/properties_dialog.cc
@@ -50,8 +50,8 @@ PropertiesDialog::PropertiesDialog (wxWindow* parent, shared_ptr<Film> film)
_encoded = new ThreadedStaticText (this, _("counting..."), boost::bind (&PropertiesDialog::frames_already_encoded, this));
table->Add (_encoded, 1, wxALIGN_CENTER_VERTICAL);
- _frames->SetLabel (std_to_wx (lexical_cast<string> (_film->time_to_video_frames (_film->length_with_loop()))));
- double const disk = ((double) _film->j2k_bandwidth() / 8) * _film->length_with_loop() / (TIME_HZ * 1073741824.0f);
+ _frames->SetLabel (std_to_wx (lexical_cast<string> (_film->time_to_video_frames (_film->length()))));
+ double const disk = ((double) _film->j2k_bandwidth() / 8) * _film->length() / (TIME_HZ * 1073741824.0f);
stringstream s;
s << fixed << setprecision (1) << disk << wx_to_std (_("Gb"));
_disk->SetLabel (std_to_wx (s.str ()));
@@ -78,9 +78,9 @@ PropertiesDialog::frames_already_encoded () const
return "";
}
- if (_film->length_with_loop()) {
+ if (_film->length()) {
/* XXX: encoded_frames() should check which frames have been encoded */
- u << " (" << (_film->encoded_frames() * 100 / _film->time_to_video_frames (_film->length_with_loop())) << "%)";
+ u << " (" << (_film->encoded_frames() * 100 / _film->time_to_video_frames (_film->length())) << "%)";
}
return u.str ();
}
diff --git a/src/wx/repeat_dialog.cc b/src/wx/repeat_dialog.cc
new file mode 100644
index 000000000..9eb02ba57
--- /dev/null
+++ b/src/wx/repeat_dialog.cc
@@ -0,0 +1,54 @@
+/*
+ Copyright (C) 2013 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
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "repeat_dialog.h"
+#include "wx_util.h"
+
+RepeatDialog::RepeatDialog (wxWindow* parent)
+ : wxDialog (parent, wxID_ANY, _("Repeat Content"))
+{
+ wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
+ SetSizer (overall_sizer);
+
+ wxFlexGridSizer* table = new wxFlexGridSizer (3, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
+ table->AddGrowableCol (1, 1);
+ overall_sizer->Add (table, 1, wxEXPAND | wxALL, 6);
+
+ add_label_to_sizer (table, this, _("Repeat"), true);
+ _number = new wxSpinCtrl (this, wxID_ANY);
+ table->Add (_number, 1);
+
+ add_label_to_sizer (table, this, _("times"), false);
+
+ _number->SetRange (1, 1024);
+
+ wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL);
+ if (buttons) {
+ overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
+ }
+
+ overall_sizer->Layout ();
+ overall_sizer->SetSizeHints (this);
+}
+
+int
+RepeatDialog::number () const
+{
+ return _number->GetValue ();
+}
diff --git a/src/wx/repeat_dialog.h b/src/wx/repeat_dialog.h
new file mode 100644
index 000000000..cbcc6bb7a
--- /dev/null
+++ b/src/wx/repeat_dialog.h
@@ -0,0 +1,32 @@
+/*
+ Copyright (C) 2013 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
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include <wx/wx.h>
+#include <wx/spinctrl.h>
+
+class RepeatDialog : public wxDialog
+{
+public:
+ RepeatDialog (wxWindow *);
+
+ int number () const;
+
+private:
+ wxSpinCtrl* _number;
+};
diff --git a/src/wx/timeline.cc b/src/wx/timeline.cc
index 3747a3dac..f9205fc5d 100644
--- a/src/wx/timeline.cc
+++ b/src/wx/timeline.cc
@@ -25,6 +25,7 @@
#include "film_editor.h"
#include "timeline.h"
#include "wx_util.h"
+#include "repeat_dialog.h"
using std::list;
using std::cout;
@@ -314,6 +315,10 @@ private:
int _y;
};
+enum {
+ ID_repeat
+};
+
Timeline::Timeline (wxWindow* parent, FilmEditor* ed, shared_ptr<Film> film)
: wxPanel (parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE)
, _film_editor (ed)
@@ -324,26 +329,25 @@ Timeline::Timeline (wxWindow* parent, FilmEditor* ed, shared_ptr<Film> film)
, _left_down (false)
, _down_view_start (0)
, _first_move (false)
+ , _menu (0)
{
#ifndef __WXOSX__
SetDoubleBuffered (true);
#endif
- setup_pixels_per_time_unit ();
-
Connect (wxID_ANY, wxEVT_PAINT, wxPaintEventHandler (Timeline::paint), 0, this);
Connect (wxID_ANY, wxEVT_LEFT_DOWN, wxMouseEventHandler (Timeline::left_down), 0, this);
Connect (wxID_ANY, wxEVT_LEFT_UP, wxMouseEventHandler (Timeline::left_up), 0, this);
+ Connect (wxID_ANY, wxEVT_RIGHT_DOWN, wxMouseEventHandler (Timeline::right_down), 0, this);
Connect (wxID_ANY, wxEVT_MOTION, wxMouseEventHandler (Timeline::mouse_moved), 0, this);
Connect (wxID_ANY, wxEVT_SIZE, wxSizeEventHandler (Timeline::resized), 0, this);
+ Connect (ID_repeat, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Timeline::repeat), 0, this);
playlist_changed ();
SetMinSize (wxSize (640, tracks() * track_height() + 96));
_playlist_connection = film->playlist()->Changed.connect (bind (&Timeline::playlist_changed, this));
-
- _views.push_back (_time_axis_view);
}
void
@@ -374,8 +378,9 @@ Timeline::playlist_changed ()
}
_views.clear ();
+ _views.push_back (_time_axis_view);
- Playlist::ContentList content = fl->playlist()->content_with_loop ();
+ Playlist::ContentList content = fl->playlist()->content ();
for (Playlist::ContentList::iterator i = content.begin(); i != content.end(); ++i) {
if (dynamic_pointer_cast<VideoContent> (*i)) {
@@ -387,6 +392,7 @@ Timeline::playlist_changed ()
}
assign_tracks ();
+ setup_pixels_per_time_unit ();
Refresh ();
}
@@ -460,11 +466,11 @@ Timeline::setup_pixels_per_time_unit ()
return;
}
- _pixels_per_time_unit = static_cast<double>(width() - x_offset() * 2) / film->length_with_loop();
+ _pixels_per_time_unit = static_cast<double>(width() - x_offset() * 2) / film->length ();
}
-void
-Timeline::left_down (wxMouseEvent& ev)
+shared_ptr<View>
+Timeline::event_to_view (wxMouseEvent& ev)
{
list<shared_ptr<View> >::iterator i = _views.begin();
Position<int> const p (ev.GetX(), ev.GetY());
@@ -472,24 +478,43 @@ Timeline::left_down (wxMouseEvent& ev)
++i;
}
+ if (i == _views.end ()) {
+ return shared_ptr<View> ();
+ }
+
+ return *i;
+}
+
+void
+Timeline::left_down (wxMouseEvent& ev)
+{
+ shared_ptr<View> view = event_to_view (ev);
+ shared_ptr<ContentView> content_view = dynamic_pointer_cast<ContentView> (view);
+
_down_view.reset ();
- if (i != _views.end ()) {
+ if (content_view) {
+ _down_view = content_view;
+ _down_view_start = content_view->content()->start ();
+ }
+
+ for (list<shared_ptr<View> >::iterator i = _views.begin(); i != _views.end(); ++i) {
shared_ptr<ContentView> cv = dynamic_pointer_cast<ContentView> (*i);
- if (cv) {
- _down_view = cv;
- _down_view_start = cv->content()->start ();
+ if (!cv) {
+ continue;
+ }
+
+ if (!ev.ShiftDown ()) {
+ cv->set_selected (view == *i);
+ }
+
+ if (view == *i) {
+ _film_editor->set_selection (cv->content ());
}
}
- for (list<shared_ptr<View> >::iterator j = _views.begin(); j != _views.end(); ++j) {
- shared_ptr<ContentView> cv = dynamic_pointer_cast<ContentView> (*j);
- if (cv) {
- cv->set_selected (i == j);
- if (i == j) {
- _film_editor->set_selection (cv->content ());
- }
- }
+ if (content_view && ev.ShiftDown ()) {
+ content_view->set_selected (!content_view->selected ());
}
_left_down = true;
@@ -524,6 +549,28 @@ Timeline::mouse_moved (wxMouseEvent& ev)
}
void
+Timeline::right_down (wxMouseEvent& ev)
+{
+ shared_ptr<View> view = event_to_view (ev);
+ shared_ptr<ContentView> cv = dynamic_pointer_cast<ContentView> (view);
+ if (!cv) {
+ return;
+ }
+
+ if (!cv->selected ()) {
+ clear_selection ();
+ cv->set_selected (true);
+ }
+
+ if (!_menu) {
+ _menu = new wxMenu;
+ _menu->Append (ID_repeat, _("Repeat..."));
+ }
+
+ PopupMenu (_menu, ev.GetPosition ());
+}
+
+void
Timeline::set_start_from_event (wxMouseEvent& ev)
{
wxPoint const p = ev.GetPosition();
@@ -563,3 +610,55 @@ Timeline::resized (wxSizeEvent &)
{
setup_pixels_per_time_unit ();
}
+
+void
+Timeline::clear_selection ()
+{
+ for (list<shared_ptr<View> >::iterator i = _views.begin(); i != _views.end(); ++i) {
+ shared_ptr<ContentView> cv = dynamic_pointer_cast<ContentView> (*i);
+ if (cv) {
+ cv->set_selected (false);
+ }
+ }
+}
+
+void
+Timeline::repeat (wxCommandEvent &)
+{
+ list<shared_ptr<ContentView> > sel = selected ();
+ if (sel.empty ()) {
+ return;
+ }
+
+ RepeatDialog d (this);
+ d.ShowModal ();
+
+ shared_ptr<const Film> film = _film.lock ();
+ if (!film) {
+ return;
+ }
+
+ list<shared_ptr<Content> > content;
+ for (list<shared_ptr<ContentView> >::iterator i = sel.begin(); i != sel.end(); ++i) {
+ content.push_back ((*i)->content ());
+ }
+
+ film->playlist()->repeat (content, d.number ());
+ d.Destroy ();
+}
+
+list<shared_ptr<ContentView> >
+Timeline::selected () const
+{
+ list<shared_ptr<ContentView> > sel;
+
+ for (list<shared_ptr<View> >::const_iterator i = _views.begin(); i != _views.end(); ++i) {
+ shared_ptr<ContentView> cv = dynamic_pointer_cast<ContentView> (*i);
+ if (cv && cv->selected()) {
+ sel.push_back (cv);
+ }
+ }
+
+ return sel;
+}
+
diff --git a/src/wx/timeline.h b/src/wx/timeline.h
index 6979d6a78..99094788f 100644
--- a/src/wx/timeline.h
+++ b/src/wx/timeline.h
@@ -64,13 +64,19 @@ public:
private:
void paint (wxPaintEvent &);
void left_down (wxMouseEvent &);
- void mouse_moved (wxMouseEvent &);
void left_up (wxMouseEvent &);
+ void right_down (wxMouseEvent &);
+ void mouse_moved (wxMouseEvent &);
void playlist_changed ();
void setup_pixels_per_time_unit ();
void resized (wxSizeEvent &);
void assign_tracks ();
void set_start_from_event (wxMouseEvent &);
+ void clear_selection ();
+ void repeat (wxCommandEvent &);
+
+ boost::shared_ptr<View> event_to_view (wxMouseEvent &);
+ std::list<boost::shared_ptr<ContentView> > selected () const;
FilmEditor* _film_editor;
boost::weak_ptr<Film> _film;
@@ -83,6 +89,7 @@ private:
boost::shared_ptr<ContentView> _down_view;
Time _down_view_start;
bool _first_move;
+ wxMenu* _menu;
boost::signals2::scoped_connection _playlist_connection;
};
diff --git a/src/wx/wscript b/src/wx/wscript
index 9dea367c9..3402d4b41 100644
--- a/src/wx/wscript
+++ b/src/wx/wscript
@@ -21,6 +21,7 @@ sources = """
job_wrapper.cc
new_film_dialog.cc
properties_dialog.cc
+ repeat_dialog.cc
server_dialog.cc
timecode.cc
timeline.cc