X-Git-Url: https://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fdragcheckbox.C;h=be1c312792b189569646d285b2a55ad2077dc17c;hb=d51dc1ff2dbd920c6488af4380b8064c9b6a7b4c;hp=8db8ac35953e37985657630f02f0fbd838da239f;hpb=7fd85fb66168f6b518c5f2d73e04036e87faa0e1;p=goodguy%2Fcinelerra.git diff --git a/cinelerra-5.1/cinelerra/dragcheckbox.C b/cinelerra-5.1/cinelerra/dragcheckbox.C index 8db8ac35..be1c3127 100644 --- a/cinelerra-5.1/cinelerra/dragcheckbox.C +++ b/cinelerra-5.1/cinelerra/dragcheckbox.C @@ -1,3 +1,20 @@ +/* + * 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 "automation.h" #include "bctoggle.h" #include "canvas.h" @@ -30,10 +47,21 @@ DragCheckBox::~DragCheckBox() drag_deactivate(); } +int DragCheckBox::get_track_w() +{ + Track *track = get_drag_track(); + return track ? track->track_w : mwindow->edl->session->output_w; +} +int DragCheckBox::get_track_h() +{ + Track *track = get_drag_track(); + return track ? track->track_h : mwindow->edl->session->output_h; +} + void DragCheckBox::create_objects() { - if( !drag_w ) drag_w = get_drag_track()->track_w; - if( !drag_h ) drag_h = get_drag_track()->track_h; + if( !drag_w ) drag_w = get_track_w(); + if( !drag_h ) drag_h = get_track_h(); if( get_value() ) drag_activate(); } @@ -73,6 +101,14 @@ void DragCheckBox::drag_deactivate() dragging = 0; } +int DragCheckBox::handle_ungrab() +{ + drag_deactivate(); + update(*value = 0); + update_gui(); + return 1; +} + int DragCheckBox::check_pending() { if( pending && !grab_event_count() ) { @@ -119,24 +155,24 @@ int DragCheckBox::grab_event(XEvent *event) return check_pending(); } - Track *track = get_drag_track(); - if( !track ) return 0; - if( !drag_w ) drag_w = track->track_w; - if( !drag_h ) drag_h = track->track_h; + int track_w = get_track_w(), track_h = get_track_h(); + if( !drag_w ) drag_w = track_w; + if( !drag_h ) drag_h = track_h; int64_t position = get_drag_position(); - float cursor_x = cx, cursor_y = cy; canvas->canvas_to_output(mwindow->edl, 0, cursor_x, cursor_y); float projector_x, projector_y, projector_z; - int track_w = track->track_w, track_h = track->track_h; - track->automation->get_projector( - &projector_x, &projector_y, &projector_z, - position, PLAY_FORWARD); - projector_x += mwindow->edl->session->output_w / 2; - projector_y += mwindow->edl->session->output_h / 2; - cursor_x = (cursor_x - projector_x) / projector_z + track_w / 2; - cursor_y = (cursor_y - projector_y) / projector_z + track_h / 2; + Track *track = get_drag_track(); + if( track ) { + track->automation->get_projector( + &projector_x, &projector_y, &projector_z, + position, PLAY_FORWARD); + projector_x += mwindow->edl->session->output_w / 2; + projector_y += mwindow->edl->session->output_h / 2; + cursor_x = (cursor_x - projector_x) / projector_z + track_w / 2; + cursor_y = (cursor_y - projector_y) / projector_z + track_h / 2; + } float r = MIN(track_w, track_h)/100.f + 2; float x0 = drag_x, x1 = drag_x+(drag_w+1)/2, x2 = drag_x+drag_w; float y0 = drag_y, y1 = drag_y+(drag_h+1)/2, y2 = drag_y+drag_h; @@ -236,8 +272,7 @@ int DragCheckBox::grab_event(XEvent *event) void DragCheckBox::bound() { - Track *track = get_drag_track(); - int trk_w = track->track_w, trk_h = track->track_h; + int trk_w = get_track_w(), trk_h = get_track_h(); float x1 = drag_x, x2 = x1 + drag_w; float y1 = drag_y, y2 = y1 + drag_h; bclamp(x1, 0, trk_w); bclamp(x2, 0, trk_w);