+/*
+ * 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"
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();
}
dragging = 0;
}
+int DragCheckBox::handle_ungrab()
+{
+ drag_deactivate();
+ update(*value = 0);
+ update_gui();
+ return 1;
+}
+
int DragCheckBox::check_pending()
{
if( pending && !grab_event_count() ) {
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;
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);