Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

timebar.C

Go to the documentation of this file.
00001 #include "bcsignals.h"
00002 #include "clip.h"
00003 #include "cplayback.h"
00004 #include "cursors.h"
00005 #include "cwindow.h"
00006 #include "edl.h"
00007 #include "edlsession.h"
00008 #include "filexml.h"
00009 #include "fonts.h"
00010 #include "labels.h"
00011 #include "localsession.h"
00012 #include "maincursor.h"
00013 #include "mainundo.h"
00014 #include "mbuttons.h"
00015 #include "mwindow.h"
00016 #include "mwindowgui.h"
00017 #include "patchbay.h"
00018 #include "preferences.h"
00019 #include "recordlabel.h"
00020 #include "localsession.h"
00021 #include "mainsession.h"
00022 #include "theme.h"
00023 #include "timebar.h"
00024 #include "trackcanvas.h"
00025 #include "tracks.h"
00026 #include "transportque.h"
00027 #include "units.h"
00028 #include "vframe.h"
00029 #include "vwindow.h"
00030 #include "vwindowgui.h"
00031 #include "zoombar.h"
00032 
00033 
00034 LabelGUI::LabelGUI(MWindow *mwindow, 
00035         TimeBar *timebar, 
00036         int64_t pixel, 
00037         int y, 
00038         double position,
00039         VFrame **data)
00040  : BC_Toggle(translate_pixel(mwindow, pixel), 
00041                 y, 
00042                 data ? data : mwindow->theme->label_toggle,
00043                 0)
00044 {
00045         this->mwindow = mwindow;
00046         this->timebar = timebar;
00047         this->gui = 0;
00048         this->pixel = pixel;
00049         this->position = position;
00050 }
00051 
00052 LabelGUI::~LabelGUI()
00053 {
00054 }
00055 
00056 int LabelGUI::get_y(MWindow *mwindow, TimeBar *timebar)
00057 {
00058         return timebar->get_h() - 
00059                 mwindow->theme->label_toggle[0]->get_h();
00060 }
00061 
00062 int LabelGUI::translate_pixel(MWindow *mwindow, int pixel)
00063 {
00064         int result = pixel - mwindow->theme->label_toggle[0]->get_w() / 2;
00065         return result;
00066 }
00067 
00068 void LabelGUI::reposition()
00069 {
00070         reposition_window(translate_pixel(mwindow, pixel), BC_Toggle::get_y());
00071 }
00072 
00073 int LabelGUI::handle_event()
00074 {
00075         timebar->select_label(position);
00076         return 1;
00077 }
00078 
00079 
00080 
00081 
00082 
00083 
00084 
00085 
00086 InPointGUI::InPointGUI(MWindow *mwindow, 
00087         TimeBar *timebar, 
00088         int64_t pixel, 
00089         double position)
00090  : LabelGUI(mwindow, 
00091         timebar, 
00092         pixel, 
00093         get_y(mwindow, timebar), 
00094         position, 
00095         mwindow->theme->in_point)
00096 {
00097 //printf("InPointGUI::InPointGUI %d %d\n", pixel, get_y(mwindow, timebar));
00098 }
00099 InPointGUI::~InPointGUI()
00100 {
00101 }
00102 int InPointGUI::get_y(MWindow *mwindow, TimeBar *timebar)
00103 {
00104         int result;
00105         result = timebar->get_h() - 
00106                 mwindow->theme->in_point[0]->get_h();
00107         return result;
00108 }
00109 
00110 
00111 OutPointGUI::OutPointGUI(MWindow *mwindow, 
00112         TimeBar *timebar, 
00113         int64_t pixel, 
00114         double position)
00115  : LabelGUI(mwindow, 
00116         timebar, 
00117         pixel, 
00118         get_y(mwindow, timebar), 
00119         position, 
00120         mwindow->theme->out_point)
00121 {
00122 //printf("OutPointGUI::OutPointGUI %d %d\n", pixel, get_y(mwindow, timebar));
00123 }
00124 OutPointGUI::~OutPointGUI()
00125 {
00126 }
00127 int OutPointGUI::get_y(MWindow *mwindow, TimeBar *timebar)
00128 {
00129         return timebar->get_h() - 
00130                 mwindow->theme->out_point[0]->get_h();
00131 }
00132 
00133 
00134 PresentationGUI::PresentationGUI(MWindow *mwindow, 
00135         TimeBar *timebar, 
00136         int64_t pixel, 
00137         double position)
00138  : LabelGUI(mwindow, timebar, pixel, get_y(mwindow, timebar), position)
00139 {
00140 }
00141 PresentationGUI::~PresentationGUI()
00142 {
00143 }
00144 
00145 
00146 
00147 
00148 
00149 
00150 
00151 TimeBar::TimeBar(MWindow *mwindow, 
00152         BC_WindowBase *gui,
00153         int x, 
00154         int y,
00155         int w,
00156         int h)
00157  : BC_SubWindow(x, y, w, h)
00158 {
00159 //printf("TimeBar::TimeBar %d %d %d %d\n", x, y, w, h);
00160         this->gui = gui;
00161         this->mwindow = mwindow;
00162 }
00163 
00164 TimeBar::~TimeBar()
00165 {
00166         if(in_point) delete in_point;
00167         if(out_point) delete out_point;
00168         labels.remove_all_objects();
00169         presentations.remove_all_objects();
00170 }
00171 
00172 int TimeBar::create_objects()
00173 {
00174         in_point = 0;
00175         out_point = 0;
00176         current_operation = TIMEBAR_NONE;
00177         update();
00178         return 0;
00179 }
00180 
00181 
00182 int64_t TimeBar::position_to_pixel(double position)
00183 {
00184         get_edl_length();
00185         return (int64_t)(position / time_per_pixel);
00186 }
00187 
00188 
00189 void TimeBar::update_labels()
00190 {
00191         int output = 0;
00192         EDL *edl = get_edl();
00193 
00194         if(edl)
00195         {
00196                 for(Label *current = edl->labels->first;
00197                         current;
00198                         current = NEXT)
00199                 {
00200                         int64_t pixel = position_to_pixel(current->position);
00201 
00202                         if(pixel >= 0 && pixel < get_w())
00203                         {
00204 // Create new label
00205                                 if(output >= labels.total)
00206                                 {
00207                                         LabelGUI *new_label;
00208                                         add_subwindow(new_label = 
00209                                                 new LabelGUI(mwindow, 
00210                                                         this, 
00211                                                         pixel, 
00212                                                         LabelGUI::get_y(mwindow, this), 
00213                                                         current->position));
00214                                         new_label->set_cursor(ARROW_CURSOR);
00215                                         labels.append(new_label);
00216                                 }
00217                                 else
00218 // Reposition old label
00219                                 {
00220                                         LabelGUI *gui = labels.values[output];
00221                                         if(gui->pixel != pixel)
00222                                         {
00223                                                 gui->pixel = pixel;
00224                                                 gui->reposition();
00225                                         }
00226                                         else
00227                                         {
00228                                                 gui->draw_face();
00229                                         }
00230 
00231                                         labels.values[output]->position = current->position;
00232                                 }
00233 
00234                                 if(edl->local_session->get_selectionstart(1) <= current->position &&
00235                                         edl->local_session->get_selectionend(1) >= current->position)
00236                                         labels.values[output]->update(1);
00237                                 else
00238                                 if(labels.values[output]->get_value())
00239                                         labels.values[output]->update(0);
00240 
00241                                 output++;
00242                         }
00243                 }
00244         }
00245 
00246 // Delete excess labels
00247         while(labels.total > output)
00248         {
00249                 labels.remove_object();
00250         }
00251 }
00252 
00253 void TimeBar::update_highlights()
00254 {
00255         for(int i = 0; i < labels.total; i++)
00256         {
00257                 LabelGUI *label = labels.values[i];
00258                 if(mwindow->edl->equivalent(label->position, 
00259                                 mwindow->edl->local_session->get_selectionstart(1)) ||
00260                         mwindow->edl->equivalent(label->position, 
00261                                 mwindow->edl->local_session->get_selectionend(1)))
00262                 {
00263                         if(!label->get_value()) label->update(1);
00264                 }
00265                 else
00266                         if(label->get_value()) label->update(0);
00267         }
00268 
00269         if(mwindow->edl->equivalent(mwindow->edl->local_session->get_inpoint(), 
00270                         mwindow->edl->local_session->get_selectionstart(1)) ||
00271                 mwindow->edl->equivalent(mwindow->edl->local_session->get_inpoint(), 
00272                         mwindow->edl->local_session->get_selectionend(1)))
00273         {
00274                 if(in_point) in_point->update(1);
00275         }
00276         else
00277                 if(in_point) in_point->update(0);
00278 
00279         if(mwindow->edl->equivalent(mwindow->edl->local_session->get_outpoint(), 
00280                         mwindow->edl->local_session->get_selectionstart(1)) ||
00281                 mwindow->edl->equivalent(mwindow->edl->local_session->get_outpoint(), 
00282                         mwindow->edl->local_session->get_selectionend(1)))
00283         {
00284                 if(out_point) out_point->update(1);
00285         }
00286         else
00287                 if(out_point) out_point->update(0);
00288 }
00289 
00290 void TimeBar::update_points()
00291 {
00292         EDL *edl = get_edl();
00293         int64_t pixel;
00294 
00295         if(edl) pixel = position_to_pixel(edl->local_session->get_inpoint());
00296 
00297 
00298         if(in_point)
00299         {
00300                 if(edl && 
00301                         edl->local_session->inpoint_valid() && 
00302                         pixel >= 0 && 
00303                         pixel < get_w())
00304                 {
00305                         if(!EQUIV(edl->local_session->get_inpoint(), in_point->position) ||
00306                                 in_point->pixel != pixel)
00307                         {
00308                                 in_point->pixel = pixel;
00309                                 in_point->position = edl->local_session->get_inpoint();
00310                                 in_point->reposition();
00311                         }
00312                         else
00313                         {
00314                                 in_point->draw_face();
00315                         }
00316                 }
00317                 else
00318                 {
00319                         delete in_point;
00320                         in_point = 0;
00321                 }
00322         }
00323         else
00324         if(edl && edl->local_session->inpoint_valid() && 
00325                 pixel >= 0 && pixel < get_w())
00326         {
00327                 add_subwindow(in_point = new InPointGUI(mwindow, 
00328                         this, 
00329                         pixel, 
00330                         edl->local_session->get_inpoint()));
00331                 in_point->set_cursor(ARROW_CURSOR);
00332         }
00333 
00334         if(edl) pixel = position_to_pixel(edl->local_session->get_outpoint());
00335 
00336         if(out_point)
00337         {
00338                 if(edl &&
00339                         edl->local_session->outpoint_valid() && 
00340                         pixel >= 0 && 
00341                         pixel < get_w())
00342                 {
00343                         if(!EQUIV(edl->local_session->get_outpoint(), out_point->position) ||
00344                                 out_point->pixel != pixel) 
00345                         {
00346                                 out_point->pixel = pixel;
00347                                 out_point->position = edl->local_session->get_outpoint();
00348                                 out_point->reposition();
00349                         }
00350                         else
00351                         {
00352                                 out_point->draw_face();
00353                         }
00354                 }
00355                 else
00356                 {
00357                         delete out_point;
00358                         out_point = 0;
00359                 }
00360         }
00361         else
00362         if(edl && 
00363                 edl->local_session->outpoint_valid() && 
00364                 pixel >= 0 && pixel < get_w())
00365         {
00366                 add_subwindow(out_point = new OutPointGUI(mwindow, 
00367                         this, 
00368                         pixel, 
00369                         edl->local_session->get_outpoint()));
00370                 out_point->set_cursor(ARROW_CURSOR);
00371         }
00372 }
00373 
00374 void TimeBar::update_presentations()
00375 {
00376 }
00377 
00378 
00379 void TimeBar::update(int do_range, int do_others)
00380 {
00381 SET_TRACE
00382         draw_time();
00383 SET_TRACE
00384 // Need to redo these when range is drawn to get the background updated.
00385         update_labels();
00386 SET_TRACE
00387         update_points();
00388 SET_TRACE
00389         update_presentations();
00390 SET_TRACE
00391         flash();
00392 SET_TRACE
00393 }
00394 
00395 
00396 
00397 int TimeBar::delete_project()
00398 {
00399 //      labels->delete_all();
00400         return 0;
00401 }
00402 
00403 int TimeBar::save(FileXML *xml)
00404 {
00405 //      labels->save(xml);
00406         return 0;
00407 }
00408 
00409 
00410 
00411 
00412 void TimeBar::draw_time()
00413 {
00414 }
00415 
00416 EDL* TimeBar::get_edl()
00417 {
00418         return mwindow->edl;
00419 }
00420 
00421 
00422 
00423 void TimeBar::draw_range()
00424 {
00425         int x1 = 0, x2 = 0;
00426         if(get_edl())
00427         {
00428                 get_preview_pixels(x1, x2);
00429 
00430 //printf("TimeBar::draw_range %f %d %d\n", edl_length, x1, x2);
00431                 draw_3segmenth(0, 0, x1, mwindow->theme->timebar_view_data);
00432                 draw_top_background(get_parent(), x1, 0, x2 - x1, get_h());
00433                 draw_3segmenth(x2, 0, get_w() - x2, mwindow->theme->timebar_view_data);
00434 
00435                 set_color(BLACK);
00436                 draw_line(x1, 0, x1, get_h());
00437                 draw_line(x2, 0, x2, get_h());
00438                 
00439                 EDL *edl;
00440                 if(edl = get_edl())
00441                 {
00442                         int64_t pixel = position_to_pixel(
00443                                 edl->local_session->get_selectionstart(1));
00444 // Draw insertion point position if this timebar beint64_ts to a window which 
00445 // has something other than the master EDL.
00446                         set_color(RED);
00447                         draw_line(pixel, 0, pixel, get_h());
00448                 }
00449         }
00450         else
00451                 draw_top_background(get_parent(), 0, 0, get_w(), get_h());
00452 }
00453 
00454 void TimeBar::select_label(double position)
00455 {
00456 }
00457 
00458 
00459 
00460 int TimeBar::draw()
00461 {
00462         return 0;
00463 }
00464 
00465 void TimeBar::get_edl_length()
00466 {
00467         edl_length = 0;
00468 
00469         if(get_edl())
00470         {
00471 //printf("TimeBar::get_edl_length 1 %f\n", get_edl()->tracks->total_playable_length());
00472                 edl_length = get_edl()->tracks->total_playable_length();
00473         }
00474 
00475 //printf("TimeBar::get_edl_length 2\n");
00476         if(!EQUIV(edl_length, 0))
00477         {
00478 //printf("TimeBar::get_edl_length 3\n");
00479                 time_per_pixel = edl_length / get_w();
00480 //printf("TimeBar::get_edl_length 4\n");
00481         }
00482         else
00483         {
00484                 time_per_pixel = 0;
00485         }
00486 //printf("TimeBar::get_edl_length 5\n");
00487 }
00488 
00489 int TimeBar::get_preview_pixels(int &x1, int &x2)
00490 {
00491         x1 = 0;
00492         x2 = 0;
00493 
00494         get_edl_length();
00495 
00496         if(get_edl())
00497         {
00498                 if(!EQUIV(edl_length, 0))
00499                 {
00500                         if(get_edl()->local_session->preview_end <= 0 ||
00501                                 get_edl()->local_session->preview_end > edl_length)
00502                                 get_edl()->local_session->preview_end = edl_length;
00503                         if(get_edl()->local_session->preview_start > 
00504                                 get_edl()->local_session->preview_end)
00505                                 get_edl()->local_session->preview_start = 0;
00506                         x1 = (int)(get_edl()->local_session->preview_start / time_per_pixel);
00507                         x2 = (int)(get_edl()->local_session->preview_end / time_per_pixel);
00508                 }
00509                 else
00510                 {
00511                         x1 = 0;
00512                         x2 = get_w();
00513                 }
00514         }
00515 // printf("TimeBar::get_preview_pixels %f %f %d %d\n", 
00516 //      get_edl()->local_session->preview_start,
00517 //      get_edl()->local_session->preview_end,
00518 //      x1, 
00519 //      x2);
00520         return 0;
00521 }
00522 
00523 
00524 int TimeBar::test_preview(int buttonpress)
00525 {
00526         int result = 0;
00527         int x1, x2;
00528 
00529         get_preview_pixels(x1, x2);
00530 //printf("TimeBar::test_preview %d %d %d\n", x1, x2, get_cursor_x());
00531 
00532         if(get_edl())
00533         {
00534 // Inside left handle
00535                 if(cursor_inside() &&
00536                         get_cursor_x() >= x1 - HANDLE_W &&
00537                         get_cursor_x() < x1 + HANDLE_W &&
00538 // Ignore left handle if both handles are up against the left side
00539                         x2 > HANDLE_W)
00540                 {
00541                         if(buttonpress)
00542                         {
00543                                 current_operation = TIMEBAR_DRAG_LEFT;
00544                                 start_position = get_edl()->local_session->preview_start;
00545                                 start_cursor_x = get_cursor_x();
00546                                 result = 1;
00547                         }
00548                         else
00549                         if(get_cursor() != LEFT_CURSOR)
00550                         {
00551                                 result = 1;
00552                                 set_cursor(LEFT_CURSOR);
00553                         }
00554                 }
00555                 else
00556 // Inside right handle
00557                 if(cursor_inside() &&
00558                         get_cursor_x() >= x2 - HANDLE_W &&
00559                         get_cursor_x() < x2 + HANDLE_W &&
00560 // Ignore right handle if both handles are up against the right side
00561                         x1 < get_w() - HANDLE_W)
00562                 {
00563                         if(buttonpress)
00564                         {
00565                                 current_operation = TIMEBAR_DRAG_RIGHT;
00566                                 start_position = get_edl()->local_session->preview_end;
00567                                 start_cursor_x = get_cursor_x();
00568                                 result = 1;
00569                         }
00570                         else
00571                         if(get_cursor() != RIGHT_CURSOR)
00572                         {
00573                                 result = 1;
00574                                 set_cursor(RIGHT_CURSOR);
00575                         }
00576                 }
00577                 else
00578                 if(cursor_inside() &&
00579                         get_cursor_x() >= x1 &&
00580                         get_cursor_x() < x2)
00581                 {
00582                         if(buttonpress)
00583                         {
00584                                 current_operation = TIMEBAR_DRAG_CENTER;
00585                                 starting_start_position = get_edl()->local_session->preview_start;
00586                                 starting_end_position = get_edl()->local_session->preview_end;
00587                                 start_cursor_x = get_cursor_x();
00588                                 result = 1;
00589                         }
00590                         else
00591                         {
00592                                 result = 1;
00593                                 set_cursor(HSEPARATE_CURSOR);
00594                         }
00595                 }
00596                 else
00597                 {
00598 // Trap all buttonpresses inside timebar
00599                         if(cursor_inside() && buttonpress)
00600                                 result = 1;
00601 
00602                         if(get_cursor() == LEFT_CURSOR ||
00603                                 get_cursor() == RIGHT_CURSOR)
00604                         {
00605                                 result = 1;
00606                                 set_cursor(ARROW_CURSOR);
00607                         }
00608                 }
00609         }
00610 
00611 
00612 
00613         return result;
00614 }
00615 
00616 int TimeBar::move_preview(int &redraw)
00617 {
00618         int result = 0;
00619 
00620         if(current_operation == TIMEBAR_DRAG_LEFT)
00621         {
00622                 get_edl()->local_session->preview_start = 
00623                         start_position + 
00624                         time_per_pixel * (get_cursor_x() - start_cursor_x);
00625                 CLAMP(get_edl()->local_session->preview_start, 
00626                         0, 
00627                         get_edl()->local_session->preview_end);
00628                 result = 1;
00629         }
00630         else
00631         if(current_operation == TIMEBAR_DRAG_RIGHT)
00632         {
00633                 get_edl()->local_session->preview_end = 
00634                         start_position + 
00635                         time_per_pixel * (get_cursor_x() - start_cursor_x);
00636                 CLAMP(get_edl()->local_session->preview_end, 
00637                         get_edl()->local_session->preview_start, 
00638                         edl_length);
00639                 result = 1;
00640         }
00641         else
00642         if(current_operation == TIMEBAR_DRAG_CENTER)
00643         {
00644                 get_edl()->local_session->preview_start = 
00645                         starting_start_position +
00646                         time_per_pixel * (get_cursor_x() - start_cursor_x);
00647                 get_edl()->local_session->preview_end = 
00648                         starting_end_position +
00649                         time_per_pixel * (get_cursor_x() - start_cursor_x);
00650                 if(get_edl()->local_session->preview_start < 0)
00651                 {
00652                         get_edl()->local_session->preview_end -= get_edl()->local_session->preview_start;
00653                         get_edl()->local_session->preview_start = 0;
00654                 }
00655                 else
00656                 if(get_edl()->local_session->preview_end > edl_length)
00657                 {
00658                         get_edl()->local_session->preview_start -= get_edl()->local_session->preview_end - edl_length;
00659                         get_edl()->local_session->preview_end = edl_length;
00660                 }
00661                 result = 1;
00662         }
00663 
00664 //printf("TimeBar::move_preview %f %f\n", get_edl()->local_session->preview_start, get_edl()->local_session->preview_end);
00665 
00666         if(result)
00667         {
00668                 update_preview();
00669                 redraw = 1;
00670         }
00671 
00672         return result;
00673 }
00674 
00675 void TimeBar::update_preview()
00676 {
00677 }
00678 
00679 int TimeBar::samplemovement()
00680 {
00681         return 0;
00682 }
00683 
00684 void TimeBar::stop_playback()
00685 {
00686 }
00687 
00688 int TimeBar::button_press_event()
00689 {
00690         if(is_event_win() && cursor_inside())
00691         {
00692 // Change time format
00693                 if(ctrl_down())
00694                 {
00695                         if(get_buttonpress() == 1)
00696                                 mwindow->next_time_format();
00697                         else
00698                         if(get_buttonpress() == 2)
00699                                 mwindow->prev_time_format();
00700                         return 1;
00701                 }
00702                 else
00703                 if(test_preview(1))
00704                 {
00705                 }
00706                 else
00707                 {
00708                         stop_playback();
00709 
00710 // Select region between two labels
00711                         if(get_double_click())
00712                         {
00713                                 double position = (double)get_cursor_x() * 
00714                                         mwindow->edl->local_session->zoom_sample / 
00715                                         mwindow->edl->session->sample_rate + 
00716                                         (double)mwindow->edl->local_session->view_start *
00717                                         mwindow->edl->local_session->zoom_sample / 
00718                                         mwindow->edl->session->sample_rate;
00719 // Test labels
00720                                 select_region(position);
00721                                 return 1;
00722                         }
00723                         else
00724 // Reposition highlight cursor
00725                         if(is_event_win() && cursor_inside())
00726                         {
00727                                 update_cursor();
00728                                 mwindow->gui->canvas->activate();
00729                                 return 1;
00730                         }
00731                 }
00732         }
00733         return 0;
00734 }
00735 
00736 int TimeBar::repeat_event(int64_t duration)
00737 {
00738         if(!mwindow->gui->canvas->drag_scroll) return 0;
00739         if(duration != BC_WindowBase::get_resources()->scroll_repeat) return 0;
00740 
00741         int distance = 0;
00742         int x_movement = 0;
00743         int relative_cursor_x = mwindow->gui->canvas->get_relative_cursor_x();
00744         if(current_operation == TIMEBAR_DRAG)
00745         {
00746                 if(relative_cursor_x >= mwindow->gui->canvas->get_w())
00747                 {
00748                         distance = relative_cursor_x - mwindow->gui->canvas->get_w();
00749                         x_movement = 1;
00750                 }
00751                 else
00752                 if(relative_cursor_x < 0)
00753                 {
00754                         distance = relative_cursor_x;
00755                         x_movement = 1;
00756                 }
00757 
00758 
00759 
00760                 if(x_movement)
00761                 {
00762                         update_cursor();
00763                         mwindow->samplemovement(mwindow->edl->local_session->view_start + 
00764                                 distance);
00765                 }
00766                 return 1;
00767         }
00768         return 0;
00769 }
00770 
00771 int TimeBar::cursor_motion_event()
00772 {
00773         int result = 0;
00774         int redraw = 0;
00775 
00776         switch(current_operation)
00777         {
00778                 case TIMEBAR_DRAG:
00779                 {
00780                         update_cursor();
00781 //printf("TimeBar::cursor_motion_event 1\n");
00782                         int relative_cursor_x = mwindow->gui->canvas->get_relative_cursor_x();
00783                         if(relative_cursor_x >= mwindow->gui->canvas->get_w() || 
00784                                 relative_cursor_x < 0)
00785                         {
00786                                 mwindow->gui->canvas->start_dragscroll();
00787                         }
00788                         else
00789                         if(relative_cursor_x < mwindow->gui->canvas->get_w() && 
00790                                 relative_cursor_x >= 0)
00791                         {
00792                                 mwindow->gui->canvas->stop_dragscroll();
00793                         }
00794                         result = 1;
00795 //printf("TimeBar::cursor_motion_event 10\n");
00796                         break;
00797                 }
00798 
00799 
00800                 case TIMEBAR_DRAG_LEFT:
00801                 case TIMEBAR_DRAG_RIGHT:
00802                 case TIMEBAR_DRAG_CENTER:
00803                         result = move_preview(redraw);
00804                         break;
00805 
00806                 default:
00807 //printf("TimeBar::cursor_motion_event 20\n");
00808                         result = test_preview(0);
00809 //printf("TimeBar::cursor_motion_event 30\n");
00810                         break;
00811         }
00812 
00813         if(redraw)
00814         {
00815                 update();
00816         }
00817 
00818         return result;
00819 }
00820 
00821 int TimeBar::button_release_event()
00822 {
00823 //printf("TimeBar::button_release_event %d\n", current_operation);
00824         int result = 0;
00825         switch(current_operation)
00826         {
00827                 case TIMEBAR_DRAG:
00828                         mwindow->undo->update_undo(_("select"), LOAD_SESSION, 0, 0);
00829                         mwindow->gui->canvas->stop_dragscroll();
00830                         current_operation = TIMEBAR_NONE;
00831                         result = 1;
00832                         break;
00833 
00834                 default:
00835                         if(current_operation != TIMEBAR_NONE)
00836                         {
00837                                 current_operation = TIMEBAR_NONE;
00838                                 result = 1;
00839                         }
00840                         break;
00841         }
00842         return result;
00843 }
00844 
00845 // Update the selection cursor during a dragging operation
00846 void TimeBar::update_cursor()
00847 {
00848         double position = (double)get_cursor_x() * 
00849                 mwindow->edl->local_session->zoom_sample / 
00850                 mwindow->edl->session->sample_rate + 
00851                 (double)mwindow->edl->local_session->view_start * 
00852                 mwindow->edl->local_session->zoom_sample / 
00853                 mwindow->edl->session->sample_rate;
00854         
00855         position = mwindow->edl->align_to_frame(position, 0);
00856         position = MAX(0, position);
00857         current_operation = TIMEBAR_DRAG;
00858 
00859         mwindow->select_point(position);
00860         update_highlights();
00861 }
00862 
00863 
00864 int TimeBar::select_region(double position)
00865 {
00866         Label *start = 0, *end = 0, *current;
00867         for(current = mwindow->edl->labels->first; current; current = NEXT)
00868         {
00869                 if(current->position > position)
00870                 {
00871                         end = current;
00872                         break;
00873                 }
00874         }
00875 
00876         for(current = mwindow->edl->labels->last ; current; current = PREVIOUS)
00877         {
00878                 if(current->position <= position)
00879                 {
00880                         start = current;
00881                         break;
00882                 }
00883         }
00884 
00885 // Select region
00886         if(end != start)
00887         {
00888                 if(!start)
00889                         mwindow->edl->local_session->set_selectionstart(0);
00890                 else
00891                         mwindow->edl->local_session->set_selectionstart(start->position);
00892 
00893                 if(!end)
00894                         mwindow->edl->local_session->set_selectionend(mwindow->edl->tracks->total_length());
00895                 else
00896                         mwindow->edl->local_session->set_selectionend(end->position);
00897         }
00898         else
00899         if(end || start)
00900         {
00901                 mwindow->edl->local_session->set_selectionstart(start->position);
00902                 mwindow->edl->local_session->set_selectionend(start->position);
00903         }
00904 
00905 // Que the CWindow
00906         mwindow->cwindow->update(1, 0, 0);
00907         mwindow->gui->cursor->hide();
00908         mwindow->gui->cursor->draw();
00909         mwindow->gui->canvas->flash();
00910         mwindow->gui->canvas->activate();
00911         mwindow->gui->zoombar->update();
00912         mwindow->undo->update_undo(_("select"), LOAD_SESSION, 0, 0);
00913         update_highlights();
00914         return 0;
00915 }
00916 
00917 
00918 
00919 
00920 int TimeBar::delete_arrows()
00921 {
00922         return 0;
00923 }
00924 
00925 

Generated on Sun Jan 8 13:39:00 2006 for Cinelerra-svn by  doxygen 1.4.4