X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fvtimebar.C;fp=cinelerra-5.1%2Fcinelerra%2Fvtimebar.C;h=a62e347c0e7152c7cf2e497a674c73349f35ca1f;hb=30bdb85eb33a8ee7ba675038a86c6be59c43d7bd;hp=0000000000000000000000000000000000000000;hpb=52fcc46226f9df46f9ce9d0566dc568455a7db0b;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/cinelerra/vtimebar.C b/cinelerra-5.1/cinelerra/vtimebar.C new file mode 100644 index 00000000..a62e347c --- /dev/null +++ b/cinelerra-5.1/cinelerra/vtimebar.C @@ -0,0 +1,131 @@ + +/* + * CINELERRA + * Copyright (C) 2008 Adam Williams + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "edl.h" +#include "localsession.h" +#include "mwindow.h" +#include "theme.h" +#include "vtimebar.h" +#include "vwindow.h" +#include "vwindowgui.h" + + +VTimeBar::VTimeBar(MWindow *mwindow, + VWindowGUI *gui, + int x, + int y, + int w, + int h) + : TimeBar(mwindow, + gui, + x, + y, + w, + h) +{ + this->mwindow = mwindow; + this->gui = gui; +} + +int VTimeBar::resize_event() +{ + reposition_window(mwindow->theme->vtimebar_x, + mwindow->theme->vtimebar_y, + mwindow->theme->vtimebar_w, + mwindow->theme->vtimebar_h); + update(0); + return 1; +} + +EDL* VTimeBar::get_edl() +{ + return gui->vwindow->get_edl(); +} + +void VTimeBar::draw_time() +{ + draw_range(); +} + +void VTimeBar::select_label(double position) +{ + EDL *edl = get_edl(); + + if(edl) + { + unlock_window(); + gui->transport->handle_transport(STOP, 1, 0, 0); + lock_window(); + + position = mwindow->edl->align_to_frame(position, 1); + + if(shift_down()) + { + if(position > edl->local_session->get_selectionend(1) / 2 + + edl->local_session->get_selectionstart(1) / 2) + { + + edl->local_session->set_selectionend(position); + } + else + { + edl->local_session->set_selectionstart(position); + } + } + else + { + edl->local_session->set_selectionstart(position); + edl->local_session->set_selectionend(position); + } + +// Que the CWindow + gui->vwindow->update_position(CHANGE_NONE, + 0, + 1, + 0); + update(1); + } +} + +double VTimeBar::pixel_to_position(int pixel) +{ + double start = 0, length = 0; + EDL *edl = get_edl(); + if(edl) + { + start = edl->local_session->preview_start; + if(start >= 0) + length = edl->local_session->preview_end - start; + } + if(length <= 0) + length = get_edl_length(); + return start + (double)pixel * length / get_w(); +} + +void VTimeBar::update_cursor() +{ + int rx = get_relative_cursor_x(); + double position = pixel_to_position(rx); + gui->vwindow->update_position(position); + update(1); +} + +