13
0

show playhead on all export report widgets

This commit is contained in:
Robin Gareus 2016-02-14 14:02:46 +01:00
parent f23bb163a8
commit 1e2299b254
2 changed files with 42 additions and 17 deletions

View File

@ -78,6 +78,8 @@ ExportReport::ExportReport (Session* session, StatusPtr s)
std::string path = i->first;
ExportAnalysisPtr p = i->second;
std::list<CimgArea*> playhead_widgets;
l = manage (new Label (_("File:"), ALIGN_END));
t->attach (*l, 0, 1, 0, 1);
l = manage (new Label ());
@ -499,6 +501,9 @@ ExportReport::ExportReport (Session* session, StatusPtr s)
wave->flush ();
CimgArea *wv = manage (new CimgArea (wave));
wv->set_audition_axis (m_l, width);
playhead_widgets.push_back (wv);
wv->seek_playhead.connect (sigc::bind<0> (sigc::mem_fun (*this, &ExportReport::audition_seek), page));
vb->pack_start (*wv);
}
@ -553,12 +558,10 @@ ExportReport::ExportReport (Session* session, StatusPtr s)
ytme->flush ();
CimgArea *tm = manage (new CimgArea (ytme));
tm->set_audition_axis (m_l, width);
tm->set_audition_axis (m_l, width, true);
playhead_widgets.push_back (tm);
tm->seek_playhead.connect (sigc::bind<0> (sigc::mem_fun (*this, &ExportReport::audition_seek), page));
timeline.push_back (tm);
vb->pack_start (*tm);
} else {
timeline.push_back (0);
}
{
@ -614,9 +617,13 @@ ExportReport::ExportReport (Session* session, StatusPtr s)
spec->flush ();
CimgArea *sp = manage (new CimgArea (spec));
sp->set_audition_axis (m_l, width);
playhead_widgets.push_back (sp);
sp->seek_playhead.connect (sigc::bind<0> (sigc::mem_fun (*this, &ExportReport::audition_seek), page));
vb->pack_start (*sp);
}
timeline[page] = playhead_widgets;
pages.pages ().push_back (Notebook_Helpers::TabElem (*vb, Glib::path_get_basename (i->first)));
pages.signal_switch_page().connect (sigc::mem_fun (*this, &ExportReport::on_switch_page));
}
@ -670,8 +677,11 @@ ExportReport::audition_active (bool active)
{
stop_btn->set_sensitive (active);
if (!active && _audition_num == _page_num) {
assert (timeline[_audition_num]);
timeline[_audition_num]->set_playhead (-1);
for (std::list<CimgArea*>::const_iterator i = timeline[_audition_num].begin();
i != timeline[_audition_num].end();
++i) {
(*i)->set_playhead (-1);
}
}
}
@ -742,8 +752,11 @@ void
ExportReport::stop_audition ()
{
if (_audition_num == _page_num) {
assert (timeline[_audition_num]);
timeline[_audition_num]->set_playhead (-1);
for (std::list<CimgArea*>::const_iterator i = timeline[_audition_num].begin();
i != timeline[_audition_num].end();
++i) {
(*i)->set_playhead (-1);
}
}
if (_session) {
_session->cancel_audition();
@ -755,8 +768,11 @@ void
ExportReport::on_switch_page (GtkNotebookPage*, guint page_num)
{
if (_audition_num == _page_num) {
assert (timeline[_audition_num]);
timeline[_audition_num]->set_playhead (-1);
for (std::list<CimgArea*>::const_iterator i = timeline[_audition_num].begin();
i != timeline[_audition_num].end();
++i) {
(*i)->set_playhead (-1);
}
}
_page_num = page_num;
}
@ -765,8 +781,12 @@ void
ExportReport::audition_progress (framecnt_t pos, framecnt_t len)
{
if (_audition_num == _page_num) {
assert (timeline[_audition_num]);
timeline[_audition_num]->set_playhead ((float)pos / len);
const float p = (float)pos / len;
for (std::list<CimgArea*>::const_iterator i = timeline[_audition_num].begin();
i != timeline[_audition_num].end();
++i) {
(*i)->set_playhead (p);
}
}
}

View File

@ -35,6 +35,7 @@ public:
, _playhead(-1)
, _x0 (0)
, _aw (0)
, _highlight (false)
{
set_size_request (sf->get_width (), sf->get_height ());
}
@ -48,9 +49,11 @@ public:
cairo_paint (cr);
if (_playhead > 0 && _playhead < 1.0 && _aw > 0) {
cairo_rectangle (cr, _x0, 0, _aw, _surface->get_height());
cairo_set_source_rgba (cr, .4, .4, .6, .4);
cairo_fill (cr);
if (_highlight) {
cairo_rectangle (cr, _x0, 0, _aw, _surface->get_height());
cairo_set_source_rgba (cr, .4, .4, .6, .4);
cairo_fill (cr);
}
const float x = _playhead * _aw;
const float h = _surface->get_height();
@ -75,9 +78,10 @@ public:
_playhead = pos;
}
void set_audition_axis (float x0, float w) {
void set_audition_axis (float x0, float w, bool h = false) {
_x0 = x0;
_aw = w;
_highlight = h;
}
sigc::signal<void, float> seek_playhead;
@ -95,6 +99,7 @@ private:
Cairo::RefPtr<Cairo::ImageSurface> _surface;
float _playhead;
float _x0, _aw;
bool _highlight;
void invalidate (float pos) {
if (pos < 0 || pos > 1) { return; }
@ -130,7 +135,7 @@ private:
Gtk::Button* stop_btn;
PBD::ScopedConnectionList auditioner_connections;
std::vector<CimgArea*> timeline;
std::map<int, std::list<CimgArea*> > timeline;
int _audition_num;
int _page_num;
};