// coords relative to pixmap
int64_t total_x = edit_x - pixmap_x, total_w = edit_w;
int64_t x = total_x, w = total_w;
- int left_margin = 10;
+ int left_margin = xS(10);
if( x < 0 ) { w -= -x; x = 0; }
if( w > pixmap_w ) w -= w - pixmap_w;
text_x = MAX(left_margin, text_x);
//printf("ResourcePixmap::draw_title 1 %d\n", text_x);
canvas->draw_text(text_x, // 2,
- canvas->get_text_ascent(mwindow->theme->title_font) + 2,
+ canvas->get_text_ascent(mwindow->theme->title_font) + yS(2),
title, strlen(title), this);
}
IndexState *index_state = indexable->index_state;
double asset_over_session = (double)indexable->get_sample_rate() /
mwindow->edl->session->sample_rate;
-
// Develop strategy for drawing
// printf("ResourcePixmap::draw_audio_resource %d %p %d\n",
// __LINE__,
{
case INDEX_NOTTESTED:
return;
- break;
// Disabled. All files have an index.
// case INDEX_TOOSMALL:
// draw_audio_source(canvas, edit, x, w);
// break;
case INDEX_BUILDING:
- case INDEX_READY:
- {
+ case INDEX_READY: {
IndexFile indexfile(mwindow, indexable);
if( !indexfile.open_index() ) {
if( index_state->index_zoom >
- mwindow->edl->local_session->zoom_sample *
+ mwindow->edl->local_session->zoom_sample *
asset_over_session ) {
-//printf("ResourcePixmap::draw_audio_resource %d\n", __LINE__);
-
draw_audio_source(canvas, edit, x, w);
}
else {
-//printf("ResourcePixmap::draw_audio_resource %d\n", __LINE__);
- indexfile.draw_index(canvas,
- this,
- edit,
- x,
- w);
-SET_TRACE
+ indexfile.draw_index(canvas, this, edit, x, w);
}
-
indexfile.close_index();
-SET_TRACE
}
break;
}
}
+ if( !mwindow->preferences->rectify_audio ) {
+ int center_pixel = calculate_center_pixel(edit->track);
+ canvas->set_line_dashes(1);
+ canvas->set_color(mwindow->theme->zero_crossing_color);
+ canvas->draw_line(x, center_pixel, x + w, center_pixel, this);
+ canvas->set_line_dashes(0);
+ }
}
-void ResourcePixmap::draw_audio_source(TrackCanvas *canvas, Edit *edit, int x, int w)
+int ResourcePixmap::calculate_center_pixel(Track *track)
{
- w++;
- Indexable *indexable = edit->get_source();
int rect_audio = mwindow->preferences->rectify_audio;
int center_pixel = !rect_audio ?
mwindow->edl->local_session->zoom_track / 2 :
mwindow->edl->local_session->zoom_track ;
- if( edit->track->show_titles() )
+ if( track->show_titles() )
center_pixel += mwindow->theme->get_image("title_bg_data")->get_h();
+ return center_pixel;
+}
+
+void ResourcePixmap::draw_audio_source(TrackCanvas *canvas, Edit *edit, int x, int w)
+{
+ w++;
+ Indexable *indexable = edit->get_source();
+ int center_pixel = calculate_center_pixel(edit->track);
+ int rect_audio = mwindow->preferences->rectify_audio;
int64_t scale_y = !rect_audio ?
mwindow->edl->local_session->zoom_y :
mwindow->edl->local_session->zoom_y * 2;
int y1 = center_pixel - sample * scale_y / 2;
int y2 = CLIP(y1, 0, y_max);
- for( int x0=0; x0<w; ++x0 ) {
- int x1 = x0 + x, x2 = x1 + 1;
+ for( int x1=x; x1<w; ++x1 ) {
+ int x2 = x1 + 1;
edit_position = (x1 + pixmap_x - edit_x) * project_zoom;
int64_t speed_position = edit->startsource;
speed_position += !speed_autos ? edit_position :
y1 = center_pixel - sample * scale_y / 2;
y2 = CLIP(y1, 0, y_max);
//printf("ResourcePixmap::draw_audio_source %d %d %d\n", __LINE__, y1, y2);
- canvas->draw_line(x0, y0, x2, y2, this);
+ if( !rect_audio )
+ canvas->draw_line(x1, y0, x2, y2, this);
+ else
+ canvas->draw_line(x2, center_pixel, x2, y2, this);
}
}
y_lo = y1; y_hi = y2;
}
prev_y1 = y1; prev_y2 = y2;
- canvas->draw_line(x, y_lo, x, y_hi, this);
+ canvas->draw_line(x, !rect_audio ? y_lo : center_pixel, x, y_hi, this);
//printf("ResourcePixmap::draw_audio_source %d %d %d %d\n", __LINE__, x, y1, y2);
mwindow->wave_cache->unlock();
}
CLAMP(y1, top_pixel, bottom_pixel);
CLAMP(y2, top_pixel, bottom_pixel);
canvas->set_color(mwindow->theme->audio_color);
- canvas->draw_line(x, y1, x, y2, this);
+ canvas->draw_line(x, !rect_audio ? y1 : bottom_pixel, x, y2, this);
}
{
SEdit *sedit = (SEdit *)edit;
char *text = sedit->get_text();
- if( !*text || w < 10 ) return;
+ if( !*text || w < xS(10) ) return;
int center_pixel = canvas->resource_h() / 2;
if( edit->track->show_titles() )
center_pixel += mwindow->theme->get_image("title_bg_data")->get_h();
canvas->set_color(color);
int ch = canvas->get_text_height(font);
int hh = canvas->get_text_height(font,text) + ch/2;
- int y1 = y_max - hh - 10;
+ int y1 = y_max - hh - yS(10);
if( y1 < 0 ) y1 = 0;
canvas->draw_text(x1, y1, text, -1, this);
}