--- /dev/null
+/*
+ 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 "lib/film.h"
+#include "content_menu.h"
+#include "repeat_dialog.h"
+
+using std::cout;
+using boost::shared_ptr;
+
+enum {
+ ID_repeat,
+ ID_remove
+};
+
+ContentMenu::ContentMenu (shared_ptr<Film> f, wxWindow* p)
+ : _menu (new wxMenu)
+ , _film (f)
+ , _parent (p)
+{
+ _menu->Append (ID_repeat, _("Repeat..."));
+ _menu->AppendSeparator ();
+ _menu->Append (ID_remove, _("Remove"));
+
+ _parent->Bind (wxEVT_COMMAND_MENU_SELECTED, &ContentMenu::repeat, this, ID_repeat);
+ _parent->Bind (wxEVT_COMMAND_MENU_SELECTED, &ContentMenu::remove, this, ID_remove);
+}
+
+ContentMenu::~ContentMenu ()
+{
+ delete _menu;
+}
+
+void
+ContentMenu::popup (ContentList c, wxPoint p)
+{
+ _content = c;
+ _parent->PopupMenu (_menu, p);
+}
+
+void
+ContentMenu::repeat (wxCommandEvent &)
+{
+ if (_content.empty ()) {
+ return;
+ }
+
+ RepeatDialog d (_parent);
+ d.ShowModal ();
+
+ shared_ptr<const Film> film = _film.lock ();
+ if (!film) {
+ return;
+ }
+
+ film->playlist()->repeat (_content, d.number ());
+ d.Destroy ();
+
+ _content.clear ();
+}
+
+void
+ContentMenu::remove (wxCommandEvent &)
+{
+ if (_content.empty ()) {
+ return;
+ }
+
+ shared_ptr<const Film> film = _film.lock ();
+ if (!film) {
+ return;
+ }
+
+ film->playlist()->remove (_content);
+
+ _content.clear ();
+}
+
--- /dev/null
+/*
+ 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.
+
+*/
+
+#ifndef DCPOMATIC_CONTENT_MENU_H
+#define DCPOMATIC_CONTENT_MENU_H
+
+#include <wx/wx.h>
+#include <boost/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
+#include "lib/types.h"
+
+class Film;
+
+class ContentMenu
+{
+public:
+ ContentMenu (boost::shared_ptr<Film>, wxWindow *);
+ ~ContentMenu ();
+
+ void popup (ContentList, wxPoint);
+
+private:
+ void repeat (wxCommandEvent &);
+ void remove (wxCommandEvent &);
+
+ wxMenu* _menu;
+ boost::weak_ptr<Film> _film;
+ wxWindow* _parent;
+ ContentList _content;
+};
+
+#endif
/** @param f Film to edit */
FilmEditor::FilmEditor (shared_ptr<Film> f, wxWindow* parent)
: wxPanel (parent)
+ , _menu (f, this)
, _generally_sensitive (true)
, _audio_dialog (0)
, _timeline_dialog (0)
_ratio->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (FilmEditor::ratio_changed), 0, this);
_content->Connect (wxID_ANY, wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler (FilmEditor::content_selection_changed), 0, this);
_content->Connect (wxID_ANY, wxEVT_COMMAND_LIST_ITEM_DESELECTED, wxListEventHandler (FilmEditor::content_selection_changed), 0, this);
+ _content->Connect (wxID_ANY, wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK,wxListEventHandler (FilmEditor::content_right_click), 0, this);
_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);
}
shared_ptr<Content> content = weak_content.lock ();
+ if (content != selected_content ()) {
+ return;
+ }
+
shared_ptr<VideoContent> video_content;
shared_ptr<AudioContent> audio_content;
shared_ptr<SubtitleContent> subtitle_content;
{
_film->set_sequence_video (_sequence_video->GetValue ());
}
+
+void
+FilmEditor::content_right_click (wxListEvent& ev)
+{
+ ContentList cl;
+ cl.push_back (selected_content ());
+ _menu.popup (cl, ev.GetPoint ());
+}
#include <wx/collpane.h>
#include <boost/signals2.hpp>
#include "lib/film.h"
+#include "content_menu.h"
class wxNotebook;
class wxListCtrl;
void dcp_audio_channels_changed (wxCommandEvent &);
void dcp_resolution_changed (wxCommandEvent &);
void sequence_video_changed (wxCommandEvent &);
+ void content_right_click (wxListEvent &);
/* Handle changes to the model */
void film_changed (Film::Property);
Timecode* _length;
wxChoice* _dcp_resolution;
+ ContentMenu _menu;
+
std::vector<Ratio const *> _ratios;
bool _generally_sensitive;
#include "film_editor.h"
#include "timeline.h"
#include "wx_util.h"
-#include "repeat_dialog.h"
using std::list;
using std::cout;
int _y;
};
-enum {
- ID_repeat,
- ID_remove
-};
-
Timeline::Timeline (wxWindow* parent, FilmEditor* ed, shared_ptr<Film> film)
: wxPanel (parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE)
, _film_editor (ed)
, _left_down (false)
, _down_view_start (0)
, _first_move (false)
- , _menu (0)
+ , _menu (film, this)
{
#ifndef __WXOSX__
SetDoubleBuffered (true);
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);
- Connect (ID_remove, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Timeline::remove), 0, this);
-
playlist_changed ();
SetMinSize (wxSize (640, tracks() * track_height() + 96));
cv->set_selected (true);
}
- if (!_menu) {
- _menu = new wxMenu;
- _menu->Append (ID_repeat, _("Repeat..."));
- _menu->AppendSeparator ();
- _menu->Append (ID_remove, _("Remove"));
- }
-
- PopupMenu (_menu, ev.GetPosition ());
+ _menu.popup (selected_content (), ev.GetPosition ());
}
void
}
}
-void
-Timeline::repeat (wxCommandEvent &)
-{
- ContentList sel = selected_content ();
- if (sel.empty ()) {
- return;
- }
-
- RepeatDialog d (this);
- d.ShowModal ();
-
- shared_ptr<const Film> film = _film.lock ();
- if (!film) {
- return;
- }
-
- film->playlist()->repeat (sel, d.number ());
- d.Destroy ();
-}
-
-void
-Timeline::remove (wxCommandEvent &)
-{
- ContentList sel = selected_content ();
- if (sel.empty ()) {
- return;
- }
-
- shared_ptr<const Film> film = _film.lock ();
- if (!film) {
- return;
- }
-
- film->playlist()->remove (sel);
-}
-
Timeline::ContentViewList
Timeline::selected_views () const
{
#include <wx/wx.h>
#include "lib/util.h"
#include "lib/rect.h"
+#include "content_menu.h"
class Film;
class View;
void set_start_from_event (wxMouseEvent &);
void clear_selection ();
- void repeat (wxCommandEvent &);
- void remove (wxCommandEvent &);
-
typedef std::vector<boost::shared_ptr<View> > ViewList;
typedef std::vector<boost::shared_ptr<ContentView> > ContentViewList;
boost::shared_ptr<ContentView> _down_view;
Time _down_view_start;
bool _first_move;
- wxMenu* _menu;
+ ContentMenu _menu;
boost::signals2::scoped_connection _playlist_connection;
};
audio_mapping_view.cc
audio_plot.cc
config_dialog.cc
+ content_menu.cc
dci_metadata_dialog.cc
dir_picker_ctrl.cc
film_editor.cc