, layout_x_offset (0)
, em_width (0)
, _edit_by_click_field (false)
+ , _negative_allowed (false)
+ , edit_is_negative (false)
, editing_attr (0)
, foreground_attr (0)
, first_height (0)
tmp->set_text ("8");
tmp->get_pixel_size (em_width, ignore_height);
+
+ /* force redraw of markup with new font-size */
+ set (last_when, true);
}
void
_layout->set_attributes (editing_attributes);
}
- if (_left_layout) {
- _left_layout->set_attributes (info_attributes);
- _right_layout->set_attributes (info_attributes);
- }
-
queue_draw ();
}
cairo_set_source_rgba (cr, bg_r, bg_g, bg_b, bg_a);
if (corner_radius) {
if (_left_layout) {
- Gtkmm2ext::rounded_top_half_rectangle (cr, 0, 0, get_width() - corner_radius/2.0, upper_height, corner_radius);
+ Gtkmm2ext::rounded_top_half_rectangle (cr, 0, 0, get_width(), upper_height, corner_radius);
} else {
Gtkmm2ext::rounded_rectangle (cr, 0, 0, get_width(), upper_height, corner_radius);
}
if (!_fixed_width) {
cairo_move_to (cr, layout_x_offset, 0);
} else {
- int xcenter = layout_x_offset != 0 ? 0 : (get_width() - _mode_width[_mode]) /2;
+ int xcenter = layout_x_offset > 0 ? 0 : (get_width() - _mode_width[_mode]) /2;
cairo_move_to (cr, layout_x_offset + xcenter, (upper_height - layout_height) / 2.0);
}
if (corner_radius) {
Gtkmm2ext::rounded_bottom_half_rectangle (cr, 0, upper_height + separator_height,
left_rect_width + (separator_height == 0 ? corner_radius : 0),
- h - corner_radius/2.0, corner_radius);
+ h, corner_radius);
} else {
cairo_rectangle (cr, 0, upper_height + separator_height, left_rect_width, h);
}
if (corner_radius) {
Gtkmm2ext::rounded_bottom_half_rectangle (cr, left_rect_width + separator_height,
upper_height + separator_height,
- get_width() - separator_height - left_rect_width - corner_radius/2.0,
- h - corner_radius/2.0, corner_radius);
+ get_width() - separator_height - left_rect_width,
+ h, corner_radius);
} else {
cairo_rectangle (cr, left_rect_width + separator_height, upper_height + separator_height,
get_width() - separator_height - left_rect_width, h);
*/
int x, rw, rh;
_right_layout->get_pixel_size(rw, rh);
- x = get_width() - rw- separator_height - x_leading_padding;
+ x = get_width() - rw - separator_height - x_leading_padding;
if (x < x_leading_padding + left_rect_width + separator_height) {
+ /* rather cut off the right end than overlap with the text on the left */
x = x_leading_padding + left_rect_width + separator_height;
}
cairo_move_to (cr, x, upper_height + separator_height + ((h - info_height)/2.0));
if (editing) {
if (!insert_map.empty()) {
- int xcenter = layout_x_offset != 0 ? 0 : (get_width() - _mode_width[_mode]) /2;
+ int xcenter = layout_x_offset > 0 ? 0 : (get_width() - _mode_width[_mode]) /2;
if (input_string.length() < insert_map.size()) {
Pango::Rectangle cursor;
int ignored;
tmp->set_text ("-88:88:88:88");
tmp->get_pixel_size (_mode_width[Timecode], ignored);
- tmp->set_text (" 8888|88|8888");
+ tmp->set_text (" 88888|88|8888");
tmp->get_pixel_size (_mode_width[BBT], ignored);
tmp->set_text (" 88:88:88,888");
tmp->get_pixel_size (_mode_width[MinSec], ignored);
not be sufficient for 24h worth of BBT
*/
- tmp->set_text (" 8888888888::,");
+ tmp->set_text (" 88888888888::,");
} else {
switch (_mode) {
case Timecode:
tmp->set_text ("-88:88:88:88");
break;
case BBT:
- tmp->set_text (" 8888|88|8888");
+ tmp->set_text (" 88888|88|8888");
break;
case MinSec:
tmp->set_text (" 88:88:88,888");
req->height += separator_height;
}
- req->height += corner_radius/2.0;
- req->width += corner_radius/2.0;
-
first_height = req->height;
first_width = req->width;
}
edit_string.clear ();
_layout->set_text ("");
}
+
input_string.clear ();
editing = true;
+ edit_is_negative = false;
if (f) {
input_string = get_field (f);
} else {
editing = false;
+ edit_is_negative = false;
_layout->set_attributes (normal_attributes);
_layout->set_text (pre_edit_string);
}
} else {
framepos_t c = current_time();
- if (c > frames) {
+ if (c > frames || _negative_allowed) {
set (c - frames, true);
} else {
set (0, true);
drop_focus ();
}
+void
+AudioClock::session_property_changed (const PropertyChange& p)
+{
+ set (last_when, true);
+}
+
void
AudioClock::session_configuration_changed (std::string p)
{
+ if (_negative_allowed) {
+ /* session option editor clock */
+ return;
+ }
+
if (p == "sync-source" || p == "external-sync") {
set (current_time(), true);
return;
}
if (when == last_when && !force) {
- if (_mode != Timecode) {
- /* timecode may need to force display of TC source
+ if (_mode != Timecode && _mode != MinSec) {
+ /* may need to force display of TC source
* time, so don't return early.
*/
return;
break;
case MinSec:
+ if (_right_layout) {
+ _right_layout->set_alignment(Pango::ALIGN_RIGHT);
+ }
set_minsec (when, force);
break;
last_when = when;
}
+void
+AudioClock::set_slave_info ()
+{
+ if (!_left_layout || !_right_layout) {
+ return;
+ }
+
+ SyncSource sync_src = Config->get_sync_source();
+
+ if (_session->config.get_external_sync()) {
+ Slave* slave = _session->slave();
+
+ switch (sync_src) {
+ case JACK:
+ _left_layout->set_markup (string_compose ("<span size=\"%1\" foreground=\"white\">%2</span>",
+ INFO_FONT_SIZE, sync_source_to_string(sync_src, true)));
+ _right_layout->set_text ("");
+ break;
+ case MIDIClock:
+ if (slave) {
+ _left_layout->set_markup (string_compose ("<span size=\"%1\" foreground=\"white\">%2</span>",
+ INFO_FONT_SIZE, sync_source_to_string(sync_src, true)));
+ _right_layout->set_markup (string_compose ("<span size=\"%1\" foreground=\"white\">%2</span>",
+ INFO_FONT_SIZE, slave->approximate_current_delta()));
+ } else {
+ _left_layout->set_markup (string_compose ("<span size=\"%1\" foreground=\"white\">%2</span>",
+ INFO_FONT_SIZE, _("--pending--")));
+ _right_layout->set_text ("");
+ }
+ break;
+ case LTC:
+ case MTC:
+ if (slave) {
+ bool matching;
+ TimecodeSlave* tcslave;
+ if ((tcslave = dynamic_cast<TimecodeSlave*>(_session->slave())) != 0) {
+ matching = (tcslave->apparent_timecode_format() == _session->config.get_timecode_format());
+ _left_layout->set_markup (string_compose ("<span size=\"%1\"><span foreground=\"white\">%2</span><span foreground=\"%3\">%4</span></span>",
+ INFO_FONT_SIZE, sync_source_to_string(sync_src, true)[0], (matching?"green":"red"),
+ dynamic_cast<TimecodeSlave*>(slave)->approximate_current_position()));
+ _right_layout->set_markup (string_compose ("<span size=\"%1\" foreground=\"white\">%2</span>",
+ INFO_FONT_SIZE, slave->approximate_current_delta()));
+ }
+ } else {
+ _left_layout->set_markup (string_compose ("<span size=\"%1\" foreground=\"white\">%2</span>",
+ INFO_FONT_SIZE, _("--pending--")));
+ _right_layout->set_text ("");
+ }
+ break;
+ }
+ } else {
+ _left_layout->set_markup (string_compose ("<span size=\"%1\" foreground=\"white\">INT/%2</span>",
+ INFO_FONT_SIZE, sync_source_to_string(sync_src, true)));
+ _right_layout->set_text ("");
+ }
+}
+
void
AudioClock::set_frames (framepos_t when, bool /*force*/)
{
float vid_pullup = _session->config.get_video_pullup();
if (vid_pullup == 0.0) {
- _right_layout->set_markup (string_compose ("<span size=\"%1\" foreground=\"white\">%2</span>",
- INFO_FONT_SIZE, _("pullup: \u2012")));
+ _right_layout->set_markup (string_compose ("<span size=\"%1\"><span foreground=\"white\">%2 </span><span foreground=\"green\">off</span></span>",
+ INFO_FONT_SIZE, _("Pull")));
} else {
- sprintf (buf, _("%+-6.4f%%"), vid_pullup);
- _right_layout->set_markup (string_compose ("<span size=\"%1\" foreground=\"green\">%2</span>",
- INFO_FONT_SIZE, buf));
+ sprintf (buf, _("%+.4f%%"), vid_pullup);
+ _right_layout->set_markup (string_compose ("<span size=\"%1\"><span foreground=\"white\">%2 </span><span foreground=\"green\">%3</span></span>",
+ INFO_FONT_SIZE, _("Pull"), buf));
}
}
}
}
_layout->set_text (buf);
+ set_slave_info();
}
void
_layout->set_text (Timecode::timecode_format_time(TC));
- if (_left_layout && _right_layout) {
-
- SyncSource sync_src = Config->get_sync_source();
-
- if (_session->config.get_external_sync()) {
- Slave* slave = _session->slave();
-
- switch (sync_src) {
- case JACK:
- _left_layout->set_markup (string_compose ("<span size=\"%1\" foreground=\"white\">%2</span>",
- INFO_FONT_SIZE, sync_source_to_string(sync_src, true)));
- _right_layout->set_text ("");
- break;
- case LTC:
- case MTC:
- case MIDIClock:
- if (slave) {
- _left_layout->set_markup (string_compose ("<span size=\"%1\" foreground=\"green\">%2</span>",
- INFO_FONT_SIZE, dynamic_cast<TimecodeSlave*>(slave)->approximate_current_position()));
- _right_layout->set_markup (string_compose ("<span size=\"%1\" foreground=\"white\">%2</span>",
- INFO_FONT_SIZE, slave->approximate_current_delta()));
- } else {
- _left_layout->set_markup (string_compose ("<span size=\"%1\" foreground=\"white\">%2</span>",
- INFO_FONT_SIZE, _("--pending--")));
- _right_layout->set_text ("");
- }
- break;
- }
- } else {
- _left_layout->set_markup (string_compose ("<span size=\"%1\" foreground=\"white\">INT/%2</span>",
- INFO_FONT_SIZE, sync_source_to_string(sync_src, true)));
- _right_layout->set_text ("");
- }
- }
+ set_slave_info();
}
void
TempoMetric m (_session->tempo_map().metric_at (pos));
sprintf (buf, "%-5.2f", m.tempo().beats_per_minute());
- _left_layout->set_markup (string_compose ("<span size=\"%1\" foreground=\"green\">%2</span>",
+ _left_layout->set_markup (string_compose ("<span size=\"%1\" foreground=\"white\">Tempo <span foreground=\"green\">%2</span></span>",
INFO_FONT_SIZE, buf));
sprintf (buf, "%g/%g", m.meter().divisions_per_bar(), m.meter().note_divisor());
- _right_layout->set_markup (string_compose ("<span size=\"%1\" foreground=\"green\">%2</span>",
+ _right_layout->set_markup (string_compose ("<span size=\"%1\" foreground=\"white\">Meter <span foreground=\"green\">%2</span></span>",
INFO_FONT_SIZE, buf));
}
}
if (_session) {
_session->config.ParameterChanged.connect (_session_connections, invalidator (*this), boost::bind (&AudioClock::session_configuration_changed, this, _1), gui_context());
+ _session->tempo_map().PropertyChanged.connect (_session_connections, invalidator (*this), boost::bind (&AudioClock::session_property_changed, this, _1), gui_context());
const XMLProperty* prop;
XMLNode* node = _session->extra_xml (X_("ClockModes"));
case GDK_minus:
case GDK_KP_Subtract:
- end_edit_relative (false);
+ if (_negative_allowed && input_string.empty()) {
+ edit_is_negative = true;
+ edit_string.replace(0,1,"-");
+ _layout->set_text (edit_string);
+ queue_draw ();
+ } else {
+ end_edit_relative (false);
+ }
return true;
break;
case GDK_plus:
- case GDK_KP_Add:
end_edit_relative (true);
return true;
break;
highlight_length = merge_input_and_edit_string ();
}
+ if (edit_is_negative) {
+ edit_string.replace(0,1,"-");
+ } else {
+ if (pre_edit_string.at(0) == '-') {
+ edit_string.replace(0,1,"_");
+ } else {
+ edit_string.replace(0,1," ");
+ }
+ }
+
show_edit_status (highlight_length);
_layout->set_text (edit_string);
queue_draw ();
/* the text has been centered vertically, so adjust
* x and y.
*/
+ int xcenter = !_fixed_width || layout_x_offset > 0 ? 0 : (get_width() - _mode_width[_mode]) /2;
y = ev->y - ((upper_height - layout_height)/2);
- x = ev->x - layout_x_offset;
+ x = ev->x - layout_x_offset - xcenter;
if (!_layout->xy_to_index (x * PANGO_SCALE, y * PANGO_SCALE, index, trailing)) {
/* pretend it is a character on the far right */
if (_edit_by_click_field) {
+ int xcenter = !_fixed_width || layout_x_offset > 0 ? 0 : (get_width() - _mode_width[_mode]) /2;
int index = 0;
int trailing;
int y = ev->y - ((upper_height - layout_height)/2);
- int x = ev->x - layout_x_offset;
+ int x = ev->x - layout_x_offset - xcenter;
Field f;
if (!_layout->xy_to_index (x * PANGO_SCALE, y * PANGO_SCALE, index, trailing)) {
* x and y.
*/
+ int xcenter = !_fixed_width || layout_x_offset > 0 ? 0 : (get_width() - _mode_width[_mode]) /2;
y = ev->y - ((upper_height - layout_height)/2);
- x = ev->x - layout_x_offset;
+ x = ev->x - layout_x_offset - xcenter;
if (!_layout->xy_to_index (x * PANGO_SCALE, y * PANGO_SCALE, index, trailing)) {
/* not in the main layout */
frames *= 10;
}
- if ((double)current_time() - (double)frames < 0.0) {
+ if (!_negative_allowed && (double)current_time() - (double)frames < 0.0) {
set (0, true);
} else {
set (current_time() - frames, true);
AudioClock::timecode_validate_edit (const string&)
{
Timecode::Time TC;
+ int hours;
+ char ignored[2];
+
+ if (sscanf (_layout->get_text().c_str(), "%" PRId32 ":%" PRId32 ":%" PRId32 "%[:;]%" PRId32,
+ &hours, &TC.minutes, &TC.seconds, ignored, &TC.frames) != 5) {
+ return false;
+ }
+
+ if (hours < 0) {
+ TC.hours = hours * -1;
+ TC.negative = true;
+ } else {
+ TC.hours = hours;
+ TC.negative = false;
+ }
- if (sscanf (_layout->get_text().c_str(), "%" PRId32 ":%" PRId32 ":%" PRId32 ":%" PRId32,
- &TC.hours, &TC.minutes, &TC.seconds, &TC.frames) != 4) {
+ if (TC.negative && !_negative_allowed) {
return false;
}
Timecode::Time TC;
framepos_t sample;
+ char ignored[2];
+ int hours;
- if (sscanf (str.c_str(), "%d:%d:%d:%d", &TC.hours, &TC.minutes, &TC.seconds, &TC.frames) != 4) {
+ if (sscanf (str.c_str(), "%d:%d:%d%[:;]%d", &hours, &TC.minutes, &TC.seconds, ignored, &TC.frames) != 5) {
error << string_compose (_("programming error: %1 %2"), "badly formatted timecode clock string", str) << endmsg;
return 0;
}
-
+ TC.hours = abs(hours);
TC.rate = _session->timecode_frames_per_second();
TC.drop= _session->timecode_drop_frames();
_session->timecode_to_sample (TC, sample, false /* use_offset */, false /* use_subframes */ );
// timecode_tester ();
+ if (edit_is_negative) {
+ sample = - sample;
+ }
return sample;
}
int ignored;
_left_layout->set_text (" 1234567890");
_left_layout->get_pixel_size (ignored, info_height);
- info_height += 4;
_left_layout->set_text ("");
_right_layout->set_text ("");
break;
case MinSec:
- mode_based_info_ratio = 1.0;
+ mode_based_info_ratio = 0.5;
insert_map.push_back (12);
insert_map.push_back (11);
insert_map.push_back (10);
first_height = 0;
queue_resize ();
}
+
+void
+AudioClock::set_negative_allowed (bool yn)
+{
+ _negative_allowed = yn;
+}