allow to re-use export-report UI

(we should probably change the name to LoudnessReport)
This commit is contained in:
Robin Gareus 2016-03-11 17:25:52 +01:00
parent 43603a9893
commit 361309d83f
2 changed files with 50 additions and 24 deletions

View File

@ -53,22 +53,38 @@ using namespace ARDOUR;
ExportReport::ExportReport (Session* session, StatusPtr s) ExportReport::ExportReport (Session* session, StatusPtr s)
: ArdourDialog (_("Export Report/Analysis")) : ArdourDialog (_("Export Report/Analysis"))
, status (s)
, _session (session) , _session (session)
, stop_btn (0)
, play_btn (0)
, _audition_num (-1) , _audition_num (-1)
, _page_num (0) , _page_num (0)
{
init (s->result_map, true);
}
ExportReport::ExportReport (const std::string & title, const AnalysisResults & ar)
: ArdourDialog (title)
, _session (0)
, stop_btn (0)
, play_btn (0)
, _audition_num (-1)
, _page_num (0)
{
init (ar, false);
}
void
ExportReport::init (const AnalysisResults & ar, bool with_file)
{ {
set_resizable (false); set_resizable (false);
pages.set_scrollable (); pages.set_scrollable ();
AnalysisResults & ar = status->result_map;
std::vector<double> dashes; std::vector<double> dashes;
dashes.push_back (3.0); dashes.push_back (3.0);
dashes.push_back (5.0); dashes.push_back (5.0);
int page = 0; int page = 0;
for (AnalysisResults::iterator i = ar.begin (); i != ar.end (); ++i, ++page) { for (AnalysisResults::const_iterator i = ar.begin (); i != ar.end (); ++i, ++page) {
Label *l; Label *l;
VBox *vb = manage (new VBox ()); VBox *vb = manage (new VBox ());
Table *t = manage (new Table (4, 4)); Table *t = manage (new Table (4, 4));
@ -87,19 +103,21 @@ ExportReport::ExportReport (Session* session, StatusPtr s)
std::list<CimgPlayheadArea*> playhead_widgets; std::list<CimgPlayheadArea*> playhead_widgets;
l = manage (new Label (_("File:"), ALIGN_END)); if (with_file) {
t->attach (*l, 0, 1, 0, 1); l = manage (new Label (_("File:"), ALIGN_END));
l = manage (new Label ()); t->attach (*l, 0, 1, 0, 1);
l->set_ellipsize (Pango::ELLIPSIZE_START); l = manage (new Label ());
l->set_width_chars (48); l->set_ellipsize (Pango::ELLIPSIZE_START);
l->set_max_width_chars (48); l->set_width_chars (48);
l->set_text (path); l->set_max_width_chars (48);
l->set_alignment (ALIGN_START, ALIGN_CENTER); l->set_text (path);
t->attach (*l, 1, 3, 0, 1, FILL, SHRINK); l->set_alignment (ALIGN_START, ALIGN_CENTER);
t->attach (*l, 1, 3, 0, 1, FILL, SHRINK);
Button *b = manage (new Button (_("Open Folder"))); Button *b = manage (new Button (_("Open Folder")));
t->attach (*b, 3, 4, 0, 2, FILL, SHRINK); t->attach (*b, 3, 4, 0, 2, FILL, SHRINK);
b->signal_clicked ().connect (sigc::bind (sigc::mem_fun (*this, &ExportReport::open_folder), path)); b->signal_clicked ().connect (sigc::bind (sigc::mem_fun (*this, &ExportReport::open_folder), path));
}
SoundFileInfo info; SoundFileInfo info;
std::string errmsg; std::string errmsg;
@ -109,7 +127,7 @@ ExportReport::ExportReport (Session* session, StatusPtr s)
framecnt_t start_off = 0; framecnt_t start_off = 0;
unsigned int channels = 0; unsigned int channels = 0;
if (AudioFileSource::get_soundfile_info (path, info, errmsg)) { if (with_file && AudioFileSource::get_soundfile_info (path, info, errmsg)) {
AudioClock * clock; AudioClock * clock;
file_length = info.length; file_length = info.length;
@ -161,7 +179,7 @@ ExportReport::ExportReport (Session* session, StatusPtr s)
clock->set_mode (AudioClock::Timecode); clock->set_mode (AudioClock::Timecode);
clock->set (info.timecode * src_coef + 0.5, true); clock->set (info.timecode * src_coef + 0.5, true);
t->attach (*clock, 3, 4, 3, 4); t->attach (*clock, 3, 4, 3, 4);
} else { } else if (with_file) {
l = manage (new Label (_("Error:"), ALIGN_END)); l = manage (new Label (_("Error:"), ALIGN_END));
t->attach (*l, 0, 1, 1, 2); t->attach (*l, 0, 1, 1, 2);
l = manage (new Label (errmsg, ALIGN_START)); l = manage (new Label (errmsg, ALIGN_START));
@ -721,14 +739,18 @@ ExportReport::ExportReport (Session* session, StatusPtr s)
_session->the_auditioner()->AuditionProgress.connect(auditioner_connections, invalidator (*this), boost::bind (&ExportReport::audition_progress, this, _1, _2), gui_context()); _session->the_auditioner()->AuditionProgress.connect(auditioner_connections, invalidator (*this), boost::bind (&ExportReport::audition_progress, this, _1, _2), gui_context());
} }
play_btn = add_button (Stock::MEDIA_PLAY, RESPONSE_ACCEPT); if (_session && with_file) {
stop_btn = add_button (Stock::MEDIA_STOP, RESPONSE_ACCEPT); play_btn = add_button (Stock::MEDIA_PLAY, RESPONSE_ACCEPT);
stop_btn = add_button (Stock::MEDIA_STOP, RESPONSE_ACCEPT);
}
add_button (Stock::CLOSE, RESPONSE_CLOSE); add_button (Stock::CLOSE, RESPONSE_CLOSE);
set_default_response (RESPONSE_CLOSE); set_default_response (RESPONSE_CLOSE);
stop_btn->signal_clicked().connect (sigc::mem_fun (*this, &ExportReport::stop_audition)); if (_session && with_file) {
play_btn->signal_clicked().connect (sigc::mem_fun (*this, &ExportReport::play_audition)); stop_btn->signal_clicked().connect (sigc::mem_fun (*this, &ExportReport::stop_audition));
stop_btn->set_sensitive (false); play_btn->signal_clicked().connect (sigc::mem_fun (*this, &ExportReport::play_audition));
stop_btn->set_sensitive (false);
}
show_all (); show_all ();
} }
@ -757,6 +779,9 @@ ExportReport::open_folder (std::string p)
void void
ExportReport::audition_active (bool active) ExportReport::audition_active (bool active)
{ {
if (!stop_btn || !play_btn) {
return;
}
stop_btn->set_sensitive (active); stop_btn->set_sensitive (active);
play_btn->set_sensitive (!active); play_btn->set_sensitive (!active);

View File

@ -186,9 +186,11 @@ class ExportReport : public ArdourDialog
public: public:
typedef boost::shared_ptr<ARDOUR::ExportStatus> StatusPtr; typedef boost::shared_ptr<ARDOUR::ExportStatus> StatusPtr;
ExportReport (ARDOUR::Session*, StatusPtr); ExportReport (ARDOUR::Session*, StatusPtr);
ExportReport (const std::string & title, const ARDOUR::AnalysisResults & ar);
int run (); int run ();
private: private:
void init (const ARDOUR::AnalysisResults &, bool);
void draw_waveform (Cairo::RefPtr<Cairo::ImageSurface>& wave, void draw_waveform (Cairo::RefPtr<Cairo::ImageSurface>& wave,
ARDOUR::ExportAnalysisPtr, uint32_t, int, size_t, int, int, bool, bool); ARDOUR::ExportAnalysisPtr, uint32_t, int, size_t, int, int, bool, bool);
@ -203,7 +205,6 @@ private:
void on_logscale_toggled (Gtk::ToggleButton*); void on_logscale_toggled (Gtk::ToggleButton*);
void on_rectivied_toggled (Gtk::ToggleButton*); void on_rectivied_toggled (Gtk::ToggleButton*);
StatusPtr status;
Gtk::Notebook pages; Gtk::Notebook pages;
ARDOUR::Session* _session; ARDOUR::Session* _session;
Gtk::Button* stop_btn; Gtk::Button* stop_btn;