From 0567c143f11fd8dd9c2ec4df9ee6bcf9fb26827d Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 11 May 2021 23:09:23 +0200 Subject: [PATCH] Tweak export-report to fit on smaller screens #8698 When the screen-height is insufficient, the loudness-graph is not included in the dialog. It is still visible in the image saved with the export (save-export-analysis-image). For tiny screens the conformity analysis may also be skipped. --- gtk2_ardour/export_report.cc | 39 ++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/gtk2_ardour/export_report.cc b/gtk2_ardour/export_report.cc index 7649747659..71b3cbfa61 100644 --- a/gtk2_ardour/export_report.cc +++ b/gtk2_ardour/export_report.cc @@ -277,6 +277,17 @@ ExportReport::init (const AnalysisResults & ar, bool with_file) int png_w = 0; int png_y0 = 0; + Glib::RefPtr win = get_window (); + Glib::RefPtr screen; + if (win) { + screen = win->get_screen(); + } else { + screen = Gdk::Screen::get_default(); + } + int win_h = screen ? screen->get_height() : -1; + int tbl_h = 4 * (lin[4] * 1.3 + 4); // height of file-info table t + win_h -= 60 + lin[4] * 4.5 ; // window title, file-tab, bottom buttons + if (with_file && UIConfiguration::instance().get_save_export_analysis_image ()) { /*png image */ const int top_w = 540 + 2 * (mnw + 4); // 4px spacing const int wav_w = m_l + m_r + 4 + sizeof (p->peaks) / sizeof (ARDOUR::PeakData::PeakDatum) / 4; @@ -538,6 +549,7 @@ ExportReport::init (const AnalysisResults & ar, bool with_file) wtbl->attach (*hb, 0, 2, wrow, wrow + 1, SHRINK, SHRINK); ++wrow; + tbl_h += hh + 4; } { @@ -571,6 +583,7 @@ ExportReport::init (const AnalysisResults & ar, bool with_file) wv->seek_playhead.connect (sigc::bind<0> (sigc::mem_fun (*this, &ExportReport::audition_seek), page)); wtbl->attach (*wv, 0, 1, wrow, wrow + 1, SHRINK, SHRINK); ++wrow; + tbl_h += 2 * waveh2 + 4; if (png_surface) { Cairo::RefPtr pcx = Cairo::Context::create (png_surface); @@ -591,6 +604,7 @@ ExportReport::init (const AnalysisResults & ar, bool with_file) tm->seek_playhead.connect (sigc::bind<0> (sigc::mem_fun (*this, &ExportReport::audition_seek), page)); wtbl->attach (*tm, 0, 1, wrow, wrow + 1, SHRINK, SHRINK); ++wrow; + tbl_h += ytme->get_height() + 4; if (png_surface) { Cairo::RefPtr pcx = Cairo::Context::create (png_surface); @@ -612,6 +626,7 @@ ExportReport::init (const AnalysisResults & ar, bool with_file) wtbl->attach (*sp, 0, 1, wrow, wrow + 1, SHRINK, SHRINK); wtbl->attach (*an, 1, 2, wrow, wrow + 1, SHRINK, SHRINK); ++wrow; + tbl_h += spec->get_height() + 4; if (png_surface) { Cairo::RefPtr pcx = Cairo::Context::create (png_surface); @@ -626,11 +641,15 @@ ExportReport::init (const AnalysisResults & ar, bool with_file) if (p->have_loudness && p->have_dbtp && p->have_lufs_graph && sample_rate > 0) { /* Loudness */ Cairo::RefPtr las = ArdourGraphs::plot_loudness (get_pango_context (), p, loudnh, m_l, sample_rate); - CimgPlayheadArea *lp = manage (new CimgPlayheadArea (las, m_l, las->get_width () - m_l)); - playhead_widgets.push_back (lp); - lp->seek_playhead.connect (sigc::bind<0> (sigc::mem_fun (*this, &ExportReport::audition_seek), page)); - wtbl->attach (*lp, 0, 1, wrow, wrow + 1, SHRINK, SHRINK); - ++wrow; + + if (win_h < 0 || win_h > tbl_h + las->get_height()) { + CimgPlayheadArea *lp = manage (new CimgPlayheadArea (las, m_l, las->get_width () - m_l)); + playhead_widgets.push_back (lp); + lp->seek_playhead.connect (sigc::bind<0> (sigc::mem_fun (*this, &ExportReport::audition_seek), page)); + wtbl->attach (*lp, 0, 1, wrow, wrow + 1, SHRINK, SHRINK); + ++wrow; + tbl_h += las->get_height() + 4; + } if (png_surface) { Cairo::RefPtr pcx = Cairo::Context::create (png_surface); @@ -722,9 +741,13 @@ ExportReport::init (const AnalysisResults & ar, bool with_file) } ++i; } - CimgArea *ci = manage (new CimgArea (conf)); - wtbl->attach (*ci, 0, 1, wrow, wrow + 1, SHRINK, SHRINK); - ++wrow; + + if (win_h < 0 || win_h > tbl_h + conf->get_height()) { + CimgArea *ci = manage (new CimgArea (conf)); + wtbl->attach (*ci, 0, 1, wrow, wrow + 1, SHRINK, SHRINK); + ++wrow; + tbl_h += conf->get_height() + 4; + } if (png_surface) { Cairo::RefPtr pcx = Cairo::Context::create (png_surface);