projects
/
ardour.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix ExportFormatSpecification copy-c'tor
[ardour.git]
/
gtk2_ardour
/
mini_timeline.cc
diff --git
a/gtk2_ardour/mini_timeline.cc
b/gtk2_ardour/mini_timeline.cc
index b5259af31095bec942549560bb3b9bc8609f25ee..b4652583ca3e34300e03d18354613bb99b1eb453 100644
(file)
--- a/
gtk2_ardour/mini_timeline.cc
+++ b/
gtk2_ardour/mini_timeline.cc
@@
-20,12
+20,10
@@
#include "ardour/session.h"
#include "ardour/tempo.h"
#include "ardour/session.h"
#include "ardour/tempo.h"
+#include "gtkmm2ext/colors.h"
#include "gtkmm2ext/gui_thread.h"
#include "gtkmm2ext/keyboard.h"
#include "gtkmm2ext/gui_thread.h"
#include "gtkmm2ext/keyboard.h"
-#include "canvas/colors.h"
-#include "canvas/utils.h"
-
#include "widgets/tooltips.h"
#include "ardour_ui.h"
#include "widgets/tooltips.h"
#include "ardour_ui.h"
@@
-43,7
+41,7
@@
using namespace ARDOUR;
MiniTimeline::MiniTimeline ()
using namespace ARDOUR;
MiniTimeline::MiniTimeline ()
- : _last_update_
fram
e (-1)
+ : _last_update_
sampl
e (-1)
, _clock_mode (AudioClock::Timecode)
, _time_width (0)
, _time_height (0)
, _clock_mode (AudioClock::Timecode)
, _time_width (0)
, _time_height (0)
@@
-153,6
+151,7
@@
void
MiniTimeline::set_colors ()
{
// TODO UIConfiguration::instance().color & font
MiniTimeline::set_colors ()
{
// TODO UIConfiguration::instance().color & font
+ _phead_color = UIConfiguration::instance().color ("play head");
}
void
}
void
@@
-182,7
+181,7
@@
MiniTimeline::on_size_allocate (Gtk::Allocation& alloc)
}
void
}
void
-MiniTimeline::set_span (
fram
ecnt_t ts)
+MiniTimeline::set_span (
sampl
ecnt_t ts)
{
assert (_session);
if (_session->config.get_minitimeline_span () == ts) {
{
assert (_session);
if (_session->config.get_minitimeline_span () == ts) {
@@
-200,11
+199,11
@@
MiniTimeline::super_rapid_update ()
if (!_session || !_session->engine().running() || !is_mapped ()) {
return;
}
if (!_session || !_session->engine().running() || !is_mapped ()) {
return;
}
-
framepos_t const fram
e = PublicEditor::instance().playhead_cursor_sample ();
+
samplepos_t const sampl
e = PublicEditor::instance().playhead_cursor_sample ();
AudioClock::Mode m = ARDOUR_UI::instance()->primary_clock->mode();
bool change = false;
AudioClock::Mode m = ARDOUR_UI::instance()->primary_clock->mode();
bool change = false;
- if (fabs ((_last_update_
frame - fram
e) * _px_per_sample) >= 1.0) {
+ if (fabs ((_last_update_
sample - sampl
e) * _px_per_sample) >= 1.0) {
change = true;
}
change = true;
}
@@
-220,7
+219,7
@@
MiniTimeline::super_rapid_update ()
}
if (change) {
}
if (change) {
- _last_update_
frame = fram
e;
+ _last_update_
sample = sampl
e;
update_minitimeline ();
}
}
update_minitimeline ();
}
}
@@
-244,7
+243,8
@@
MiniTimeline::calculate_time_width ()
case AudioClock::MinSec:
_layout->set_text ("88:88:88,88");
break;
case AudioClock::MinSec:
_layout->set_text ("88:88:88,88");
break;
- case AudioClock::Frames:
+ case AudioClock::Seconds:
+ case AudioClock::Samples:
_layout->set_text ("8888888888");
break;
}
_layout->set_text ("8888888888");
break;
}
@@
-260,15
+260,15
@@
MiniTimeline::calculate_time_spacing ()
return;
}
return;
}
- const
fram
ecnt_t time_span = _session->config.get_minitimeline_span () / 2;
- _time_span_samples = time_span * _session->nominal_
fram
e_rate ();
- _time_granularity = _session->nominal_
fram
e_rate () * ceil (2. * time_span / _n_labels);
+ const
sampl
ecnt_t time_span = _session->config.get_minitimeline_span () / 2;
+ _time_span_samples = time_span * _session->nominal_
sampl
e_rate ();
+ _time_granularity = _session->nominal_
sampl
e_rate () * ceil (2. * time_span / _n_labels);
_px_per_sample = get_width () / (2. * _time_span_samples);
//_px_per_sample = 1.0 / round (1.0 / _px_per_sample);
}
void
_px_per_sample = get_width () / (2. * _time_span_samples);
//_px_per_sample = 1.0 / round (1.0 / _px_per_sample);
}
void
-MiniTimeline::format_time (
fram
epos_t when)
+MiniTimeline::format_time (
sampl
epos_t when)
{
switch (_clock_mode) {
case AudioClock::Timecode:
{
switch (_clock_mode) {
case AudioClock::Timecode:
@@
-282,7
+282,7
@@
MiniTimeline::format_time (framepos_t when)
case AudioClock::BBT:
{
char buf[64];
case AudioClock::BBT:
{
char buf[64];
- Timecode::BBT_Time BBT = _session->tempo_map().bbt_at_
fram
e (when);
+ Timecode::BBT_Time BBT = _session->tempo_map().bbt_at_
sampl
e (when);
snprintf (buf, sizeof (buf), "%03" PRIu32 BBT_BAR_CHAR "%02" PRIu32 BBT_BAR_CHAR "%04" PRIu32,
BBT.bars, BBT.beats, BBT.ticks);
_layout->set_text (buf);
snprintf (buf, sizeof (buf), "%03" PRIu32 BBT_BAR_CHAR "%02" PRIu32 BBT_BAR_CHAR "%04" PRIu32,
BBT.bars, BBT.beats, BBT.ticks);
_layout->set_text (buf);
@@
-291,11
+291,18
@@
MiniTimeline::format_time (framepos_t when)
case AudioClock::MinSec:
{
char buf[32];
case AudioClock::MinSec:
{
char buf[32];
- AudioClock::print_minsec (when, buf, sizeof (buf), _session->
fram
e_rate());
+ AudioClock::print_minsec (when, buf, sizeof (buf), _session->
sampl
e_rate());
_layout->set_text (std::string(buf).substr(1));
}
break;
_layout->set_text (std::string(buf).substr(1));
}
break;
- case AudioClock::Frames:
+ case AudioClock::Seconds:
+ {
+ char buf[32];
+ snprintf (buf, sizeof (buf), "%.1f", when / (float)_session->sample_rate());
+ _layout->set_text (buf);
+ }
+ break;
+ case AudioClock::Samples:
{
char buf[32];
snprintf (buf, sizeof (buf), "%" PRId64, when);
{
char buf[32];
snprintf (buf, sizeof (buf), "%" PRId64, when);
@@
-306,14
+313,14
@@
MiniTimeline::format_time (framepos_t when)
}
void
}
void
-MiniTimeline::draw_dots (cairo_t* cr, int left, int right, int y,
ArdourCanvas
::Color color)
+MiniTimeline::draw_dots (cairo_t* cr, int left, int right, int y,
Gtkmm2ext
::Color color)
{
if (left + 1 >= right) {
return;
}
cairo_move_to (cr, left + .5, y + .5);
cairo_line_to (cr, right - .5, y + .5);
{
if (left + 1 >= right) {
return;
}
cairo_move_to (cr, left + .5, y + .5);
cairo_line_to (cr, right - .5, y + .5);
-
ArdourCanvas
::set_source_rgb_a(cr, color, 0.3);
+
Gtkmm2ext
::set_source_rgb_a(cr, color, 0.3);
const double dashes[] = { 0, 1 };
cairo_set_dash (cr, dashes, 2, 1);
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
const double dashes[] = { 0, 1 };
cairo_set_dash (cr, dashes, 2, 1);
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
@@
-358,7
+365,7
@@
MiniTimeline::draw_mark (cairo_t* cr, int x0, int x1, const std::string& label,
prelight ? "entered marker" : "location marker");
double r, g, b, a;
prelight ? "entered marker" : "location marker");
double r, g, b, a;
-
ArdourCanvas
::color_to_rgba (color, r, g, b, a);
+
Gtkmm2ext
::color_to_rgba (color, r, g, b, a);
if (rw < x0) {
rw = x1;
if (rw < x0) {
rw = x1;
@@
-445,7
+452,7
@@
MiniTimeline::draw_edge (cairo_t* cr, int x0, int x1, bool left, const std::stri
prelight ? "entered marker" : "location marker");
double r, g, b, a;
prelight ? "entered marker" : "location marker");
double r, g, b, a;
-
ArdourCanvas
::color_to_rgba (color, r, g, b, a);
+
Gtkmm2ext
::color_to_rgba (color, r, g, b, a);
if (with_label) {
const int y = PADDING;
if (with_label) {
const int y = PADDING;
@@
-477,10
+484,10
@@
MiniTimeline::draw_edge (cairo_t* cr, int x0, int x1, bool left, const std::stri
struct LocationMarker {
struct LocationMarker {
- LocationMarker (const std::string& l,
fram
epos_t w)
+ LocationMarker (const std::string& l,
sampl
epos_t w)
: label (l), when (w) {}
std::string label;
: label (l), when (w) {}
std::string label;
-
fram
epos_t when;
+
sampl
epos_t when;
};
struct LocationMarkerSort {
};
struct LocationMarkerSort {
@@
-494,8
+501,8
@@
MiniTimeline::render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_
{
cairo_t* cr = ctx->cobj();
// TODO cache, set_colors()
{
cairo_t* cr = ctx->cobj();
// TODO cache, set_colors()
-
ArdourCanvas
::Color base = UIConfiguration::instance().color ("ruler base");
-
ArdourCanvas
::Color text = UIConfiguration::instance().color ("ruler text");
+
Gtkmm2ext
::Color base = UIConfiguration::instance().color ("ruler base");
+
Gtkmm2ext
::Color text = UIConfiguration::instance().color ("ruler text");
if (_n_labels == 0) {
return;
if (_n_labels == 0) {
return;
@@
-505,7
+512,7
@@
MiniTimeline::render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_
const int height = get_height ();
Gtkmm2ext::rounded_rectangle (cr, 0, 0, width, height, 4);
const int height = get_height ();
Gtkmm2ext::rounded_rectangle (cr, 0, 0, width, height, 4);
-
ArdourCanvas
::set_source_rgba(cr, base);
+
Gtkmm2ext
::set_source_rgba(cr, base);
cairo_fill (cr);
Gtkmm2ext::rounded_rectangle (cr, PADDING, PADDING, width - PADDING - PADDING, height - PADDING - PADDING, 4);
cairo_fill (cr);
Gtkmm2ext::rounded_rectangle (cr, PADDING, PADDING, width - PADDING - PADDING, height - PADDING - PADDING, 4);
@@
-516,12
+523,12
@@
MiniTimeline::render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_
}
/* time */
}
/* time */
- const
framepos_t p = _last_update_fram
e;
- const
framepos_t lower = (std::max ((fram
epos_t)0, (p - _time_span_samples)) / _time_granularity) * _time_granularity;
+ const
samplepos_t p = _last_update_sampl
e;
+ const
samplepos_t lower = (std::max ((sampl
epos_t)0, (p - _time_span_samples)) / _time_granularity) * _time_granularity;
int dot_left = width * .5 + (lower - p) * _px_per_sample;
for (int i = 0; i < 2 + _n_labels; ++i) {
int dot_left = width * .5 + (lower - p) * _px_per_sample;
for (int i = 0; i < 2 + _n_labels; ++i) {
-
fram
epos_t when = lower + i * _time_granularity;
+
sampl
epos_t when = lower + i * _time_granularity;
double xpos = width * .5 + (when - p) * _px_per_sample;
// TODO round to nearest display TC in +/- 1px
double xpos = width * .5 + (when - p) * _px_per_sample;
// TODO round to nearest display TC in +/- 1px
@@
-537,15
+544,15
@@
MiniTimeline::render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_
draw_dots (cr, dot_left, x0, y0 + _time_height * .5, text);
cairo_move_to (cr, x0, y0);
draw_dots (cr, dot_left, x0, y0 + _time_height * .5, text);
cairo_move_to (cr, x0, y0);
-
ArdourCanvas
::set_source_rgba(cr, text);
+
Gtkmm2ext
::set_source_rgba(cr, text);
pango_cairo_show_layout (cr, _layout->gobj());
dot_left = x0 + lw;
}
draw_dots (cr, dot_left, width, height - PADDING - _time_height * .5, text);
/* locations */
pango_cairo_show_layout (cr, _layout->gobj());
dot_left = x0 + lw;
}
draw_dots (cr, dot_left, width, height - PADDING - _time_height * .5, text);
/* locations */
-
framepos_t lmin = std::max ((fram
epos_t)0, (p - _time_span_samples));
-
fram
epos_t lmax = p + _time_span_samples;
+
samplepos_t lmin = std::max ((sampl
epos_t)0, (p - _time_span_samples));
+
sampl
epos_t lmax = p + _time_span_samples;
int tw, th;
_layout->set_text (X_("Marker@"));
int tw, th;
_layout->set_text (X_("Marker@"));
@@
-587,7
+594,7
@@
MiniTimeline::render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_
int id = 0;
for (std::vector<LocationMarker>::const_iterator l = lm.begin(); l != lm.end(); ++id) {
int id = 0;
for (std::vector<LocationMarker>::const_iterator l = lm.begin(); l != lm.end(); ++id) {
-
fram
epos_t when = (*l).when;
+
sampl
epos_t when = (*l).when;
if (when < lmin) {
outside_left = l;
if (++l != lm.end()) {
if (when < lmin) {
outside_left = l;
if (++l != lm.end()) {
@@
-642,7
+649,8
@@
MiniTimeline::render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_
/* playhead on top */
int xc = width * 0.5f;
cairo_set_line_width (cr, 1.0);
/* playhead on top */
int xc = width * 0.5f;
cairo_set_line_width (cr, 1.0);
- cairo_set_source_rgb (cr, 1, 0, 0); // playhead color
+ double r,g,b,a; Gtkmm2ext::color_to_rgba(_phead_color, r,g,b,a);
+ cairo_set_source_rgb (cr, r,g,b); // playhead color
cairo_move_to (cr, xc - .5, 0);
cairo_rel_line_to (cr, 0, height);
cairo_stroke (cr);
cairo_move_to (cr, xc - .5, 0);
cairo_rel_line_to (cr, 0, height);
cairo_stroke (cr);
@@
-662,13
+670,13
@@
MiniTimeline::build_minitl_context_menu ()
assert (_session);
assert (_session);
- const
fram
ecnt_t time_span = _session->config.get_minitimeline_span ();
+ const
sampl
ecnt_t time_span = _session->config.get_minitimeline_span ();
_minitl_context_menu = new Gtk::Menu();
MenuList& items = _minitl_context_menu->items();
// ideally this would have a heading (or rather be a sub-menu to "Visible Time")
_minitl_context_menu = new Gtk::Menu();
MenuList& items = _minitl_context_menu->items();
// ideally this would have a heading (or rather be a sub-menu to "Visible Time")
- std::map<
fram
ecnt_t, std::string> spans;
+ std::map<
sampl
ecnt_t, std::string> spans;
spans[30] = _("30 sec");
spans[60] = _("1 min");
spans[120] = _("2 mins");
spans[30] = _("30 sec");
spans[60] = _("1 min");
spans[120] = _("2 mins");
@@
-677,7
+685,7
@@
MiniTimeline::build_minitl_context_menu ()
spans[1200] = _("20 mins");
RadioMenuItem::Group span_group;
spans[1200] = _("20 mins");
RadioMenuItem::Group span_group;
- for (std::map<
fram
ecnt_t, std::string>::const_iterator i = spans.begin (); i != spans.end (); ++i) {
+ for (std::map<
sampl
ecnt_t, std::string>::const_iterator i = spans.begin (); i != spans.end (); ++i) {
items.push_back (RadioMenuElem (span_group, i->second, sigc::bind (sigc::mem_fun (*this, &MiniTimeline::set_span), i->first)));
if (time_span == i->first) {
static_cast<RadioMenuItem*>(&items.back())->set_active ();
items.push_back (RadioMenuElem (span_group, i->second, sigc::bind (sigc::mem_fun (*this, &MiniTimeline::set_span), i->first)));
if (time_span == i->first) {
static_cast<RadioMenuItem*>(&items.back())->set_active ();
@@
-719,8
+727,8
@@
MiniTimeline::on_button_release_event (GdkEventButton *ev)
}
if (ev->button == 1) {
}
if (ev->button == 1) {
-
framepos_t when = _last_update_fram
e + (ev->x - get_width() * .5) / _px_per_sample;
- _session->request_locate (std::max ((
fram
epos_t)0, when), _session->transport_rolling ());
+
samplepos_t when = _last_update_sampl
e + (ev->x - get_width() * .5) / _px_per_sample;
+ _session->request_locate (std::max ((
sampl
epos_t)0, when), _session->transport_rolling ());
}
return true;
}
return true;
@@
-776,8
+784,8
@@
MiniTimeline::on_scroll_event (GdkEventScroll *ev)
{
if (!_session) { return true; }
if (_session->actively_recording ()) { return true; }
{
if (!_session) { return true; }
if (_session->actively_recording ()) { return true; }
- const
fram
ecnt_t time_span = _session->config.get_minitimeline_span ();
-
framepos_t when = _session->audible_fram
e ();
+ const
sampl
ecnt_t time_span = _session->config.get_minitimeline_span ();
+
samplepos_t when = _session->audible_sampl
e ();
double scale = time_span / 60.0;
double scale = time_span / 60.0;
@@
-792,16
+800,16
@@
MiniTimeline::on_scroll_event (GdkEventScroll *ev)
switch (ev->direction) {
case GDK_SCROLL_UP:
case GDK_SCROLL_RIGHT:
switch (ev->direction) {
case GDK_SCROLL_UP:
case GDK_SCROLL_RIGHT:
- when += scale * _session->nominal_
fram
e_rate ();
+ when += scale * _session->nominal_
sampl
e_rate ();
break;
case GDK_SCROLL_DOWN:
case GDK_SCROLL_LEFT:
break;
case GDK_SCROLL_DOWN:
case GDK_SCROLL_LEFT:
- when -= scale * _session->nominal_
fram
e_rate ();
+ when -= scale * _session->nominal_
sampl
e_rate ();
break;
default:
return true;
break;
}
break;
default:
return true;
break;
}
- _session->request_locate (std::max ((
fram
epos_t)0, when), _session->transport_rolling ());
+ _session->request_locate (std::max ((
sampl
epos_t)0, when), _session->transport_rolling ());
return true;
}
return true;
}