summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2012-07-26 02:21:14 +0100
committerCarl Hetherington <cth@carlh.net>2012-07-26 02:21:14 +0100
commitaf67dbe553391e7cf9387ba1804429e554f4fb16 (patch)
treef0bf4dcd86dd4f912845d176500b6024df04c851 /src
parent5fa99824e1bf31f569245e5f2640aeecd84de42d (diff)
Port DCP range dialog.
Diffstat (limited to 'src')
-rw-r--r--src/wx/dcp_range_dialog.cc119
-rw-r--r--src/wx/dcp_range_dialog.h25
-rw-r--r--src/wx/film_editor.cc15
-rw-r--r--src/wx/wscript2
4 files changed, 90 insertions, 71 deletions
diff --git a/src/wx/dcp_range_dialog.cc b/src/wx/dcp_range_dialog.cc
index d1fef0e8b..1397eb536 100644
--- a/src/wx/dcp_range_dialog.cc
+++ b/src/wx/dcp_range_dialog.cc
@@ -17,64 +17,80 @@
*/
-#include "dcp_range_dialog.h"
#include "lib/film.h"
+#include "dcp_range_dialog.h"
+#include "wx_util.h"
-DCPRangeDialog::DCPRangeDialog (Film* f)
- : _film (f)
- , _whole ("Whole film")
- , _first ("First")
- , _cut ("Cut remainder")
- , _black_out ("Black-out remainder")
+DCPRangeDialog::DCPRangeDialog (wxWindow* p, Film* f)
+ : wxDialog (p, wxID_ANY, _("DCP Range"))
+ , _film (f)
{
- set_title ("DCP range");
-
- Gtk::Table* table = Gtk::manage (new Gtk::Table ());
- table->set_border_width (6);
- table->set_row_spacings (6);
- table->set_col_spacings (6);
- table->attach (_whole, 0, 4, 0, 1);
- table->attach (_first, 0, 1, 1, 2);
- table->attach (_n_frames, 1, 2, 1, 2);
- table->attach (*manage (new Gtk::Label ("frames")), 2, 3, 1, 2);
- table->attach (_cut, 1, 2, 2, 3);
- table->attach (_black_out, 1, 2, 3, 4);
-
- Gtk::RadioButtonGroup g = _whole.get_group ();
- _first.set_group (g);
-
- g = _black_out.get_group ();
- _cut.set_group (g);
-
- _n_frames.set_range (1, INT_MAX - 1);
- _n_frames.set_increments (24, 24 * 60);
+ wxFlexGridSizer* table = new wxFlexGridSizer (2, 6, 6);
+
+ _whole = new wxRadioButton (this, wxID_ANY, _("Whole film"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
+ table->Add (_whole, 1);
+ table->AddSpacer (0);
+
+ _first = new wxRadioButton (this, wxID_ANY, _("First"));
+ table->Add (_first);
+ {
+ wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
+ _n_frames = new wxSpinCtrl (this, wxID_ANY);
+ s->Add (_n_frames);
+ add_label_to_sizer (s, this, "frames");
+ table->Add (s);
+ }
+
+ table->AddSpacer (0);
+ _cut = new wxRadioButton (this, wxID_ANY, _("Cut remainder"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
+ table->Add (_cut);
+
+ table->AddSpacer (0);
+ _black_out = new wxRadioButton (this, wxID_ANY, _("Black-out remainder"));
+ table->Add (_black_out);
+
+ _n_frames->SetRange (1, INT_MAX - 1);
if (_film->dcp_frames() > 0) {
- _whole.set_active (false);
- _first.set_active (true);
- _n_frames.set_value (_film->dcp_frames ());
+ _whole->SetValue (false);
+ _first->SetValue (true);
+ _n_frames->SetValue (_film->dcp_frames ());
} else {
- _whole.set_active (true);
- _first.set_active (false);
- _n_frames.set_value (24);
+ _whole->SetValue (true);
+ _first->SetValue (false);
+ _n_frames->SetValue (24);
}
- _black_out.set_active (_film->dcp_trim_action() == BLACK_OUT);
- _cut.set_active (_film->dcp_trim_action() == CUT);
+ _black_out->Enable (_film->dcp_trim_action() == BLACK_OUT);
+ _cut->Enable (_film->dcp_trim_action() == CUT);
+
+ _whole->Connect (wxID_ANY, wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler (DCPRangeDialog::whole_toggled), 0, this);
+ _first->Connect (wxID_ANY, wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler (DCPRangeDialog::first_toggled), 0, this);
+ _cut->Connect (wxID_ANY, wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler (DCPRangeDialog::cut_toggled), 0, this);
+ _n_frames->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (DCPRangeDialog::n_frames_changed), 0, this);
- _whole.signal_toggled().connect (sigc::mem_fun (*this, &DCPRangeDialog::whole_toggled));
- _cut.signal_toggled().connect (sigc::mem_fun (*this, &DCPRangeDialog::cut_toggled));
- _n_frames.signal_value_changed().connect (sigc::mem_fun (*this, &DCPRangeDialog::n_frames_changed));
+ wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
+ overall_sizer->Add (table);
+
+ wxSizer* buttons = CreateSeparatedButtonSizer (wxOK);
+ if (buttons) {
+ overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
+ }
- get_vbox()->pack_start (*table);
+ SetSizer (overall_sizer);
+ overall_sizer->SetSizeHints (this);
- add_button ("Close", Gtk::RESPONSE_CLOSE);
- show_all_children ();
+ set_sensitivity ();
+}
+void
+DCPRangeDialog::whole_toggled (wxCommandEvent &)
+{
set_sensitivity ();
+ emit_changed ();
}
void
-DCPRangeDialog::whole_toggled ()
+DCPRangeDialog::first_toggled (wxCommandEvent &)
{
set_sensitivity ();
emit_changed ();
@@ -83,19 +99,20 @@ DCPRangeDialog::whole_toggled ()
void
DCPRangeDialog::set_sensitivity ()
{
- _n_frames.set_sensitive (_first.get_active ());
- _black_out.set_sensitive (_first.get_active ());
- _cut.set_sensitive (_first.get_active ());
+ _n_frames->Enable (_first->GetValue ());
+ _black_out->Enable (_first->GetValue ());
+ _cut->Enable (_first->GetValue ());
}
void
-DCPRangeDialog::cut_toggled ()
+DCPRangeDialog::cut_toggled (wxCommandEvent &)
{
+ set_sensitivity ();
emit_changed ();
}
void
-DCPRangeDialog::n_frames_changed ()
+DCPRangeDialog::n_frames_changed (wxCommandEvent &)
{
emit_changed ();
}
@@ -104,12 +121,12 @@ void
DCPRangeDialog::emit_changed ()
{
int frames = 0;
- if (!_whole.get_active ()) {
- frames = _n_frames.get_value_as_int ();
+ if (!_whole->GetValue ()) {
+ frames = _n_frames->GetValue ();
}
TrimAction action = CUT;
- if (_black_out.get_active ()) {
+ if (_black_out->GetValue ()) {
action = BLACK_OUT;
}
diff --git a/src/wx/dcp_range_dialog.h b/src/wx/dcp_range_dialog.h
index 7469a2576..706b0e430 100644
--- a/src/wx/dcp_range_dialog.h
+++ b/src/wx/dcp_range_dialog.h
@@ -17,30 +17,33 @@
*/
-#include <gtkmm.h>
+#include <wx/wx.h>
+#include <wx/spinctrl.h>
+#include <sigc++/sigc++.h>
#include "lib/trim_action.h"
class Film;
-class DCPRangeDialog : public Gtk::Dialog
+class DCPRangeDialog : public wxDialog
{
public:
- DCPRangeDialog (Film *);
+ DCPRangeDialog (wxWindow *, Film *);
sigc::signal2<void, int, TrimAction> Changed;
private:
- void whole_toggled ();
- void cut_toggled ();
- void n_frames_changed ();
+ void whole_toggled (wxCommandEvent &);
+ void first_toggled (wxCommandEvent &);
+ void cut_toggled (wxCommandEvent &);
+ void n_frames_changed (wxCommandEvent &);
void set_sensitivity ();
void emit_changed ();
Film* _film;
- Gtk::RadioButton _whole;
- Gtk::RadioButton _first;
- Gtk::SpinButton _n_frames;
- Gtk::RadioButton _cut;
- Gtk::RadioButton _black_out;
+ wxRadioButton* _whole;
+ wxRadioButton* _first;
+ wxSpinCtrl* _n_frames;
+ wxRadioButton* _cut;
+ wxRadioButton* _black_out;
};
diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc
index 62acbfb70..604f71e62 100644
--- a/src/wx/film_editor.cc
+++ b/src/wx/film_editor.cc
@@ -40,7 +40,7 @@
#include "filter_dialog.h"
#include "wx_util.h"
#include "film_editor.h"
-//#include "dcp_range_dialog.h"
+#include "dcp_range_dialog.h"
using namespace std;
using namespace boost;
@@ -143,9 +143,9 @@ FilmEditor::FilmEditor (Film* f, wxWindow* parent)
video_control (add_label_to_sizer (_sizer, this, "Range"));
wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
_dcp_range = new wxStaticText (this, wxID_ANY, wxT (""));
- s->Add (video_control (_dcp_range), 1, wxALIGN_CENTER_VERTICAL);
+ s->Add (video_control (_dcp_range), 1, wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM | wxRIGHT, 6);
_change_dcp_range_button = new wxButton (this, wxID_ANY, wxT ("Edit..."));
- s->Add (video_control (_change_dcp_range_button));
+ s->Add (video_control (_change_dcp_range_button), 0, 0, 6);
_sizer->Add (s);
}
@@ -398,6 +398,7 @@ FilmEditor::film_changed (Film::Property p)
s << "First " << _film->dcp_frames() << " frames";
_dcp_range->SetLabel (std_to_wx (s.str ()));
}
+ _sizer->Layout ();
break;
case Film::DCP_TRIM_ACTION:
break;
@@ -627,16 +628,14 @@ FilmEditor::still_duration_changed (wxCommandEvent &)
void
FilmEditor::change_dcp_range_clicked (wxCommandEvent &)
{
-//XXX DCPRangeDialog d (_film);
-//XXX d.Changed.connect (sigc::mem_fun (*this, &FilmEditor::dcp_range_changed));
-//XXX d.run ();
+ DCPRangeDialog* d = new DCPRangeDialog (this, _film);
+ d->Changed.connect (sigc::mem_fun (*this, &FilmEditor::dcp_range_changed));
+ d->ShowModal ();
}
void
FilmEditor::dcp_range_changed (int frames, TrimAction action)
{
- _ignore_changes = true;
_film->set_dcp_frames (frames);
_film->set_dcp_trim_action (action);
- _ignore_changes = false;
}
diff --git a/src/wx/wscript b/src/wx/wscript
index a4227ccd8..78a787a86 100644
--- a/src/wx/wscript
+++ b/src/wx/wscript
@@ -17,10 +17,10 @@ def build(bld):
config_dialog.cc
filter_dialog.cc
filter_view.cc
+ dcp_range_dialog.cc
"""
# alignment.cc
-# dcp_range_dialog.cc
# film_list.cc
# dvd_title_dialog.cc