double CTimeBar::pixel_to_position(int pixel)
{
- double start = 0, length = 0;
+ double start = 0, end = get_edl_length();
EDL *edl = get_edl();
if( edl ) {
- start = edl->local_session->preview_start;
- if( start >= 0 )
- length = edl->local_session->preview_end - start;
+ double preview_start = edl->local_session->preview_start;
+ double preview_end = edl->local_session->preview_end;
+ if( preview_end >= 0 || preview_start > 0 )
+ start = preview_start;
+ if( preview_end >= 0 && preview_end < end )
+ end = preview_end;
}
- if( length <= 0 )
- length = get_edl_length();
- return start + (double)pixel * length / get_w();
+ if( start > end ) start = end;
+ return start + (double)pixel * (end - start) / get_w();
}
void CWindowEditing::to_clip()
{
- mwindow->to_clip(mwindow->edl, _("composer window: "), 0);
+ mwindow->to_clip(mwindow->edl, _("composer window: "), 0);
}
void CWindowSlider::set_position()
{
double new_length = mwindow->edl->tracks->total_length();
-// if(mwindow->edl->local_session->preview_end <= 0 ||
-// mwindow->edl->local_session->preview_end > new_length)
-// mwindow->edl->local_session->preview_end = new_length;
-// if(mwindow->edl->local_session->preview_start >
-// mwindow->edl->local_session->preview_end)
-// mwindow->edl->local_session->preview_start = 0;
-
-
update(mwindow->theme->cslider_w,
mwindow->edl->local_session->get_selectionstart(1),
- 0,
- new_length);
-// mwindow->edl->local_session->preview_start,
-// mwindow->edl->local_session->preview_end);
+ 0, new_length);
}
redraw = 1;
}
}
- else
+ else
// Translate all 4 points
if(gui->current_operation == CWINDOW_CROP && gui->crop_translate)
{
void EDL::optimize()
{
//printf("EDL::optimize 1\n");
- if( local_session->preview_start < 0 ) local_session->preview_start = 0;
double length = tracks->total_length();
- if( local_session->preview_end > length ) local_session->preview_end = length;
- if( local_session->preview_start >= local_session->preview_end ) {
- local_session->preview_start = 0;
- local_session->preview_end = length;
- }
+ double preview_start = local_session->preview_start;
+ double preview_end = local_session->preview_end;
+ if( preview_end < 0 || preview_end > length )
+ preview_end = length;
+ if( preview_start == 0 && preview_end >= length )
+ local_session->preview_end = -1;
+ if( preview_start > preview_end )
+ local_session->preview_start = preview_end;
for( Track *current=tracks->first; current; current=NEXT )
current->optimize();
}
loop_start = loop_end = 0;
playback_start = -1;
playback_end = 0;
- preview_start = preview_end = 0;
+ preview_start = 0; preview_end = -1;
zoom_sample = DEFAULT_ZOOM_TIME;
zoom_y = 0;
zoom_track = 0;
file->tag.set_property("ZOOM_TRACK", zoom_track);
double preview_start = this->preview_start - start;
- if(preview_start < 0) preview_start = 0;
+ if( preview_start < 0 ) preview_start = 0;
double preview_end = this->preview_end - start;
- if(preview_end < 0) preview_end = 0;
-
+ if( preview_end < preview_start ) preview_end = -1;
file->tag.set_property("PREVIEW_START", preview_start);
file->tag.set_property("PREVIEW_END", preview_end);
file->tag.set_property("FLOATAUTO_TYPE", floatauto_type);
edl->session->proxy_auto_scale = 0;
edl->session->proxy_beep = 0;
edl->local_session->preview_start = 0;
- edl->local_session->preview_end = 0;
+ edl->local_session->preview_end = -1;
edl->local_session->loop_playback = 0;
edl->local_session->set_selectionstart(0);
edl->local_session->set_selectionend(0);
void MWindowGUI::update_proxy_toggle()
{
+ int value = mwindow->edl->session->proxy_scale == 1 ? 1 : 0;
+ proxy_toggle->set_value(value);
if( mwindow->edl->session->proxy_scale == 1 &&
mwindow->edl->session->proxy_disabled_scale == 1 )
proxy_toggle->hide();
int TimeBar::get_preview_pixels(int &x1, int &x2)
{
- x1 = 0;
- x2 = 0;
-
+ x1 = 0; x2 = get_w();
get_edl_length();
-
- if( get_edl() ) {
- if( !EQUIV(edl_length, 0) ) {
- if( get_edl()->local_session->preview_end <= 0 ||
- get_edl()->local_session->preview_end > edl_length )
- get_edl()->local_session->preview_end = edl_length;
- if( get_edl()->local_session->preview_start >
- get_edl()->local_session->preview_end )
- get_edl()->local_session->preview_start = 0;
- x1 = (int)(get_edl()->local_session->preview_start / time_per_pixel);
- x2 = (int)(get_edl()->local_session->preview_end / time_per_pixel);
- }
- else {
- x1 = 0;
- x2 = get_w();
+ EDL *edl = get_edl();
+ if( edl && !EQUIV(edl_length, 0) ) {
+ double preview_start = edl->local_session->preview_start;
+ double preview_end = edl->local_session->preview_end;
+ if( preview_end < 0 || preview_end > edl_length )
+ preview_end = edl_length;
+ if( preview_end >= preview_start ) {
+ x1 = (int)(preview_start / time_per_pixel);
+ x2 = (int)(preview_end / time_per_pixel);
}
}
-// printf("TimeBar::get_preview_pixels %f %f %d %d\n",
-// get_edl()->local_session->preview_start,
-// get_edl()->local_session->preview_end,
-// x1,
-// x2);
return 0;
}
if( buttonpress ) {
current_operation = TIMEBAR_DRAG_RIGHT;
start_position = get_edl()->local_session->preview_end;
+ if( start_position < 0 || start_position > edl_length )
+ start_position = edl_length;
start_cursor_x = x;
}
else if( get_cursor() != RIGHT_CURSOR )
current_operation = TIMEBAR_DRAG_CENTER;
starting_start_position = get_edl()->local_session->preview_start;
starting_end_position = get_edl()->local_session->preview_end;
+ if( starting_end_position < 0 || starting_end_position > edl_length )
+ starting_end_position = edl_length;
start_cursor_x = x;
}
if( get_cursor() != HSEPARATE_CURSOR )
int TimeBar::move_preview(int &redraw)
{
int result = 0, x = get_relative_cursor_x();
-
- if( current_operation == TIMEBAR_DRAG_LEFT ) {
+ switch( current_operation ) {
+ case TIMEBAR_DRAG_LEFT: {
get_edl()->local_session->preview_start =
start_position + time_per_pixel * (x - start_cursor_x);
- CLAMP(get_edl()->local_session->preview_start,
- 0,
- get_edl()->local_session->preview_end);
+ double preview_end = get_edl()->local_session->preview_end;
+ if( preview_end < 0 || preview_end > edl_length )
+ preview_end = get_edl()->local_session->preview_end = edl_length;
+ CLAMP(get_edl()->local_session->preview_start, 0, preview_end);
result = 1;
- }
- else
- if( current_operation == TIMEBAR_DRAG_RIGHT ) {
- get_edl()->local_session->preview_end =
+ break; }
+ case TIMEBAR_DRAG_RIGHT: {
+ double preview_end = get_edl()->local_session->preview_end =
start_position + time_per_pixel * (x - start_cursor_x);
- CLAMP(get_edl()->local_session->preview_end,
- get_edl()->local_session->preview_start,
- edl_length);
+ double preview_start = get_edl()->local_session->preview_start;
+ if( preview_end >= edl_length && !preview_start ) {
+ get_edl()->local_session->preview_end = -1;
+ if( preview_start > preview_end )
+ preview_start = get_edl()->local_session->preview_start = preview_end;
+ }
+ else
+ CLAMP(get_edl()->local_session->preview_end, preview_start, edl_length);
result = 1;
- }
- else
- if( current_operation == TIMEBAR_DRAG_CENTER ) {
+ break; }
+ case TIMEBAR_DRAG_CENTER: {
double dt = time_per_pixel * (x - start_cursor_x);
get_edl()->local_session->preview_start = starting_start_position + dt;
get_edl()->local_session->preview_end = starting_end_position + dt;
get_edl()->local_session->preview_end = edl_length;
}
result = 1;
+ break; }
}
//printf("TimeBar::move_preview %d %d\n", __LINE__, current_operation);
double VTimeBar::pixel_to_position(int pixel)
{
- double start = 0, length = 0;
+ double start = 0, end = get_edl_length();
EDL *edl = get_edl();
- if(edl)
- {
- start = edl->local_session->preview_start;
- if(start >= 0)
- length = edl->local_session->preview_end - start;
+ if( edl ) {
+ double preview_start = edl->local_session->preview_start;
+ double preview_end = edl->local_session->preview_end;
+ if( preview_end >= 0 || preview_start > 0 )
+ start = preview_start;
+ if( preview_end >= 0 && preview_end < end )
+ end = preview_end;
}
- if(length <= 0)
- length = get_edl_length();
- return start + (double)pixel * length / get_w();
+ if( start > end ) start = end;
+ return start + (double)pixel * (end - start) / get_w();
}
+
void VTimeBar::update_cursor()
{
int rx = get_relative_cursor_x();
mwindow->edl->append_vwindow_edl(edl, 1);
this->edl = edl;
this->edl->Garbage::add_user();
-
+ edl->local_session->preview_start = 0;
+ edl->local_session->preview_end = -1;
// mwindow->edl->vwindow_edl = edl;
// in order not to later delete edl if it is shared
// edl->Garbage::add_user();