16 static double xstart, ystart;
17 static double xcurrent, ycurrent;
18 static double xinit, yinit;
19 static volatile boolean b1_held;
21 static volatile boolean noupdate =
FALSE;
23 static LiVESWidget *fbord_eventbox;
26 static double calc_fd_scale(
int width,
int height) {
61 static void start_preview(LiVESButton *button,
lives_rfx_t *rfx) {
84 if (
cfile->start == 0) {
153 framedraw->
rfx = rfx;
156 LIVES_WIDGET_VALUE_CHANGED_SIGNAL,
157 LIVES_GUI_CALLBACK(after_framedraw_frame_spinbutton_changed), framedraw);
159 LIVES_GUI_CALLBACK(framedraw_redraw_cb), framedraw);
161 LIVES_GUI_CALLBACK(framedraw_redraw_cb), framedraw);
177 lives_signal_sync_connect(LIVES_GUI_OBJECT(
mainw->
framedraw), LIVES_WIDGET_SCROLL_EVENT,
201 LiVESWidget *hbox_rst;
219 static void redraw_framedraw_image(
weed_layer_t *layer) {
225 lives_painter_t *cr, *cr2;
226 LiVESWidget *fd_widget;
228 int fd_width, fd_height;
229 int width, height, cx, cy;
238 if (!LIVES_IS_WIDGET(fd_widget))
return;
243 width =
cfile->hsize;
244 height =
cfile->vsize;
257 cx = (fd_width - width) / 2;
258 cy = (fd_height - height) / 2;
270 static boolean expose_fd_event(LiVESWidget *widget, lives_painter_t *cr, livespointer user_data) {
271 if (!LIVES_IS_WIDGET(widget))
return TRUE;
279 void widget_add_framedraw(LiVESVBox *box,
int start,
int end,
boolean add_preview_button,
int width,
int height,
285 LiVESAdjustment *spinbutton_adj;
287 LiVESWidget *vseparator;
291 LiVESWidget *cbutton;
309 fd_scale = calc_fd_scale(width, height);
344 LIVES_BUTTON_PRESS_MASK | LIVES_ENTER_NOTIFY_MASK | LIVES_LEAVE_NOTIFY_MASK);
371 FALSE, &opcol, NULL, NULL, NULL, NULL);
378 start, start, end, 1., 10., 0, LIVES_BOX(hbox), NULL);
408 if (add_preview_button) {
435 LiVESWidget *fd_widget;
437 double xstartf, ystartf, xendf, yendf;
446 if (noupdate)
return NULL;
450 if (!LIVES_IS_WIDGET(fd_widget))
return NULL;
455 if (fd_width < 4 || fd_height < 4)
return NULL;
457 width =
cfile->hsize;
458 height =
cfile->vsize;
476 weed_plant_free(layer);
504 switch (framedraw->
type) {
509 xstartf = xstartf / (double)
cfile->hsize * (
double)width;
512 xstartf = xstartf * (double)width;
517 xendf = xendf / (double)
cfile->hsize * (
double)width;
520 xendf = xendf * (double)width;
525 ystartf = ystartf / (double)
cfile->vsize * (
double)height;
528 ystartf = ystartf * (double)height;
533 yendf = yendf / (double)
cfile->vsize * (
double)height;
536 yendf = yendf * (double)height;
550 LiVESWidgetColor maskcol;
556 LIVES_WIDGET_COLOR_SCALE(maskcol.blue), opacity);
567 xstartf = xstartf / (double)
cfile->hsize * (
double)width;
570 xstartf *= (double)width;
575 ystartf = ystartf / (double)
cfile->vsize * (
double)height;
578 ystartf *= (double)height;
582 xstartf = xcurrent * (double)width;
583 ystartf = ycurrent * (double)height;
587 if (scale == 0.)
break;
593 / (
double)
cfile->hsize;
598 / (
double)
cfile->vsize;
603 if (xpos - xstartf / scale < 0.) xstartf = xpos * scale;
604 else if (xpos + xstartf / scale > 1.) xstartf = 1. - (1. - xpos) * scale;
605 if (ypos - ystartf / scale < 0.) ystartf = ypos * scale;
606 else if (ypos + ystartf / scale > 1.) ystartf = 1. - (1. - ypos) * scale;
607 xstartf *= (double)width;
608 ystartf *= (double)height;
674 FILE *infofile = NULL;
707 weed_plant_free(
cfile->pumper);
708 cfile->pumper = NULL;
730 if (infofile) fclose(infofile);
734 weed_plant_free(
cfile->pumper);
735 cfile->pumper = NULL;
748 }
while (retval == LIVES_RESPONSE_RETRY);
755 tot_frames =
cfile->end;
759 char **array = lives_strsplit(
mainw->
msg,
"|", numtok);
761 cfile->hsize = atoi(array[1]);
762 cfile->vsize = atoi(array[2]);
763 cfile->fps =
cfile->pb_fps = strtod(array[3], NULL);
765 tot_frames = atoi(array[4]);
766 lives_strfreev(array);
783 cfile->frames = tot_frames;
804 weed_plant_free(layer);
826 if (!framedraw)
return FALSE;
830 switch (framedraw->
type) {
856 LiVESWidget *fd_widget;
857 if (!framedraw)
return FALSE;
862 if (!LIVES_IS_WIDGET(fd_widget))
return FALSE;
878 int width =
cfile->hsize;
879 int height =
cfile->vsize;
881 int xstarti, ystarti;
885 if (!framedraw)
return FALSE;
893 if (event->button != 1)
return FALSE;
898 widget, &xstarti, &ystarti);
916 xstart = (double)xstarti - (
double)(fd_width - width) / 2.;
917 ystart = (double)ystarti - (
double)(fd_height - height) / 2.;
919 xstart /= (double)(width - 1);
920 ystart /= (double)(height - 1);
922 xend = xcurrent = xstart;
923 yend = ycurrent = ystart;
927 switch (framedraw->
type) {
936 / (
double)
cfile->hsize;
941 / (
double)
cfile->vsize;
953 (
int)(xstart * (
double)
cfile->hsize + .5));
958 (
int)(ystart * (
double)
cfile->vsize + .5));
991 int xcurrenti, ycurrenti;
993 int fd_width, fd_height, width, height;
995 if (noupdate)
return FALSE;
997 if (!b1_held)
return FALSE;
1000 if (!framedraw)
return FALSE;
1004 widget, &xcurrenti, &ycurrenti);
1007 width =
cfile->hsize;
1008 height =
cfile->vsize;
1015 xcurrent = (double)xcurrenti - (fd_width - width) / 2.;
1016 ycurrent = (double)ycurrenti - (fd_height - height) / 2.;
1018 xcurrent /= (double)(width - 1);
1019 ycurrent /= (double)(height - 1);
1023 switch (framedraw->
type) {
1026 double xscale, yscale;
1028 xscale = xcurrent - xstart;
1029 yscale = ycurrent - ystart;
1036 (
int)(xscale * (
double)
cfile->hsize + .5));
1043 (
int)(-xscale * (
double)
cfile->hsize - .5));
1045 (
int)(xcurrent * (
double)
cfile->hsize + .5));
1054 (
int)(yscale * (
double)
cfile->vsize + .5));
1061 (
int)(-yscale * (
double)
cfile->vsize - .5));
1063 (
int)(ycurrent * (
double)
cfile->vsize + .5));
1071 if (xcurrent > xstart) {
1076 (
int)(xcurrent * (
double)
cfile->hsize + .5));
1083 (
int)(xstart * (
double)
cfile->hsize + .5));
1085 (
int)(xcurrent * (
double)
cfile->hsize + .5));
1089 if (ycurrent > ystart) {
1094 (
int)(ycurrent * (
double)
cfile->vsize + .5));
1101 (
int)(ystart * (
double)
cfile->vsize + .5));
1103 (
int)(ycurrent * (
double)
cfile->vsize + .5));
1111 double offs_x, offs_y;
1113 if (scale == 0.)
break;
1114 offs_x = (xstart - xcurrent) / scale;
1115 offs_y = (ystart - ycurrent) / scale;
1117 if (xinit + offs_x < .5 / scale) offs_x = .5 / scale - xinit;
1118 if (xinit + offs_x > 1. - .5 / scale) offs_x = 1. - .5 / scale - xinit;
1119 if (yinit + offs_y < .5 / scale) offs_y = .5 / scale - yinit;
1120 if (yinit + offs_y > 1. - .5 / scale) offs_y = 1. - .5 / scale - yinit;
1126 * (
double)
cfile->hsize + .5));
1131 * (
double)
cfile->vsize + .5));
1139 #if !GTK_CHECK_VERSION(3, 0, 0)
1158 int xcurrenti, ycurrenti;
1159 int fd_width, fd_height, width, height;
1161 if (event->button != 1 || !b1_held)
return FALSE;
1166 if (!framedraw)
return FALSE;
1170 widget, &xcurrenti, &ycurrenti);
1173 width =
cfile->hsize;
1174 height =
cfile->vsize;
1181 xcurrent = (double)xcurrenti - (fd_width - width) / 2.;
1182 ycurrent = (double)ycurrenti - (fd_height - height) / 2.;
1184 xcurrent /= (double)(width - 1);
1185 ycurrent /= (double)(height - 1);
1187 switch (framedraw->
type) {
1198 double offs_x, offs_y, scale, xend, yend;
1199 if (noupdate)
break;
1202 if (scale == 0.)
break;
1208 / (
double)
cfile->hsize;
1213 / (
double)
cfile->vsize;
1215 if (xend == xinit && yend == yinit && xcurrent == xstart && ycurrent == ystart) {
1221 if (xend - xstart / scale < 0.) xstart = xend * scale;
1222 else if (xend + xstart / scale > 1.) xstart = 1. - (1. - xend) * scale;
1223 if (yend - ystart / scale < 0.) ystart = yend * scale;
1224 else if (yend + ystart / scale > 1.) ystart = 1. - (1. - yend) * scale;
1226 offs_x = (xcurrent - xstart) / scale;
1227 offs_y = (ycurrent - ystart) / scale;
1233 * (
double)
cfile->hsize + .5));
1238 *
cfile->vsize + .5));
1248 (
int)(xstart * (
double)
cfile->hsize + .5));
1253 (
int)(ystart * (
double)
cfile->vsize + .5));
1266 if (!framedraw)
return FALSE;