13
0

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)
: ArdourDialog (_("Export Report/Analysis"))
, status (s)
, _session (session)
, stop_btn (0)
, play_btn (0)
, _audition_num (-1)
, _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);
pages.set_scrollable ();
AnalysisResults & ar = status->result_map;
std::vector<double> dashes;
dashes.push_back (3.0);
dashes.push_back (5.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;
VBox *vb = manage (new VBox ());
Table *t = manage (new Table (4, 4));
@ -87,6 +103,7 @@ ExportReport::ExportReport (Session* session, StatusPtr s)
std::list<CimgPlayheadArea*> playhead_widgets;
if (with_file) {
l = manage (new Label (_("File:"), ALIGN_END));
t->attach (*l, 0, 1, 0, 1);
l = manage (new Label ());
@ -100,6 +117,7 @@ ExportReport::ExportReport (Session* session, StatusPtr s)
Button *b = manage (new Button (_("Open Folder")));
t->attach (*b, 3, 4, 0, 2, FILL, SHRINK);
b->signal_clicked ().connect (sigc::bind (sigc::mem_fun (*this, &ExportReport::open_folder), path));
}
SoundFileInfo info;
std::string errmsg;
@ -109,7 +127,7 @@ ExportReport::ExportReport (Session* session, StatusPtr s)
framecnt_t start_off = 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;
file_length = info.length;
@ -161,7 +179,7 @@ ExportReport::ExportReport (Session* session, StatusPtr s)
clock->set_mode (AudioClock::Timecode);
clock->set (info.timecode * src_coef + 0.5, true);
t->attach (*clock, 3, 4, 3, 4);
} else {
} else if (with_file) {
l = manage (new Label (_("Error:"), ALIGN_END));
t->attach (*l, 0, 1, 1, 2);
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());
}
if (_session && with_file) {
play_btn = add_button (Stock::MEDIA_PLAY, RESPONSE_ACCEPT);
stop_btn = add_button (Stock::MEDIA_STOP, RESPONSE_ACCEPT);
}
add_button (Stock::CLOSE, RESPONSE_CLOSE);
set_default_response (RESPONSE_CLOSE);
if (_session && with_file) {
stop_btn->signal_clicked().connect (sigc::mem_fun (*this, &ExportReport::stop_audition));
play_btn->signal_clicked().connect (sigc::mem_fun (*this, &ExportReport::play_audition));
stop_btn->set_sensitive (false);
}
show_all ();
}
@ -757,6 +779,9 @@ ExportReport::open_folder (std::string p)
void
ExportReport::audition_active (bool active)
{
if (!stop_btn || !play_btn) {
return;
}
stop_btn->set_sensitive (active);
play_btn->set_sensitive (!active);

View File

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